@@ -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,46 +1,48 | |||||
1 |
|
1 | |||
2 | app_moc_headers = [ |
|
2 | app_moc_headers = [ | |
3 | 'include/MainWindow.h' |
|
3 | 'include/MainWindow.h' | |
|
4 | 'include/toolbar.h' | |||
4 | ] |
|
5 | ] | |
5 |
|
6 | |||
6 | app_ui_files = [ |
|
7 | app_ui_files = [ | |
7 | 'ui/MainWindow.ui' |
|
8 | 'ui/MainWindow.ui' | |
8 | ] |
|
9 | ] | |
9 |
|
10 | |||
10 | app_qresources = ['resources/qlopapp.qrc'] |
|
11 | app_qresources = ['resources/qlopapp.qrc'] | |
11 |
|
12 | |||
12 | app_moc_files = qt5.preprocess(moc_headers : app_moc_headers, |
|
13 | app_moc_files = qt5.preprocess(moc_headers : app_moc_headers, | |
13 | ui_files : app_ui_files, |
|
14 | ui_files : app_ui_files, | |
14 | qresources : app_qresources) |
|
15 | qresources : app_qresources) | |
15 |
|
16 | |||
16 | app_sources = [ |
|
17 | app_sources = [ | |
17 | 'src/Main.cpp', |
|
18 | 'src/Main.cpp', | |
18 | 'src/MainWindow.cpp' |
|
19 | 'src/MainWindow.cpp' | |
|
20 | 'src/toolbar.cpp' | |||
19 | ] |
|
21 | ] | |
20 |
|
22 | |||
21 | app_inc = include_directories(['include']) |
|
23 | app_inc = include_directories(['include']) | |
22 |
|
24 | |||
23 | if host_machine.system()=='windows' or build_machine.system()=='windows' |
|
25 | if host_machine.system()=='windows' or build_machine.system()=='windows' | |
24 | winmod = import('windows') |
|
26 | winmod = import('windows') | |
25 | rc = winmod.compile_resources('resources/qlopapp.rc') |
|
27 | rc = winmod.compile_resources('resources/qlopapp.rc') | |
26 | else |
|
28 | else | |
27 | rc = [] |
|
29 | rc = [] | |
28 | endif |
|
30 | endif | |
29 |
|
31 | |||
30 | app_libs = [] |
|
32 | app_libs = [] | |
31 | cpp_args = [] |
|
33 | cpp_args = [] | |
32 | if 'static' == get_option('default_library') |
|
34 | if 'static' == get_option('default_library') | |
33 | app_libs = [sciqlop_python_providers] |
|
35 | app_libs = [sciqlop_python_providers] | |
34 | cpp_args += ['-DQT_STATICPLUGIN'] |
|
36 | cpp_args += ['-DQT_STATICPLUGIN'] | |
35 | endif |
|
37 | endif | |
36 |
|
38 | |||
37 | sciqlop_app = executable('sciqlop', |
|
39 | sciqlop_app = executable('sciqlop', | |
38 | app_sources, |
|
40 | app_sources, | |
39 | app_moc_files, |
|
41 | app_moc_files, | |
40 | rc, |
|
42 | rc, | |
41 | include_directories : [ app_inc], |
|
43 | include_directories : [ app_inc], | |
42 | link_with: app_libs, |
|
44 | link_with: app_libs, | |
43 | cpp_args: cpp_args, |
|
45 | cpp_args: cpp_args, | |
44 | dependencies : [sciqlop_gui, sciqlop_core], |
|
46 | dependencies : [sciqlop_gui, sciqlop_core], | |
45 | install : true |
|
47 | install : true | |
46 | ) |
|
48 | ) |
@@ -1,395 +1,291 | |||||
1 | /*------------------------------------------------------------------------------ |
|
1 | /*------------------------------------------------------------------------------ | |
2 | -- This file is a part of the SciQLop Software |
|
2 | -- This file is a part of the SciQLop Software | |
3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS | |
4 | -- |
|
4 | -- | |
5 | -- This program is free software; you can redistribute it and/or modify |
|
5 | -- This program is free software; you can redistribute it and/or modify | |
6 | -- it under the terms of the GNU General Public License as published by |
|
6 | -- it under the terms of the GNU General Public License as published by | |
7 | -- the Free Software Foundation; either version 2 of the License, or |
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |
8 | -- (at your option) any later version. |
|
8 | -- (at your option) any later version. | |
9 | -- |
|
9 | -- | |
10 | -- This program is distributed in the hope that it will be useful, |
|
10 | -- This program is distributed in the hope that it will be useful, | |
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | -- GNU General Public License for more details. |
|
13 | -- GNU General Public License for more details. | |
14 | -- |
|
14 | -- | |
15 | -- You should have received a copy of the GNU General Public License |
|
15 | -- You should have received a copy of the GNU General Public License | |
16 | -- along with this program; if not, write to the Free Software |
|
16 | -- along with this program; if not, write to the Free Software | |
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | -------------------------------------------------------------------------------*/ |
|
18 | -------------------------------------------------------------------------------*/ | |
19 | /*-- Author : Alexis Jeandet |
|
19 | /*-- Author : Alexis Jeandet | |
20 | -- Mail : alexis.jeandet@member.fsf.org |
|
20 | -- Mail : alexis.jeandet@member.fsf.org | |
21 | ----------------------------------------------------------------------------*/ |
|
21 | ----------------------------------------------------------------------------*/ | |
22 | #include "MainWindow.h" |
|
22 | #include "MainWindow.h" | |
23 | #include "ui_MainWindow.h" |
|
23 | #include "ui_MainWindow.h" | |
24 |
|
24 | |||
25 | #include <Catalogue/CatalogueController.h> |
|
25 | #include <Catalogue/CatalogueController.h> | |
26 | #include <Catalogue2/browser.h> |
|
26 | #include <Catalogue2/browser.h> | |
27 | #include <DataSource/DataSourceController.h> |
|
27 | #include <DataSource/DataSourceController.h> | |
28 | #include <DataSource/DataSourceWidget.h> |
|
28 | #include <DataSource/DataSourceWidget.h> | |
29 | #include <Settings/SqpSettingsDialog.h> |
|
29 | #include <Settings/SqpSettingsDialog.h> | |
30 | #include <Settings/SqpSettingsGeneralWidget.h> |
|
30 | #include <Settings/SqpSettingsGeneralWidget.h> | |
31 | #include <SidePane/SqpSidePane.h> |
|
31 | #include <SidePane/SqpSidePane.h> | |
32 | #include <SqpApplication.h> |
|
32 | #include <SqpApplication.h> | |
33 | #include <Time/TimeController.h> |
|
33 | #include <Time/TimeController.h> | |
34 | #include <TimeWidget/TimeWidget.h> |
|
34 | #include <TimeWidget/TimeWidget.h> | |
35 | #include <Visualization/VisualizationController.h> |
|
35 | #include <Visualization/VisualizationController.h> | |
36 |
|
36 | |||
|
37 | #include "toolbar.h" | |||
|
38 | ||||
37 | #include <QAction> |
|
39 | #include <QAction> | |
38 | #include <QCloseEvent> |
|
40 | #include <QCloseEvent> | |
39 | #include <QDate> |
|
41 | #include <QDate> | |
40 | #include <QDir> |
|
42 | #include <QDir> | |
41 | #include <QFileDialog> |
|
43 | #include <QFileDialog> | |
42 | #include <QMessageBox> |
|
44 | #include <QMessageBox> | |
43 | #include <QToolBar> |
|
45 | #include <QToolBar> | |
44 | #include <QToolButton> |
|
46 | #include <QToolButton> | |
45 | #include <memory.h> |
|
47 | #include <memory.h> | |
46 |
|
48 | |||
47 |
|
49 | |||
48 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") |
|
50 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") | |
49 |
|
51 | |||
50 | namespace |
|
52 | namespace | |
51 | { |
|
53 | { | |
52 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; |
|
54 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; | |
53 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; |
|
55 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; | |
54 | const auto VIEWPLITTERINDEX = 2; |
|
56 | const auto VIEWPLITTERINDEX = 2; | |
55 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; |
|
57 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; | |
56 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; |
|
58 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; | |
57 | } |
|
59 | } | |
58 |
|
60 | |||
59 | class MainWindow::MainWindowPrivate |
|
61 | class MainWindow::MainWindowPrivate | |
60 | { |
|
62 | { | |
61 | public: |
|
63 | public: | |
62 | explicit MainWindowPrivate(MainWindow* mainWindow) |
|
64 | explicit MainWindowPrivate(MainWindow* mainWindow) | |
63 | : m_LastOpenLeftInspectorSize {} |
|
65 | : m_LastOpenLeftInspectorSize {} | |
64 | , m_LastOpenRightInspectorSize {} |
|
66 | , m_LastOpenRightInspectorSize {} | |
65 | , m_GeneralSettingsWidget { new SqpSettingsGeneralWidget { mainWindow } } |
|
67 | , m_GeneralSettingsWidget { new SqpSettingsGeneralWidget { mainWindow } } | |
66 | , m_SettingsDialog { new SqpSettingsDialog { mainWindow } } |
|
68 | , m_SettingsDialog { new SqpSettingsDialog { mainWindow } } | |
67 | , m_CatalogExplorer { new CataloguesBrowser { mainWindow } } |
|
69 | , m_CatalogExplorer { new CataloguesBrowser { mainWindow } } | |
68 | { |
|
70 | { | |
69 | } |
|
71 | } | |
70 |
|
72 | |||
71 | QSize m_LastOpenLeftInspectorSize; |
|
73 | QSize m_LastOpenLeftInspectorSize; | |
72 | QSize m_LastOpenRightInspectorSize; |
|
74 | QSize m_LastOpenRightInspectorSize; | |
73 | /// General settings widget. MainWindow has the ownership |
|
75 | /// General settings widget. MainWindow has the ownership | |
74 | SqpSettingsGeneralWidget* m_GeneralSettingsWidget; |
|
76 | SqpSettingsGeneralWidget* m_GeneralSettingsWidget; | |
75 | /// Settings dialog. MainWindow has the ownership |
|
77 | /// Settings dialog. MainWindow has the ownership | |
76 | SqpSettingsDialog* m_SettingsDialog; |
|
78 | SqpSettingsDialog* m_SettingsDialog; | |
77 | /// Catalogue dialog. MainWindow has the ownership |
|
79 | /// Catalogue dialog. MainWindow has the ownership | |
78 | CataloguesBrowser* m_CatalogExplorer; |
|
80 | CataloguesBrowser* m_CatalogExplorer; | |
79 |
|
81 | |||
80 | bool checkDataToSave(QWidget* parentWidget); |
|
82 | bool checkDataToSave(QWidget* parentWidget); | |
81 | }; |
|
83 | }; | |
82 |
|
84 | |||
83 | MainWindow::MainWindow(QWidget* parent) |
|
85 | MainWindow::MainWindow(QWidget* parent) | |
84 | : QMainWindow { parent } |
|
86 | : QMainWindow { parent } | |
85 | , m_Ui { new Ui::MainWindow } |
|
87 | , m_Ui { new Ui::MainWindow } | |
86 | , impl { spimpl::make_unique_impl<MainWindowPrivate>(this) } |
|
88 | , impl { spimpl::make_unique_impl<MainWindowPrivate>(this) } | |
87 | { |
|
89 | { | |
88 | m_Ui->setupUi(this); |
|
90 | m_Ui->setupUi(this); | |
89 | setWindowTitle(QString("SciQLop v%1").arg(SCIQLOP_VERSION)); |
|
91 | setWindowTitle(QString("SciQLop v%1").arg(SCIQLOP_VERSION)); | |
90 |
|
92 | |||
91 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
93 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); | |
92 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
94 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); | |
93 |
|
95 | |||
94 | // impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view); |
|
96 | // impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view); | |
95 |
|
97 | |||
96 |
|
98 | |||
97 | auto spacerLeftTop = new QWidget {}; |
|
99 | auto spacerLeftTop = new QWidget {}; | |
98 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
100 | spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
99 |
|
101 | |||
100 | auto spacerLeftBottom = new QWidget {}; |
|
102 | auto spacerLeftBottom = new QWidget {}; | |
101 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
103 | spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
102 |
|
104 | |||
103 |
|
105 | |||
104 | auto spacerRightTop = new QWidget {}; |
|
106 | auto spacerRightTop = new QWidget {}; | |
105 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
107 | spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
106 |
|
108 | |||
107 | auto spacerRightBottom = new QWidget {}; |
|
109 | auto spacerRightBottom = new QWidget {}; | |
108 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
110 | spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
109 |
|
111 | |||
110 |
|
112 | |||
111 | auto openInspector = [this](bool checked, bool right, auto action) { |
|
113 | auto openInspector = [this](bool checked, bool right, auto action) { | |
112 | action->setIcon( |
|
114 | action->setIcon( | |
113 | QIcon { (checked ^ right) ? ":/icones/next.png" : ":/icones/previous.png" }); |
|
115 | QIcon { (checked ^ right) ? ":/icones/next.png" : ":/icones/previous.png" }); | |
114 |
|
116 | |||
115 | auto& lastInspectorSize |
|
117 | auto& lastInspectorSize | |
116 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; |
|
118 | = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize; | |
117 |
|
119 | |||
118 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() |
|
120 | auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size() | |
119 | : m_Ui->leftMainInspectorWidget->size(); |
|
121 | : m_Ui->leftMainInspectorWidget->size(); | |
120 |
|
122 | |||
121 | // Update of the last opened geometry |
|
123 | // Update of the last opened geometry | |
122 | if (checked) |
|
124 | if (checked) | |
123 | { |
|
125 | { | |
124 | lastInspectorSize = nextInspectorSize; |
|
126 | lastInspectorSize = nextInspectorSize; | |
125 | } |
|
127 | } | |
126 |
|
128 | |||
127 | auto startSize = lastInspectorSize; |
|
129 | auto startSize = lastInspectorSize; | |
128 | auto endSize = startSize; |
|
130 | auto endSize = startSize; | |
129 | endSize.setWidth(0); |
|
131 | endSize.setWidth(0); | |
130 |
|
132 | |||
131 | auto splitterInspectorIndex |
|
133 | auto splitterInspectorIndex | |
132 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; |
|
134 | = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX; | |
133 |
|
135 | |||
134 | auto currentSizes = m_Ui->splitter->sizes(); |
|
136 | auto currentSizes = m_Ui->splitter->sizes(); | |
135 | if (checked) |
|
137 | if (checked) | |
136 | { |
|
138 | { | |
137 | // adjust sizes individually here, e.g. |
|
139 | // adjust sizes individually here, e.g. | |
138 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); |
|
140 | currentSizes[splitterInspectorIndex] -= lastInspectorSize.width(); | |
139 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); |
|
141 | currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width(); | |
140 | m_Ui->splitter->setSizes(currentSizes); |
|
142 | m_Ui->splitter->setSizes(currentSizes); | |
141 | } |
|
143 | } | |
142 | else |
|
144 | else | |
143 | { |
|
145 | { | |
144 | // adjust sizes individually here, e.g. |
|
146 | // adjust sizes individually here, e.g. | |
145 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); |
|
147 | currentSizes[splitterInspectorIndex] += lastInspectorSize.width(); | |
146 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); |
|
148 | currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width(); | |
147 | m_Ui->splitter->setSizes(currentSizes); |
|
149 | m_Ui->splitter->setSizes(currentSizes); | |
148 | } |
|
150 | } | |
149 | }; |
|
151 | }; | |
150 |
|
152 | |||
151 |
|
153 | |||
152 | // //////////////// // |
|
154 | // //////////////// // | |
153 | // Menu and Toolbar // |
|
155 | // Menu and Toolbar // | |
154 | // //////////////// // |
|
156 | // //////////////// // | |
155 | this->menuBar()->addAction(tr("File")); |
|
157 | this->menuBar()->addAction(tr("File")); | |
156 | auto toolsMenu = this->menuBar()->addMenu(tr("Tools")); |
|
158 | auto toolsMenu = this->menuBar()->addMenu(tr("Tools")); | |
157 | toolsMenu->addAction(tr("Settings..."), [this]() { |
|
159 | toolsMenu->addAction(tr("Settings..."), [this]() { | |
158 | // Loads settings |
|
160 | // Loads settings | |
159 | impl->m_SettingsDialog->loadSettings(); |
|
161 | impl->m_SettingsDialog->loadSettings(); | |
160 |
|
162 | |||
161 | // Open settings dialog and save settings if the dialog is accepted |
|
163 | // Open settings dialog and save settings if the dialog is accepted | |
162 | if (impl->m_SettingsDialog->exec() == QDialog::Accepted) |
|
164 | if (impl->m_SettingsDialog->exec() == QDialog::Accepted) | |
163 | { |
|
165 | { | |
164 | impl->m_SettingsDialog->saveSettings(); |
|
166 | impl->m_SettingsDialog->saveSettings(); | |
165 | } |
|
167 | } | |
166 | }); |
|
168 | }); | |
167 |
|
169 | auto mainToolBar = new ToolBar(this); | ||
168 |
|
|
170 | this->addToolBar(mainToolBar); | |
169 |
|
171 | connect(mainToolBar, &ToolBar::setPlotsInteractionMode, sqpApp, | ||
170 | auto timeWidget = new TimeWidget {}; |
|
172 | &SqpApplication::setPlotsInteractionMode); | |
171 | mainToolBar->addWidget(timeWidget); |
|
173 | connect(mainToolBar, &ToolBar::setPlotsCursorMode, sqpApp, &SqpApplication::setPlotsCursorMode); | |
172 |
|
174 | connect(mainToolBar, &ToolBar::showCataloguesBrowser, | ||
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", |
|
|||
276 | [this]() { impl->m_CatalogExplorer->show(); }); |
|
175 | [this]() { impl->m_CatalogExplorer->show(); }); | |
277 |
|
176 | |||
278 | // //////// // |
|
177 | // //////// // | |
279 | // Settings // |
|
178 | // Settings // | |
280 | // //////// // |
|
179 | // //////// // | |
281 |
|
180 | |||
282 | // Registers "general settings" widget to the settings dialog |
|
181 | // Registers "general settings" widget to the settings dialog | |
283 | impl->m_SettingsDialog->registerWidget( |
|
182 | impl->m_SettingsDialog->registerWidget( | |
284 | QStringLiteral("General"), impl->m_GeneralSettingsWidget); |
|
183 | QStringLiteral("General"), impl->m_GeneralSettingsWidget); | |
285 |
|
184 | |||
286 | // /////////// // |
|
185 | // /////////// // | |
287 | // Connections // |
|
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 | // Widgets / controllers connections |
|
189 | // Widgets / controllers connections | |
296 |
|
190 | |||
297 | // DataSource |
|
191 | // DataSource | |
298 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem*)), |
|
192 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem*)), | |
299 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem*))); |
|
193 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem*))); | |
300 |
|
194 | |||
301 | // Time |
|
195 | // Time | |
302 | connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), |
|
196 | // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), | |
303 | SLOT(onTimeToUpdate(DateTimeRange))); |
|
197 | // SLOT(onTimeToUpdate(DateTimeRange))); | |
|
198 | connect(mainToolBar, &ToolBar::timeUpdated, &sqpApp->timeController(), | |||
|
199 | &TimeController::setDateTimeRange); | |||
304 |
|
200 | |||
305 | // Visualization |
|
201 | // Visualization | |
306 | connect(&sqpApp->visualizationController(), |
|
202 | connect(&sqpApp->visualizationController(), | |
307 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable2>)), m_Ui->view, |
|
203 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable2>)), m_Ui->view, | |
308 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable2>))); |
|
204 | SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable2>))); | |
309 |
|
205 | |||
310 | connect(&sqpApp->visualizationController(), |
|
206 | connect(&sqpApp->visualizationController(), | |
311 | SIGNAL(rangeChanged(std::shared_ptr<Variable2>, const DateTimeRange&)), m_Ui->view, |
|
207 | SIGNAL(rangeChanged(std::shared_ptr<Variable2>, const DateTimeRange&)), m_Ui->view, | |
312 | SLOT(onRangeChanged(std::shared_ptr<Variable2>, const DateTimeRange&))); |
|
208 | SLOT(onRangeChanged(std::shared_ptr<Variable2>, const DateTimeRange&))); | |
313 |
|
209 | |||
314 | // Widgets / widgets connections |
|
210 | // Widgets / widgets connections | |
315 |
|
211 | |||
316 | // For the following connections, we use DirectConnection to allow each widget that can |
|
212 | // For the following connections, we use DirectConnection to allow each widget that can | |
317 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. |
|
213 | // potentially attach a menu to the variable's menu to do so before this menu is displayed. | |
318 | // The order of connections is also important, since it determines the order in which each |
|
214 | // The order of connections is also important, since it determines the order in which each | |
319 | // widget will attach its menu |
|
215 | // widget will attach its menu | |
320 | connect(m_Ui->variableInspectorWidget, |
|
216 | connect(m_Ui->variableInspectorWidget, | |
321 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu*, const QVector<std::shared_ptr<Variable>>&)), |
|
217 | SIGNAL(tableMenuAboutToBeDisplayed(QMenu*, const QVector<std::shared_ptr<Variable>>&)), | |
322 | m_Ui->view, SLOT(attachVariableMenu(QMenu*, const QVector<std::shared_ptr<Variable>>&)), |
|
218 | m_Ui->view, SLOT(attachVariableMenu(QMenu*, const QVector<std::shared_ptr<Variable>>&)), | |
323 | Qt::DirectConnection); |
|
219 | Qt::DirectConnection); | |
324 | } |
|
220 | } | |
325 |
|
221 | |||
326 | MainWindow::~MainWindow() {} |
|
222 | MainWindow::~MainWindow() {} | |
327 |
|
223 | |||
328 | void MainWindow::changeEvent(QEvent* e) |
|
224 | void MainWindow::changeEvent(QEvent* e) | |
329 | { |
|
225 | { | |
330 | QMainWindow::changeEvent(e); |
|
226 | QMainWindow::changeEvent(e); | |
331 | switch (e->type()) |
|
227 | switch (e->type()) | |
332 | { |
|
228 | { | |
333 | case QEvent::LanguageChange: |
|
229 | case QEvent::LanguageChange: | |
334 | m_Ui->retranslateUi(this); |
|
230 | m_Ui->retranslateUi(this); | |
335 | break; |
|
231 | break; | |
336 | default: |
|
232 | default: | |
337 | break; |
|
233 | break; | |
338 | } |
|
234 | } | |
339 | } |
|
235 | } | |
340 |
|
236 | |||
341 | void MainWindow::closeEvent(QCloseEvent* event) |
|
237 | void MainWindow::closeEvent(QCloseEvent* event) | |
342 | { |
|
238 | { | |
343 | if (!impl->checkDataToSave(this)) |
|
239 | if (!impl->checkDataToSave(this)) | |
344 | { |
|
240 | { | |
345 | event->ignore(); |
|
241 | event->ignore(); | |
346 | } |
|
242 | } | |
347 | else |
|
243 | else | |
348 | { |
|
244 | { | |
349 | event->accept(); |
|
245 | event->accept(); | |
350 | } |
|
246 | } | |
351 | } |
|
247 | } | |
352 |
|
248 | |||
353 | void MainWindow::keyPressEvent(QKeyEvent* event) |
|
249 | void MainWindow::keyPressEvent(QKeyEvent* event) | |
354 | { |
|
250 | { | |
355 | switch (event->key()) |
|
251 | switch (event->key()) | |
356 | { |
|
252 | { | |
357 | case Qt::Key_F11: |
|
253 | case Qt::Key_F11: | |
358 | if (this->isFullScreen()) |
|
254 | if (this->isFullScreen()) | |
359 | { |
|
255 | { | |
360 | this->showNormal(); |
|
256 | this->showNormal(); | |
361 | } |
|
257 | } | |
362 | else |
|
258 | else | |
363 | { |
|
259 | { | |
364 | this->showFullScreen(); |
|
260 | this->showFullScreen(); | |
365 | } |
|
261 | } | |
366 | break; |
|
262 | break; | |
367 | default: |
|
263 | default: | |
368 | break; |
|
264 | break; | |
369 | } |
|
265 | } | |
370 | } |
|
266 | } | |
371 |
|
267 | |||
372 | bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget* parentWidget) |
|
268 | bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget* parentWidget) | |
373 | { |
|
269 | { | |
374 | // auto hasChanges = sqpApp->catalogueController().hasChanges(); |
|
270 | // auto hasChanges = sqpApp->catalogueController().hasChanges(); | |
375 | // if (hasChanges) |
|
271 | // if (hasChanges) | |
376 | // { |
|
272 | // { | |
377 | // // There are some unsaved changes |
|
273 | // // There are some unsaved changes | |
378 | // switch (QMessageBox::question(parentWidget, tr("Save changes"), |
|
274 | // switch (QMessageBox::question(parentWidget, tr("Save changes"), | |
379 | // tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"), |
|
275 | // tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"), | |
380 | // QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel, |
|
276 | // QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel, | |
381 | // QMessageBox::SaveAll)) |
|
277 | // QMessageBox::SaveAll)) | |
382 | // { |
|
278 | // { | |
383 | // case QMessageBox::SaveAll: |
|
279 | // case QMessageBox::SaveAll: | |
384 | // sqpApp->catalogueController().saveAll(); |
|
280 | // sqpApp->catalogueController().saveAll(); | |
385 | // break; |
|
281 | // break; | |
386 | // case QMessageBox::Discard: |
|
282 | // case QMessageBox::Discard: | |
387 | // break; |
|
283 | // break; | |
388 | // case QMessageBox::Cancel: |
|
284 | // case QMessageBox::Cancel: | |
389 | // default: |
|
285 | // default: | |
390 | // return false; |
|
286 | // return false; | |
391 | // } |
|
287 | // } | |
392 | // } |
|
288 | // } | |
393 |
|
289 | |||
394 | return true; |
|
290 | return true; | |
395 | } |
|
291 | } |
@@ -1,162 +1,177 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>MainWindow</class> |
|
3 | <class>MainWindow</class> | |
4 | <widget class="QMainWindow" name="MainWindow"> |
|
4 | <widget class="QMainWindow" name="MainWindow"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>800</width> |
|
9 | <width>800</width> | |
10 | <height>600</height> |
|
10 | <height>600</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>SciQlop</string> |
|
14 | <string>SciQlop</string> | |
15 | </property> |
|
15 | </property> | |
16 | <property name="dockNestingEnabled"> |
|
16 | <property name="dockNestingEnabled"> | |
17 | <bool>true</bool> |
|
17 | <bool>true</bool> | |
18 | </property> |
|
18 | </property> | |
19 | <widget class="QWidget" name="centralWidget"> |
|
19 | <widget class="QWidget" name="centralWidget"> | |
20 | <property name="enabled"> |
|
20 | <property name="enabled"> | |
21 | <bool>true</bool> |
|
21 | <bool>true</bool> | |
22 | </property> |
|
22 | </property> | |
23 | <property name="sizePolicy"> |
|
23 | <property name="sizePolicy"> | |
24 | <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> |
|
24 | <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> | |
25 | <horstretch>0</horstretch> |
|
25 | <horstretch>0</horstretch> | |
26 | <verstretch>0</verstretch> |
|
26 | <verstretch>0</verstretch> | |
27 | </sizepolicy> |
|
27 | </sizepolicy> | |
28 | </property> |
|
28 | </property> | |
29 | <property name="maximumSize"> |
|
29 | <property name="maximumSize"> | |
30 | <size> |
|
30 | <size> | |
31 | <width>16777215</width> |
|
31 | <width>16777215</width> | |
32 | <height>16777215</height> |
|
32 | <height>16777215</height> | |
33 | </size> |
|
33 | </size> | |
34 | </property> |
|
34 | </property> | |
35 | <layout class="QHBoxLayout" name="horizontalLayout"> |
|
35 | <layout class="QHBoxLayout" name="horizontalLayout"> | |
36 | <property name="spacing"> |
|
36 | <property name="spacing"> | |
37 | <number>0</number> |
|
37 | <number>0</number> | |
38 | </property> |
|
38 | </property> | |
39 | <property name="leftMargin"> |
|
39 | <property name="leftMargin"> | |
40 | <number>0</number> |
|
40 | <number>0</number> | |
41 | </property> |
|
41 | </property> | |
42 | <property name="topMargin"> |
|
42 | <property name="topMargin"> | |
43 | <number>0</number> |
|
43 | <number>0</number> | |
44 | </property> |
|
44 | </property> | |
45 | <property name="rightMargin"> |
|
45 | <property name="rightMargin"> | |
46 | <number>0</number> |
|
46 | <number>0</number> | |
47 | </property> |
|
47 | </property> | |
48 | <property name="bottomMargin"> |
|
48 | <property name="bottomMargin"> | |
49 | <number>0</number> |
|
49 | <number>0</number> | |
50 | </property> |
|
50 | </property> | |
51 | <item> |
|
51 | <item> | |
52 | <widget class="QSplitter" name="splitter"> |
|
52 | <widget class="QSplitter" name="splitter"> | |
53 | <property name="orientation"> |
|
53 | <property name="orientation"> | |
54 | <enum>Qt::Horizontal</enum> |
|
54 | <enum>Qt::Horizontal</enum> | |
55 | </property> |
|
55 | </property> | |
56 | <widget class="QWidget" name="leftMainInspectorWidget" native="true"> |
|
56 | <widget class="QWidget" name="leftMainInspectorWidget" native="true"> | |
57 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
57 | <layout class="QVBoxLayout" name="verticalLayout"> | |
58 | <property name="spacing"> |
|
58 | <property name="spacing"> | |
59 | <number>0</number> |
|
59 | <number>0</number> | |
60 | </property> |
|
60 | </property> | |
61 | <property name="leftMargin"> |
|
61 | <property name="leftMargin"> | |
62 | <number>0</number> |
|
62 | <number>0</number> | |
63 | </property> |
|
63 | </property> | |
64 | <property name="topMargin"> |
|
64 | <property name="topMargin"> | |
65 | <number>0</number> |
|
65 | <number>0</number> | |
66 | </property> |
|
66 | </property> | |
67 | <property name="rightMargin"> |
|
67 | <property name="rightMargin"> | |
68 | <number>0</number> |
|
68 | <number>0</number> | |
69 | </property> |
|
69 | </property> | |
70 | <property name="bottomMargin"> |
|
70 | <property name="bottomMargin"> | |
71 | <number>0</number> |
|
71 | <number>0</number> | |
72 | </property> |
|
72 | </property> | |
73 | <item> |
|
73 | <item> | |
74 | <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/> |
|
74 | <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/> | |
75 | </item> |
|
75 | </item> | |
76 | <item> |
|
76 | <item> | |
77 | <widget class="QWidget" name="dateTimeWidget" native="true"/> |
|
77 | <widget class="QWidget" name="dateTimeWidget" native="true"/> | |
78 | </item> |
|
78 | </item> | |
79 | <item> |
|
79 | <item> | |
80 | <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/> |
|
80 | <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/> | |
81 | </item> |
|
81 | </item> | |
82 | </layout> |
|
82 | </layout> | |
83 | </widget> |
|
83 | </widget> | |
84 | <widget class="VisualizationWidget" name="view" native="true"> |
|
84 | <widget class="VisualizationWidget" name="view" native="true"> | |
85 | <property name="sizePolicy"> |
|
85 | <property name="sizePolicy"> | |
86 | <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> |
|
86 | <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> | |
87 | <horstretch>0</horstretch> |
|
87 | <horstretch>0</horstretch> | |
88 | <verstretch>0</verstretch> |
|
88 | <verstretch>0</verstretch> | |
89 | </sizepolicy> |
|
89 | </sizepolicy> | |
90 | </property> |
|
90 | </property> | |
91 | </widget> |
|
91 | </widget> | |
92 | <widget class="QWidget" name="rightMainInspectorWidget" native="true"> |
|
92 | <widget class="QWidget" name="rightMainInspectorWidget" native="true"> | |
93 | <layout class="QVBoxLayout" name="verticalLayout_3"> |
|
93 | <layout class="QVBoxLayout" name="verticalLayout_3"> | |
94 | <property name="spacing"> |
|
94 | <property name="spacing"> | |
95 | <number>0</number> |
|
95 | <number>0</number> | |
96 | </property> |
|
96 | </property> | |
97 | <property name="leftMargin"> |
|
97 | <property name="leftMargin"> | |
98 | <number>0</number> |
|
98 | <number>0</number> | |
99 | </property> |
|
99 | </property> | |
100 | <property name="topMargin"> |
|
100 | <property name="topMargin"> | |
101 | <number>0</number> |
|
101 | <number>0</number> | |
102 | </property> |
|
102 | </property> | |
103 | <property name="rightMargin"> |
|
103 | <property name="rightMargin"> | |
104 | <number>0</number> |
|
104 | <number>0</number> | |
105 | </property> |
|
105 | </property> | |
106 | <property name="bottomMargin"> |
|
106 | <property name="bottomMargin"> | |
107 | <number>0</number> |
|
107 | <number>0</number> | |
108 | </property> |
|
108 | </property> | |
109 | <item> |
|
109 | <item> | |
110 | <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/> |
|
110 | <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/> | |
111 | </item> |
|
111 | </item> | |
112 | <item> |
|
112 | <item> | |
113 | <widget class="QTreeWidget" name="catalogWidget"> |
|
113 | <widget class="QTreeWidget" name="catalogWidget"> | |
114 | <column> |
|
114 | <column> | |
115 | <property name="text"> |
|
115 | <property name="text"> | |
116 | <string notr="true">Name</string> |
|
116 | <string notr="true">Name</string> | |
117 | </property> |
|
117 | </property> | |
118 | </column> |
|
118 | </column> | |
119 | </widget> |
|
119 | </widget> | |
120 | </item> |
|
120 | </item> | |
121 | </layout> |
|
121 | </layout> | |
122 | </widget> |
|
122 | </widget> | |
123 | </widget> |
|
123 | </widget> | |
124 | </item> |
|
124 | </item> | |
125 | </layout> |
|
125 | </layout> | |
126 | </widget> |
|
126 | </widget> | |
127 | <widget class="QMenuBar" name="menuBar"> |
|
127 | <widget class="QMenuBar" name="menuBar"> | |
128 | <property name="geometry"> |
|
128 | <property name="geometry"> | |
129 | <rect> |
|
129 | <rect> | |
130 | <x>0</x> |
|
130 | <x>0</x> | |
131 | <y>0</y> |
|
131 | <y>0</y> | |
132 | <width>800</width> |
|
132 | <width>800</width> | |
133 |
<height>2 |
|
133 | <height>27</height> | |
134 | </rect> |
|
134 | </rect> | |
135 | </property> |
|
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 | </widget> |
|
151 | </widget> | |
137 | <widget class="QStatusBar" name="statusBar"/> |
|
152 | <widget class="QStatusBar" name="statusBar"/> | |
138 | </widget> |
|
153 | </widget> | |
139 | <layoutdefault spacing="6" margin="11"/> |
|
154 | <layoutdefault spacing="6" margin="11"/> | |
140 | <customwidgets> |
|
155 | <customwidgets> | |
141 | <customwidget> |
|
156 | <customwidget> | |
142 | <class>VisualizationWidget</class> |
|
157 | <class>VisualizationWidget</class> | |
143 | <extends>QWidget</extends> |
|
158 | <extends>QWidget</extends> | |
144 | <header location="global">Visualization/VisualizationWidget.h</header> |
|
159 | <header location="global">Visualization/VisualizationWidget.h</header> | |
145 | <container>1</container> |
|
160 | <container>1</container> | |
146 | </customwidget> |
|
161 | </customwidget> | |
147 | <customwidget> |
|
162 | <customwidget> | |
148 | <class>DataSourceWidget</class> |
|
163 | <class>DataSourceWidget</class> | |
149 | <extends>QWidget</extends> |
|
164 | <extends>QWidget</extends> | |
150 | <header location="global">DataSource/DataSourceWidget.h</header> |
|
165 | <header location="global">DataSource/DataSourceWidget.h</header> | |
151 | <container>1</container> |
|
166 | <container>1</container> | |
152 | </customwidget> |
|
167 | </customwidget> | |
153 | <customwidget> |
|
168 | <customwidget> | |
154 | <class>VariableInspectorWidget</class> |
|
169 | <class>VariableInspectorWidget</class> | |
155 | <extends>QWidget</extends> |
|
170 | <extends>QWidget</extends> | |
156 | <header location="global">Variable/VariableInspectorWidget.h</header> |
|
171 | <header location="global">Variable/VariableInspectorWidget.h</header> | |
157 | <container>1</container> |
|
172 | <container>1</container> | |
158 | </customwidget> |
|
173 | </customwidget> | |
159 | </customwidgets> |
|
174 | </customwidgets> | |
160 | <resources/> |
|
175 | <resources/> | |
161 | <connections/> |
|
176 | <connections/> | |
162 | </ui> |
|
177 | </ui> |
@@ -1,76 +1,117 | |||||
1 | #ifndef SCIQLOP_SQPAPPLICATION_H |
|
1 | #ifndef SCIQLOP_SQPAPPLICATION_H | |
2 | #define SCIQLOP_SQPAPPLICATION_H |
|
2 | #define SCIQLOP_SQPAPPLICATION_H | |
3 |
|
3 | |||
4 | #include "SqpApplication.h" |
|
4 | #include "SqpApplication.h" | |
5 |
|
5 | |||
|
6 | #include <QAction> | |||
6 | #include <QApplication> |
|
7 | #include <QApplication> | |
7 | #include <QLoggingCategory> |
|
8 | #include <QLoggingCategory> | |
|
9 | #include <QMenuBar> | |||
|
10 | #include <QProxyStyle> | |||
|
11 | #include <QStyleOption> | |||
|
12 | #include <QWidget> | |||
|
13 | #include <QWidgetAction> | |||
8 |
|
14 | |||
9 | #include <Common/spimpl.h> |
|
15 | #include <Common/spimpl.h> | |
10 |
|
16 | |||
11 | Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) |
|
17 | Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) | |
12 |
|
18 | |||
13 | #if defined(sqpApp) |
|
19 | #if defined(sqpApp) | |
14 | #undef sqpApp |
|
20 | #undef sqpApp | |
15 | #endif |
|
21 | #endif | |
16 |
#define sqpApp (static_cast<SqpApplication |
|
22 | #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance())) | |
17 |
|
23 | |||
18 | class DataSourceController; |
|
24 | class DataSourceController; | |
19 | class NetworkController; |
|
25 | class NetworkController; | |
20 | class TimeController; |
|
26 | class TimeController; | |
21 | class VariableController; |
|
27 | class VariableController; | |
22 | class VariableController2; |
|
28 | class VariableController2; | |
23 | class VariableModel2; |
|
29 | class VariableModel2; | |
24 | class VisualizationController; |
|
30 | class VisualizationController; | |
25 | class DragDropGuiController; |
|
31 | class DragDropGuiController; | |
26 | class ActionsGuiController; |
|
32 | class ActionsGuiController; | |
27 | class CatalogueController; |
|
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 | * @brief The SqpApplication class aims to make the link between SciQlop |
|
57 | * @brief The SqpApplication class aims to make the link between SciQlop | |
31 | * and its plugins. This is the intermediate class that SciQlop has to use |
|
58 | * and its plugins. This is the intermediate class that SciQlop has to use | |
32 | * in the way to connect a data source. Please first use load method to initialize |
|
59 | * in the way to connect a data source. Please first use load method to initialize | |
33 | * a plugin specified by its metadata name (JSON plugin source) then others specifics |
|
60 | * a plugin specified by its metadata name (JSON plugin source) then others specifics | |
34 | * method will be able to access it. |
|
61 | * method will be able to access it. | |
35 | * You can load a data source driver plugin then create a data source. |
|
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 | Q_OBJECT |
|
67 | Q_OBJECT | |
40 | public: |
|
68 | public: | |
41 |
explicit SqpApplication(int |
|
69 | explicit SqpApplication(int& argc, char** argv); | |
42 |
|
|
70 | ~SqpApplication() override; | |
43 | void initialize(); |
|
71 | void initialize(); | |
44 |
|
72 | |||
45 | /// Accessors for the differents sciqlop controllers |
|
73 | /// Accessors for the differents sciqlop controllers | |
46 |
DataSourceController |
|
74 | DataSourceController& dataSourceController() noexcept; | |
47 |
NetworkController |
|
75 | NetworkController& networkController() noexcept; | |
48 |
TimeController |
|
76 | TimeController& timeController() noexcept; | |
49 |
VariableController2 |
|
77 | VariableController2& variableController() noexcept; | |
50 | std::shared_ptr<VariableController2> variableControllerOwner() noexcept; |
|
78 | std::shared_ptr<VariableController2> variableControllerOwner() noexcept; | |
51 | //@TODO there should not be any global model it's just GUI impl detail |
|
79 | //@TODO there should not be any global model it's just GUI impl detail | |
52 | // VariableModel2 &variableModel() noexcept; |
|
80 | // VariableModel2 &variableModel() noexcept; | |
53 |
VisualizationController |
|
81 | VisualizationController& visualizationController() noexcept; | |
54 |
CatalogueController |
|
82 | CatalogueController& catalogueController() noexcept; | |
55 |
|
83 | |||
56 | /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but |
|
84 | /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but | |
57 | /// doesn't live in a thread and access gui |
|
85 | /// doesn't live in a thread and access gui | |
58 |
DragDropGuiController |
|
86 | DragDropGuiController& dragDropGuiController() noexcept; | |
59 |
ActionsGuiController |
|
87 | ActionsGuiController& actionsGuiController() noexcept; | |
60 |
|
88 | |||
61 | enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones }; |
|
89 | enum class PlotsInteractionMode | |
|
90 | { | |||
|
91 | None, | |||
|
92 | ZoomBox, | |||
|
93 | DragAndDrop, | |||
|
94 | SelectionZones | |||
|
95 | }; | |||
62 |
|
96 | |||
63 | enum class PlotsCursorMode { NoCursor, Vertical, Temporal, Horizontal, Cross }; |
|
97 | enum class PlotsCursorMode | |
|
98 | { | |||
|
99 | NoCursor, | |||
|
100 | Vertical, | |||
|
101 | Temporal, | |||
|
102 | Horizontal, | |||
|
103 | Cross | |||
|
104 | }; | |||
64 |
|
105 | |||
65 | PlotsInteractionMode plotsInteractionMode() const; |
|
106 | PlotsInteractionMode plotsInteractionMode() const; | |
66 | void setPlotsInteractionMode(PlotsInteractionMode mode); |
|
107 | void setPlotsInteractionMode(PlotsInteractionMode mode); | |
67 |
|
108 | |||
68 | PlotsCursorMode plotsCursorMode() const; |
|
109 | PlotsCursorMode plotsCursorMode() const; | |
69 | void setPlotsCursorMode(PlotsCursorMode mode); |
|
110 | void setPlotsCursorMode(PlotsCursorMode mode); | |
70 |
|
111 | |||
71 | private: |
|
112 | private: | |
72 | class SqpApplicationPrivate; |
|
113 | class SqpApplicationPrivate; | |
73 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; |
|
114 | spimpl::unique_impl_ptr<SqpApplicationPrivate> impl; | |
74 | }; |
|
115 | }; | |
75 |
|
116 | |||
76 | #endif // SCIQLOP_SQPAPPLICATION_H |
|
117 | #endif // SCIQLOP_SQPAPPLICATION_H |
@@ -1,47 +1,64 | |||||
1 | #ifndef SCIQLOP_TIMEWIDGET_H |
|
1 | #ifndef SCIQLOP_TIMEWIDGET_H | |
2 | #define SCIQLOP_TIMEWIDGET_H |
|
2 | #define SCIQLOP_TIMEWIDGET_H | |
3 |
|
3 | |||
4 | #include <QWidget> |
|
4 | #include <QWidget> | |
|
5 | #include <QWidgetAction> | |||
5 |
|
6 | |||
6 | #include <Data/DateTimeRange.h> |
|
7 | #include <Data/DateTimeRange.h> | |
7 |
|
8 | |||
8 | #include <Common/spimpl.h> |
|
9 | #include <Common/spimpl.h> | |
9 |
|
10 | |||
10 |
namespace Ui |
|
11 | namespace Ui | |
|
12 | { | |||
11 | class TimeWidget; |
|
13 | class TimeWidget; | |
12 | } // Ui |
|
14 | } // Ui | |
13 |
|
15 | |||
14 | class TimeWidget : public QWidget { |
|
16 | ||
|
17 | class TimeWidget : public QWidget | |||
|
18 | { | |||
15 | Q_OBJECT |
|
19 | Q_OBJECT | |
16 |
|
20 | |||
17 | public: |
|
21 | public: | |
18 |
explicit TimeWidget(QWidget |
|
22 | explicit TimeWidget(QWidget* parent = 0); | |
19 | virtual ~TimeWidget(); |
|
23 | virtual ~TimeWidget(); | |
20 |
|
24 | |||
21 | void setTimeRange(DateTimeRange time); |
|
25 | void setTimeRange(DateTimeRange time); | |
22 | DateTimeRange timeRange() const; |
|
26 | DateTimeRange timeRange() const; | |
23 |
|
27 | |||
24 | signals: |
|
28 | signals: | |
25 | /// Signal emitted when the time parameters has beed updated |
|
29 | /// Signal emitted when the time parameters has beed updated | |
26 | void timeUpdated(DateTimeRange time); |
|
30 | void timeUpdated(DateTimeRange time); | |
27 |
|
31 | |||
28 | public slots: |
|
32 | public slots: | |
29 | /// slot called when time parameters update has ben requested |
|
33 | /// slot called when time parameters update has ben requested | |
30 | void onTimeUpdateRequested(); |
|
34 | void onTimeUpdateRequested(); | |
31 |
|
35 | |||
32 | protected: |
|
36 | protected: | |
33 |
void dragEnterEvent(QDragEnterEvent |
|
37 | void dragEnterEvent(QDragEnterEvent* event) override; | |
34 |
void dragLeaveEvent(QDragLeaveEvent |
|
38 | void dragLeaveEvent(QDragLeaveEvent* event) override; | |
35 |
void dropEvent(QDropEvent |
|
39 | void dropEvent(QDropEvent* event) override; | |
36 |
|
40 | |||
37 |
void mousePressEvent(QMouseEvent |
|
41 | void mousePressEvent(QMouseEvent* event) override; | |
38 |
void mouseMoveEvent(QMouseEvent |
|
42 | void mouseMoveEvent(QMouseEvent* event) override; | |
39 |
|
43 | |||
40 | private: |
|
44 | private: | |
41 |
Ui::TimeWidget |
|
45 | Ui::TimeWidget* ui; | |
42 |
|
46 | |||
43 | class TimeWidgetPrivate; |
|
47 | class TimeWidgetPrivate; | |
44 | spimpl::unique_impl_ptr<TimeWidgetPrivate> impl; |
|
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 | #endif // SCIQLOP_ SQPSIDEPANE_H |
|
64 | #endif // SCIQLOP_ SQPSIDEPANE_H |
@@ -1,31 +1,32 | |||||
1 | <RCC> |
|
1 | <RCC> | |
2 | <qresource prefix="/"> |
|
2 | <qresource prefix="/"> | |
3 |
|
|
3 | <file>icones/dataSourceComponent.png</file> | |
4 |
|
|
4 | <file>icones/dataSourceNode.png</file> | |
5 |
|
|
5 | <file>icones/dataSourceProduct.png</file> | |
6 |
|
|
6 | <file>icones/dataSourceRoot.png</file> | |
7 |
|
|
7 | <file>icones/delete.png</file> | |
8 | <file>icones/down.png</file> |
|
8 | <file>icones/down.png</file> | |
9 | <file>icones/openInspector.png</file> |
|
9 | <file>icones/openInspector.png</file> | |
10 | <file>icones/next.png</file> |
|
10 | <file>icones/next.png</file> | |
11 | <file>icones/plot.png</file> |
|
11 | <file>icones/plot.png</file> | |
12 | <file>icones/previous.png</file> |
|
12 | <file>icones/previous.png</file> | |
13 | <file>icones/unplot.png</file> |
|
13 | <file>icones/unplot.png</file> | |
14 | <file>icones/up.png</file> |
|
14 | <file>icones/up.png</file> | |
15 |
|
|
15 | <file>icones/time.png</file> | |
16 |
|
|
16 | <file>icones/zoom.png</file> | |
17 |
|
|
17 | <file>icones/rectangle.png</file> | |
18 |
|
|
18 | <file>icones/drag.png</file> | |
19 |
|
|
19 | <file>icones/cursor.png</file> | |
20 |
|
|
20 | <file>icones/pointer.png</file> | |
21 |
|
|
21 | <file>icones/catalogue.png</file> | |
22 |
|
|
22 | <file>icones/add.png</file> | |
23 |
|
|
23 | <file>icones/remove.png</file> | |
24 |
|
|
24 | <file>icones/chart.png</file> | |
25 |
|
|
25 | <file>icones/allEvents.png</file> | |
26 |
|
|
26 | <file>icones/trash.png</file> | |
27 |
|
|
27 | <file>icones/database.png</file> | |
28 |
|
|
28 | <file>icones/save.png</file> | |
29 |
|
|
29 | <file>icones/discard.png</file> | |
|
30 | <file>icones/Simple_icon_time.svg</file> | |||
30 | </qresource> |
|
31 | </qresource> | |
31 | </RCC> |
|
32 | </RCC> |
@@ -1,192 +1,193 | |||||
1 | #include "SqpApplication.h" |
|
1 | #include "SqpApplication.h" | |
2 |
|
2 | |||
3 | #include <Actions/ActionsGuiController.h> |
|
3 | #include <Actions/ActionsGuiController.h> | |
4 | #include <Catalogue/CatalogueController.h> |
|
4 | #include <Catalogue/CatalogueController.h> | |
5 | #include <Data/IDataProvider.h> |
|
5 | #include <Data/IDataProvider.h> | |
6 | #include <DataSource/DataSourceController.h> |
|
6 | #include <DataSource/DataSourceController.h> | |
7 | #include <DragAndDrop/DragDropGuiController.h> |
|
7 | #include <DragAndDrop/DragDropGuiController.h> | |
8 | #include <Network/NetworkController.h> |
|
8 | #include <Network/NetworkController.h> | |
9 | #include <QThread> |
|
9 | #include <QThread> | |
10 | #include <Time/TimeController.h> |
|
10 | #include <Time/TimeController.h> | |
11 | #include <Variable/VariableController2.h> |
|
11 | #include <Variable/VariableController2.h> | |
12 | #include <Variable/VariableModel2.h> |
|
12 | #include <Variable/VariableModel2.h> | |
13 | #include <Visualization/VisualizationController.h> |
|
13 | #include <Visualization/VisualizationController.h> | |
14 |
|
14 | |||
15 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
|
15 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") | |
16 |
|
16 | |||
17 | class SqpApplication::SqpApplicationPrivate |
|
17 | class SqpApplication::SqpApplicationPrivate | |
18 | { |
|
18 | { | |
19 | public: |
|
19 | public: | |
20 | SqpApplicationPrivate() |
|
20 | SqpApplicationPrivate() | |
21 | : m_VariableController { std::make_shared<VariableController2>() } |
|
21 | : m_VariableController { std::make_shared<VariableController2>() } | |
22 | , m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None) |
|
22 | , m_PlotInterractionMode(SqpApplication::PlotsInteractionMode::None) | |
23 | , m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) |
|
23 | , m_PlotCursorMode(SqpApplication::PlotsCursorMode::NoCursor) | |
24 | { |
|
24 | { | |
25 | // /////////////////////////////// // |
|
25 | // /////////////////////////////// // | |
26 | // Connections between controllers // |
|
26 | // Connections between controllers // | |
27 | // /////////////////////////////// // |
|
27 | // /////////////////////////////// // | |
28 |
|
28 | |||
29 | // VariableController <-> DataSourceController |
|
29 | // VariableController <-> DataSourceController | |
30 | connect(&m_DataSourceController, &DataSourceController::createVariable, |
|
30 | connect(&m_DataSourceController, &DataSourceController::createVariable, | |
31 | [](const QString& variableName, const QVariantHash& variableMetadata, |
|
31 | [](const QString& variableName, const QVariantHash& variableMetadata, | |
32 | std::shared_ptr<IDataProvider> variableProvider) { |
|
32 | std::shared_ptr<IDataProvider> variableProvider) { | |
33 | sqpApp->variableController().createVariable(variableName, variableMetadata, |
|
33 | sqpApp->variableController().createVariable(variableName, variableMetadata, | |
34 | variableProvider, sqpApp->timeController().dateTime()); |
|
34 | variableProvider, sqpApp->timeController().dateTime()); | |
35 | }); |
|
35 | }); | |
36 |
|
36 | |||
37 | // VariableController <-> VisualizationController |
|
37 | // VariableController <-> VisualizationController | |
38 | // connect(m_VariableController.get(), |
|
38 | // connect(m_VariableController.get(), | |
39 | // SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), |
|
39 | // SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | |
40 | // m_VisualizationController.get(), |
|
40 | // m_VisualizationController.get(), | |
41 | // SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), |
|
41 | // SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), | |
42 | // Qt::DirectConnection); |
|
42 | // Qt::DirectConnection); | |
43 |
|
43 | |||
44 | // connect(m_VariableController.get(), |
|
44 | // connect(m_VariableController.get(), | |
45 | // SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), |
|
45 | // SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), | |
46 | // m_VisualizationController.get(), |
|
46 | // m_VisualizationController.get(), | |
47 | // SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &))); |
|
47 | // SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &))); | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | m_DataSourceController.moveToThread(&m_DataSourceControllerThread); |
|
50 | m_DataSourceController.moveToThread(&m_DataSourceControllerThread); | |
51 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); |
|
51 | m_DataSourceControllerThread.setObjectName("DataSourceControllerThread"); | |
52 | m_NetworkController.moveToThread(&m_NetworkControllerThread); |
|
52 | m_NetworkController.moveToThread(&m_NetworkControllerThread); | |
53 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); |
|
53 | m_NetworkControllerThread.setObjectName("NetworkControllerThread"); | |
54 | m_VisualizationController.moveToThread(&m_VisualizationControllerThread); |
|
54 | m_VisualizationController.moveToThread(&m_VisualizationControllerThread); | |
55 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); |
|
55 | m_VisualizationControllerThread.setObjectName("VsualizationControllerThread"); | |
56 |
|
56 | |||
57 | // Additionnal init |
|
57 | // Additionnal init | |
58 | // m_VariableController->setTimeController(m_TimeController.get()); |
|
58 | // m_VariableController->setTimeController(m_TimeController.get()); | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | virtual ~SqpApplicationPrivate() |
|
61 | virtual ~SqpApplicationPrivate() | |
62 | { |
|
62 | { | |
63 | m_DataSourceControllerThread.quit(); |
|
63 | m_DataSourceControllerThread.quit(); | |
64 | m_DataSourceControllerThread.wait(); |
|
64 | m_DataSourceControllerThread.wait(); | |
65 |
|
65 | |||
66 | m_NetworkControllerThread.quit(); |
|
66 | m_NetworkControllerThread.quit(); | |
67 | m_NetworkControllerThread.wait(); |
|
67 | m_NetworkControllerThread.wait(); | |
68 |
|
68 | |||
69 | m_VisualizationControllerThread.quit(); |
|
69 | m_VisualizationControllerThread.quit(); | |
70 | m_VisualizationControllerThread.wait(); |
|
70 | m_VisualizationControllerThread.wait(); | |
71 | } |
|
71 | } | |
72 |
|
72 | |||
73 | DataSourceController m_DataSourceController; |
|
73 | DataSourceController m_DataSourceController; | |
74 | std::shared_ptr<VariableController2> m_VariableController; |
|
74 | std::shared_ptr<VariableController2> m_VariableController; | |
75 | TimeController m_TimeController; |
|
75 | TimeController m_TimeController; | |
76 | NetworkController m_NetworkController; |
|
76 | NetworkController m_NetworkController; | |
77 | VisualizationController m_VisualizationController; |
|
77 | VisualizationController m_VisualizationController; | |
78 | CatalogueController m_CatalogueController; |
|
78 | CatalogueController m_CatalogueController; | |
79 |
|
79 | |||
80 | QThread m_DataSourceControllerThread; |
|
80 | QThread m_DataSourceControllerThread; | |
81 | QThread m_NetworkControllerThread; |
|
81 | QThread m_NetworkControllerThread; | |
82 | QThread m_VisualizationControllerThread; |
|
82 | QThread m_VisualizationControllerThread; | |
83 |
|
83 | |||
84 | DragDropGuiController m_DragDropGuiController; |
|
84 | DragDropGuiController m_DragDropGuiController; | |
85 | ActionsGuiController m_ActionsGuiController; |
|
85 | ActionsGuiController m_ActionsGuiController; | |
86 |
|
86 | |||
87 | SqpApplication::PlotsInteractionMode m_PlotInterractionMode; |
|
87 | SqpApplication::PlotsInteractionMode m_PlotInterractionMode; | |
88 | SqpApplication::PlotsCursorMode m_PlotCursorMode; |
|
88 | SqpApplication::PlotsCursorMode m_PlotCursorMode; | |
89 | }; |
|
89 | }; | |
90 |
|
90 | |||
91 |
|
91 | |||
92 | SqpApplication::SqpApplication(int& argc, char** argv) |
|
92 | SqpApplication::SqpApplication(int& argc, char** argv) | |
93 | : QApplication { argc, argv }, impl { spimpl::make_unique_impl<SqpApplicationPrivate>() } |
|
93 | : QApplication { argc, argv }, impl { spimpl::make_unique_impl<SqpApplicationPrivate>() } | |
94 | { |
|
94 | { | |
|
95 | this->setStyle(new MyProxyStyle(this->style())); | |||
95 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); |
|
96 | qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); | |
96 |
|
97 | |||
97 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); |
|
98 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); | |
98 |
|
99 | |||
99 | connect(&impl->m_DataSourceControllerThread, &QThread::started, &impl->m_DataSourceController, |
|
100 | connect(&impl->m_DataSourceControllerThread, &QThread::started, &impl->m_DataSourceController, | |
100 | &DataSourceController::initialize); |
|
101 | &DataSourceController::initialize); | |
101 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, &impl->m_DataSourceController, |
|
102 | connect(&impl->m_DataSourceControllerThread, &QThread::finished, &impl->m_DataSourceController, | |
102 | &DataSourceController::finalize); |
|
103 | &DataSourceController::finalize); | |
103 |
|
104 | |||
104 | connect(&impl->m_NetworkControllerThread, &QThread::started, &impl->m_NetworkController, |
|
105 | connect(&impl->m_NetworkControllerThread, &QThread::started, &impl->m_NetworkController, | |
105 | &NetworkController::initialize); |
|
106 | &NetworkController::initialize); | |
106 | connect(&impl->m_NetworkControllerThread, &QThread::finished, &impl->m_NetworkController, |
|
107 | connect(&impl->m_NetworkControllerThread, &QThread::finished, &impl->m_NetworkController, | |
107 | &NetworkController::finalize); |
|
108 | &NetworkController::finalize); | |
108 |
|
109 | |||
109 | connect(&impl->m_VisualizationControllerThread, &QThread::started, |
|
110 | connect(&impl->m_VisualizationControllerThread, &QThread::started, | |
110 | &impl->m_VisualizationController, &VisualizationController::initialize); |
|
111 | &impl->m_VisualizationController, &VisualizationController::initialize); | |
111 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, |
|
112 | connect(&impl->m_VisualizationControllerThread, &QThread::finished, | |
112 | &impl->m_VisualizationController, &VisualizationController::finalize); |
|
113 | &impl->m_VisualizationController, &VisualizationController::finalize); | |
113 |
|
114 | |||
114 | impl->m_DataSourceControllerThread.start(); |
|
115 | impl->m_DataSourceControllerThread.start(); | |
115 | impl->m_NetworkControllerThread.start(); |
|
116 | impl->m_NetworkControllerThread.start(); | |
116 | impl->m_VisualizationControllerThread.start(); |
|
117 | impl->m_VisualizationControllerThread.start(); | |
117 | // impl->m_CatalogueController.initialize(); |
|
118 | // impl->m_CatalogueController.initialize(); | |
118 | } |
|
119 | } | |
119 |
|
120 | |||
120 | SqpApplication::~SqpApplication() {} |
|
121 | SqpApplication::~SqpApplication() {} | |
121 |
|
122 | |||
122 | void SqpApplication::initialize() {} |
|
123 | void SqpApplication::initialize() {} | |
123 |
|
124 | |||
124 | DataSourceController& SqpApplication::dataSourceController() noexcept |
|
125 | DataSourceController& SqpApplication::dataSourceController() noexcept | |
125 | { |
|
126 | { | |
126 | return impl->m_DataSourceController; |
|
127 | return impl->m_DataSourceController; | |
127 | } |
|
128 | } | |
128 |
|
129 | |||
129 | NetworkController& SqpApplication::networkController() noexcept |
|
130 | NetworkController& SqpApplication::networkController() noexcept | |
130 | { |
|
131 | { | |
131 | return impl->m_NetworkController; |
|
132 | return impl->m_NetworkController; | |
132 | } |
|
133 | } | |
133 |
|
134 | |||
134 | TimeController& SqpApplication::timeController() noexcept |
|
135 | TimeController& SqpApplication::timeController() noexcept | |
135 | { |
|
136 | { | |
136 | return impl->m_TimeController; |
|
137 | return impl->m_TimeController; | |
137 | } |
|
138 | } | |
138 |
|
139 | |||
139 | VariableController2& SqpApplication::variableController() noexcept |
|
140 | VariableController2& SqpApplication::variableController() noexcept | |
140 | { |
|
141 | { | |
141 | return *impl->m_VariableController; |
|
142 | return *impl->m_VariableController; | |
142 | } |
|
143 | } | |
143 |
|
144 | |||
144 | std::shared_ptr<VariableController2> SqpApplication::variableControllerOwner() noexcept |
|
145 | std::shared_ptr<VariableController2> SqpApplication::variableControllerOwner() noexcept | |
145 | { |
|
146 | { | |
146 | return impl->m_VariableController; |
|
147 | return impl->m_VariableController; | |
147 | } |
|
148 | } | |
148 |
|
149 | |||
149 | // VariableModel2 &SqpApplication::variableModel() noexcept |
|
150 | // VariableModel2 &SqpApplication::variableModel() noexcept | |
150 | //{ |
|
151 | //{ | |
151 | // return impl->m_VariableModel; |
|
152 | // return impl->m_VariableModel; | |
152 | //} |
|
153 | //} | |
153 |
|
154 | |||
154 | VisualizationController& SqpApplication::visualizationController() noexcept |
|
155 | VisualizationController& SqpApplication::visualizationController() noexcept | |
155 | { |
|
156 | { | |
156 | return impl->m_VisualizationController; |
|
157 | return impl->m_VisualizationController; | |
157 | } |
|
158 | } | |
158 |
|
159 | |||
159 | CatalogueController& SqpApplication::catalogueController() noexcept |
|
160 | CatalogueController& SqpApplication::catalogueController() noexcept | |
160 | { |
|
161 | { | |
161 | return impl->m_CatalogueController; |
|
162 | return impl->m_CatalogueController; | |
162 | } |
|
163 | } | |
163 |
|
164 | |||
164 | DragDropGuiController& SqpApplication::dragDropGuiController() noexcept |
|
165 | DragDropGuiController& SqpApplication::dragDropGuiController() noexcept | |
165 | { |
|
166 | { | |
166 | return impl->m_DragDropGuiController; |
|
167 | return impl->m_DragDropGuiController; | |
167 | } |
|
168 | } | |
168 |
|
169 | |||
169 | ActionsGuiController& SqpApplication::actionsGuiController() noexcept |
|
170 | ActionsGuiController& SqpApplication::actionsGuiController() noexcept | |
170 | { |
|
171 | { | |
171 | return impl->m_ActionsGuiController; |
|
172 | return impl->m_ActionsGuiController; | |
172 | } |
|
173 | } | |
173 |
|
174 | |||
174 | SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const |
|
175 | SqpApplication::PlotsInteractionMode SqpApplication::plotsInteractionMode() const | |
175 | { |
|
176 | { | |
176 | return impl->m_PlotInterractionMode; |
|
177 | return impl->m_PlotInterractionMode; | |
177 | } |
|
178 | } | |
178 |
|
179 | |||
179 | void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode) |
|
180 | void SqpApplication::setPlotsInteractionMode(SqpApplication::PlotsInteractionMode mode) | |
180 | { |
|
181 | { | |
181 | impl->m_PlotInterractionMode = mode; |
|
182 | impl->m_PlotInterractionMode = mode; | |
182 | } |
|
183 | } | |
183 |
|
184 | |||
184 | SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const |
|
185 | SqpApplication::PlotsCursorMode SqpApplication::plotsCursorMode() const | |
185 | { |
|
186 | { | |
186 | return impl->m_PlotCursorMode; |
|
187 | return impl->m_PlotCursorMode; | |
187 | } |
|
188 | } | |
188 |
|
189 | |||
189 | void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode) |
|
190 | void SqpApplication::setPlotsCursorMode(SqpApplication::PlotsCursorMode mode) | |
190 | { |
|
191 | { | |
191 | impl->m_PlotCursorMode = mode; |
|
192 | impl->m_PlotCursorMode = mode; | |
192 | } |
|
193 | } |
@@ -1,156 +1,158 | |||||
1 | #include "TimeWidget/TimeWidget.h" |
|
1 | #include "TimeWidget/TimeWidget.h" | |
2 | #include "ui_TimeWidget.h" |
|
2 | #include "ui_TimeWidget.h" | |
3 |
|
3 | |||
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/DragDropGuiController.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 | |||
11 | #include <QDrag> |
|
11 | #include <QDrag> | |
12 | #include <QDragEnterEvent> |
|
12 | #include <QDragEnterEvent> | |
13 | #include <QDropEvent> |
|
13 | #include <QDropEvent> | |
14 | #include <QMimeData> |
|
14 | #include <QMimeData> | |
15 | #include <QStyle> |
|
15 | #include <QStyle> | |
16 |
|
16 | |||
17 |
|
17 | |||
18 |
struct TimeWidget::TimeWidgetPrivate |
|
18 | struct TimeWidget::TimeWidgetPrivate | |
|
19 | { | |||
19 |
|
20 | |||
20 | explicit TimeWidgetPrivate() {} |
|
21 | explicit TimeWidgetPrivate() {} | |
21 |
|
22 | |||
22 | QPoint m_DragStartPosition; |
|
23 | QPoint m_DragStartPosition; | |
23 | }; |
|
24 | }; | |
24 |
|
25 | |||
25 |
TimeWidget::TimeWidget(QWidget |
|
26 | TimeWidget::TimeWidget(QWidget* parent) | |
26 |
: QWidget{parent} |
|
27 | : QWidget { parent } | |
27 |
|
|
28 | , ui { new Ui::TimeWidget } | |
28 |
|
|
29 | , impl { spimpl::make_unique_impl<TimeWidgetPrivate>() } | |
29 | { |
|
30 | { | |
30 | ui->setupUi(this); |
|
31 | ui->setupUi(this); | |
31 |
|
32 | |||
32 | ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton)); |
|
|||
33 |
|
||||
34 | // Connection |
|
33 | // Connection | |
35 | connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
34 | connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, | |
36 |
|
|
35 | &TimeWidget::onTimeUpdateRequested); | |
37 |
|
36 | |||
38 | connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, |
|
37 | connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, | |
39 |
|
|
38 | &TimeWidget::onTimeUpdateRequested); | |
40 |
|
39 | |||
41 |
|
||||
42 | connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(), |
|
|||
43 | &TimeController::onTimeNotify); |
|
|||
44 |
|
||||
45 | // Initialisation |
|
40 | // Initialisation | |
46 | auto endDateTime = QDateTime::currentDateTimeUtc(); |
|
41 | auto endDateTime = QDateTime::currentDateTimeUtc(); | |
47 | auto startDateTime = endDateTime.addSecs(-3600); // one hour before |
|
42 | auto startDateTime = endDateTime.addSecs(-3600); // one hour before | |
48 |
|
43 | |||
49 | ui->startDateTimeEdit->setDateTime(startDateTime); |
|
44 | ui->startDateTimeEdit->setDateTime(startDateTime); | |
50 | ui->endDateTimeEdit->setDateTime(endDateTime); |
|
45 | ui->endDateTimeEdit->setDateTime(endDateTime); | |
51 |
|
46 | |||
52 | auto dateTime = DateTimeRange{DateUtils::secondsSinceEpoch(startDateTime), |
|
47 | auto dateTime = DateTimeRange { DateUtils::secondsSinceEpoch(startDateTime), | |
53 |
|
|
48 | DateUtils::secondsSinceEpoch(endDateTime) }; | |
54 |
|
49 | |||
55 | sqpApp->timeController().setDateTimeRange(dateTime); |
|
50 | sqpApp->timeController().setDateTimeRange(dateTime); | |
56 | } |
|
51 | } | |
57 |
|
52 | |||
58 |
|
53 | |||
59 | TimeWidget::~TimeWidget() |
|
54 | TimeWidget::~TimeWidget() | |
60 | { |
|
55 | { | |
61 | delete ui; |
|
56 | delete ui; | |
62 | } |
|
57 | } | |
63 |
|
58 | |||
64 | void TimeWidget::setTimeRange(DateTimeRange time) |
|
59 | void TimeWidget::setTimeRange(DateTimeRange time) | |
65 | { |
|
60 | { | |
66 | auto startDateTime = DateUtils::dateTime(time.m_TStart); |
|
61 | auto startDateTime = DateUtils::dateTime(time.m_TStart); | |
67 | auto endDateTime = DateUtils::dateTime(time.m_TEnd); |
|
62 | auto endDateTime = DateUtils::dateTime(time.m_TEnd); | |
68 |
|
63 | |||
69 | ui->startDateTimeEdit->setDateTime(startDateTime); |
|
64 | ui->startDateTimeEdit->setDateTime(startDateTime); | |
70 | ui->endDateTimeEdit->setDateTime(endDateTime); |
|
65 | ui->endDateTimeEdit->setDateTime(endDateTime); | |
71 | } |
|
66 | } | |
72 |
|
67 | |||
73 | DateTimeRange TimeWidget::timeRange() const |
|
68 | DateTimeRange TimeWidget::timeRange() const | |
74 | { |
|
69 | { | |
75 | return DateTimeRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), |
|
70 | return DateTimeRange { DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), | |
76 |
|
|
71 | DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime()) }; | |
77 | } |
|
72 | } | |
78 |
|
73 | |||
79 | void TimeWidget::onTimeUpdateRequested() |
|
74 | void TimeWidget::onTimeUpdateRequested() | |
80 | { |
|
75 | { | |
81 | auto dateTime = timeRange(); |
|
76 | auto dateTime = timeRange(); | |
82 | emit timeUpdated(std::move(dateTime)); |
|
77 | emit timeUpdated(std::move(dateTime)); | |
83 | sqpApp->timeController().setDateTimeRange(dateTime); |
|
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 | event->acceptProposedAction(); |
|
85 | event->acceptProposedAction(); | |
90 | setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}"); |
|
86 | setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}"); | |
91 | } |
|
87 | } | |
92 |
else |
|
88 | else | |
|
89 | { | |||
93 | event->ignore(); |
|
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 | auto mimeData = event->mimeData()->data(MIME_TYPE_TIME_RANGE); |
|
103 | auto mimeData = event->mimeData()->data(MIME_TYPE_TIME_RANGE); | |
106 | auto timeRange = TimeController::timeRangeForMimeData(mimeData); |
|
104 | auto timeRange = TimeController::timeRangeForMimeData(mimeData); | |
107 |
|
105 | |||
108 | setTimeRange(timeRange); |
|
106 | setTimeRange(timeRange); | |
109 | } |
|
107 | } | |
110 |
else |
|
108 | else | |
|
109 | { | |||
111 | event->ignore(); |
|
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 | impl->m_DragStartPosition = event->pos(); |
|
121 | impl->m_DragStartPosition = event->pos(); | |
122 | } |
|
122 | } | |
123 |
|
123 | |||
124 | QWidget::mousePressEvent(event); |
|
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 | return; |
|
131 | return; | |
131 | } |
|
132 | } | |
132 |
|
133 | |||
133 | if ((event->pos() - impl->m_DragStartPosition).manhattanLength() |
|
134 | if ((event->pos() - impl->m_DragStartPosition).manhattanLength() | |
134 |
< QApplication::startDragDistance()) |
|
135 | < QApplication::startDragDistance()) | |
|
136 | { | |||
135 | return; |
|
137 | return; | |
136 | } |
|
138 | } | |
137 |
|
139 | |||
138 | // Note: The management of the drag object is done by Qt |
|
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 | auto mimeData = new QMimeData; |
|
143 | auto mimeData = new QMimeData; | |
142 | auto timeData = TimeController::mimeDataForTimeRange(timeRange()); |
|
144 | auto timeData = TimeController::mimeDataForTimeRange(timeRange()); | |
143 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeData); |
|
145 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeData); | |
144 |
|
146 | |||
145 | drag->setMimeData(mimeData); |
|
147 | drag->setMimeData(mimeData); | |
146 |
|
148 | |||
147 | auto pixmap = QPixmap{":/icones/time.png"}; |
|
149 | auto pixmap = QPixmap { ":/icones/time.png" }; | |
148 | drag->setPixmap(pixmap.scaledToWidth(22)); |
|
150 | drag->setPixmap(pixmap.scaledToWidth(22)); | |
149 |
|
151 | |||
150 | sqpApp->dragDropGuiController().resetDragAndDrop(); |
|
152 | sqpApp->dragDropGuiController().resetDragAndDrop(); | |
151 |
|
153 | |||
152 | // Note: The exec() is blocking on windows but not on linux and macOS |
|
154 | // Note: The exec() is blocking on windows but not on linux and macOS | |
153 | drag->exec(Qt::MoveAction | Qt::CopyAction); |
|
155 | drag->exec(Qt::MoveAction | Qt::CopyAction); | |
154 |
|
156 | |||
155 | QWidget::mouseMoveEvent(event); |
|
157 | QWidget::mouseMoveEvent(event); | |
156 | } |
|
158 | } |
@@ -1,104 +1,97 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>TimeWidget</class> |
|
3 | <class>TimeWidget</class> | |
4 | <widget class="QWidget" name="TimeWidget"> |
|
4 | <widget class="QWidget" name="TimeWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>716</width> |
|
9 | <width>716</width> | |
10 | <height>48</height> |
|
10 | <height>48</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="sizePolicy"> |
|
13 | <property name="sizePolicy"> | |
14 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> |
|
14 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> | |
15 | <horstretch>0</horstretch> |
|
15 | <horstretch>0</horstretch> | |
16 | <verstretch>0</verstretch> |
|
16 | <verstretch>0</verstretch> | |
17 | </sizepolicy> |
|
17 | </sizepolicy> | |
18 | </property> |
|
18 | </property> | |
19 | <property name="acceptDrops"> |
|
19 | <property name="acceptDrops"> | |
20 | <bool>true</bool> |
|
20 | <bool>true</bool> | |
21 | </property> |
|
21 | </property> | |
22 | <property name="windowTitle"> |
|
22 | <property name="windowTitle"> | |
23 | <string>Form</string> |
|
23 | <string>Form</string> | |
24 | </property> |
|
24 | </property> | |
25 | <property name="styleSheet"> |
|
25 | <property name="styleSheet"> | |
26 | <string notr="true">b</string> |
|
26 | <string notr="true">b</string> | |
27 | </property> |
|
27 | </property> | |
28 | <layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
28 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | |
29 | <item> |
|
29 | <item> | |
30 | <widget class="QLabel" name="label"> |
|
30 | <widget class="QLabel" name="label"> | |
31 | <property name="sizePolicy"> |
|
31 | <property name="sizePolicy"> | |
32 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> |
|
32 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> | |
33 | <horstretch>0</horstretch> |
|
33 | <horstretch>0</horstretch> | |
34 | <verstretch>0</verstretch> |
|
34 | <verstretch>0</verstretch> | |
35 | </sizepolicy> |
|
35 | </sizepolicy> | |
36 | </property> |
|
36 | </property> | |
37 | <property name="text"> |
|
37 | <property name="text"> | |
38 | <string>TStart :</string> |
|
38 | <string>TStart :</string> | |
39 | </property> |
|
39 | </property> | |
40 | </widget> |
|
40 | </widget> | |
41 | </item> |
|
41 | </item> | |
42 | <item> |
|
42 | <item> | |
43 | <widget class="QDateTimeEdit" name="startDateTimeEdit"> |
|
43 | <widget class="QDateTimeEdit" name="startDateTimeEdit"> | |
44 | <property name="sizePolicy"> |
|
44 | <property name="sizePolicy"> | |
45 | <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
|
45 | <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | |
46 | <horstretch>0</horstretch> |
|
46 | <horstretch>0</horstretch> | |
47 | <verstretch>0</verstretch> |
|
47 | <verstretch>0</verstretch> | |
48 | </sizepolicy> |
|
48 | </sizepolicy> | |
49 | </property> |
|
49 | </property> | |
50 | <property name="displayFormat"> |
|
50 | <property name="displayFormat"> | |
51 | <string>dd/MM/yyyy HH:mm:ss:zzz</string> |
|
51 | <string>dd/MM/yyyy HH:mm:ss:zzz</string> | |
52 | </property> |
|
52 | </property> | |
53 | <property name="calendarPopup"> |
|
53 | <property name="calendarPopup"> | |
54 | <bool>true</bool> |
|
54 | <bool>true</bool> | |
55 | </property> |
|
55 | </property> | |
56 | <property name="timeSpec"> |
|
56 | <property name="timeSpec"> | |
57 | <enum>Qt::UTC</enum> |
|
57 | <enum>Qt::UTC</enum> | |
58 | </property> |
|
58 | </property> | |
59 | </widget> |
|
59 | </widget> | |
60 | </item> |
|
60 | </item> | |
61 | <item> |
|
61 | <item> | |
62 | <widget class="QLabel" name="label_2"> |
|
62 | <widget class="QLabel" name="label_2"> | |
63 | <property name="sizePolicy"> |
|
63 | <property name="sizePolicy"> | |
64 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> |
|
64 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> | |
65 | <horstretch>0</horstretch> |
|
65 | <horstretch>0</horstretch> | |
66 | <verstretch>0</verstretch> |
|
66 | <verstretch>0</verstretch> | |
67 | </sizepolicy> |
|
67 | </sizepolicy> | |
68 | </property> |
|
68 | </property> | |
69 | <property name="text"> |
|
69 | <property name="text"> | |
70 | <string>TEnd :</string> |
|
70 | <string>TEnd :</string> | |
71 | </property> |
|
71 | </property> | |
72 | </widget> |
|
72 | </widget> | |
73 | </item> |
|
73 | </item> | |
74 | <item> |
|
74 | <item> | |
75 | <widget class="QDateTimeEdit" name="endDateTimeEdit"> |
|
75 | <widget class="QDateTimeEdit" name="endDateTimeEdit"> | |
76 | <property name="sizePolicy"> |
|
76 | <property name="sizePolicy"> | |
77 | <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> |
|
77 | <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | |
78 | <horstretch>0</horstretch> |
|
78 | <horstretch>0</horstretch> | |
79 | <verstretch>0</verstretch> |
|
79 | <verstretch>0</verstretch> | |
80 | </sizepolicy> |
|
80 | </sizepolicy> | |
81 | </property> |
|
81 | </property> | |
82 | <property name="displayFormat"> |
|
82 | <property name="displayFormat"> | |
83 | <string>dd/MM/yyyy HH:mm:ss:zzz</string> |
|
83 | <string>dd/MM/yyyy HH:mm:ss:zzz</string> | |
84 | </property> |
|
84 | </property> | |
85 | <property name="calendarPopup"> |
|
85 | <property name="calendarPopup"> | |
86 | <bool>true</bool> |
|
86 | <bool>true</bool> | |
87 | </property> |
|
87 | </property> | |
88 | <property name="timeSpec"> |
|
88 | <property name="timeSpec"> | |
89 | <enum>Qt::UTC</enum> |
|
89 | <enum>Qt::UTC</enum> | |
90 | </property> |
|
90 | </property> | |
91 | </widget> |
|
91 | </widget> | |
92 | </item> |
|
92 | </item> | |
93 | <item> |
|
|||
94 | <widget class="QToolButton" name="applyToolButton"> |
|
|||
95 | <property name="text"> |
|
|||
96 | <string>...</string> |
|
|||
97 | </property> |
|
|||
98 | </widget> |
|
|||
99 | </item> |
|
|||
100 | </layout> |
|
93 | </layout> | |
101 | </widget> |
|
94 | </widget> | |
102 | <resources/> |
|
95 | <resources/> | |
103 | <connections/> |
|
96 | <connections/> | |
104 | </ui> |
|
97 | </ui> |
General Comments 0
You need to be logged in to leave comments.
Login now