##// END OF EJS Templates
Reset of the drag&drop operations when a drag is started from the datasource or from the variables
trabillard -
r883:4dce99ba7a36
parent child
Show More
@@ -0,0 +1,14
1 #ifndef SCIQLOP_VARIABLEINSPECTORTABLEVIEW_H
2 #define SCIQLOP_VARIABLEINSPECTORTABLEVIEW_H
3
4 #include <QTableView>
5
6 class VariableInspectorTableView : public QTableView {
7 public:
8 VariableInspectorTableView(QWidget *parent = nullptr);
9
10 protected:
11 void startDrag(Qt::DropActions supportedActions);
12 };
13
14 #endif // SCIQLOP_VARIABLEINSPECTORTABLEVIEW_H
@@ -0,0 +1,13
1 #include "Variable/VariableInspectorTableView.h"
2
3 #include "DragDropHelper.h"
4 #include "SqpApplication.h"
5
6 VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent) {}
7
8 void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions)
9 {
10 // Resets the drag&drop operations before it's starting
11 sqpApp->dragDropHelper().resetDragAndDrop();
12 QTableView::startDrag(supportedActions);
13 }
@@ -130,7 +130,7 DataSourceItem *DataSourceItem::findItem(const QVariantHash &data, bool recursiv
130 return child.get();
130 return child.get();
131 }
131 }
132
132
133 if (recursive) {
133 if (recursive) {
134 if (auto foundItem = child->findItem(data, true)) {
134 if (auto foundItem = child->findItem(data, true)) {
135 return foundItem;
135 return foundItem;
136 }
136 }
@@ -9,6 +9,7 public:
9
9
10 protected:
10 protected:
11 QMimeData *mimeData(const QList<QTreeWidgetItem *> items) const override;
11 QMimeData *mimeData(const QList<QTreeWidgetItem *> items) const override;
12 void startDrag(Qt::DropActions supportedActions) override;
12 };
13 };
13
14
14 #endif // SCIQLOP_DATASOURCETREEWIDGET_H
15 #endif // SCIQLOP_DATASOURCETREEWIDGET_H
@@ -8,6 +8,7 gui_moc_headers = [
8 'include/DragDropHelper.h',
8 'include/DragDropHelper.h',
9 'include/TimeWidget/TimeWidget.h',
9 'include/TimeWidget/TimeWidget.h',
10 'include/Variable/VariableInspectorWidget.h',
10 'include/Variable/VariableInspectorWidget.h',
11 'include/Variable/VariableInspectorTableView.h',
11 'include/Variable/RenameVariableDialog.h',
12 'include/Variable/RenameVariableDialog.h',
12 'include/Visualization/qcustomplot.h',
13 'include/Visualization/qcustomplot.h',
13 'include/Visualization/VisualizationGraphWidget.h',
14 'include/Visualization/VisualizationGraphWidget.h',
@@ -52,6 +53,7 gui_sources = [
52 'src/SidePane/SqpSidePane.cpp',
53 'src/SidePane/SqpSidePane.cpp',
53 'src/TimeWidget/TimeWidget.cpp',
54 'src/TimeWidget/TimeWidget.cpp',
54 'src/Variable/VariableInspectorWidget.cpp',
55 'src/Variable/VariableInspectorWidget.cpp',
56 'src/Variable/VariableInspectorTableView.cpp',
55 'src/Variable/VariableMenuHeaderWidget.cpp',
57 'src/Variable/VariableMenuHeaderWidget.cpp',
56 'src/Variable/RenameVariableDialog.cpp',
58 'src/Variable/RenameVariableDialog.cpp',
57 'src/Visualization/VisualizationGraphHelper.cpp',
59 'src/Visualization/VisualizationGraphHelper.cpp',
@@ -4,6 +4,7
4 #include "DataSource/DataSourceItem.h"
4 #include "DataSource/DataSourceItem.h"
5 #include "DataSource/DataSourceTreeWidgetItem.h"
5 #include "DataSource/DataSourceTreeWidgetItem.h"
6
6
7 #include "DragDropHelper.h"
7 #include "SqpApplication.h"
8 #include "SqpApplication.h"
8
9
9 #include <QMimeData>
10 #include <QMimeData>
@@ -35,3 +36,10 QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items)
35
36
36 return mimeData;
37 return mimeData;
37 }
38 }
39
40 void DataSourceTreeWidget::startDrag(Qt::DropActions supportedActions)
41 {
42 // Resets the drag&drop operations before it's starting
43 sqpApp->dragDropHelper().resetDragAndDrop();
44 QTreeWidget::startDrag(supportedActions);
45 }
@@ -152,11 +152,6 VariableInspectorWidget::VariableInspectorWidget(QWidget *parent)
152 ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
152 ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu);
153 connect(ui->tableView, &QTableView::customContextMenuRequested, this,
153 connect(ui->tableView, &QTableView::customContextMenuRequested, this,
154 &VariableInspectorWidget::onTableMenuRequested);
154 &VariableInspectorWidget::onTableMenuRequested);
155
156 // Resets the drag&drop operation on a left-click (the drag&drop is also started by a left
157 // click).
158 connect(ui->tableView, &QTableView::clicked,
159 [](const auto &modelIndex) { sqpApp->dragDropHelper().resetDragAndDrop(); });
160 }
155 }
161
156
162 VariableInspectorWidget::~VariableInspectorWidget()
157 VariableInspectorWidget::~VariableInspectorWidget()
@@ -15,7 +15,7
15 </property>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
17 <item row="0" column="0">
18 <widget class="QTableView" name="tableView">
18 <widget class="VariableInspectorTableView" name="tableView">
19 <property name="acceptDrops">
19 <property name="acceptDrops">
20 <bool>true</bool>
20 <bool>true</bool>
21 </property>
21 </property>
@@ -35,6 +35,13
35 </item>
35 </item>
36 </layout>
36 </layout>
37 </widget>
37 </widget>
38 <customwidgets>
39 <customwidget>
40 <class>VariableInspectorTableView</class>
41 <extends>QTableView</extends>
42 <header>Variable/VariableInspectorTableView.h</header>
43 </customwidget>
44 </customwidgets>
38 <resources/>
45 <resources/>
39 <connections/>
46 <connections/>
40 </ui>
47 </ui>
General Comments 3
Under Review
author

Pull request updated. Auto status change to "Under Review"

Changed commits:
  * 1 added
  * 0 removed

Changed files:
  * A core/tests/meson.build
You need to be logged in to leave comments. Login now