@@ -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 variable = variables.first(); | |
|
309 | if (variable->dataSeries() != nullptr) { | |
|
310 | ||
|
311 | // Check that the variable is not already in a graph | |
|
312 | ||
|
308 | 313 | auto parent = dropContainer->parentWidget(); |
|
309 | 314 | while (parent && qobject_cast<VisualizationWidget *>(parent) == nullptr) { |
|
310 | parent = parent->parentWidget(); | |
|
315 | parent = parent->parentWidget(); // Search for the top level VisualizationWidget | |
|
311 | 316 | } |
|
312 | 317 | |
|
313 | 318 | if (parent) { |
|
314 | 319 | auto visualizationWidget = static_cast<VisualizationWidget *>(parent); |
|
315 | 320 | |
|
316 |
FindVariableOperation findVariableOperation{variable |
|
|
321 | FindVariableOperation findVariableOperation{variable}; | |
|
317 | 322 | visualizationWidget->accept(&findVariableOperation); |
|
318 | 323 | auto variableContainers = findVariableOperation.result(); |
|
319 |
if ( |
|
|
320 |
result = |
|
|
324 | if (variableContainers.empty()) { | |
|
325 | result = true; | |
|
326 | } | |
|
327 | else { | |
|
328 | // result = false: the variable already exist in the visualisation | |
|
321 | 329 | } |
|
322 | 330 | } |
|
323 | 331 | else { |
|
324 | 332 | qCWarning(LOG_DragDropHelper()) << QObject::tr( |
|
325 | 333 | "DragDropHelper::checkMimeDataForVisualization, the parent " |
|
326 |
"VisualizationWidget cannot be found." |
|
|
327 | result = false; | |
|
334 | "VisualizationWidget cannot be found. Cannot check if the variable is " | |
|
335 | "already used or not."); | |
|
328 | 336 | } |
|
329 | 337 | } |
|
330 | 338 | else { |
|
331 | result = false; | |
|
339 | // result = false: the variable is not fully loaded | |
|
332 | 340 | } |
|
333 | 341 | } |
|
342 | else { | |
|
343 | // result = false: cannot drop multiple variables in the visualisation | |
|
344 | } | |
|
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