@@ -0,0 +1,37 | |||
|
1 | #ifndef TOOLBAR_H | |
|
2 | #define TOOLBAR_H | |
|
3 | ||
|
4 | #include <Data/DateTimeRange.h> | |
|
5 | #include <QAction> | |
|
6 | #include <QActionGroup> | |
|
7 | #include <QObject> | |
|
8 | #include <QToolBar> | |
|
9 | #include <QWidget> | |
|
10 | #include <TimeWidget/TimeWidget.h> | |
|
11 | ||
|
12 | // @TODO remove this, shouldn't need to include SqpApplication to get PlotsInteractionMode | |
|
13 | #include <SqpApplication.h> | |
|
14 | ||
|
15 | class ToolBar : public QToolBar | |
|
16 | { | |
|
17 | Q_OBJECT | |
|
18 | public: | |
|
19 | explicit ToolBar(QWidget* parent = nullptr); | |
|
20 | ||
|
21 | QAction* timeRange; | |
|
22 | QAction* pointerMode; | |
|
23 | QAction* zoomMode; | |
|
24 | QAction* organizationMode; | |
|
25 | QAction* zonesMode; | |
|
26 | QAction* cursorsActn; | |
|
27 | QAction* cataloguesActn; | |
|
28 | ||
|
29 | TimeWidgetAction* timeWidget; | |
|
30 | signals: | |
|
31 | void setPlotsInteractionMode(SqpApplication::PlotsInteractionMode); | |
|
32 | void setPlotsCursorMode(SqpApplication::PlotsCursorMode); | |
|
33 | void timeUpdated(DateTimeRange time); | |
|
34 | void showCataloguesBrowser(); | |
|
35 | }; | |
|
36 | ||
|
37 | #endif // TOOLBAR_H |
@@ -0,0 +1,68 | |||
|
1 | #include "toolbar.h" | |
|
2 | #include <QIcon> | |
|
3 | #include <QMenu> | |
|
4 | #include <QStringLiteral> | |
|
5 | #include <tuple> | |
|
6 | ||
|
7 | using InteractionMode = SqpApplication::PlotsInteractionMode; | |
|
8 | using CursorMode = SqpApplication::PlotsCursorMode; | |
|
9 | ||
|
10 | ToolBar::ToolBar(QWidget* parent) | |
|
11 | { | |
|
12 | #define mk_tuple std::make_tuple | |
|
13 | ||
|
14 | for (auto [action, icon, text, checkable] : | |
|
15 | { mk_tuple(&this->timeRange, ":/icones/Simple_icon_time.svg", "Set time range", false), | |
|
16 | mk_tuple(&this->pointerMode, ":/icones/pointer.png", "Move", true), | |
|
17 | mk_tuple(&this->zoomMode, ":/icones/zoom.png", "Zoom", true), | |
|
18 | mk_tuple(&this->organizationMode, ":/icones/drag.png", "Organize", true), | |
|
19 | mk_tuple(&this->zonesMode, ":/icones/rectangle.png", "Zones", true), | |
|
20 | mk_tuple(&this->cursorsActn, ":/icones/cursor.png", "Cursors", false), | |
|
21 | mk_tuple(&this->cataloguesActn, ":/icones/catalogue.png", "Catalogues", false) }) | |
|
22 | { | |
|
23 | *action = new QAction(QIcon(icon), text, this); | |
|
24 | (*action)->setCheckable(checkable); | |
|
25 | this->addAction(*action); | |
|
26 | } | |
|
27 | connect(this->cataloguesActn, &QAction::triggered, this, &ToolBar::showCataloguesBrowser); | |
|
28 | this->pointerMode->setChecked(true); | |
|
29 | { | |
|
30 | this->cursorsActn->setMenu(new QMenu()); | |
|
31 | auto menu = this->cursorsActn->menu(); | |
|
32 | auto group = new QActionGroup { this }; | |
|
33 | group->setExclusive(true); | |
|
34 | for (auto [icon, text, mode, checked] : | |
|
35 | { mk_tuple("", "No Cursor", CursorMode::NoCursor, true), | |
|
36 | mk_tuple("", "Vertical Cursor", CursorMode::Vertical, false), | |
|
37 | mk_tuple("", "Horizontal Cursor", CursorMode::Horizontal, false), | |
|
38 | mk_tuple("", "Cross Cursor", CursorMode::Cross, false) }) | |
|
39 | { | |
|
40 | auto action = menu->addAction(text); | |
|
41 | group->addAction(action); | |
|
42 | action->setCheckable(true); | |
|
43 | action->setChecked(checked); | |
|
44 | connect(action, &QAction::triggered, | |
|
45 | [this, mode = mode]() { emit this->setPlotsCursorMode(mode); }); | |
|
46 | } | |
|
47 | } | |
|
48 | ||
|
49 | for (auto [actn, mode] : { mk_tuple(this->pointerMode, InteractionMode::None), | |
|
50 | mk_tuple(this->zoomMode, InteractionMode::ZoomBox), | |
|
51 | mk_tuple(this->organizationMode, InteractionMode::DragAndDrop), | |
|
52 | mk_tuple(this->zonesMode, InteractionMode::SelectionZones) }) | |
|
53 | { | |
|
54 | connect(actn, &QAction::triggered, | |
|
55 | [this, mode = mode]() { emit this->setPlotsInteractionMode(mode); }); | |
|
56 | } | |
|
57 | ||
|
58 | auto cursorModeActionGroup = new QActionGroup { this }; | |
|
59 | cursorModeActionGroup->setExclusive(true); | |
|
60 | for (auto actn : { this->pointerMode, this->organizationMode, this->zoomMode, this->zonesMode }) | |
|
61 | { | |
|
62 | cursorModeActionGroup->addAction(actn); | |
|
63 | } | |
|
64 | ||
|
65 | this->timeWidget = new TimeWidgetAction(); | |
|
66 | this->timeRange->setMenu(new QMenu()); | |
|
67 | this->timeRange->menu()->addAction(this->timeWidget); | |
|
68 | } |
@@ -0,0 +1,20 | |||
|
1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
|
2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | |
|
3 | <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="50.000008" height="39.999996" id="svg12257" sodipodi:version="0.32" inkscape:version="0.44" version="1.0" sodipodi:docbase="D:\Home\Wikipedia" sodipodi:docname="Simple icon time.svg"> | |
|
4 | <defs id="defs12259"/> | |
|
5 | <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.5795652" inkscape:cx="27.142857" inkscape:cy="44.285714" inkscape:document-units="px" inkscape:current-layer="layer1" inkscape:window-width="1024" inkscape:window-height="682" inkscape:window-x="-4" inkscape:window-y="-4"/> | |
|
6 | <metadata id="metadata12262"> | |
|
7 | <rdf:RDF> | |
|
8 | <cc:Work rdf:about=""> | |
|
9 | <dc:format>image/svg+xml</dc:format> | |
|
10 | <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> | |
|
11 | </cc:Work> | |
|
12 | </rdf:RDF> | |
|
13 | </metadata> | |
|
14 | <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" transform="translate(-306.4286,-335.2193)"> | |
|
15 | <g id="g1960" transform="translate(131.4286,99.34979)"> | |
|
16 | <path id="path1948" d="M 200,237.86949 C 190.08587,237.86949 181.99999,245.95537 181.99999,255.86951 C 181.99999,265.78364 190.08587,273.86952 200,273.86952 C 209.91414,273.86952 218.00002,265.78364 218.00002,255.86951 C 218.00002,245.95537 209.91414,237.86949 200,237.86949 z M 200,241.8695 C 207.74989,241.8695 214.00002,248.11963 214.00002,255.86951 C 214.00002,263.61939 207.74989,269.86952 200,269.86952 C 192.25012,269.86952 185.99999,263.61939 185.99999,255.86951 C 185.99999,248.11963 192.25012,241.8695 200,241.8695 z " style="color:black;fill:black;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.00000048;stroke-linecap:butt;stroke-linejoin:round;marker:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible"/> | |
|
17 | <path id="path1950" d="M 200.25,242.625 C 199.14542,242.64223 198.26397,243.55167 198.28125,244.65625 L 198.28125,258.375 C 198.27245,259.10687 198.6641,259.78511 199.30238,260.14332 C 199.94065,260.50154 200.72361,260.48253 201.34375,260.09375 L 208.625,255.625 C 209.25907,255.26307 209.64557,254.58442 209.63336,253.85443 C 209.62115,253.12444 209.21217,252.45909 208.56636,252.11857 C 207.92054,251.77804 207.1405,251.81644 206.53125,252.21875 L 202.28125,254.8125 L 202.28125,244.65625 C 202.28972,244.11498 202.07843,243.59338 201.69565,243.2106 C 201.31287,242.82782 200.79127,242.61653 200.25,242.625 z " style="fill:black;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.99999881;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/> | |
|
18 | </g> | |
|
19 | </g> | |
|
20 | </svg> No newline at end of file |
@@ -1,6 +1,7 | |||
|
1 | 1 | |
|
2 | 2 | app_moc_headers = [ |
|
3 | 3 | 'include/MainWindow.h' |
|
4 | 'include/toolbar.h' | |
|
4 | 5 | ] |
|
5 | 6 | |
|
6 | 7 | app_ui_files = [ |
@@ -16,6 +17,7 app_moc_files = qt5.preprocess(moc_headers : app_moc_headers, | |||
|
16 | 17 | app_sources = [ |
|
17 | 18 | 'src/Main.cpp', |
|
18 | 19 | 'src/MainWindow.cpp' |
|
20 | 'src/toolbar.cpp' | |
|
19 | 21 | ] |
|
20 | 22 | |
|
21 | 23 | app_inc = include_directories(['include']) |
@@ -34,6 +34,8 | |||
|
34 | 34 | #include <TimeWidget/TimeWidget.h> |
|
35 | 35 | #include <Visualization/VisualizationController.h> |
|
36 | 36 | |
|
37 | #include "toolbar.h" | |
|
38 | ||
|
37 | 39 | #include <QAction> |
|
38 | 40 | #include <QCloseEvent> |
|
39 | 41 | #include <QDate> |
@@ -164,115 +166,12 MainWindow::MainWindow(QWidget* parent) | |||
|
164 | 166 | impl->m_SettingsDialog->saveSettings(); |
|
165 | 167 | } |
|
166 | 168 | }); |
|
167 | ||
|
168 |
|
|
|
169 | ||
|
170 | auto timeWidget = new TimeWidget {}; | |
|
171 | mainToolBar->addWidget(timeWidget); | |
|
172 | ||
|
173 | // Interaction modes | |
|
174 | auto actionPointerMode = new QAction { QIcon(":/icones/pointer.png"), "Move", this }; | |
|
175 | actionPointerMode->setCheckable(true); | |
|
176 | actionPointerMode->setChecked( | |
|
177 | sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::None); | |
|
178 | connect(actionPointerMode, &QAction::triggered, | |
|
179 | []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); }); | |
|
180 | ||
|
181 | auto actionZoomMode = new QAction { QIcon(":/icones/zoom.png"), "Zoom", this }; | |
|
182 | actionZoomMode->setCheckable(true); | |
|
183 | actionZoomMode->setChecked( | |
|
184 | sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::ZoomBox); | |
|
185 | connect(actionZoomMode, &QAction::triggered, | |
|
186 | []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox); }); | |
|
187 | ||
|
188 | auto actionOrganisationMode = new QAction { QIcon(":/icones/drag.png"), "Organize", this }; | |
|
189 | actionOrganisationMode->setCheckable(true); | |
|
190 | actionOrganisationMode->setChecked( | |
|
191 | sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::DragAndDrop); | |
|
192 | connect(actionOrganisationMode, &QAction::triggered, []() { | |
|
193 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop); | |
|
194 | }); | |
|
195 | ||
|
196 | auto actionZonesMode = new QAction { QIcon(":/icones/rectangle.png"), "Zones", this }; | |
|
197 | actionZonesMode->setCheckable(true); | |
|
198 | actionZonesMode->setChecked( | |
|
199 | sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones); | |
|
200 | connect(actionZonesMode, &QAction::triggered, []() { | |
|
201 | sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones); | |
|
202 | }); | |
|
203 | ||
|
204 | auto modeActionGroup = new QActionGroup { this }; | |
|
205 | modeActionGroup->addAction(actionZoomMode); | |
|
206 | modeActionGroup->addAction(actionZonesMode); | |
|
207 | modeActionGroup->addAction(actionOrganisationMode); | |
|
208 | modeActionGroup->addAction(actionPointerMode); | |
|
209 | modeActionGroup->setExclusive(true); | |
|
210 | ||
|
211 | mainToolBar->addSeparator(); | |
|
212 | mainToolBar->addAction(actionPointerMode); | |
|
213 | mainToolBar->addAction(actionZoomMode); | |
|
214 | mainToolBar->addAction(actionOrganisationMode); | |
|
215 | mainToolBar->addAction(actionZonesMode); | |
|
216 | mainToolBar->addSeparator(); | |
|
217 | ||
|
218 | // Cursors | |
|
219 | auto btnCursor = new QToolButton { this }; | |
|
220 | btnCursor->setIcon(QIcon(":/icones/cursor.png")); | |
|
221 | btnCursor->setText("Cursor"); | |
|
222 | btnCursor->setToolTip("Cursor"); | |
|
223 | btnCursor->setPopupMode(QToolButton::InstantPopup); | |
|
224 | auto cursorMenu = new QMenu("CursorMenu", this); | |
|
225 | btnCursor->setMenu(cursorMenu); | |
|
226 | ||
|
227 | auto noCursorAction = cursorMenu->addAction("No Cursor"); | |
|
228 | noCursorAction->setCheckable(true); | |
|
229 | noCursorAction->setChecked( | |
|
230 | sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::NoCursor); | |
|
231 | connect(noCursorAction, &QAction::triggered, | |
|
232 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); }); | |
|
233 | ||
|
234 | cursorMenu->addSeparator(); | |
|
235 | auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor"); | |
|
236 | verticalCursorAction->setCheckable(true); | |
|
237 | verticalCursorAction->setChecked( | |
|
238 | sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Vertical); | |
|
239 | connect(verticalCursorAction, &QAction::triggered, | |
|
240 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); }); | |
|
241 | ||
|
242 | auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor"); | |
|
243 | temporalCursorAction->setCheckable(true); | |
|
244 | temporalCursorAction->setChecked( | |
|
245 | sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Temporal); | |
|
246 | connect(temporalCursorAction, &QAction::triggered, | |
|
247 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); }); | |
|
248 | ||
|
249 | auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor"); | |
|
250 | horizontalCursorAction->setCheckable(true); | |
|
251 | horizontalCursorAction->setChecked( | |
|
252 | sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Horizontal); | |
|
253 | connect(horizontalCursorAction, &QAction::triggered, | |
|
254 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); }); | |
|
255 | ||
|
256 | auto crossCursorAction = cursorMenu->addAction("Cross Cursor"); | |
|
257 | crossCursorAction->setCheckable(true); | |
|
258 | crossCursorAction->setChecked( | |
|
259 | sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Cross); | |
|
260 | connect(crossCursorAction, &QAction::triggered, | |
|
261 | []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); }); | |
|
262 | ||
|
263 | mainToolBar->addWidget(btnCursor); | |
|
264 | ||
|
265 | auto cursorModeActionGroup = new QActionGroup { this }; | |
|
266 | cursorModeActionGroup->setExclusive(true); | |
|
267 | cursorModeActionGroup->addAction(noCursorAction); | |
|
268 | cursorModeActionGroup->addAction(verticalCursorAction); | |
|
269 | cursorModeActionGroup->addAction(temporalCursorAction); | |
|
270 | cursorModeActionGroup->addAction(horizontalCursorAction); | |
|
271 | cursorModeActionGroup->addAction(crossCursorAction); | |
|
272 | ||
|
273 | // Catalog | |
|
274 | mainToolBar->addSeparator(); | |
|
275 | mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues", | |
|
169 | auto mainToolBar = new ToolBar(this); | |
|
170 | this->addToolBar(mainToolBar); | |
|
171 | connect(mainToolBar, &ToolBar::setPlotsInteractionMode, sqpApp, | |
|
172 | &SqpApplication::setPlotsInteractionMode); | |
|
173 | connect(mainToolBar, &ToolBar::setPlotsCursorMode, sqpApp, &SqpApplication::setPlotsCursorMode); | |
|
174 | connect(mainToolBar, &ToolBar::showCataloguesBrowser, | |
|
276 | 175 | [this]() { impl->m_CatalogExplorer->show(); }); |
|
277 | 176 | |
|
278 | 177 | // //////// // |
@@ -287,11 +186,6 MainWindow::MainWindow(QWidget* parent) | |||
|
287 | 186 | // Connections // |
|
288 | 187 | // /////////// // |
|
289 | 188 | |
|
290 | // Controllers / controllers connections | |
|
291 | // connect(&sqpApp->timeController(), SIGNAL(timeUpdated(DateTimeRange)), | |
|
292 | // &sqpApp->variableController(), | |
|
293 | // SLOT(onDateTimeOnSelection(DateTimeRange))); | |
|
294 | ||
|
295 | 189 | // Widgets / controllers connections |
|
296 | 190 | |
|
297 | 191 | // DataSource |
@@ -299,8 +193,10 MainWindow::MainWindow(QWidget* parent) | |||
|
299 | 193 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem*))); |
|
300 | 194 | |
|
301 | 195 | // Time |
|
302 | connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), | |
|
303 | SLOT(onTimeToUpdate(DateTimeRange))); | |
|
196 | // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), | |
|
197 | // SLOT(onTimeToUpdate(DateTimeRange))); | |
|
198 | connect(mainToolBar, &ToolBar::timeUpdated, &sqpApp->timeController(), | |
|
199 | &TimeController::setDateTimeRange); | |
|
304 | 200 | |
|
305 | 201 | // Visualization |
|
306 | 202 | connect(&sqpApp->visualizationController(), |
@@ -130,9 +130,24 | |||
|
130 | 130 | <x>0</x> |
|
131 | 131 | <y>0</y> |
|
132 | 132 | <width>800</width> |
|
133 |
<height>2 |
|
|
133 | <height>27</height> | |
|
134 | 134 | </rect> |
|
135 | 135 | </property> |
|
136 | <property name="sizePolicy"> | |
|
137 | <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> | |
|
138 | <horstretch>0</horstretch> | |
|
139 | <verstretch>0</verstretch> | |
|
140 | </sizepolicy> | |
|
141 | </property> | |
|
142 | <property name="minimumSize"> | |
|
143 | <size> | |
|
144 | <width>0</width> | |
|
145 | <height>0</height> | |
|
146 | </size> | |
|
147 | </property> | |
|
148 | <property name="nativeMenuBar"> | |
|
149 | <bool>true</bool> | |
|
150 | </property> | |
|
136 | 151 | </widget> |
|
137 | 152 | <widget class="QStatusBar" name="statusBar"/> |
|
138 | 153 | </widget> |
@@ -3,8 +3,14 | |||
|
3 | 3 | |
|
4 | 4 | #include "SqpApplication.h" |
|
5 | 5 | |
|
6 | #include <QAction> | |
|
6 | 7 | #include <QApplication> |
|
7 | 8 | #include <QLoggingCategory> |
|
9 | #include <QMenuBar> | |
|
10 | #include <QProxyStyle> | |
|
11 | #include <QStyleOption> | |
|
12 | #include <QWidget> | |
|
13 | #include <QWidgetAction> | |
|
8 | 14 | |
|
9 | 15 | #include <Common/spimpl.h> |
|
10 | 16 | |
@@ -13,7 +19,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) | |||
|
13 | 19 | #if defined(sqpApp) |
|
14 | 20 | #undef sqpApp |
|
15 | 21 | #endif |
|
16 |
#define sqpApp (static_cast<SqpApplication |
|
|
22 | #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance())) | |
|
17 | 23 | |
|
18 | 24 | class DataSourceController; |
|
19 | 25 | class NetworkController; |
@@ -26,6 +32,27 class DragDropGuiController; | |||
|
26 | 32 | class ActionsGuiController; |
|
27 | 33 | class CatalogueController; |
|
28 | 34 | |
|
35 | /* stolen from here https://forum.qt.io/topic/90403/show-tooltip-immediatly/6 */ | |
|
36 | class MyProxyStyle : public QProxyStyle | |
|
37 | { | |
|
38 | public: | |
|
39 | using QProxyStyle::QProxyStyle; | |
|
40 | ||
|
41 | int styleHint(StyleHint hint, const QStyleOption* option = nullptr, | |
|
42 | const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) const override | |
|
43 | { | |
|
44 | if (widget) | |
|
45 | auto cname = widget->metaObject()->className(); | |
|
46 | if (hint == QStyle::SH_ToolButton_PopupDelay && widget | |
|
47 | /*&& widget->inherits(QWidgetAction::staticMetaObject.className())*/) | |
|
48 | { | |
|
49 | return 0; | |
|
50 | } | |
|
51 | ||
|
52 | return QProxyStyle::styleHint(hint, option, widget, returnData); | |
|
53 | } | |
|
54 | }; | |
|
55 | ||
|
29 | 56 | /** |
|
30 | 57 | * @brief The SqpApplication class aims to make the link between SciQlop |
|
31 | 58 | * and its plugins. This is the intermediate class that SciQlop has to use |
@@ -35,32 +62,46 class CatalogueController; | |||
|
35 | 62 | * You can load a data source driver plugin then create a data source. |
|
36 | 63 | */ |
|
37 | 64 | |
|
38 |
class SqpApplication : public QApplication |
|
|
65 | class SqpApplication : public QApplication | |
|
66 | { | |
|
39 | 67 | Q_OBJECT |
|
40 | 68 | public: |
|
41 |
explicit SqpApplication(int |
|
|
42 |
|
|
|
69 | explicit SqpApplication(int& argc, char** argv); | |
|
70 | ~SqpApplication() override; | |
|
43 | 71 | void initialize(); |
|
44 | 72 | |
|
45 | 73 | /// Accessors for the differents sciqlop controllers |
|
46 |
DataSourceController |
|
|
47 |
NetworkController |
|
|
48 |
TimeController |
|
|
49 |
VariableController2 |
|
|
74 | DataSourceController& dataSourceController() noexcept; | |
|
75 | NetworkController& networkController() noexcept; | |
|
76 | TimeController& timeController() noexcept; | |
|
77 | VariableController2& variableController() noexcept; | |
|
50 | 78 | std::shared_ptr<VariableController2> variableControllerOwner() noexcept; |
|
51 | 79 | //@TODO there should not be any global model it's just GUI impl detail |
|
52 | // VariableModel2 &variableModel() noexcept; | |
|
53 |
VisualizationController |
|
|
54 |
CatalogueController |
|
|
80 | // VariableModel2 &variableModel() noexcept; | |
|
81 | VisualizationController& visualizationController() noexcept; | |
|
82 | CatalogueController& catalogueController() noexcept; | |
|
55 | 83 | |
|
56 | 84 | /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but |
|
57 | 85 | /// doesn't live in a thread and access gui |
|
58 |
DragDropGuiController |
|
|
59 |
ActionsGuiController |
|
|
60 | ||
|
61 | enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones }; | |
|
62 | ||
|
63 | enum class PlotsCursorMode { NoCursor, Vertical, Temporal, Horizontal, Cross }; | |
|
86 | DragDropGuiController& dragDropGuiController() noexcept; | |
|
87 | ActionsGuiController& actionsGuiController() noexcept; | |
|
88 | ||
|
89 | enum class PlotsInteractionMode | |
|
90 | { | |
|
91 | None, | |
|
92 | ZoomBox, | |
|
93 | DragAndDrop, | |
|
94 | SelectionZones | |
|
95 | }; | |
|
96 | ||
|
97 | enum class PlotsCursorMode | |
|
98 | { | |
|
99 | NoCursor, | |
|
100 | Vertical, | |
|
101 | Temporal, | |
|
102 | Horizontal, | |
|
103 | Cross | |
|
104 | }; | |
|
64 | 105 | |
|
65 | 106 | PlotsInteractionMode plotsInteractionMode() const; |
|
66 | 107 | void setPlotsInteractionMode(PlotsInteractionMode mode); |
@@ -2,20 +2,24 | |||
|
2 | 2 | #define SCIQLOP_TIMEWIDGET_H |
|
3 | 3 | |
|
4 | 4 | #include <QWidget> |
|
5 | #include <QWidgetAction> | |
|
5 | 6 | |
|
6 | 7 | #include <Data/DateTimeRange.h> |
|
7 | 8 | |
|
8 | 9 | #include <Common/spimpl.h> |
|
9 | 10 | |
|
10 |
namespace Ui |
|
|
11 | namespace Ui | |
|
12 | { | |
|
11 | 13 | class TimeWidget; |
|
12 | 14 | } // Ui |
|
13 | 15 | |
|
14 | class TimeWidget : public QWidget { | |
|
16 | ||
|
17 | class TimeWidget : public QWidget | |
|
18 | { | |
|
15 | 19 | Q_OBJECT |
|
16 | 20 | |
|
17 | 21 | public: |
|
18 |
explicit TimeWidget(QWidget |
|
|
22 | explicit TimeWidget(QWidget* parent = 0); | |
|
19 | 23 | virtual ~TimeWidget(); |
|
20 | 24 | |
|
21 | 25 | void setTimeRange(DateTimeRange time); |
@@ -30,18 +34,31 public slots: | |||
|
30 | 34 | void onTimeUpdateRequested(); |
|
31 | 35 | |
|
32 | 36 | protected: |
|
33 |
void dragEnterEvent(QDragEnterEvent |
|
|
34 |
void dragLeaveEvent(QDragLeaveEvent |
|
|
35 |
void dropEvent(QDropEvent |
|
|
37 | void dragEnterEvent(QDragEnterEvent* event) override; | |
|
38 | void dragLeaveEvent(QDragLeaveEvent* event) override; | |
|
39 | void dropEvent(QDropEvent* event) override; | |
|
36 | 40 | |
|
37 |
void mousePressEvent(QMouseEvent |
|
|
38 |
void mouseMoveEvent(QMouseEvent |
|
|
41 | void mousePressEvent(QMouseEvent* event) override; | |
|
42 | void mouseMoveEvent(QMouseEvent* event) override; | |
|
39 | 43 | |
|
40 | 44 | private: |
|
41 |
Ui::TimeWidget |
|
|
45 | Ui::TimeWidget* ui; | |
|
42 | 46 | |
|
43 | 47 | class TimeWidgetPrivate; |
|
44 | 48 | spimpl::unique_impl_ptr<TimeWidgetPrivate> impl; |
|
45 | 49 | }; |
|
46 | 50 | |
|
51 | class TimeWidgetAction : public QWidgetAction | |
|
52 | { | |
|
53 | Q_OBJECT | |
|
54 | TimeWidget* timeWidget; | |
|
55 | ||
|
56 | public: | |
|
57 | explicit TimeWidgetAction(QWidget* parent = 0) : QWidgetAction(parent) | |
|
58 | { | |
|
59 | timeWidget = new TimeWidget(); | |
|
60 | this->setDefaultWidget(timeWidget); | |
|
61 | } | |
|
62 | }; | |
|
63 | ||
|
47 | 64 | #endif // SCIQLOP_ SQPSIDEPANE_H |
@@ -1,10 +1,10 | |||
|
1 | 1 | <RCC> |
|
2 | 2 | <qresource prefix="/"> |
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
3 | <file>icones/dataSourceComponent.png</file> | |
|
4 | <file>icones/dataSourceNode.png</file> | |
|
5 | <file>icones/dataSourceProduct.png</file> | |
|
6 | <file>icones/dataSourceRoot.png</file> | |
|
7 | <file>icones/delete.png</file> | |
|
8 | 8 | <file>icones/down.png</file> |
|
9 | 9 | <file>icones/openInspector.png</file> |
|
10 | 10 | <file>icones/next.png</file> |
@@ -12,20 +12,21 | |||
|
12 | 12 | <file>icones/previous.png</file> |
|
13 | 13 | <file>icones/unplot.png</file> |
|
14 | 14 | <file>icones/up.png</file> |
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
15 | <file>icones/time.png</file> | |
|
16 | <file>icones/zoom.png</file> | |
|
17 | <file>icones/rectangle.png</file> | |
|
18 | <file>icones/drag.png</file> | |
|
19 | <file>icones/cursor.png</file> | |
|
20 | <file>icones/pointer.png</file> | |
|
21 | <file>icones/catalogue.png</file> | |
|
22 | <file>icones/add.png</file> | |
|
23 | <file>icones/remove.png</file> | |
|
24 | <file>icones/chart.png</file> | |
|
25 | <file>icones/allEvents.png</file> | |
|
26 | <file>icones/trash.png</file> | |
|
27 | <file>icones/database.png</file> | |
|
28 | <file>icones/save.png</file> | |
|
29 | <file>icones/discard.png</file> | |
|
30 | <file>icones/Simple_icon_time.svg</file> | |
|
30 | 31 | </qresource> |
|
31 | 32 | </RCC> |
@@ -92,6 +92,7 public: | |||
|
92 | 92 | SqpApplication::SqpApplication(int& argc, char** argv) |
|
93 | 93 | : QApplication { argc, argv }, impl { spimpl::make_unique_impl<SqpApplicationPrivate>() } |
|
94 | 94 | { |
|
95 | this->setStyle(new MyProxyStyle(this->style())); | |
|
95 | 96 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); |
|
96 | 97 | |
|
97 | 98 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
@@ -15,32 +15,27 | |||
|
15 | 15 | #include <QStyle> |
|
16 | 16 | |
|
17 | 17 | |
|
18 |
struct TimeWidget::TimeWidgetPrivate |
|
|
18 | struct TimeWidget::TimeWidgetPrivate | |
|
19 | { | |
|
19 | 20 | |
|
20 | 21 | explicit TimeWidgetPrivate() {} |
|
21 | 22 | |
|
22 | 23 | QPoint m_DragStartPosition; |
|
23 | 24 | }; |
|
24 | 25 | |
|
25 |
TimeWidget::TimeWidget(QWidget |
|
|
26 |
: QWidget{parent} |
|
|
27 |
|
|
|
28 |
|
|
|
26 | TimeWidget::TimeWidget(QWidget* parent) | |
|
27 | : QWidget { parent } | |
|
28 | , ui { new Ui::TimeWidget } | |
|
29 | , impl { spimpl::make_unique_impl<TimeWidgetPrivate>() } | |
|
29 | 30 | { |
|
30 | 31 | ui->setupUi(this); |
|
31 | 32 | |
|
32 | ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton)); | |
|
33 | ||
|
34 | 33 | // Connection |
|
35 | 34 | connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
36 |
|
|
|
35 | &TimeWidget::onTimeUpdateRequested); | |
|
37 | 36 | |
|
38 | 37 | connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
39 |
|
|
|
40 | ||
|
41 | ||
|
42 | connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(), | |
|
43 | &TimeController::onTimeNotify); | |
|
38 | &TimeWidget::onTimeUpdateRequested); | |
|
44 | 39 | |
|
45 | 40 | // Initialisation |
|
46 | 41 | auto endDateTime = QDateTime::currentDateTimeUtc(); |
@@ -49,8 +44,8 TimeWidget::TimeWidget(QWidget *parent) | |||
|
49 | 44 | ui->startDateTimeEdit->setDateTime(startDateTime); |
|
50 | 45 | ui->endDateTimeEdit->setDateTime(endDateTime); |
|
51 | 46 | |
|
52 | auto dateTime = DateTimeRange{DateUtils::secondsSinceEpoch(startDateTime), | |
|
53 |
|
|
|
47 | auto dateTime = DateTimeRange { DateUtils::secondsSinceEpoch(startDateTime), | |
|
48 | DateUtils::secondsSinceEpoch(endDateTime) }; | |
|
54 | 49 | |
|
55 | 50 | sqpApp->timeController().setDateTimeRange(dateTime); |
|
56 | 51 | } |
@@ -72,8 +67,8 void TimeWidget::setTimeRange(DateTimeRange time) | |||
|
72 | 67 | |
|
73 | 68 | DateTimeRange TimeWidget::timeRange() const |
|
74 | 69 | { |
|
75 | return DateTimeRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), | |
|
76 |
|
|
|
70 | return DateTimeRange { DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), | |
|
71 | DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime()) }; | |
|
77 | 72 | } |
|
78 | 73 | |
|
79 | 74 | void TimeWidget::onTimeUpdateRequested() |
@@ -83,60 +78,67 void TimeWidget::onTimeUpdateRequested() | |||
|
83 | 78 | sqpApp->timeController().setDateTimeRange(dateTime); |
|
84 | 79 | } |
|
85 | 80 | |
|
86 |
void TimeWidget::dragEnterEvent(QDragEnterEvent |
|
|
81 | void TimeWidget::dragEnterEvent(QDragEnterEvent* event) | |
|
87 | 82 | { |
|
88 |
if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) |
|
|
83 | if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) | |
|
84 | { | |
|
89 | 85 | event->acceptProposedAction(); |
|
90 | 86 | setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}"); |
|
91 | 87 | } |
|
92 |
else |
|
|
88 | else | |
|
89 | { | |
|
93 | 90 | event->ignore(); |
|
94 | 91 | } |
|
95 | 92 | } |
|
96 | 93 | |
|
97 |
void TimeWidget::dragLeaveEvent(QDragLeaveEvent |
|
|
94 | void TimeWidget::dragLeaveEvent(QDragLeaveEvent* event) | |
|
98 | 95 | { |
|
99 | setStyleSheet(QString{}); | |
|
96 | setStyleSheet(QString {}); | |
|
100 | 97 | } |
|
101 | 98 | |
|
102 |
void TimeWidget::dropEvent(QDropEvent |
|
|
99 | void TimeWidget::dropEvent(QDropEvent* event) | |
|
103 | 100 | { |
|
104 |
if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) |
|
|
101 | if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) | |
|
102 | { | |
|
105 | 103 | auto mimeData = event->mimeData()->data(MIME_TYPE_TIME_RANGE); |
|
106 | 104 | auto timeRange = TimeController::timeRangeForMimeData(mimeData); |
|
107 | 105 | |
|
108 | 106 | setTimeRange(timeRange); |
|
109 | 107 | } |
|
110 |
else |
|
|
108 | else | |
|
109 | { | |
|
111 | 110 | event->ignore(); |
|
112 | 111 | } |
|
113 | 112 | |
|
114 | setStyleSheet(QString{}); | |
|
113 | setStyleSheet(QString {}); | |
|
115 | 114 | } |
|
116 | 115 | |
|
117 | 116 | |
|
118 |
void TimeWidget::mousePressEvent(QMouseEvent |
|
|
117 | void TimeWidget::mousePressEvent(QMouseEvent* event) | |
|
119 | 118 | { |
|
120 |
if (event->button() == Qt::LeftButton) |
|
|
119 | if (event->button() == Qt::LeftButton) | |
|
120 | { | |
|
121 | 121 | impl->m_DragStartPosition = event->pos(); |
|
122 | 122 | } |
|
123 | 123 | |
|
124 | 124 | QWidget::mousePressEvent(event); |
|
125 | 125 | } |
|
126 | 126 | |
|
127 |
void TimeWidget::mouseMoveEvent(QMouseEvent |
|
|
127 | void TimeWidget::mouseMoveEvent(QMouseEvent* event) | |
|
128 | 128 | { |
|
129 |
if (!(event->buttons() & Qt::LeftButton)) |
|
|
129 | if (!(event->buttons() & Qt::LeftButton)) | |
|
130 | { | |
|
130 | 131 | return; |
|
131 | 132 | } |
|
132 | 133 | |
|
133 | 134 | if ((event->pos() - impl->m_DragStartPosition).manhattanLength() |
|
134 |
< QApplication::startDragDistance()) |
|
|
135 | < QApplication::startDragDistance()) | |
|
136 | { | |
|
135 | 137 | return; |
|
136 | 138 | } |
|
137 | 139 | |
|
138 | 140 | // Note: The management of the drag object is done by Qt |
|
139 | auto drag = new QDrag{this}; | |
|
141 | auto drag = new QDrag { this }; | |
|
140 | 142 | |
|
141 | 143 | auto mimeData = new QMimeData; |
|
142 | 144 | auto timeData = TimeController::mimeDataForTimeRange(timeRange()); |
@@ -144,7 +146,7 void TimeWidget::mouseMoveEvent(QMouseEvent *event) | |||
|
144 | 146 | |
|
145 | 147 | drag->setMimeData(mimeData); |
|
146 | 148 | |
|
147 | auto pixmap = QPixmap{":/icones/time.png"}; | |
|
149 | auto pixmap = QPixmap { ":/icones/time.png" }; | |
|
148 | 150 | drag->setPixmap(pixmap.scaledToWidth(22)); |
|
149 | 151 | |
|
150 | 152 | sqpApp->dragDropGuiController().resetDragAndDrop(); |
General Comments 0
You need to be logged in to leave comments.
Login now