@@ -5,6 +5,7 | |||
|
5 | 5 | #include "Visualization/VisualizationWidget.h" |
|
6 | 6 | #include "Visualization/operations/FindVariableOperation.h" |
|
7 | 7 | |
|
8 | #include "Variable/Variable.h" | |
|
8 | 9 | #include "Variable/VariableController.h" |
|
9 | 10 | |
|
10 | 11 | #include "Common/MimeTypesDef.h" |
@@ -160,7 +161,7 struct DragDropHelper::DragDropHelperPrivate { | |||
|
160 | 161 | sqpApp->installEventFilter(m_DragDropScroller.get()); |
|
161 | 162 | |
|
162 | 163 | |
|
163 | m_ImageTempUrl = QDir::temp().absoluteFilePath("Scqlop_graph.png"); | |
|
164 | m_ImageTempUrl = QDir::temp().absoluteFilePath("Sciqlop_graph.png"); | |
|
164 | 165 | } |
|
165 | 166 | |
|
166 | 167 | void preparePlaceHolder() const |
@@ -293,44 +294,60 bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData, | |||
|
293 | 294 | qCWarning(LOG_DragDropHelper()) << QObject::tr( |
|
294 | 295 | "DragDropHelper::checkMimeDataForVisualization, invalid input parameters."); |
|
295 | 296 | Q_ASSERT(false); |
|
297 | return false; | |
|
296 | 298 | } |
|
297 | 299 | |
|
298 |
auto result = |
|
|
300 | auto result = false; | |
|
299 | 301 | |
|
300 | 302 | if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST)) { |
|
301 | 303 | auto variables = sqpApp->variableController().variablesForMimeData( |
|
302 | 304 | mimeData->data(MIME_TYPE_VARIABLE_LIST)); |
|
303 | 305 | |
|
304 | 306 | if (variables.count() == 1) { |
|
305 | // Check that the viariable is not already in a graph | |
|
306 | 307 | |
|
307 | // Search for the top level VisualizationWidget | |
|
308 | auto parent = dropContainer->parentWidget(); | |
|
309 | while (parent && qobject_cast<VisualizationWidget *>(parent) == nullptr) { | |
|
310 | parent = parent->parentWidget(); | |
|
311 | } | |
|
308 | auto variable = variables.first(); | |
|
309 | if (variable->dataSeries() != nullptr) { | |
|
310 | ||
|
311 | // Check that the variable is not already in a graph | |
|
312 | 312 | |
|
313 | if (parent) { | |
|
314 |
|
|
|
313 | auto parent = dropContainer->parentWidget(); | |
|
314 | while (parent && qobject_cast<VisualizationWidget *>(parent) == nullptr) { | |
|
315 | parent = parent->parentWidget(); // Search for the top level VisualizationWidget | |
|
316 | } | |
|
315 | 317 | |
|
316 | FindVariableOperation findVariableOperation{variables.first()}; | |
|
317 |
visualizationWidget |
|
|
318 | auto variableContainers = findVariableOperation.result(); | |
|
319 | if (!variableContainers.empty()) { | |
|
320 | result = false; | |
|
318 | if (parent) { | |
|
319 | auto visualizationWidget = static_cast<VisualizationWidget *>(parent); | |
|
320 | ||
|
321 | FindVariableOperation findVariableOperation{variable}; | |
|
322 | visualizationWidget->accept(&findVariableOperation); | |
|
323 | auto variableContainers = findVariableOperation.result(); | |
|
324 | if (variableContainers.empty()) { | |
|
325 | result = true; | |
|
326 | } | |
|
327 | else { | |
|
328 | // result = false: the variable already exist in the visualisation | |
|
329 | } | |
|
330 | } | |
|
331 | else { | |
|
332 | qCWarning(LOG_DragDropHelper()) << QObject::tr( | |
|
333 | "DragDropHelper::checkMimeDataForVisualization, the parent " | |
|
334 | "VisualizationWidget cannot be found. Cannot check if the variable is " | |
|
335 | "already used or not."); | |
|
321 | 336 | } |
|
322 | 337 | } |
|
323 | 338 | else { |
|
324 | qCWarning(LOG_DragDropHelper()) << QObject::tr( | |
|
325 | "DragDropHelper::checkMimeDataForVisualization, the parent " | |
|
326 | "VisualizationWidget cannot be found."); | |
|
327 | result = false; | |
|
339 | // result = false: the variable is not fully loaded | |
|
328 | 340 | } |
|
329 | 341 | } |
|
330 | 342 | else { |
|
331 | result = false; | |
|
343 | // result = false: cannot drop multiple variables in the visualisation | |
|
332 | 344 | } |
|
333 | 345 | } |
|
346 | else { | |
|
347 | // Other MIME data | |
|
348 | // no special rules, accepted by default | |
|
349 | result = true; | |
|
350 | } | |
|
334 | 351 | |
|
335 | 352 | return result; |
|
336 | 353 | } |
General Comments 0
You need to be logged in to leave comments.
Login now