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