@@ -111,8 +111,8 void TestOptionalAxis::testSize_data() | |||||
111 | QTest::newRow("data1") << axis({}) << 0; |
|
111 | QTest::newRow("data1") << axis({}) << 0; | |
112 | QTest::newRow("data2") << axis({1, 2, 3}) << 3; |
|
112 | QTest::newRow("data2") << axis({1, 2, 3}) << 3; | |
113 | QTest::newRow("data3") << axis({1, 2, 3, 4}) << 4; |
|
113 | QTest::newRow("data3") << axis({1, 2, 3, 4}) << 4; | |
114 | QTest::newRow("data4 (axis not defined)") |
|
114 | QTest::newRow("data4 (axis not defined)") << OptionalAxis{} | |
115 |
|
|
115 | << 0; // Expects 0 for undefined axis | |
116 | } |
|
116 | } | |
117 |
|
117 | |||
118 | void TestOptionalAxis::testSize() |
|
118 | void TestOptionalAxis::testSize() | |
@@ -135,8 +135,8 void TestOptionalAxis::testUnit_data() | |||||
135 |
|
135 | |||
136 | QTest::newRow("data1") << axis(Unit{"Hz"}) << Unit{"Hz"}; |
|
136 | QTest::newRow("data1") << axis(Unit{"Hz"}) << Unit{"Hz"}; | |
137 | QTest::newRow("data2") << axis(Unit{"t", true}) << Unit{"t", true}; |
|
137 | QTest::newRow("data2") << axis(Unit{"t", true}) << Unit{"t", true}; | |
138 | QTest::newRow("data3 (axis not defined)") |
|
138 | QTest::newRow("data3 (axis not defined)") << OptionalAxis{} | |
139 |
|
|
139 | << Unit{}; // Expects default unit for undefined axis | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | void TestOptionalAxis::testUnit() |
|
142 | void TestOptionalAxis::testUnit() |
@@ -173,8 +173,7 void TestScalarSeries::testMergeWithVector_data() | |||||
173 | { |
|
173 | { | |
174 | testMergeDifferentTypes_struct<VectorSeries, ScalarSeries>(); |
|
174 | testMergeDifferentTypes_struct<VectorSeries, ScalarSeries>(); | |
175 |
|
175 | |||
176 | QTest::newRow("mergeVectorInScalar") |
|
176 | QTest::newRow("mergeVectorInScalar") << ScalarBuilder{} | |
177 | << ScalarBuilder{} |
|
|||
178 | .setX({1., 2., 3., 4., 5.}) |
|
177 | .setX({1., 2., 3., 4., 5.}) | |
179 | .setValues({100., 200., 300., 400., 500.}) |
|
178 | .setValues({100., 200., 300., 400., 500.}) | |
180 | .build() |
|
179 | .build() | |
@@ -184,7 +183,8 void TestScalarSeries::testMergeWithVector_data() | |||||
184 | .setYValues({610., 710., 810., 910., 1010.}) |
|
183 | .setYValues({610., 710., 810., 910., 1010.}) | |
185 | .setZValues({620., 720., 820., 920., 1020.}) |
|
184 | .setZValues({620., 720., 820., 920., 1020.}) | |
186 | .build() |
|
185 | .build() | |
187 | << DataContainer{1., 2., 3., 4., 5.} << DataContainer{100., 200., 300., 400., 500.}; |
|
186 | << DataContainer{1., 2., 3., 4., 5.} | |
|
187 | << DataContainer{100., 200., 300., 400., 500.}; | |||
188 | } |
|
188 | } | |
189 |
|
189 | |||
190 | void TestScalarSeries::testMergeWithVector() |
|
190 | void TestScalarSeries::testMergeWithVector() | |
@@ -278,12 +278,12 void TestScalarSeries::testPurge_data() | |||||
278 | .build() |
|
278 | .build() | |
279 | << 2. << 4. << DataContainer{2., 3., 4.} |
|
279 | << 2. << 4. << DataContainer{2., 3., 4.} | |
280 | << std::vector<DataContainer>{{200., 300., 400.}}; |
|
280 | << std::vector<DataContainer>{{200., 300., 400.}}; | |
281 | QTest::newRow("purgeScalar1 (min/max swap)") |
|
281 | QTest::newRow("purgeScalar1 (min/max swap)") << ScalarBuilder{} | |
282 | << ScalarBuilder{} |
|
|||
283 | .setX({1., 2., 3., 4., 5.}) |
|
282 | .setX({1., 2., 3., 4., 5.}) | |
284 | .setValues({100., 200., 300., 400., 500.}) |
|
283 | .setValues({100., 200., 300., 400., 500.}) | |
285 | .build() |
|
284 | .build() | |
286 | << 4. << 2. << DataContainer{2., 3., 4.} << std::vector<DataContainer>{{200., 300., 400.}}; |
|
285 | << 4. << 2. << DataContainer{2., 3., 4.} | |
|
286 | << std::vector<DataContainer>{{200., 300., 400.}}; | |||
287 | QTest::newRow("purgeScalar2") << ScalarBuilder{} |
|
287 | QTest::newRow("purgeScalar2") << ScalarBuilder{} | |
288 | .setX({1., 2., 3., 4., 5.}) |
|
288 | .setX({1., 2., 3., 4., 5.}) | |
289 | .setValues({100., 200., 300., 400., 500.}) |
|
289 | .setValues({100., 200., 300., 400., 500.}) | |
@@ -324,12 +324,12 void TestScalarSeries::testXAxisRange_data() | |||||
324 | .build() |
|
324 | .build() | |
325 | << -1. << 3.2 << DataContainer{1., 2., 3.} |
|
325 | << -1. << 3.2 << DataContainer{1., 2., 3.} | |
326 | << DataContainer{100., 200., 300.}; |
|
326 | << DataContainer{100., 200., 300.}; | |
327 | QTest::newRow("xAxisRange1 (min/max swap)") |
|
327 | QTest::newRow("xAxisRange1 (min/max swap)") << ScalarBuilder{} | |
328 | << ScalarBuilder{} |
|
|||
329 | .setX({1., 2., 3., 4., 5.}) |
|
328 | .setX({1., 2., 3., 4., 5.}) | |
330 | .setValues({100., 200., 300., 400., 500.}) |
|
329 | .setValues({100., 200., 300., 400., 500.}) | |
331 | .build() |
|
330 | .build() | |
332 | << 3.2 << -1. << DataContainer{1., 2., 3.} << DataContainer{100., 200., 300.}; |
|
331 | << 3.2 << -1. << DataContainer{1., 2., 3.} | |
|
332 | << DataContainer{100., 200., 300.}; | |||
333 | QTest::newRow("xAxisRange2") << ScalarBuilder{} |
|
333 | QTest::newRow("xAxisRange2") << ScalarBuilder{} | |
334 | .setX({1., 2., 3., 4., 5.}) |
|
334 | .setX({1., 2., 3., 4., 5.}) | |
335 | .setValues({100., 200., 300., 400., 500.}) |
|
335 | .setValues({100., 200., 300., 400., 500.}) | |
@@ -401,10 +401,10 void TestScalarSeries::testValuesBounds_data() | |||||
401 | .setValues({100., 200., 300., 400., 500.}) |
|
401 | .setValues({100., 200., 300., 400., 500.}) | |
402 | .build() |
|
402 | .build() | |
403 | << 5.1 << 6. << false << nan << nan; |
|
403 | << 5.1 << 6. << false << nan << nan; | |
404 | QTest::newRow("scalarBounds5") |
|
404 | QTest::newRow("scalarBounds5") << ScalarBuilder{}.setX({1.}).setValues({100.}).build() << 0. | |
405 | << ScalarBuilder{}.setX({1.}).setValues({100.}).build() << 0. << 2. << true << 100. << 100.; |
|
405 | << 2. << true << 100. << 100.; | |
406 | QTest::newRow("scalarBounds6") |
|
406 | QTest::newRow("scalarBounds6") << ScalarBuilder{}.setX({}).setValues({}).build() << 0. << 2. | |
407 | << ScalarBuilder{}.setX({}).setValues({}).build() << 0. << 2. << false << nan << nan; |
|
407 | << false << nan << nan; | |
408 |
|
408 | |||
409 | // Tests with NaN values: NaN values are not included in min/max search |
|
409 | // Tests with NaN values: NaN values are not included in min/max search | |
410 | QTest::newRow("scalarBounds7") << ScalarBuilder{} |
|
410 | QTest::newRow("scalarBounds7") << ScalarBuilder{} |
@@ -63,6 +63,10 public: | |||||
63 | void setHightlightedDragWidget(VisualizationDragWidget *dragWidget); |
|
63 | void setHightlightedDragWidget(VisualizationDragWidget *dragWidget); | |
64 | VisualizationDragWidget *getHightlightedDragWidget() const; |
|
64 | VisualizationDragWidget *getHightlightedDragWidget() const; | |
65 |
|
65 | |||
|
66 | /// Delays the closing of a widget during a drag&drop operation | |||
|
67 | void delayedCloseWidget(QWidget *widget); | |||
|
68 | void doCloseWidgets(); | |||
|
69 | ||||
66 | private: |
|
70 | private: | |
67 | class DragDropHelperPrivate; |
|
71 | class DragDropHelperPrivate; | |
68 | spimpl::unique_impl_ptr<DragDropHelperPrivate> impl; |
|
72 | spimpl::unique_impl_ptr<DragDropHelperPrivate> impl; |
@@ -9,7 +9,9 | |||||
9 |
|
9 | |||
10 | #include <QMimeData> |
|
10 | #include <QMimeData> | |
11 |
|
11 | |||
12 |
DataSourceTreeWidget::DataSourceTreeWidget(QWidget *parent) : QTreeWidget(parent) |
|
12 | DataSourceTreeWidget::DataSourceTreeWidget(QWidget *parent) : QTreeWidget(parent) | |
|
13 | { | |||
|
14 | } | |||
13 |
|
15 | |||
14 | QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const |
|
16 | QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items) const | |
15 | { |
|
17 | { |
@@ -38,6 +38,8 struct DragDropHelper::DragDropHelperPrivate { | |||||
38 | QMetaObject::Connection m_DragWidgetDestroyedConnection; |
|
38 | QMetaObject::Connection m_DragWidgetDestroyedConnection; | |
39 | QMetaObject::Connection m_HighlightedWidgetDestroyedConnection; |
|
39 | QMetaObject::Connection m_HighlightedWidgetDestroyedConnection; | |
40 |
|
40 | |||
|
41 | QList<QWidget *> m_WidgetToClose; | |||
|
42 | ||||
41 | explicit DragDropHelperPrivate() |
|
43 | explicit DragDropHelperPrivate() | |
42 | : m_PlaceHolder{std::make_unique<QWidget>()}, |
|
44 | : m_PlaceHolder{std::make_unique<QWidget>()}, | |
43 | m_DragDropScroller{std::make_unique<DragDropScroller>()}, |
|
45 | m_DragDropScroller{std::make_unique<DragDropScroller>()}, | |
@@ -95,7 +97,9 struct DragDropHelper::DragDropHelperPrivate { | |||||
95 | }; |
|
97 | }; | |
96 |
|
98 | |||
97 |
|
99 | |||
98 |
DragDropHelper::DragDropHelper() : impl{spimpl::make_unique_impl<DragDropHelperPrivate>()} |
|
100 | DragDropHelper::DragDropHelper() : impl{spimpl::make_unique_impl<DragDropHelperPrivate>()} | |
|
101 | { | |||
|
102 | } | |||
99 |
|
103 | |||
100 | DragDropHelper::~DragDropHelper() |
|
104 | DragDropHelper::~DragDropHelper() | |
101 | { |
|
105 | { | |
@@ -209,6 +213,21 VisualizationDragWidget *DragDropHelper::getHightlightedDragWidget() const | |||||
209 | return impl->m_HighlightedDragWidget; |
|
213 | return impl->m_HighlightedDragWidget; | |
210 | } |
|
214 | } | |
211 |
|
215 | |||
|
216 | void DragDropHelper::delayedCloseWidget(QWidget *widget) | |||
|
217 | { | |||
|
218 | widget->hide(); | |||
|
219 | impl->m_WidgetToClose << widget; | |||
|
220 | } | |||
|
221 | ||||
|
222 | void DragDropHelper::doCloseWidgets() | |||
|
223 | { | |||
|
224 | for (auto widget : impl->m_WidgetToClose) { | |||
|
225 | widget->close(); | |||
|
226 | } | |||
|
227 | ||||
|
228 | impl->m_WidgetToClose.clear(); | |||
|
229 | } | |||
|
230 | ||||
212 | bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData, |
|
231 | bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData, | |
213 | VisualizationDragDropContainer *dropContainer) |
|
232 | VisualizationDragDropContainer *dropContainer) | |
214 | { |
|
233 | { |
@@ -3,7 +3,9 | |||||
3 | #include "DragAndDrop/DragDropHelper.h" |
|
3 | #include "DragAndDrop/DragDropHelper.h" | |
4 | #include "SqpApplication.h" |
|
4 | #include "SqpApplication.h" | |
5 |
|
5 | |||
6 |
VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent) |
|
6 | VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent) | |
|
7 | { | |||
|
8 | } | |||
7 |
|
9 | |||
8 | void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions) |
|
10 | void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions) | |
9 | { |
|
11 | { |
@@ -210,8 +210,9 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidg | |||||
210 | // do not add the placeHolder |
|
210 | // do not add the placeHolder | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | // Note: The exec() is blocking on windows but not on linux and macOS |
|
213 | drag->exec(Qt::MoveAction | Qt::CopyAction, Qt::MoveAction); | |
214 | drag->exec(Qt::MoveAction | Qt::CopyAction); |
|
214 | ||
|
215 | helper.doCloseWidgets(); | |||
215 | } |
|
216 | } | |
216 | else { |
|
217 | else { | |
217 | qCWarning(LOG_VisualizationDragDropContainer()) |
|
218 | qCWarning(LOG_VisualizationDragDropContainer()) |
@@ -237,11 +237,11 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph( | |||||
237 |
|
237 | |||
238 | if (nbGraph == 1) { |
|
238 | if (nbGraph == 1) { | |
239 | // This is the only graph in the previous zone, close the zone |
|
239 | // This is the only graph in the previous zone, close the zone | |
240 |
graphWidget->parentZoneWidget() |
|
240 | helper.delayedCloseWidget(graphWidget->parentZoneWidget()); | |
241 | } |
|
241 | } | |
242 | else { |
|
242 | else { | |
243 | // Close the graph |
|
243 | // Close the graph | |
244 | graphWidget->close(); |
|
244 | helper.delayedCloseWidget(graphWidget); | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | tabWidget->createZone(variables, index); |
|
247 | tabWidget->createZone(variables, index); | |
@@ -258,7 +258,7 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph( | |||||
258 |
|
258 | |||
259 | // Close the old zone if it was the only graph inside |
|
259 | // Close the old zone if it was the only graph inside | |
260 | if (nbGraph == 1) { |
|
260 | if (nbGraph == 1) { | |
261 |
parentZoneWidget |
|
261 | helper.delayedCloseWidget(parentZoneWidget); | |
262 | } |
|
262 | } | |
263 | } |
|
263 | } | |
264 | } |
|
264 | } |
@@ -452,11 +452,11 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph( | |||||
452 | auto nbGraph = parentDragDropContainer->countDragWidget(); |
|
452 | auto nbGraph = parentDragDropContainer->countDragWidget(); | |
453 | if (nbGraph == 1) { |
|
453 | if (nbGraph == 1) { | |
454 | // This is the only graph in the previous zone, close the zone |
|
454 | // This is the only graph in the previous zone, close the zone | |
455 |
previousParentZoneWidget |
|
455 | helper.delayedCloseWidget(previousParentZoneWidget); | |
456 | } |
|
456 | } | |
457 | else { |
|
457 | else { | |
458 | // Close the graph |
|
458 | // Close the graph | |
459 | graphWidget->close(); |
|
459 | helper.delayedCloseWidget(graphWidget); | |
460 | } |
|
460 | } | |
461 |
|
461 | |||
462 | // Creates the new graph in the zone |
|
462 | // Creates the new graph in the zone |
General Comments 0
You need to be logged in to leave comments.
Login now