Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+215
@@ -0,0 +1,215 @@
|
||||
/**
|
||||
**
|
||||
** @RDE_HEADER@
|
||||
** plan_overlay_model.h
|
||||
** $Id$
|
||||
** $HeadURL$
|
||||
** $Author$
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
**
|
||||
** Hardware-Environment: Intel-PC
|
||||
** Software-Environment: Windows 7, Qt 5.7. ArcGIS 100
|
||||
**
|
||||
** Language ........: C++ 11
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
**
|
||||
** Author ...........: Jörg Turla, SPD G, Tel. 3132
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
**
|
||||
** Notes .........:
|
||||
**
|
||||
** 10.07.2017, JT : First edition for use with Qt5
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/SituationMapPlugin/situation_map_gui_plugin_interface.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
namespace PlanOverlaysPlugin
|
||||
{
|
||||
|
||||
class PlanOverlayModel final : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum class ColumnSection
|
||||
{
|
||||
OrderButtons = 0,
|
||||
PlanName,
|
||||
MinScale,
|
||||
MaxScale,
|
||||
Opacity,
|
||||
CustomSection,
|
||||
ExerciseId,
|
||||
PhaseId
|
||||
};
|
||||
|
||||
PlanOverlayModel();
|
||||
~PlanOverlayModel();
|
||||
|
||||
/**
|
||||
@name Overloaded function from AbstractItemModel
|
||||
@{
|
||||
*/
|
||||
int columnCount(const QModelIndex &) const override;
|
||||
int rowCount(const QModelIndex &) const override;
|
||||
int size() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::ItemDataRole::DisplayRole) const override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::ItemDataRole::DisplayRole) const override;
|
||||
|
||||
QModelIndex index(int row, int column, const QModelIndex &) const override { return createIndex(row, column); }
|
||||
QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); }
|
||||
Qt::ItemFlags flags(const QModelIndex &modelIndex) const override;
|
||||
QModelIndex index(int row, int column) const { return index(row, column, QModelIndex()); }
|
||||
|
||||
QStringList mimeTypes() const override;
|
||||
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::CopyAction | Qt::MoveAction; }
|
||||
Qt::DropActions supportedDropActions() const override { return Qt::CopyAction | Qt::MoveAction; }
|
||||
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &) const override;
|
||||
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &) override;
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
||||
struct PlanItem
|
||||
{
|
||||
int m_keyId = -1;
|
||||
int m_folderId = -1;
|
||||
int m_fileId = -1;
|
||||
int m_exerciseId = -1;
|
||||
int m_phaseId = -1;
|
||||
QString m_dirPath;
|
||||
QString m_fileName;
|
||||
double m_minScale = 0.0;
|
||||
double m_maxScale = 0.0;
|
||||
double m_opacity = 0.0;
|
||||
bool m_visibility = true;
|
||||
|
||||
bool isValid() const { return m_keyId > 0; }
|
||||
QJsonObject toJson() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
|
||||
obj[QStringLiteral("keyId")] = m_keyId;
|
||||
obj[QStringLiteral("folderId")] = m_folderId;
|
||||
obj[QStringLiteral("fileId")] = m_fileId;
|
||||
obj[QStringLiteral("fileName")] = m_fileName;
|
||||
|
||||
obj[QStringLiteral("exerciseId")] = m_exerciseId;
|
||||
obj[QStringLiteral("phaseId")] = m_phaseId;
|
||||
|
||||
obj[QStringLiteral("opacity")] = m_opacity;
|
||||
obj[QStringLiteral("maxScale")] = m_maxScale;
|
||||
obj[QStringLiteral("minScale")] = m_minScale;
|
||||
obj[QStringLiteral("visibility")] = m_visibility;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
static PlanItem fromJson(const QJsonObject &obj)
|
||||
{
|
||||
PlanItem pi;
|
||||
|
||||
pi.m_keyId = obj[QStringLiteral("keyId")].toInt();
|
||||
pi.m_folderId = obj[QStringLiteral("folderId")].toInt();
|
||||
pi.m_fileId = obj[QStringLiteral("fileId")].toInt();
|
||||
pi.m_fileName = obj[QStringLiteral("fileName")].toInt();
|
||||
|
||||
pi.m_exerciseId = obj[QStringLiteral("exerciseId")].toInt();
|
||||
pi.m_phaseId = obj[QStringLiteral("phaseId")].toInt();
|
||||
|
||||
pi.m_opacity = obj[QStringLiteral("opacity")].toDouble();
|
||||
pi.m_maxScale = obj[QStringLiteral("maxScale")].toDouble();
|
||||
pi.m_minScale = obj[QStringLiteral("minScale")].toDouble();
|
||||
pi.m_visibility = obj[QStringLiteral("visibility")].toBool();
|
||||
|
||||
return pi;
|
||||
}
|
||||
|
||||
}; // PlanItem
|
||||
|
||||
QMap<unsigned int, PlanItem> planStore() const;
|
||||
|
||||
PlanItem planItem(int keyId);
|
||||
|
||||
PlanItem planItemValue(int keyId);
|
||||
|
||||
PlanItem planItemAtRow(int row);
|
||||
|
||||
PlanItem findPlanItemByFileId(int fileId);
|
||||
|
||||
int getRowOfId(int keyId) const;
|
||||
|
||||
void updatePlanItem(const PlanItem &planItem);
|
||||
|
||||
void renewPlanItem(const PlanItem &planItem);
|
||||
|
||||
void setMinScale(int row, double scale);
|
||||
void setMaxScale(int row, double scale);
|
||||
void setOpacity(int row, double opacity);
|
||||
|
||||
void swapRow(int row1, int row2);
|
||||
|
||||
void removeOverlay(int keyId);
|
||||
|
||||
void setFileDialogMimeType(const QString &mimeType);
|
||||
|
||||
void updateOverlay(int keyId);
|
||||
|
||||
bool reInitModel(int exerciseId, int phaseId);
|
||||
|
||||
void updateOrderOfPlans() const;
|
||||
|
||||
QJsonArray toJson() const;
|
||||
|
||||
signals:
|
||||
|
||||
void requestLoadPlan(int keyId);
|
||||
void requestReloadPlan(int keyId);
|
||||
void requestUpdatePlan(int keyId);
|
||||
void requestRemovePlan(int keyId);
|
||||
|
||||
void requestReloadPlanByName(const PlanOverlaysPlugin::PlanOverlayModel::PlanItem &planItem, int exerciseId, int phaseId, bool *removeFromModel);
|
||||
|
||||
void planMinScaleChanged(int keyId, double minScale);
|
||||
void planMaxScaleChanged(int keyId, double maxScale);
|
||||
void planOpacityChanged(int keyId, double opacity);
|
||||
|
||||
void planOrderChanged(const QVector<int> &newIdOrder);
|
||||
|
||||
void dropPlanAccepted();
|
||||
|
||||
private:
|
||||
|
||||
PlanItem &planItemRef(int keyId);
|
||||
|
||||
class InternalData;
|
||||
|
||||
InternalData *m_internal;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
}; // PlanOverlayModel
|
||||
|
||||
} // namespace PlanOverlaysPlugin
|
||||
Reference in new issue
Block a user