From f739220907c3e392de55405b0a74e6cc82cb6ee3 2017-10-27 14:54:47 From: leroux Date: 2017-10-27 14:54:47 Subject: [PATCH] Merge pull request #319 from SciQLop-fork develop Develop --- diff --git a/core/include/Common/MimeTypesDef.h b/core/include/Common/MimeTypesDef.h new file mode 100644 index 0000000..2212853 --- /dev/null +++ b/core/include/Common/MimeTypesDef.h @@ -0,0 +1,18 @@ +#ifndef SCIQLOP_MIMETYPESDEF_H +#define SCIQLOP_MIMETYPESDEF_H + +#include "CoreGlobal.h" + +#include + +// ////////////////// // +// SciQlop Mime Types // +// ////////////////// // + +extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_GRAPH; +extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_ZONE; +extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_VARIABLE_LIST; +extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_TIME_RANGE; + + +#endif // SCIQLOP_MIMETYPESDEF_H diff --git a/core/include/Variable/VariableController.h b/core/include/Variable/VariableController.h index 3e18ad1..b198dcd 100644 --- a/core/include/Variable/VariableController.h +++ b/core/include/Variable/VariableController.h @@ -68,6 +68,8 @@ public: */ void deleteVariables(const QVector > &variables) noexcept; + QByteArray mimeDataForVariables(const QList > &variables) const; + QList > variablesForMimeData(const QByteArray &mimeData) const; static AcquisitionZoomType getZoomType(const SqpRange &range, const SqpRange &oldRange); signals: diff --git a/core/include/Variable/VariableModel.h b/core/include/Variable/VariableModel.h index 960ea81..95da42c 100644 --- a/core/include/Variable/VariableModel.h +++ b/core/include/Variable/VariableModel.h @@ -18,6 +18,7 @@ enum VariableRoles { ProgressRole = Qt::UserRole }; class IDataSeries; class Variable; +class VariableController; /** * @brief The VariableModel class aims to hold the variables that have been created in SciQlop @@ -25,7 +26,7 @@ class Variable; class SCIQLOP_CORE_EXPORT VariableModel : public QAbstractTableModel { Q_OBJECT public: - explicit VariableModel(QObject *parent = nullptr); + explicit VariableModel(VariableController *parent = nullptr); /** * Adds an existing variable in the model. @@ -73,7 +74,20 @@ public: virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - + virtual Qt::ItemFlags flags(const QModelIndex &index) const override; + + // ///////////////// // + // Drag&Drop methods // + // ///////////////// // + + virtual Qt::DropActions supportedDropActions() const override; + virtual Qt::DropActions supportedDragActions() const override; + virtual QStringList mimeTypes() const override; + virtual QMimeData *mimeData(const QModelIndexList &indexes) const override; + virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent) const override; + virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, + const QModelIndex &parent) override; void abortProgress(const QModelIndex &index); diff --git a/core/src/Common/MimeTypesDef.cpp b/core/src/Common/MimeTypesDef.cpp new file mode 100644 index 0000000..24ef739 --- /dev/null +++ b/core/src/Common/MimeTypesDef.cpp @@ -0,0 +1,6 @@ +#include "Common/MimeTypesDef.h" + +const QString MIME_TYPE_GRAPH = QStringLiteral("scqlop/graph"); +const QString MIME_TYPE_ZONE = QStringLiteral("scqlop/zone"); +const QString MIME_TYPE_VARIABLE_LIST = QStringLiteral("scqlop/var-list"); +const QString MIME_TYPE_TIME_RANGE = QStringLiteral("scqlop/time-range"); diff --git a/core/src/Variable/VariableController.cpp b/core/src/Variable/VariableController.cpp index d1865e6..5377542 100644 --- a/core/src/Variable/VariableController.cpp +++ b/core/src/Variable/VariableController.cpp @@ -12,6 +12,7 @@ #include #include