##// END OF EJS Templates
Rename "DragDropHelper" in "DragDropGuiController"
trabillard -
r1110:029fbf916457
parent child
Show More
@@ -1,5 +1,5
1 #ifndef SCIQLOP_DRAGDROPHELPER_H
1 #ifndef SCIQLOP_DRAGDROPGUICONTROLLER_H
2 #define SCIQLOP_DRAGDROPHELPER_H
2 #define SCIQLOP_DRAGDROPGUICONTROLLER_H
3
3
4 #include <Common/spimpl.h>
4 #include <Common/spimpl.h>
5 #include <QLoggingCategory>
5 #include <QLoggingCategory>
@@ -12,7 +12,7 class VisualizationDragWidget;
12 class VisualizationDragDropContainer;
12 class VisualizationDragDropContainer;
13 class QMimeData;
13 class QMimeData;
14
14
15 Q_DECLARE_LOGGING_CATEGORY(LOG_DragDropHelper)
15 Q_DECLARE_LOGGING_CATEGORY(LOG_DragDropGuiController)
16
16
17 /**
17 /**
18 * @brief Helper class for drag&drop operations.
18 * @brief Helper class for drag&drop operations.
@@ -21,15 +21,15 Q_DECLARE_LOGGING_CATEGORY(LOG_DragDropHelper)
21 * can interect with the gui.
21 * can interect with the gui.
22 * @see SqpApplication
22 * @see SqpApplication
23 */
23 */
24 class DragDropHelper {
24 class DragDropGuiController {
25 public:
25 public:
26 static const QString MIME_TYPE_GRAPH;
26 static const QString MIME_TYPE_GRAPH;
27 static const QString MIME_TYPE_ZONE;
27 static const QString MIME_TYPE_ZONE;
28
28
29 enum class PlaceHolderType { Default, Graph, Zone };
29 enum class PlaceHolderType { Default, Graph, Zone };
30
30
31 DragDropHelper();
31 DragDropGuiController();
32 virtual ~DragDropHelper();
32 virtual ~DragDropGuiController();
33
33
34 /// Resets some internal variables. Must be called before any new drag&drop operation.
34 /// Resets some internal variables. Must be called before any new drag&drop operation.
35 void resetDragAndDrop();
35 void resetDragAndDrop();
@@ -68,8 +68,8 public:
68 void doCloseWidgets();
68 void doCloseWidgets();
69
69
70 private:
70 private:
71 class DragDropHelperPrivate;
71 class DragDropGuiControllerPrivate;
72 spimpl::unique_impl_ptr<DragDropHelperPrivate> impl;
72 spimpl::unique_impl_ptr<DragDropGuiControllerPrivate> impl;
73 };
73 };
74
74
75 #endif // SCIQLOP_DRAGDROPHELPER_H
75 #endif // SCIQLOP_DRAGDROPGUICONTROLLER_H
@@ -20,7 +20,7 class NetworkController;
20 class TimeController;
20 class TimeController;
21 class VariableController;
21 class VariableController;
22 class VisualizationController;
22 class VisualizationController;
23 class DragDropHelper;
23 class DragDropGuiController;
24
24
25 /**
25 /**
26 * @brief The SqpApplication class aims to make the link between SciQlop
26 * @brief The SqpApplication class aims to make the link between SciQlop
@@ -47,7 +47,7 public:
47
47
48 /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but
48 /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but
49 /// doesn't live in a thread and access gui
49 /// doesn't live in a thread and access gui
50 DragDropHelper &dragDropHelper() noexcept;
50 DragDropGuiController &dragDropGuiController() noexcept;
51
51
52 enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones };
52 enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones };
53
53
@@ -9,7 +9,7
9
9
10 #include <functional>
10 #include <functional>
11
11
12 #include <DragAndDrop/DragDropHelper.h>
12 #include <DragAndDrop/DragDropGuiController.h>
13
13
14 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationDragDropContainer)
14 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationDragDropContainer)
15
15
@@ -41,7 +41,7 public:
41
41
42 void setAcceptDragWidgetFunction(AcceptDragWidgetFunction fun);
42 void setAcceptDragWidgetFunction(AcceptDragWidgetFunction fun);
43
43
44 void setPlaceHolderType(DragDropHelper::PlaceHolderType type,
44 void setPlaceHolderType(DragDropGuiController::PlaceHolderType type,
45 const QString &placeHolderText = QString());
45 const QString &placeHolderText = QString());
46
46
47 protected:
47 protected:
@@ -4,7 +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 "DragAndDrop/DragDropHelper.h"
7 #include "DragAndDrop/DragDropGuiController.h"
8 #include "SqpApplication.h"
8 #include "SqpApplication.h"
9
9
10 #include <QMimeData>
10 #include <QMimeData>
@@ -42,6 +42,6 QMimeData *DataSourceTreeWidget::mimeData(const QList<QTreeWidgetItem *> items)
42 void DataSourceTreeWidget::startDrag(Qt::DropActions supportedActions)
42 void DataSourceTreeWidget::startDrag(Qt::DropActions supportedActions)
43 {
43 {
44 // Resets the drag&drop operations before it's starting
44 // Resets the drag&drop operations before it's starting
45 sqpApp->dragDropHelper().resetDragAndDrop();
45 sqpApp->dragDropGuiController().resetDragAndDrop();
46 QTreeWidget::startDrag(supportedActions);
46 QTreeWidget::startDrag(supportedActions);
47 }
47 }
@@ -1,4 +1,4
1 #include "DragAndDrop/DragDropHelper.h"
1 #include "DragAndDrop/DragDropGuiController.h"
2 #include "DragAndDrop/DragDropScroller.h"
2 #include "DragAndDrop/DragDropScroller.h"
3 #include "DragAndDrop/DragDropTabSwitcher.h"
3 #include "DragAndDrop/DragDropTabSwitcher.h"
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
@@ -19,10 +19,10
19 #include <QVBoxLayout>
19 #include <QVBoxLayout>
20
20
21
21
22 Q_LOGGING_CATEGORY(LOG_DragDropHelper, "DragDropHelper")
22 Q_LOGGING_CATEGORY(LOG_DragDropGuiController, "DragDropGuiController")
23
23
24
24
25 struct DragDropHelper::DragDropHelperPrivate {
25 struct DragDropGuiController::DragDropGuiControllerPrivate {
26
26
27 VisualizationDragWidget *m_CurrentDragWidget = nullptr;
27 VisualizationDragWidget *m_CurrentDragWidget = nullptr;
28 std::unique_ptr<QWidget> m_PlaceHolder = nullptr;
28 std::unique_ptr<QWidget> m_PlaceHolder = nullptr;
@@ -40,7 +40,7 struct DragDropHelper::DragDropHelperPrivate {
40
40
41 QList<QWidget *> m_WidgetToClose;
41 QList<QWidget *> m_WidgetToClose;
42
42
43 explicit DragDropHelperPrivate()
43 explicit DragDropGuiControllerPrivate()
44 : m_PlaceHolder{std::make_unique<QWidget>()},
44 : m_PlaceHolder{std::make_unique<QWidget>()},
45 m_DragDropScroller{std::make_unique<DragDropScroller>()},
45 m_DragDropScroller{std::make_unique<DragDropScroller>()},
46 m_DragDropTabSwitcher{std::make_unique<DragDropTabSwitcher>()}
46 m_DragDropTabSwitcher{std::make_unique<DragDropTabSwitcher>()}
@@ -64,7 +64,8 struct DragDropHelper::DragDropHelperPrivate {
64 m_ImageTempUrl = QDir::temp().absoluteFilePath("Sciqlop_graph.png");
64 m_ImageTempUrl = QDir::temp().absoluteFilePath("Sciqlop_graph.png");
65 }
65 }
66
66
67 void preparePlaceHolder(DragDropHelper::PlaceHolderType type, const QString &topLabelText) const
67 void preparePlaceHolder(DragDropGuiController::PlaceHolderType type,
68 const QString &topLabelText) const
68 {
69 {
69 if (m_CurrentDragWidget) {
70 if (m_CurrentDragWidget) {
70 m_PlaceHolder->setMinimumSize(m_CurrentDragWidget->size());
71 m_PlaceHolder->setMinimumSize(m_CurrentDragWidget->size());
@@ -79,12 +80,12 struct DragDropHelper::DragDropHelperPrivate {
79 }
80 }
80
81
81 switch (type) {
82 switch (type) {
82 case DragDropHelper::PlaceHolderType::Graph:
83 case DragDropGuiController::PlaceHolderType::Graph:
83 m_PlaceBackground->setStyleSheet(
84 m_PlaceBackground->setStyleSheet(
84 "background-color: #BBD5EE; border: 1px solid #2A7FD4");
85 "background-color: #BBD5EE; border: 1px solid #2A7FD4");
85 break;
86 break;
86 case DragDropHelper::PlaceHolderType::Zone:
87 case DragDropGuiController::PlaceHolderType::Zone:
87 case DragDropHelper::PlaceHolderType::Default:
88 case DragDropGuiController::PlaceHolderType::Default:
88 m_PlaceBackground->setStyleSheet(
89 m_PlaceBackground->setStyleSheet(
89 "background-color: #BBD5EE; border: 2px solid #2A7FD4");
90 "background-color: #BBD5EE; border: 2px solid #2A7FD4");
90 m_PlaceHolderLabel->setStyleSheet("color: #2A7FD4");
91 m_PlaceHolderLabel->setStyleSheet("color: #2A7FD4");
@@ -97,22 +98,23 struct DragDropHelper::DragDropHelperPrivate {
97 };
98 };
98
99
99
100
100 DragDropHelper::DragDropHelper() : impl{spimpl::make_unique_impl<DragDropHelperPrivate>()}
101 DragDropGuiController::DragDropGuiController()
102 : impl{spimpl::make_unique_impl<DragDropGuiControllerPrivate>()}
101 {
103 {
102 }
104 }
103
105
104 DragDropHelper::~DragDropHelper()
106 DragDropGuiController::~DragDropGuiController()
105 {
107 {
106 QFile::remove(impl->m_ImageTempUrl);
108 QFile::remove(impl->m_ImageTempUrl);
107 }
109 }
108
110
109 void DragDropHelper::resetDragAndDrop()
111 void DragDropGuiController::resetDragAndDrop()
110 {
112 {
111 setCurrentDragWidget(nullptr);
113 setCurrentDragWidget(nullptr);
112 impl->m_HighlightedDragWidget = nullptr;
114 impl->m_HighlightedDragWidget = nullptr;
113 }
115 }
114
116
115 void DragDropHelper::setCurrentDragWidget(VisualizationDragWidget *dragWidget)
117 void DragDropGuiController::setCurrentDragWidget(VisualizationDragWidget *dragWidget)
116 {
118 {
117 if (impl->m_CurrentDragWidget) {
119 if (impl->m_CurrentDragWidget) {
118
120
@@ -129,18 +131,18 void DragDropHelper::setCurrentDragWidget(VisualizationDragWidget *dragWidget)
129 impl->m_CurrentDragWidget = dragWidget;
131 impl->m_CurrentDragWidget = dragWidget;
130 }
132 }
131
133
132 VisualizationDragWidget *DragDropHelper::getCurrentDragWidget() const
134 VisualizationDragWidget *DragDropGuiController::getCurrentDragWidget() const
133 {
135 {
134 return impl->m_CurrentDragWidget;
136 return impl->m_CurrentDragWidget;
135 }
137 }
136
138
137 QWidget &DragDropHelper::placeHolder() const
139 QWidget &DragDropGuiController::placeHolder() const
138 {
140 {
139 return *impl->m_PlaceHolder;
141 return *impl->m_PlaceHolder;
140 }
142 }
141
143
142 void DragDropHelper::insertPlaceHolder(QVBoxLayout *layout, int index, PlaceHolderType type,
144 void DragDropGuiController::insertPlaceHolder(QVBoxLayout *layout, int index, PlaceHolderType type,
143 const QString &topLabelText)
145 const QString &topLabelText)
144 {
146 {
145 removePlaceHolder();
147 removePlaceHolder();
146 impl->preparePlaceHolder(type, topLabelText);
148 impl->preparePlaceHolder(type, topLabelText);
@@ -148,7 +150,7 void DragDropHelper::insertPlaceHolder(QVBoxLayout *layout, int index, PlaceHold
148 impl->m_PlaceHolder->show();
150 impl->m_PlaceHolder->show();
149 }
151 }
150
152
151 void DragDropHelper::removePlaceHolder()
153 void DragDropGuiController::removePlaceHolder()
152 {
154 {
153 auto parentWidget = impl->m_PlaceHolder->parentWidget();
155 auto parentWidget = impl->m_PlaceHolder->parentWidget();
154 if (parentWidget) {
156 if (parentWidget) {
@@ -158,38 +160,38 void DragDropHelper::removePlaceHolder()
158 }
160 }
159 }
161 }
160
162
161 bool DragDropHelper::isPlaceHolderSet() const
163 bool DragDropGuiController::isPlaceHolderSet() const
162 {
164 {
163 return impl->m_PlaceHolder->parentWidget();
165 return impl->m_PlaceHolder->parentWidget();
164 }
166 }
165
167
166 void DragDropHelper::addDragDropScrollArea(QScrollArea *scrollArea)
168 void DragDropGuiController::addDragDropScrollArea(QScrollArea *scrollArea)
167 {
169 {
168 impl->m_DragDropScroller->addScrollArea(scrollArea);
170 impl->m_DragDropScroller->addScrollArea(scrollArea);
169 }
171 }
170
172
171 void DragDropHelper::removeDragDropScrollArea(QScrollArea *scrollArea)
173 void DragDropGuiController::removeDragDropScrollArea(QScrollArea *scrollArea)
172 {
174 {
173 impl->m_DragDropScroller->removeScrollArea(scrollArea);
175 impl->m_DragDropScroller->removeScrollArea(scrollArea);
174 }
176 }
175
177
176 void DragDropHelper::addDragDropTabBar(QTabBar *tabBar)
178 void DragDropGuiController::addDragDropTabBar(QTabBar *tabBar)
177 {
179 {
178 impl->m_DragDropTabSwitcher->addTabBar(tabBar);
180 impl->m_DragDropTabSwitcher->addTabBar(tabBar);
179 }
181 }
180
182
181 void DragDropHelper::removeDragDropTabBar(QTabBar *tabBar)
183 void DragDropGuiController::removeDragDropTabBar(QTabBar *tabBar)
182 {
184 {
183 impl->m_DragDropTabSwitcher->removeTabBar(tabBar);
185 impl->m_DragDropTabSwitcher->removeTabBar(tabBar);
184 }
186 }
185
187
186 QUrl DragDropHelper::imageTemporaryUrl(const QImage &image) const
188 QUrl DragDropGuiController::imageTemporaryUrl(const QImage &image) const
187 {
189 {
188 image.save(impl->m_ImageTempUrl);
190 image.save(impl->m_ImageTempUrl);
189 return QUrl::fromLocalFile(impl->m_ImageTempUrl);
191 return QUrl::fromLocalFile(impl->m_ImageTempUrl);
190 }
192 }
191
193
192 void DragDropHelper::setHightlightedDragWidget(VisualizationDragWidget *dragWidget)
194 void DragDropGuiController::setHightlightedDragWidget(VisualizationDragWidget *dragWidget)
193 {
195 {
194 if (impl->m_HighlightedDragWidget) {
196 if (impl->m_HighlightedDragWidget) {
195 impl->m_HighlightedDragWidget->highlightForMerge(false);
197 impl->m_HighlightedDragWidget->highlightForMerge(false);
@@ -208,18 +210,18 void DragDropHelper::setHightlightedDragWidget(VisualizationDragWidget *dragWidg
208 impl->m_HighlightedDragWidget = dragWidget;
210 impl->m_HighlightedDragWidget = dragWidget;
209 }
211 }
210
212
211 VisualizationDragWidget *DragDropHelper::getHightlightedDragWidget() const
213 VisualizationDragWidget *DragDropGuiController::getHightlightedDragWidget() const
212 {
214 {
213 return impl->m_HighlightedDragWidget;
215 return impl->m_HighlightedDragWidget;
214 }
216 }
215
217
216 void DragDropHelper::delayedCloseWidget(QWidget *widget)
218 void DragDropGuiController::delayedCloseWidget(QWidget *widget)
217 {
219 {
218 widget->hide();
220 widget->hide();
219 impl->m_WidgetToClose << widget;
221 impl->m_WidgetToClose << widget;
220 }
222 }
221
223
222 void DragDropHelper::doCloseWidgets()
224 void DragDropGuiController::doCloseWidgets()
223 {
225 {
224 for (auto widget : impl->m_WidgetToClose) {
226 for (auto widget : impl->m_WidgetToClose) {
225 widget->close();
227 widget->close();
@@ -228,12 +230,12 void DragDropHelper::doCloseWidgets()
228 impl->m_WidgetToClose.clear();
230 impl->m_WidgetToClose.clear();
229 }
231 }
230
232
231 bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData,
233 bool DragDropGuiController::checkMimeDataForVisualization(
232 VisualizationDragDropContainer *dropContainer)
234 const QMimeData *mimeData, VisualizationDragDropContainer *dropContainer)
233 {
235 {
234 if (!mimeData || !dropContainer) {
236 if (!mimeData || !dropContainer) {
235 qCWarning(LOG_DragDropHelper()) << QObject::tr(
237 qCWarning(LOG_DragDropGuiController()) << QObject::tr(
236 "DragDropHelper::checkMimeDataForVisualization, invalid input parameters.");
238 "DragDropGuiController::checkMimeDataForVisualization, invalid input parameters.");
237 Q_ASSERT(false);
239 Q_ASSERT(false);
238 return false;
240 return false;
239 }
241 }
@@ -270,8 +272,8 bool DragDropHelper::checkMimeDataForVisualization(const QMimeData *mimeData,
270 }
272 }
271 }
273 }
272 else {
274 else {
273 qCWarning(LOG_DragDropHelper()) << QObject::tr(
275 qCWarning(LOG_DragDropGuiController()) << QObject::tr(
274 "DragDropHelper::checkMimeDataForVisualization, the parent "
276 "DragDropGuiController::checkMimeDataForVisualization, the parent "
275 "VisualizationWidget cannot be found. Cannot check if the variable is "
277 "VisualizationWidget cannot be found. Cannot check if the variable is "
276 "already used or not.");
278 "already used or not.");
277 }
279 }
@@ -3,7 +3,7
3 #include <Catalogue/CatalogueController.h>
3 #include <Catalogue/CatalogueController.h>
4 #include <Data/IDataProvider.h>
4 #include <Data/IDataProvider.h>
5 #include <DataSource/DataSourceController.h>
5 #include <DataSource/DataSourceController.h>
6 #include <DragAndDrop/DragDropHelper.h>
6 #include <DragAndDrop/DragDropGuiController.h>
7 #include <Network/NetworkController.h>
7 #include <Network/NetworkController.h>
8 #include <QThread>
8 #include <QThread>
9 #include <Time/TimeController.h>
9 #include <Time/TimeController.h>
@@ -22,7 +22,7 public:
22 m_TimeController{std::make_unique<TimeController>()},
22 m_TimeController{std::make_unique<TimeController>()},
23 m_NetworkController{std::make_unique<NetworkController>()},
23 m_NetworkController{std::make_unique<NetworkController>()},
24 m_VisualizationController{std::make_unique<VisualizationController>()},
24 m_VisualizationController{std::make_unique<VisualizationController>()},
25 m_DragDropHelper{std::make_unique<DragDropHelper>()},
25 m_DragDropGuiController{std::make_unique<DragDropGuiController>()},
26 m_CatalogueController{std::make_unique<CatalogueController>()},
26 m_CatalogueController{std::make_unique<CatalogueController>()},
27 m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None),
27 m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None),
28 m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor)
28 m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor)
@@ -100,7 +100,7 public:
100 QThread m_VisualizationControllerThread;
100 QThread m_VisualizationControllerThread;
101 QThread m_CatalogueControllerThread;
101 QThread m_CatalogueControllerThread;
102
102
103 std::unique_ptr<DragDropHelper> m_DragDropHelper;
103 std::unique_ptr<DragDropGuiController> m_DragDropGuiController;
104
104
105 SqpApplication::PlotsInteractionMode m_PlotInterractionMode;
105 SqpApplication::PlotsInteractionMode m_PlotInterractionMode;
106 SqpApplication::PlotsCursorMode m_PlotCursorMode;
106 SqpApplication::PlotsCursorMode m_PlotCursorMode;
@@ -177,9 +177,9 VisualizationController &SqpApplication::visualizationController() noexcept
177 return *impl->m_VisualizationController;
177 return *impl->m_VisualizationController;
178 }
178 }
179
179
180 DragDropHelper &SqpApplication::dragDropHelper() noexcept
180 DragDropGuiController &SqpApplication::dragDropGuiController() noexcept
181 {
181 {
182 return *impl->m_DragDropHelper;
182 return *impl->m_DragDropGuiController;
183 }
183 }
184
184
185 SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const
185 SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const
@@ -4,7 +4,7
4 #include <Common/DateUtils.h>
4 #include <Common/DateUtils.h>
5 #include <Common/MimeTypesDef.h>
5 #include <Common/MimeTypesDef.h>
6
6
7 #include <DragAndDrop/DragDropHelper.h>
7 #include <DragAndDrop/DragDropGuiController.h>
8 #include <SqpApplication.h>
8 #include <SqpApplication.h>
9 #include <Time/TimeController.h>
9 #include <Time/TimeController.h>
10
10
@@ -145,7 +145,7 void TimeWidget::mouseMoveEvent(QMouseEvent *event)
145 auto pixmap = QPixmap{":/icones/time.png"};
145 auto pixmap = QPixmap{":/icones/time.png"};
146 drag->setPixmap(pixmap.scaledToWidth(22));
146 drag->setPixmap(pixmap.scaledToWidth(22));
147
147
148 sqpApp->dragDropHelper().resetDragAndDrop();
148 sqpApp->dragDropGuiController().resetDragAndDrop();
149
149
150 // Note: The exec() is blocking on windows but not on linux and macOS
150 // Note: The exec() is blocking on windows but not on linux and macOS
151 drag->exec(Qt::MoveAction | Qt::CopyAction);
151 drag->exec(Qt::MoveAction | Qt::CopyAction);
@@ -1,6 +1,6
1 #include "Variable/VariableInspectorTableView.h"
1 #include "Variable/VariableInspectorTableView.h"
2
2
3 #include "DragAndDrop/DragDropHelper.h"
3 #include "DragAndDrop/DragDropGuiController.h"
4 #include "SqpApplication.h"
4 #include "SqpApplication.h"
5
5
6 VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent)
6 VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTableView(parent)
@@ -10,6 +10,6 VariableInspectorTableView::VariableInspectorTableView(QWidget *parent) : QTable
10 void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions)
10 void VariableInspectorTableView::startDrag(Qt::DropActions supportedActions)
11 {
11 {
12 // Resets the drag&drop operations before it's starting
12 // Resets the drag&drop operations before it's starting
13 sqpApp->dragDropHelper().resetDragAndDrop();
13 sqpApp->dragDropGuiController().resetDragAndDrop();
14 QTableView::startDrag(supportedActions);
14 QTableView::startDrag(supportedActions);
15 }
15 }
@@ -12,7 +12,7
12 #include <QStyledItemDelegate>
12 #include <QStyledItemDelegate>
13 #include <QWidgetAction>
13 #include <QWidgetAction>
14
14
15 #include <DragAndDrop/DragDropHelper.h>
15 #include <DragAndDrop/DragDropGuiController.h>
16 #include <SqpApplication.h>
16 #include <SqpApplication.h>
17
17
18 Q_LOGGING_CATEGORY(LOG_VariableInspectorWidget, "VariableInspectorWidget")
18 Q_LOGGING_CATEGORY(LOG_VariableInspectorWidget, "VariableInspectorWidget")
@@ -1,5 +1,5
1 #include "Visualization/VisualizationDragDropContainer.h"
1 #include "Visualization/VisualizationDragDropContainer.h"
2 #include "DragAndDrop/DragDropHelper.h"
2 #include "DragAndDrop/DragDropGuiController.h"
3 #include "SqpApplication.h"
3 #include "SqpApplication.h"
4 #include "Visualization/VisualizationDragWidget.h"
4 #include "Visualization/VisualizationDragWidget.h"
5
5
@@ -21,7 +21,7 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
21 QVBoxLayout *m_Layout;
21 QVBoxLayout *m_Layout;
22 QHash<QString, VisualizationDragDropContainer::DropBehavior> m_AcceptedMimeTypes;
22 QHash<QString, VisualizationDragDropContainer::DropBehavior> m_AcceptedMimeTypes;
23 QString m_PlaceHolderText;
23 QString m_PlaceHolderText;
24 DragDropHelper::PlaceHolderType m_PlaceHolderType;
24 DragDropGuiController::PlaceHolderType m_PlaceHolderType;
25
25
26 VisualizationDragDropContainer::AcceptMimeDataFunction m_AcceptMimeDataFun
26 VisualizationDragDropContainer::AcceptMimeDataFunction m_AcceptMimeDataFun
27 = [](auto mimeData) { return true; };
27 = [](auto mimeData) { return true; };
@@ -31,7 +31,7 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
31 int m_MinContainerHeight = 0;
31 int m_MinContainerHeight = 0;
32
32
33 explicit VisualizationDragDropContainerPrivate(QWidget *widget)
33 explicit VisualizationDragDropContainerPrivate(QWidget *widget)
34 : m_PlaceHolderType(DragDropHelper::PlaceHolderType::Graph)
34 : m_PlaceHolderType(DragDropGuiController::PlaceHolderType::Graph)
35 {
35 {
36 m_Layout = new QVBoxLayout(widget);
36 m_Layout = new QVBoxLayout(widget);
37 m_Layout->setContentsMargins(0, 0, 0, 0);
37 m_Layout->setContentsMargins(0, 0, 0, 0);
@@ -104,7 +104,8 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
104
104
105 bool hasPlaceHolder() const
105 bool hasPlaceHolder() const
106 {
106 {
107 return sqpApp->dragDropHelper().placeHolder().parentWidget() == m_Layout->parentWidget();
107 return sqpApp->dragDropGuiController().placeHolder().parentWidget()
108 == m_Layout->parentWidget();
108 }
109 }
109
110
110 VisualizationDragWidget *getChildDragWidgetAt(const QWidget *parent, const QPoint &pos) const
111 VisualizationDragWidget *getChildDragWidgetAt(const QWidget *parent, const QPoint &pos) const
@@ -128,7 +129,7 struct VisualizationDragDropContainer::VisualizationDragDropContainerPrivate {
128 {
129 {
129 auto widgetUnderMouse = sqpApp->widgetAt(QCursor::pos());
130 auto widgetUnderMouse = sqpApp->widgetAt(QCursor::pos());
130 return container->isAncestorOf(widgetUnderMouse) && widgetUnderMouse != container
131 return container->isAncestorOf(widgetUnderMouse) && widgetUnderMouse != container
131 && sqpApp->dragDropHelper().placeHolder().isAncestorOf(widgetUnderMouse);
132 && sqpApp->dragDropGuiController().placeHolder().isAncestorOf(widgetUnderMouse);
132 }
133 }
133
134
134 int countDragWidget(const QWidget *parent, bool onlyVisible = false) const
135 int countDragWidget(const QWidget *parent, bool onlyVisible = false) const
@@ -196,7 +197,7 void VisualizationDragDropContainer::setAcceptDragWidgetFunction(
196 impl->m_AcceptDragWidgetFun = fun;
197 impl->m_AcceptDragWidgetFun = fun;
197 }
198 }
198
199
199 void VisualizationDragDropContainer::setPlaceHolderType(DragDropHelper::PlaceHolderType type,
200 void VisualizationDragDropContainer::setPlaceHolderType(DragDropGuiController::PlaceHolderType type,
200 const QString &placeHolderText)
201 const QString &placeHolderText)
201 {
202 {
202 impl->m_PlaceHolderType = type;
203 impl->m_PlaceHolderType = type;
@@ -206,7 +207,7 void VisualizationDragDropContainer::setPlaceHolderType(DragDropHelper::PlaceHol
206 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidget,
207 void VisualizationDragDropContainer::startDrag(VisualizationDragWidget *dragWidget,
207 const QPoint &dragPosition)
208 const QPoint &dragPosition)
208 {
209 {
209 auto &helper = sqpApp->dragDropHelper();
210 auto &helper = sqpApp->dragDropGuiController();
210 helper.resetDragAndDrop();
211 helper.resetDragAndDrop();
211
212
212 // Note: The management of the drag object is done by Qt
213 // Note: The management of the drag object is done by Qt
@@ -261,7 +262,7 void VisualizationDragDropContainer::dragEnterEvent(QDragEnterEvent *event)
261 if (impl->acceptMimeData(event->mimeData())) {
262 if (impl->acceptMimeData(event->mimeData())) {
262 event->acceptProposedAction();
263 event->acceptProposedAction();
263
264
264 auto &helper = sqpApp->dragDropHelper();
265 auto &helper = sqpApp->dragDropGuiController();
265
266
266 if (!impl->hasPlaceHolder()) {
267 if (!impl->hasPlaceHolder()) {
267 auto dragWidget = helper.getCurrentDragWidget();
268 auto dragWidget = helper.getCurrentDragWidget();
@@ -298,7 +299,7 void VisualizationDragDropContainer::dragLeaveEvent(QDragLeaveEvent *event)
298 {
299 {
299 Q_UNUSED(event);
300 Q_UNUSED(event);
300
301
301 auto &helper = sqpApp->dragDropHelper();
302 auto &helper = sqpApp->dragDropGuiController();
302
303
303 if (!impl->cursorIsInContainer(this)) {
304 if (!impl->cursorIsInContainer(this)) {
304 helper.removePlaceHolder();
305 helper.removePlaceHolder();
@@ -342,7 +343,7 void VisualizationDragDropContainer::dragMoveEvent(QDragMoveEvent *event)
342
343
343 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
344 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
344 {
345 {
345 auto &helper = sqpApp->dragDropHelper();
346 auto &helper = sqpApp->dragDropGuiController();
346
347
347 if (impl->acceptMimeData(event->mimeData())) {
348 if (impl->acceptMimeData(event->mimeData())) {
348 auto dragWidget = helper.getCurrentDragWidget();
349 auto dragWidget = helper.getCurrentDragWidget();
@@ -398,7 +399,7 void VisualizationDragDropContainer::dropEvent(QDropEvent *event)
398 event->ignore();
399 event->ignore();
399 }
400 }
400
401
401 sqpApp->dragDropHelper().setHightlightedDragWidget(nullptr);
402 sqpApp->dragDropGuiController().setHightlightedDragWidget(nullptr);
402 impl->m_MinContainerHeight = 0;
403 impl->m_MinContainerHeight = 0;
403
404
404 QWidget::dropEvent(event);
405 QWidget::dropEvent(event);
@@ -409,7 +410,7 bool VisualizationDragDropContainer::VisualizationDragDropContainerPrivate::find
409 const QPoint &pos, const QMimeData *mimeData, bool canInsert, bool canMerge,
410 const QPoint &pos, const QMimeData *mimeData, bool canInsert, bool canMerge,
410 const VisualizationDragDropContainer *container)
411 const VisualizationDragDropContainer *container)
411 {
412 {
412 auto &helper = sqpApp->dragDropHelper();
413 auto &helper = sqpApp->dragDropGuiController();
413
414
414 auto absPos = container->mapToGlobal(pos);
415 auto absPos = container->mapToGlobal(pos);
415 auto isOnPlaceHolder = helper.placeHolder().isAncestorOf(sqpApp->widgetAt(absPos));
416 auto isOnPlaceHolder = helper.placeHolder().isAncestorOf(sqpApp->widgetAt(absPos));
@@ -14,7 +14,7
14 #include <Data/ArrayData.h>
14 #include <Data/ArrayData.h>
15 #include <Data/IDataSeries.h>
15 #include <Data/IDataSeries.h>
16 #include <Data/SpectrogramSeries.h>
16 #include <Data/SpectrogramSeries.h>
17 #include <DragAndDrop/DragDropHelper.h>
17 #include <DragAndDrop/DragDropGuiController.h>
18 #include <Settings/SqpSettingsDefs.h>
18 #include <Settings/SqpSettingsDefs.h>
19 #include <SqpApplication.h>
19 #include <SqpApplication.h>
20 #include <Time/TimeController.h>
20 #include <Time/TimeController.h>
@@ -11,7 +11,7
11
11
12 #include "Common/MimeTypesDef.h"
12 #include "Common/MimeTypesDef.h"
13
13
14 #include "DragAndDrop/DragDropHelper.h"
14 #include "DragAndDrop/DragDropGuiController.h"
15 #include "SqpApplication.h"
15 #include "SqpApplication.h"
16
16
17 Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget")
17 Q_LOGGING_CATEGORY(LOG_VisualizationTabWidget, "VisualizationTabWidget")
@@ -78,7 +78,7 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par
78 impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true);
78 impl->m_MacScrollBarStyle->selfInstallOn(ui->scrollArea, true);
79 #endif
79 #endif
80
80
81 ui->dragDropContainer->setPlaceHolderType(DragDropHelper::PlaceHolderType::Zone, "Zone");
81 ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Zone, "Zone");
82 ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12);
82 ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12);
83 ui->dragDropContainer->layout()->setSpacing(0);
83 ui->dragDropContainer->layout()->setSpacing(0);
84 ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH,
84 ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH,
@@ -89,14 +89,14 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par
89 VisualizationDragDropContainer::DropBehavior::Inserted);
89 VisualizationDragDropContainer::DropBehavior::Inserted);
90
90
91 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
91 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
92 return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData,
92 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData,
93 ui->dragDropContainer);
93 ui->dragDropContainer);
94 });
94 });
95
95
96 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this,
96 connect(ui->dragDropContainer, &VisualizationDragDropContainer::dropOccuredInContainer, this,
97 &VisualizationTabWidget::dropMimeData);
97 &VisualizationTabWidget::dropMimeData);
98
98
99 sqpApp->dragDropHelper().addDragDropScrollArea(ui->scrollArea);
99 sqpApp->dragDropGuiController().addDragDropScrollArea(ui->scrollArea);
100
100
101 // Widget is deleted when closed
101 // Widget is deleted when closed
102 setAttribute(Qt::WA_DeleteOnClose);
102 setAttribute(Qt::WA_DeleteOnClose);
@@ -104,7 +104,7 VisualizationTabWidget::VisualizationTabWidget(const QString &name, QWidget *par
104
104
105 VisualizationTabWidget::~VisualizationTabWidget()
105 VisualizationTabWidget::~VisualizationTabWidget()
106 {
106 {
107 sqpApp->dragDropHelper().removeDragDropScrollArea(ui->scrollArea);
107 sqpApp->dragDropGuiController().removeDragDropScrollArea(ui->scrollArea);
108 delete ui;
108 delete ui;
109 }
109 }
110
110
@@ -213,7 +213,7 void VisualizationTabWidget::dropMimeData(int index, const QMimeData *mimeData)
213 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph(
213 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph(
214 int index, VisualizationTabWidget *tabWidget)
214 int index, VisualizationTabWidget *tabWidget)
215 {
215 {
216 auto &helper = sqpApp->dragDropHelper();
216 auto &helper = sqpApp->dragDropGuiController();
217
217
218 auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
218 auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
219 if (!graphWidget) {
219 if (!graphWidget) {
@@ -286,7 +286,7 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropGraph(
286 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropZone(
286 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropZone(
287 int index, VisualizationTabWidget *tabWidget)
287 int index, VisualizationTabWidget *tabWidget)
288 {
288 {
289 auto &helper = sqpApp->dragDropHelper();
289 auto &helper = sqpApp->dragDropGuiController();
290
290
291 auto zoneWidget = qobject_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget());
291 auto zoneWidget = qobject_cast<VisualizationZoneWidget *>(helper.getCurrentDragWidget());
292 if (!zoneWidget) {
292 if (!zoneWidget) {
@@ -12,7 +12,7
12
12
13 #include "ui_VisualizationWidget.h"
13 #include "ui_VisualizationWidget.h"
14
14
15 #include "DragAndDrop/DragDropHelper.h"
15 #include "DragAndDrop/DragDropGuiController.h"
16 #include "SqpApplication.h"
16 #include "SqpApplication.h"
17
17
18 #include <QToolButton>
18 #include <QToolButton>
@@ -84,7 +84,7 VisualizationWidget::VisualizationWidget(QWidget *parent)
84 connect(addTabViewButton, &QToolButton::clicked, addTabView);
84 connect(addTabViewButton, &QToolButton::clicked, addTabView);
85 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
85 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
86
86
87 sqpApp->dragDropHelper().addDragDropTabBar(ui->tabWidget->tabBar());
87 sqpApp->dragDropGuiController().addDragDropTabBar(ui->tabWidget->tabBar());
88
88
89 // Adds default tab
89 // Adds default tab
90 addTabView();
90 addTabView();
@@ -92,7 +92,7 VisualizationWidget::VisualizationWidget(QWidget *parent)
92
92
93 VisualizationWidget::~VisualizationWidget()
93 VisualizationWidget::~VisualizationWidget()
94 {
94 {
95 sqpApp->dragDropHelper().removeDragDropTabBar(ui->tabWidget->tabBar());
95 sqpApp->dragDropGuiController().removeDragDropTabBar(ui->tabWidget->tabBar());
96 delete ui;
96 delete ui;
97 }
97 }
98
98
@@ -16,7 +16,7
16
16
17 #include <Visualization/operations/FindVariableOperation.h>
17 #include <Visualization/operations/FindVariableOperation.h>
18
18
19 #include <DragAndDrop/DragDropHelper.h>
19 #include <DragAndDrop/DragDropGuiController.h>
20 #include <QUuid>
20 #include <QUuid>
21 #include <SqpApplication.h>
21 #include <SqpApplication.h>
22 #include <cmath>
22 #include <cmath>
@@ -86,7 +86,7 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *p
86
86
87 ui->zoneNameLabel->setText(name);
87 ui->zoneNameLabel->setText(name);
88
88
89 ui->dragDropContainer->setPlaceHolderType(DragDropHelper::PlaceHolderType::Graph);
89 ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Graph);
90 ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH,
90 ui->dragDropContainer->setMimeType(MIME_TYPE_GRAPH,
91 VisualizationDragDropContainer::DropBehavior::Inserted);
91 VisualizationDragDropContainer::DropBehavior::Inserted);
92 ui->dragDropContainer->setMimeType(
92 ui->dragDropContainer->setMimeType(
@@ -98,8 +98,8 VisualizationZoneWidget::VisualizationZoneWidget(const QString &name, QWidget *p
98 ui->dragDropContainer->setMimeType(MIME_TYPE_SELECTION_ZONE,
98 ui->dragDropContainer->setMimeType(MIME_TYPE_SELECTION_ZONE,
99 VisualizationDragDropContainer::DropBehavior::Forbidden);
99 VisualizationDragDropContainer::DropBehavior::Forbidden);
100 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
100 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
101 return sqpApp->dragDropHelper().checkMimeDataForVisualization(mimeData,
101 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(mimeData,
102 ui->dragDropContainer);
102 ui->dragDropContainer);
103 });
103 });
104
104
105 auto acceptDragWidgetFun = [](auto dragWidget, auto mimeData) {
105 auto acceptDragWidgetFun = [](auto dragWidget, auto mimeData) {
@@ -501,7 +501,7 void VisualizationZoneWidget::dropMimeDataOnGraph(VisualizationDragWidget *dragW
501 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph(
501 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropGraph(
502 int index, VisualizationZoneWidget *zoneWidget)
502 int index, VisualizationZoneWidget *zoneWidget)
503 {
503 {
504 auto &helper = sqpApp->dragDropHelper();
504 auto &helper = sqpApp->dragDropGuiController();
505
505
506 auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
506 auto graphWidget = qobject_cast<VisualizationGraphWidget *>(helper.getCurrentDragWidget());
507 if (!graphWidget) {
507 if (!graphWidget) {
General Comments 4
Under Review
author

Auto status change to "Under Review"

Approved

Status change > Approved

Approved

Status change > Approved

You need to be logged in to leave comments. Login now