##// END OF EJS Templates
Move Common MIME types constants in a Definition file in core module.
trabillard -
r848:3715d1ed451c
parent child
Show More
@@ -0,0 +1,18
1 #ifndef SCIQLOP_MIMETYPESDEF_H
2 #define SCIQLOP_MIMETYPESDEF_H
3
4 #include "CoreGlobal.h"
5
6 #include <QString>
7
8 // ////////////////// //
9 // SciQlop Mime Types //
10 // ////////////////// //
11
12 extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_GRAPH;
13 extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_ZONE;
14 extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_VARIABLE_LIST;
15 extern SCIQLOP_CORE_EXPORT const QString MIME_TYPE_TIME_RANGE;
16
17
18 #endif // SCIQLOP_MIMETYPESDEF_H
@@ -0,0 +1,6
1 #include "Common/MimeTypesDef.h"
2
3 const QString MIME_TYPE_GRAPH = QStringLiteral("scqlop/graph");
4 const QString MIME_TYPE_ZONE = QStringLiteral("scqlop/zone");
5 const QString MIME_TYPE_VARIABLE_LIST = QStringLiteral("scqlop/var-list");
6 const QString MIME_TYPE_TIME_RANGE = QStringLiteral("scqlop/time-range");
@@ -10,9 +10,6
10 #include <QTimer>
10 #include <QTimer>
11 #include <QVBoxLayout>
11 #include <QVBoxLayout>
12
12
13 const QString DragDropHelper::MIME_TYPE_GRAPH = "scqlop/graph";
14 const QString DragDropHelper::MIME_TYPE_ZONE = "scqlop/zone";
15
16 const int SCROLL_SPEED = 5;
13 const int SCROLL_SPEED = 5;
17 const int SCROLL_ZONE_SIZE = 50;
14 const int SCROLL_ZONE_SIZE = 50;
18
15
@@ -6,6 +6,7
6 #include "Visualization/VisualizationZoneWidget.h"
6 #include "Visualization/VisualizationZoneWidget.h"
7 #include "ui_VisualizationGraphWidget.h"
7 #include "ui_VisualizationGraphWidget.h"
8
8
9 #include <Common/MimeTypesDef.h>
9 #include <Data/ArrayData.h>
10 #include <Data/ArrayData.h>
10 #include <Data/IDataSeries.h>
11 #include <Data/IDataSeries.h>
11 #include <DragDropHelper.h>
12 #include <DragDropHelper.h>
@@ -232,7 +233,7 QString VisualizationGraphWidget::name() const
232 QMimeData *VisualizationGraphWidget::mimeData() const
233 QMimeData *VisualizationGraphWidget::mimeData() const
233 {
234 {
234 auto mimeData = new QMimeData;
235 auto mimeData = new QMimeData;
235 mimeData->setData(DragDropHelper::MIME_TYPE_GRAPH, QByteArray());
236 mimeData->setData(MIME_TYPE_GRAPH, QByteArray());
236
237
237 return mimeData;
238 return mimeData;
238 }
239 }
@@ -7,6 +7,8
7
7
8 #include "Variable/VariableController.h"
8 #include "Variable/VariableController.h"
9
9
10 #include "Common/MimeTypesDef.h"
11
10 #include "DragDropHelper.h"
12 #include "DragDropHelper.h"
11 #include "SqpApplication.h"
13 #include "SqpApplication.h"
12
14
@@ -61,8 +63,7 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par
61 {
63 {
62 ui->setupUi(this);
64 ui->setupUi(this);
63
65
64 ui->dragDropContainer->setAcceptedMimeTypes(
66 ui->dragDropContainer->setAcceptedMimeTypes({MIME_TYPE_GRAPH, MIME_TYPE_ZONE});
65 {DragDropHelper::MIME_TYPE_GRAPH, DragDropHelper::MIME_TYPE_ZONE});
66 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccured, this,
67 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccured, this,
67 &VisualizationTabWidget::dropMimeData);
68 &VisualizationTabWidget::dropMimeData);
68 sqpApp->dragDropHelper().addDragDropScrollArea(ui->scrollArea);
69 sqpApp->dragDropHelper().addDragDropScrollArea(ui->scrollArea);
@@ -163,7 +164,7 QLayout &VisualizationTabWidget::tabLayout() const noexcept
163 void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData)
164 void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData)
164 {
165 {
165 auto &helper = sqpApp->dragDropHelper();
166 auto &helper = sqpApp->dragDropHelper();
166 if (mimeData->hasFormat(DragDropHelper::MIME_TYPE_GRAPH)) {
167 if (mimeData->hasFormat(MIME_TYPE_GRAPH)) {
167 auto graphWidget = static_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
168 auto graphWidget = static_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
168 auto parentDragDropContainer
169 auto parentDragDropContainer
169 = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget());
170 = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget());
@@ -208,7 +209,7 void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData)
208 }
209 }
209 }
210 }
210 }
211 }
211 else if (mimeData->hasFormat(DragDropHelper::MIME_TYPE_ZONE)) {
212 else if (mimeData->hasFormat(MIME_TYPE_ZONE)) {
212 // Simple move of the zone, no variable operation associated
213 // Simple move of the zone, no variable operation associated
213 auto zoneWidget = static_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget());
214 auto zoneWidget = static_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget());
214 auto parentDragDropContainer = zoneWidget->parentWidget();
215 auto parentDragDropContainer = zoneWidget->parentWidget();
@@ -5,6 +5,7
5 #include "Visualization/VisualizationGraphWidget.h"
5 #include "Visualization/VisualizationGraphWidget.h"
6 #include "ui_VisualizationZoneWidget.h"
6 #include "ui_VisualizationZoneWidget.h"
7
7
8 #include "Common/MimeTypesDef.h"
8 #include <Data/SqpRange.h>
9 #include <Data/SqpRange.h>
9 #include <Variable/Variable.h>
10 #include <Variable/Variable.h>
10 #include <Variable/VariableController.h>
11 #include <Variable/VariableController.h>
@@ -77,7 +78,7 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *p
77
78
78 ui->zoneNameLabel->setText(name);
79 ui->zoneNameLabel->setText(name);
79
80
80 ui->dragDropContainer->setAcceptedMimeTypes({DragDropHelper::MIME_TYPE_GRAPH});
81 ui->dragDropContainer->setAcceptedMimeTypes({MIME_TYPE_GRAPH});
81 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccured, this,
82 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccured, this,
82 &VisualizationZoneWidget::dropMimeData);
83 &VisualizationZoneWidget::dropMimeData);
83
84
@@ -315,7 +316,7 QString VisualizationZoneWidget::name() const
315 QMimeData *VisualizationZoneWidget::mimeData() const
316 QMimeData *VisualizationZoneWidget::mimeData() const
316 {
317 {
317 auto mimeData = new QMimeData;
318 auto mimeData = new QMimeData;
318 mimeData->setData(DragDropHelper::MIME_TYPE_ZONE, QByteArray());
319 mimeData->setData(MIME_TYPE_ZONE, QByteArray());
319
320
320 return mimeData;
321 return mimeData;
321 }
322 }
@@ -355,7 +356,7 void VisualizationZoneWidget::onVariableAboutToBeRemoved(std::shared_ptr<Variabl
355 void VisualizationZoneWidget::dropMimeData(int index, const QMimeData *mimeData)
356 void VisualizationZoneWidget::dropMimeData(int index, const QMimeData *mimeData)
356 {
357 {
357 auto &helper = sqpApp->dragDropHelper();
358 auto &helper = sqpApp->dragDropHelper();
358 if (mimeData->hasFormat(DragDropHelper::MIME_TYPE_GRAPH)) {
359 if (mimeData->hasFormat(MIME_TYPE_GRAPH)) {
359 auto graphWidget = static_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
360 auto graphWidget = static_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
360 auto parentDragDropContainer
361 auto parentDragDropContainer
361 = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget());
362 = qobject_cast<VisualizationDragDropContainer *>(graphWidget->parentWidget());
General Comments 0
You need to be logged in to leave comments. Login now