diff --git a/core/src/DataSource/DataSourceItem.cpp b/core/src/DataSource/DataSourceItem.cpp index cff4322..35972b7 100644 --- a/core/src/DataSource/DataSourceItem.cpp +++ b/core/src/DataSource/DataSourceItem.cpp @@ -130,7 +130,7 @@ DataSourceItem *DataSourceItem::findItem(const QVariantHash &data, bool recursiv return child.get(); } - if (recursive) { + if (recursive) { if (auto foundItem = child->findItem(data, true)) { return foundItem; } diff --git a/gui/include/DataSource/DataSourceTreeWidget.h b/gui/include/DataSource/DataSourceTreeWidget.h index 08043ba..43141e3 100644 --- a/gui/include/DataSource/DataSourceTreeWidget.h +++ b/gui/include/DataSource/DataSourceTreeWidget.h @@ -9,6 +9,7 @@ public: protected: QMimeData *mimeData(const QList items) const override; + void startDrag(Qt::DropActions supportedActions) override; }; #endif // SCIQLOP_DATASOURCETREEWIDGET_H diff --git a/gui/include/Variable/VariableInspectorTableView.h b/gui/include/Variable/VariableInspectorTableView.h new file mode 100644 index 0000000..42bc9f1 --- /dev/null +++ b/gui/include/Variable/VariableInspectorTableView.h @@ -0,0 +1,14 @@ +#ifndef SCIQLOP_VARIABLEINSPECTORTABLEVIEW_H +#define SCIQLOP_VARIABLEINSPECTORTABLEVIEW_H + +#include + +class VariableInspectorTableView : public QTableView { +public: + VariableInspectorTableView(QWidget *parent = nullptr); + +protected: + void startDrag(Qt::DropActions supportedActions); +}; + +#endif // SCIQLOP_VARIABLEINSPECTORTABLEVIEW_H diff --git a/gui/meson.build b/gui/meson.build index c57ee52..8c2e5be 100644 --- a/gui/meson.build +++ b/gui/meson.build @@ -8,6 +8,7 @@ gui_moc_headers = [ 'include/DragDropHelper.h', 'include/TimeWidget/TimeWidget.h', 'include/Variable/VariableInspectorWidget.h', + 'include/Variable/VariableInspectorTableView.h', 'include/Variable/RenameVariableDialog.h', 'include/Visualization/qcustomplot.h', 'include/Visualization/VisualizationGraphWidget.h', @@ -52,6 +53,7 @@ gui_sources = [ 'src/SidePane/SqpSidePane.cpp', 'src/TimeWidget/TimeWidget.cpp', 'src/Variable/VariableInspectorWidget.cpp', + 'src/Variable/VariableInspectorTableView.cpp', 'src/Variable/VariableMenuHeaderWidget.cpp', 'src/Variable/RenameVariableDialog.cpp', 'src/Visualization/VisualizationGraphHelper.cpp', diff --git a/gui/src/DataSource/DataSourceTreeWidget.cpp b/gui/src/DataSource/DataSourceTreeWidget.cpp index 2e39d7e..97e62b1 100644 --- a/gui/src/DataSource/DataSourceTreeWidget.cpp +++ b/gui/src/DataSource/DataSourceTreeWidget.cpp @@ -4,6 +4,7 @@ #include "DataSource/DataSourceItem.h" #include "DataSource/DataSourceTreeWidgetItem.h" +#include "DragDropHelper.h" #include "SqpApplication.h" #include @@ -35,3 +36,10 @@ QMimeData *DataSourceTreeWidget::mimeData(const QList items) return mimeData; } + +void DataSourceTreeWidget::startDrag(Qt::DropActions supportedActions) +{ + // Resets the drag&drop operations before it's starting + sqpApp->dragDropHelper().resetDragAndDrop(); + QTreeWidget::startDrag(supportedActions); +} diff --git a/gui/src/Variable/VariableInspectorTableView.cpp b/gui/src/Variable/VariableInspectorTableView.cpp new file mode 100644 index 0000000..e03b5d3 --- /dev/null +++ b/gui/src/Variable/VariableInspectorTableView.cpp @@ -0,0 +1,13 @@ +#include "Variable/VariableInspectorTableView.h" + +#include "DragDropHelper.h" +#include "SqpApplication.h" + +VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent) {} + +void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions) +{ + // Resets the drag&drop operations before it's starting + sqpApp->dragDropHelper().resetDragAndDrop(); + QTableView::startDrag(supportedActions); +} diff --git a/gui/src/Variable/VariableInspectorWidget.cpp b/gui/src/Variable/VariableInspectorWidget.cpp index 138fe12..8cd27ba 100644 --- a/gui/src/Variable/VariableInspectorWidget.cpp +++ b/gui/src/Variable/VariableInspectorWidget.cpp @@ -152,11 +152,6 @@ VariableInspectorWidget::VariableInspectorWidget(QWidget *parent) ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->tableView, &QTableView::customContextMenuRequested, this, &VariableInspectorWidget::onTableMenuRequested); - - // Resets the drag&drop operation on a left-click (the drag&drop is also started by a left - // click). - connect(ui->tableView, &QTableView::clicked, - [](const auto &modelIndex) { sqpApp->dragDropHelper().resetDragAndDrop(); }); } VariableInspectorWidget::~VariableInspectorWidget() diff --git a/gui/ui/Variable/VariableInspectorWidget.ui b/gui/ui/Variable/VariableInspectorWidget.ui index 66b9377..6f8e92a 100644 --- a/gui/ui/Variable/VariableInspectorWidget.ui +++ b/gui/ui/Variable/VariableInspectorWidget.ui @@ -15,7 +15,7 @@ - + true @@ -35,6 +35,13 @@ + + + VariableInspectorTableView + QTableView +
Variable/VariableInspectorTableView.h
+
+