@@ -0,0 +1,32 | |||
|
1 | #ifndef SCIQLOP_DATASOURCETREEWIDGETITEM_H | |
|
2 | #define SCIQLOP_DATASOURCETREEWIDGETITEM_H | |
|
3 | ||
|
4 | #include <Common/spimpl.h> | |
|
5 | ||
|
6 | #include <QLoggingCategory> | |
|
7 | #include <QTreeWidgetItem> | |
|
8 | ||
|
9 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem) | |
|
10 | ||
|
11 | class DataSourceItem; | |
|
12 | ||
|
13 | /** | |
|
14 | * @brief The DataSourceTreeWidgetItem is the graphical representation of a data source item. It is | |
|
15 | * intended to be displayed in a QTreeWidget. | |
|
16 | * @sa DataSourceItem | |
|
17 | */ | |
|
18 | class DataSourceTreeWidgetItem : public QTreeWidgetItem { | |
|
19 | public: | |
|
20 | explicit DataSourceTreeWidgetItem(const DataSourceItem *data, int type = Type); | |
|
21 | explicit DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data, | |
|
22 | int type = Type); | |
|
23 | ||
|
24 | virtual QVariant data(int column, int role) const override; | |
|
25 | virtual void setData(int column, int role, const QVariant &value) override; | |
|
26 | ||
|
27 | private: | |
|
28 | class DataSourceTreeWidgetItemPrivate; | |
|
29 | spimpl::unique_impl_ptr<DataSourceTreeWidgetItemPrivate> impl; | |
|
30 | }; | |
|
31 | ||
|
32 | #endif // SCIQLOP_DATASOURCETREEWIDGETITEM_H |
@@ -0,0 +1,33 | |||
|
1 | #ifndef SCIQLOP_DATASOURCEWIDGET_H | |
|
2 | #define SCIQLOP_DATASOURCEWIDGET_H | |
|
3 | ||
|
4 | #include <Common/spimpl.h> | |
|
5 | ||
|
6 | #include <QWidget> | |
|
7 | ||
|
8 | class DataSourceItem; | |
|
9 | ||
|
10 | /** | |
|
11 | * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources | |
|
12 | * attached to SciQlop. | |
|
13 | */ | |
|
14 | class DataSourceWidget : public QWidget { | |
|
15 | Q_OBJECT | |
|
16 | ||
|
17 | public: | |
|
18 | explicit DataSourceWidget(QWidget *parent = 0); | |
|
19 | ||
|
20 | public slots: | |
|
21 | /** | |
|
22 | * Adds a data source. An item associated to the data source is created and then added to the | |
|
23 | * representation tree | |
|
24 | * @param dataSource the data source to add | |
|
25 | */ | |
|
26 | void addDataSource(DataSourceItem &dataSource) noexcept; | |
|
27 | ||
|
28 | private: | |
|
29 | class DataSourceWidgetPrivate; | |
|
30 | spimpl::unique_impl_ptr<DataSourceWidgetPrivate> impl; | |
|
31 | }; | |
|
32 | ||
|
33 | #endif // SCIQLOP_DATASOURCEWIDGET_H |
@@ -0,0 +1,68 | |||
|
1 | #include <DataSource/DataSourceItem.h> | |
|
2 | #include <DataSource/DataSourceTreeWidgetItem.h> | |
|
3 | ||
|
4 | #include <SqpApplication.h> | |
|
5 | ||
|
6 | Q_LOGGING_CATEGORY(LOG_DataSourceTreeWidgetItem, "DataSourceTreeWidgetItem") | |
|
7 | ||
|
8 | namespace { | |
|
9 | ||
|
10 | QIcon itemIcon(const DataSourceItem *dataSource) | |
|
11 | { | |
|
12 | if (dataSource) { | |
|
13 | auto dataSourceType = dataSource->type(); | |
|
14 | switch (dataSourceType) { | |
|
15 | case DataSourceItemType::NODE: | |
|
16 | return sqpApp->style()->standardIcon(QStyle::SP_DirIcon); | |
|
17 | case DataSourceItemType::PRODUCT: | |
|
18 | return sqpApp->style()->standardIcon(QStyle::SP_FileIcon); | |
|
19 | default: | |
|
20 | // No action | |
|
21 | break; | |
|
22 | } | |
|
23 | } | |
|
24 | ||
|
25 | // Default cases | |
|
26 | return QIcon{}; | |
|
27 | } | |
|
28 | ||
|
29 | } // namespace | |
|
30 | ||
|
31 | struct DataSourceTreeWidgetItem::DataSourceTreeWidgetItemPrivate { | |
|
32 | explicit DataSourceTreeWidgetItemPrivate(const DataSourceItem *data) : m_Data{data} {} | |
|
33 | ||
|
34 | /// Model used to retrieve data source information | |
|
35 | const DataSourceItem *m_Data; | |
|
36 | }; | |
|
37 | ||
|
38 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(const DataSourceItem *data, int type) | |
|
39 | : DataSourceTreeWidgetItem{nullptr, data, type} | |
|
40 | { | |
|
41 | } | |
|
42 | ||
|
43 | DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const DataSourceItem *data, | |
|
44 | int type) | |
|
45 | : QTreeWidgetItem{parent, type}, | |
|
46 | impl{spimpl::make_unique_impl<DataSourceTreeWidgetItemPrivate>(data)} | |
|
47 | { | |
|
48 | // Sets the icon depending on the data source | |
|
49 | setIcon(0, itemIcon(impl->m_Data)); | |
|
50 | } | |
|
51 | ||
|
52 | QVariant DataSourceTreeWidgetItem::data(int column, int role) const | |
|
53 | { | |
|
54 | if (role == Qt::DisplayRole) { | |
|
55 | return (impl->m_Data) ? impl->m_Data->data(column) : QVariant{}; | |
|
56 | } | |
|
57 | else { | |
|
58 | return QTreeWidgetItem::data(column, role); | |
|
59 | } | |
|
60 | } | |
|
61 | ||
|
62 | void DataSourceTreeWidgetItem::setData(int column, int role, const QVariant &value) | |
|
63 | { | |
|
64 | // Data can't be changed by edition | |
|
65 | if (role != Qt::EditRole) { | |
|
66 | QTreeWidgetItem::setData(column, role, value); | |
|
67 | } | |
|
68 | } |
@@ -0,0 +1,61 | |||
|
1 | #include <DataSource/DataSourceWidget.h> | |
|
2 | ||
|
3 | #include <ui_DataSourceWidget.h> | |
|
4 | ||
|
5 | #include <DataSource/DataSourceItem.h> | |
|
6 | #include <DataSource/DataSourceTreeWidgetItem.h> | |
|
7 | ||
|
8 | namespace { | |
|
9 | ||
|
10 | /// Number of columns displayed in the tree | |
|
11 | const auto TREE_NB_COLUMNS = 1; | |
|
12 | ||
|
13 | /// Header labels for the tree | |
|
14 | const auto TREE_HEADER_LABELS = QStringList{QObject::tr("Name")}; | |
|
15 | ||
|
16 | /** | |
|
17 | * Creates the item associated to a data source | |
|
18 | * @param dataSource the data source for which to create the item | |
|
19 | * @return the new item | |
|
20 | */ | |
|
21 | DataSourceTreeWidgetItem *createTreeWidgetItem(DataSourceItem *dataSource) | |
|
22 | { | |
|
23 | // Creates item for the data source | |
|
24 | auto item = new DataSourceTreeWidgetItem{dataSource}; | |
|
25 | ||
|
26 | // Generates items for the children of the data source | |
|
27 | for (auto i = 0; i < dataSource->childCount(); ++i) { | |
|
28 | item->addChild(createTreeWidgetItem(dataSource->child(i))); | |
|
29 | } | |
|
30 | ||
|
31 | return item; | |
|
32 | } | |
|
33 | ||
|
34 | } // namespace | |
|
35 | ||
|
36 | class DataSourceWidget::DataSourceWidgetPrivate { | |
|
37 | public: | |
|
38 | explicit DataSourceWidgetPrivate(DataSourceWidget &widget) | |
|
39 | : m_Ui{std::make_unique<Ui::DataSourceWidget>()} | |
|
40 | { | |
|
41 | m_Ui->setupUi(&widget); | |
|
42 | ||
|
43 | // Set tree properties | |
|
44 | m_Ui->treeWidget->setColumnCount(TREE_NB_COLUMNS); | |
|
45 | m_Ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS); | |
|
46 | } | |
|
47 | ||
|
48 | std::unique_ptr<Ui::DataSourceWidget> m_Ui; | |
|
49 | }; | |
|
50 | ||
|
51 | DataSourceWidget::DataSourceWidget(QWidget *parent) | |
|
52 | : QWidget{parent}, impl{spimpl::make_unique_impl<DataSourceWidgetPrivate>(*this)} | |
|
53 | { | |
|
54 | } | |
|
55 | ||
|
56 | void DataSourceWidget::addDataSource(DataSourceItem &dataSource) noexcept | |
|
57 | { | |
|
58 | // Creates the item associated to the source and adds it to the tree widget. The tree widget | |
|
59 | // takes the ownership of the item | |
|
60 | impl->m_Ui->treeWidget->addTopLevelItem(createTreeWidgetItem(&dataSource)); | |
|
61 | } |
@@ -0,0 +1,24 | |||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
|
2 | <ui version="4.0"> | |
|
3 | <class>DataSourceWidget</class> | |
|
4 | <widget class="QWidget" name="DataSourceWidget"> | |
|
5 | <property name="geometry"> | |
|
6 | <rect> | |
|
7 | <x>0</x> | |
|
8 | <y>0</y> | |
|
9 | <width>400</width> | |
|
10 | <height>300</height> | |
|
11 | </rect> | |
|
12 | </property> | |
|
13 | <property name="windowTitle"> | |
|
14 | <string>Data sources</string> | |
|
15 | </property> | |
|
16 | <layout class="QGridLayout" name="gridLayout"> | |
|
17 | <item row="0" column="0"> | |
|
18 | <widget class="QTreeWidget" name="treeWidget"/> | |
|
19 | </item> | |
|
20 | </layout> | |
|
21 | </widget> | |
|
22 | <resources/> | |
|
23 | <connections/> | |
|
24 | </ui> |
@@ -1,38 +1,59 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the QLop Software |
|
3 | 3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "MainWindow.h" |
|
23 | 23 | #include <QProcessEnvironment> |
|
24 | 24 | #include <QThread> |
|
25 | 25 | #include <SqpApplication.h> |
|
26 | 26 | #include <qglobal.h> |
|
27 | 27 | |
|
28 | #include <Plugin/PluginManager.h> | |
|
29 | #include <QDir> | |
|
30 | ||
|
31 | namespace { | |
|
32 | ||
|
33 | /// Name of the directory containing the plugins | |
|
34 | const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins"); | |
|
35 | ||
|
36 | } // namespace | |
|
37 | ||
|
28 | 38 | int main(int argc, char *argv[]) |
|
29 | 39 | { |
|
30 | 40 | SqpApplication a{argc, argv}; |
|
31 | 41 | SqpApplication::setOrganizationName("LPP"); |
|
32 | 42 | SqpApplication::setOrganizationDomain("lpp.fr"); |
|
33 | 43 | SqpApplication::setApplicationName("SciQLop"); |
|
34 | 44 | MainWindow w; |
|
35 | 45 | w.show(); |
|
36 | 46 | |
|
47 | // Loads plugins | |
|
48 | auto pluginDir = QDir{sqpApp->applicationDirPath()}; | |
|
49 | pluginDir.mkdir(PLUGIN_DIRECTORY_NAME); | |
|
50 | pluginDir.cd(PLUGIN_DIRECTORY_NAME); | |
|
51 | ||
|
52 | qCDebug(LOG_PluginManager()) | |
|
53 | << QObject::tr("Plugin directory: %1").arg(pluginDir.absolutePath()); | |
|
54 | ||
|
55 | PluginManager pluginManager{}; | |
|
56 | pluginManager.loadPlugins(pluginDir); | |
|
57 | ||
|
37 | 58 | return a.exec(); |
|
38 | 59 | } |
@@ -1,118 +1,128 | |||
|
1 | 1 | /*------------------------------------------------------------------------------ |
|
2 | 2 | -- This file is a part of the SciQLop Software |
|
3 | 3 | -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS |
|
4 | 4 | -- |
|
5 | 5 | -- This program is free software; you can redistribute it and/or modify |
|
6 | 6 | -- it under the terms of the GNU General Public License as published by |
|
7 | 7 | -- the Free Software Foundation; either version 2 of the License, or |
|
8 | 8 | -- (at your option) any later version. |
|
9 | 9 | -- |
|
10 | 10 | -- This program is distributed in the hope that it will be useful, |
|
11 | 11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | -- GNU General Public License for more details. |
|
14 | 14 | -- |
|
15 | 15 | -- You should have received a copy of the GNU General Public License |
|
16 | 16 | -- along with this program; if not, write to the Free Software |
|
17 | 17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 | 18 | -------------------------------------------------------------------------------*/ |
|
19 | 19 | /*-- Author : Alexis Jeandet |
|
20 | 20 | -- Mail : alexis.jeandet@member.fsf.org |
|
21 | 21 | ----------------------------------------------------------------------------*/ |
|
22 | 22 | #include "MainWindow.h" |
|
23 | 23 | #include "ui_MainWindow.h" |
|
24 | ||
|
25 | #include <DataSource/DataSourceController.h> | |
|
26 | #include <DataSource/DataSourceWidget.h> | |
|
27 | #include <SqpApplication.h> | |
|
28 | ||
|
24 | 29 | #include <QAction> |
|
25 | 30 | #include <QDate> |
|
26 | 31 | #include <QDateTime> |
|
27 | 32 | #include <QDir> |
|
28 | 33 | #include <QFileDialog> |
|
29 | 34 | //#include <omp.h> |
|
30 | 35 | //#include <network/filedownloader.h> |
|
31 | 36 | //#include <qlopdatabase.h> |
|
32 | 37 | //#include <qlopsettings.h> |
|
33 | 38 | //#include <qlopgui.h> |
|
34 | 39 | //#include <spacedata.h> |
|
35 | 40 | //#include "qlopcore.h" |
|
36 | 41 | //#include "qlopcodecmanager.h" |
|
37 | 42 | //#include "cdfcodec.h" |
|
38 | 43 | //#include "amdatxtcodec.h" |
|
39 | 44 | //#include <qlopplotmanager.h> |
|
40 | 45 | #include <QAction> |
|
41 | 46 | #include <QToolBar> |
|
42 | 47 | #include <memory.h> |
|
43 | 48 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_Ui(new Ui::MainWindow) |
|
44 | 49 | { |
|
45 | 50 | m_Ui->setupUi(this); |
|
46 | 51 | |
|
47 | 52 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); |
|
48 | 53 | leftSidePane->addAction("ACTION L1"); |
|
49 | 54 | leftSidePane->addAction("ACTION L2"); |
|
50 | 55 | leftSidePane->addAction("ACTION L3"); |
|
51 | 56 | |
|
52 | 57 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); |
|
53 | 58 | rightSidePane->addAction("ACTION R1"); |
|
54 | 59 | rightSidePane->addAction("ACTION R2"); |
|
55 | 60 | rightSidePane->addAction("ACTION R3"); |
|
56 | 61 | |
|
57 | 62 | this->menuBar()->addAction("File"); |
|
58 | 63 | auto mainToolBar = this->addToolBar("MainToolBar"); |
|
59 | 64 | mainToolBar->addAction("A1"); |
|
65 | ||
|
66 | // Widgets / controllers connections | |
|
67 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem &)), | |
|
68 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem &))); | |
|
69 | ||
|
60 | 70 | /* QLopGUI::registerMenuBar(menuBar()); |
|
61 | 71 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
|
62 | 72 | this->m_progressWidget = new QWidget(); |
|
63 | 73 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); |
|
64 | 74 | this->m_progressWidget->setLayout(this->m_progressLayout); |
|
65 | 75 | this->m_progressWidget->setWindowModality(Qt::WindowModal); |
|
66 | 76 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); |
|
67 | 77 | for(int i=0;i<OMP_THREADS;i++) |
|
68 | 78 | { |
|
69 | 79 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); |
|
70 | 80 | this->m_progress.last()->setMinimum(0); |
|
71 | 81 | this->m_progress.last()->setMaximum(100); |
|
72 | 82 | this->m_progressLayout->addWidget(this->m_progress.last()); |
|
73 | 83 | this->m_progressWidget->hide(); |
|
74 | 84 | this->m_progressThreadIds[i] = -1; |
|
75 | 85 | } |
|
76 | 86 | this->m_progressWidget->setWindowTitle("Loading File"); |
|
77 | 87 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() |
|
78 | 88 | << QLopCore::self() |
|
79 | 89 | << QLopPlotManager::self() |
|
80 | 90 | << QLopCodecManager::self() |
|
81 | 91 | << FileDownloader::self() |
|
82 | 92 | << QLopDataBase::self() |
|
83 | 93 | << SpaceData::self(); |
|
84 | 94 | |
|
85 | 95 | CDFCodec::registerToManager(); |
|
86 | 96 | AMDATXTCodec::registerToManager(); |
|
87 | 97 | |
|
88 | 98 | |
|
89 | 99 | for(int i=0;i<ServicesToLoad.count();i++) |
|
90 | 100 | { |
|
91 | 101 | qDebug()<<ServicesToLoad.at(i)->serviceName(); |
|
92 | 102 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI |
|
93 | 103 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); |
|
94 | 104 | if(wdgt) |
|
95 | 105 | { |
|
96 | 106 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
97 | 107 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); |
|
98 | 108 | } |
|
99 | 109 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); |
|
100 | 110 | }*/ |
|
101 | 111 | } |
|
102 | 112 | |
|
103 | 113 | MainWindow::~MainWindow() |
|
104 | 114 | { |
|
105 | 115 | } |
|
106 | 116 | |
|
107 | 117 | |
|
108 | 118 | void MainWindow::changeEvent(QEvent *e) |
|
109 | 119 | { |
|
110 | 120 | QMainWindow::changeEvent(e); |
|
111 | 121 | switch (e->type()) { |
|
112 | 122 | case QEvent::LanguageChange: |
|
113 | 123 | m_Ui->retranslateUi(this); |
|
114 | 124 | break; |
|
115 | 125 | default: |
|
116 | 126 | break; |
|
117 | 127 | } |
|
118 | 128 | } |
@@ -1,208 +1,214 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <ui version="4.0"> |
|
3 | 3 | <class>MainWindow</class> |
|
4 | 4 | <widget class="QMainWindow" name="MainWindow"> |
|
5 | 5 | <property name="geometry"> |
|
6 | 6 | <rect> |
|
7 | 7 | <x>0</x> |
|
8 | 8 | <y>0</y> |
|
9 | 9 | <width>800</width> |
|
10 | 10 | <height>600</height> |
|
11 | 11 | </rect> |
|
12 | 12 | </property> |
|
13 | 13 | <property name="windowTitle"> |
|
14 | 14 | <string>QLop</string> |
|
15 | 15 | </property> |
|
16 | 16 | <property name="dockNestingEnabled"> |
|
17 | 17 | <bool>true</bool> |
|
18 | 18 | </property> |
|
19 | 19 | <widget class="QWidget" name="centralWidget"> |
|
20 | 20 | <property name="enabled"> |
|
21 | 21 | <bool>true</bool> |
|
22 | 22 | </property> |
|
23 | 23 | <property name="sizePolicy"> |
|
24 | 24 | <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> |
|
25 | 25 | <horstretch>0</horstretch> |
|
26 | 26 | <verstretch>0</verstretch> |
|
27 | 27 | </sizepolicy> |
|
28 | 28 | </property> |
|
29 | 29 | <property name="maximumSize"> |
|
30 | 30 | <size> |
|
31 | 31 | <width>16777215</width> |
|
32 | 32 | <height>16777215</height> |
|
33 | 33 | </size> |
|
34 | 34 | </property> |
|
35 | 35 | <layout class="QHBoxLayout" name="horizontalLayout"> |
|
36 | 36 | <property name="spacing"> |
|
37 | 37 | <number>3</number> |
|
38 | 38 | </property> |
|
39 | 39 | <property name="leftMargin"> |
|
40 | 40 | <number>0</number> |
|
41 | 41 | </property> |
|
42 | 42 | <property name="topMargin"> |
|
43 | 43 | <number>0</number> |
|
44 | 44 | </property> |
|
45 | 45 | <property name="rightMargin"> |
|
46 | 46 | <number>0</number> |
|
47 | 47 | </property> |
|
48 | 48 | <property name="bottomMargin"> |
|
49 | 49 | <number>0</number> |
|
50 | 50 | </property> |
|
51 | 51 | <item> |
|
52 | 52 | <widget class="QWidget" name="leftInspectorWidget" native="true"> |
|
53 | 53 | <layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
54 | 54 | <property name="spacing"> |
|
55 | 55 | <number>3</number> |
|
56 | 56 | </property> |
|
57 | 57 | <property name="leftMargin"> |
|
58 | 58 | <number>0</number> |
|
59 | 59 | </property> |
|
60 | 60 | <property name="topMargin"> |
|
61 | 61 | <number>0</number> |
|
62 | 62 | </property> |
|
63 | 63 | <property name="rightMargin"> |
|
64 | 64 | <number>0</number> |
|
65 | 65 | </property> |
|
66 | 66 | <property name="bottomMargin"> |
|
67 | 67 | <number>0</number> |
|
68 | 68 | </property> |
|
69 | 69 | <item> |
|
70 | 70 | <widget class="QWidget" name="widget" native="true"> |
|
71 | 71 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
72 | 72 | <property name="spacing"> |
|
73 | 73 | <number>3</number> |
|
74 | 74 | </property> |
|
75 | 75 | <property name="leftMargin"> |
|
76 | 76 | <number>0</number> |
|
77 | 77 | </property> |
|
78 | 78 | <property name="topMargin"> |
|
79 | 79 | <number>0</number> |
|
80 | 80 | </property> |
|
81 | 81 | <property name="rightMargin"> |
|
82 | 82 | <number>0</number> |
|
83 | 83 | </property> |
|
84 | 84 | <property name="bottomMargin"> |
|
85 | 85 | <number>0</number> |
|
86 | 86 | </property> |
|
87 | 87 | <item> |
|
88 |
<widget class=" |
|
|
88 | <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/> | |
|
89 | 89 | </item> |
|
90 | 90 | <item> |
|
91 | 91 | <widget class="QWidget" name="dateTimeWidget" native="true"/> |
|
92 | 92 | </item> |
|
93 | 93 | <item> |
|
94 | 94 | <widget class="QWidget" name="variableInspectorWidget" native="true"/> |
|
95 | 95 | </item> |
|
96 | 96 | </layout> |
|
97 | 97 | </widget> |
|
98 | 98 | </item> |
|
99 | 99 | <item> |
|
100 | 100 | <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"> |
|
101 | 101 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
|
102 | 102 | <property name="spacing"> |
|
103 | 103 | <number>3</number> |
|
104 | 104 | </property> |
|
105 | 105 | <property name="leftMargin"> |
|
106 | 106 | <number>0</number> |
|
107 | 107 | </property> |
|
108 | 108 | <property name="topMargin"> |
|
109 | 109 | <number>0</number> |
|
110 | 110 | </property> |
|
111 | 111 | <property name="rightMargin"> |
|
112 | 112 | <number>0</number> |
|
113 | 113 | </property> |
|
114 | 114 | <property name="bottomMargin"> |
|
115 | 115 | <number>0</number> |
|
116 | 116 | </property> |
|
117 | 117 | </layout> |
|
118 | 118 | </widget> |
|
119 | 119 | </item> |
|
120 | 120 | </layout> |
|
121 | 121 | </widget> |
|
122 | 122 | </item> |
|
123 | 123 | <item> |
|
124 | 124 | <widget class="VisualizationWidget" name="view" native="true"/> |
|
125 | 125 | </item> |
|
126 | 126 | <item> |
|
127 | 127 | <widget class="QWidget" name="rightInspectorWidget" native="true"> |
|
128 | 128 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
|
129 | 129 | <property name="spacing"> |
|
130 | 130 | <number>3</number> |
|
131 | 131 | </property> |
|
132 | 132 | <property name="leftMargin"> |
|
133 | 133 | <number>0</number> |
|
134 | 134 | </property> |
|
135 | 135 | <property name="topMargin"> |
|
136 | 136 | <number>0</number> |
|
137 | 137 | </property> |
|
138 | 138 | <property name="rightMargin"> |
|
139 | 139 | <number>0</number> |
|
140 | 140 | </property> |
|
141 | 141 | <property name="bottomMargin"> |
|
142 | 142 | <number>0</number> |
|
143 | 143 | </property> |
|
144 | 144 | <item> |
|
145 | 145 | <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/> |
|
146 | 146 | </item> |
|
147 | 147 | <item> |
|
148 | 148 | <widget class="QWidget" name="widget_2" native="true"> |
|
149 | 149 | <layout class="QVBoxLayout" name="verticalLayout_3"> |
|
150 | 150 | <property name="spacing"> |
|
151 | 151 | <number>3</number> |
|
152 | 152 | </property> |
|
153 | 153 | <property name="leftMargin"> |
|
154 | 154 | <number>0</number> |
|
155 | 155 | </property> |
|
156 | 156 | <property name="topMargin"> |
|
157 | 157 | <number>0</number> |
|
158 | 158 | </property> |
|
159 | 159 | <property name="rightMargin"> |
|
160 | 160 | <number>0</number> |
|
161 | 161 | </property> |
|
162 | 162 | <property name="bottomMargin"> |
|
163 | 163 | <number>0</number> |
|
164 | 164 | </property> |
|
165 | 165 | <item> |
|
166 | 166 | <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/> |
|
167 | 167 | </item> |
|
168 | 168 | <item> |
|
169 | 169 | <widget class="QWidget" name="catalogWidget" native="true"/> |
|
170 | 170 | </item> |
|
171 | 171 | </layout> |
|
172 | 172 | </widget> |
|
173 | 173 | </item> |
|
174 | 174 | </layout> |
|
175 | 175 | </widget> |
|
176 | 176 | </item> |
|
177 | 177 | </layout> |
|
178 | 178 | </widget> |
|
179 | 179 | <widget class="QMenuBar" name="menuBar"> |
|
180 | 180 | <property name="geometry"> |
|
181 | 181 | <rect> |
|
182 | 182 | <x>0</x> |
|
183 | 183 | <y>0</y> |
|
184 | 184 | <width>800</width> |
|
185 | 185 | <height>26</height> |
|
186 | 186 | </rect> |
|
187 | 187 | </property> |
|
188 | 188 | </widget> |
|
189 | 189 | <widget class="QStatusBar" name="statusBar"/> |
|
190 | 190 | </widget> |
|
191 | 191 | <layoutdefault spacing="6" margin="11"/> |
|
192 | 192 | <customwidgets> |
|
193 | 193 | <customwidget> |
|
194 | 194 | <class>VisualizationWidget</class> |
|
195 | 195 | <extends>QWidget</extends> |
|
196 | 196 | <header location="global">visualization/VisualizationWidget.h</header> |
|
197 | 197 | <container>1</container> |
|
198 | 198 | </customwidget> |
|
199 | 199 | <customwidget> |
|
200 | 200 | <class>SqpSidePane</class> |
|
201 | 201 | <extends>QWidget</extends> |
|
202 | 202 | <header location="global">sidepane/SqpSidePane.h</header> |
|
203 | 203 | <container>1</container> |
|
204 | 204 | </customwidget> |
|
205 | <customwidget> | |
|
206 | <class>DataSourceWidget</class> | |
|
207 | <extends>QWidget</extends> | |
|
208 | <header location="global">DataSource/DataSourceWidget.h</header> | |
|
209 | <container>1</container> | |
|
210 | </customwidget> | |
|
205 | 211 | </customwidgets> |
|
206 | 212 | <resources/> |
|
207 | 213 | <connections/> |
|
208 | 214 | </ui> |
@@ -1,61 +1,61 | |||
|
1 | 1 | #ifndef SCIQLOP_DATASOURCECONTROLLER_H |
|
2 | 2 | #define SCIQLOP_DATASOURCECONTROLLER_H |
|
3 | 3 | |
|
4 | 4 | #include <QLoggingCategory> |
|
5 | 5 | #include <QObject> |
|
6 | 6 | #include <QUuid> |
|
7 | 7 | |
|
8 | 8 | #include <Common/spimpl.h> |
|
9 | 9 | |
|
10 | 10 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController) |
|
11 | 11 | |
|
12 | 12 | class DataSourceItem; |
|
13 | 13 | |
|
14 | 14 | /** |
|
15 | 15 | * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This |
|
16 | 16 | * is the intermediate class that SciQlop has to use in the way to connect a data source. Please |
|
17 | 17 | * first use register method to initialize a plugin specified by its metadata name (JSON plugin |
|
18 | 18 | * source) then others specifics method will be able to access it. You can load a data source driver |
|
19 | 19 | * plugin then create a data source. |
|
20 | 20 | */ |
|
21 | 21 | class DataSourceController : public QObject { |
|
22 | 22 | Q_OBJECT |
|
23 | 23 | public: |
|
24 | 24 | explicit DataSourceController(QObject *parent = 0); |
|
25 | 25 | virtual ~DataSourceController(); |
|
26 | 26 | |
|
27 | 27 | /** |
|
28 | 28 | * Registers a data source. The method delivers a unique id that can be used afterwards to |
|
29 | 29 | * access to the data source properties (structure, connection parameters, data provider, etc.) |
|
30 | 30 | * @param dataSourceName the name of the data source |
|
31 | 31 | * @return the unique id with which the data source has been registered |
|
32 | 32 | */ |
|
33 | 33 | QUuid registerDataSource(const QString &dataSourceName) noexcept; |
|
34 | 34 | |
|
35 | 35 | /** |
|
36 | 36 | * Sets the structure of a data source. The controller takes ownership of the structure. |
|
37 | 37 | * @param dataSourceUid the unique id with which the data source has been registered into the |
|
38 | 38 | * controller. If it is invalid, the method has no effect. |
|
39 | 39 | * @param dataSourceItem the structure of the data source |
|
40 | 40 | * @sa registerDataSource() |
|
41 | 41 | */ |
|
42 | 42 | void setDataSourceItem(const QUuid &dataSourceUid, |
|
43 | 43 | std::unique_ptr<DataSourceItem> dataSourceItem) noexcept; |
|
44 | 44 | |
|
45 | 45 | public slots: |
|
46 | 46 | /// Manage init/end of the controller |
|
47 | 47 | void initialize(); |
|
48 | 48 | void finalize(); |
|
49 | 49 | |
|
50 | 50 | signals: |
|
51 | 51 | /// Signal emitted when a structure has been set for a data source |
|
52 |
void dataSourceItemSet( |
|
|
52 | void dataSourceItemSet(DataSourceItem &dataSourceItem); | |
|
53 | 53 | |
|
54 | 54 | private: |
|
55 | 55 | void waitForFinish(); |
|
56 | 56 | |
|
57 | 57 | class DataSourceControllerPrivate; |
|
58 | 58 | spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl; |
|
59 | 59 | }; |
|
60 | 60 | |
|
61 | 61 | #endif // SCIQLOP_DATASOURCECONTROLLER_H |
@@ -1,52 +1,59 | |||
|
1 | 1 | #ifndef SCIQLOP_DATASOURCEITEM_H |
|
2 | 2 | #define SCIQLOP_DATASOURCEITEM_H |
|
3 | 3 | |
|
4 | 4 | #include <Common/spimpl.h> |
|
5 | 5 | |
|
6 | 6 | #include <QVariant> |
|
7 | 7 | #include <QVector> |
|
8 | 8 | |
|
9 | 9 | /** |
|
10 | * Possible types of an item | |
|
11 | */ | |
|
12 | enum class DataSourceItemType { NODE, PRODUCT }; | |
|
13 | ||
|
14 | /** | |
|
10 | 15 | * @brief The DataSourceItem class aims to represent a structure element of a data source. |
|
11 | 16 | * A data source has a tree structure that is made up of a main DataSourceItem object (root) |
|
12 | 17 | * containing other DataSourceItem objects (children). |
|
13 | 18 | * For each DataSourceItem can be associated a set of data representing it. |
|
14 | 19 | */ |
|
15 | 20 | class DataSourceItem { |
|
16 | 21 | public: |
|
17 | explicit DataSourceItem(QVector<QVariant> data = {}); | |
|
22 | explicit DataSourceItem(DataSourceItemType type, QVector<QVariant> data = {}); | |
|
18 | 23 | |
|
19 | 24 | /** |
|
20 | 25 | * Adds a child to the item. The item takes ownership of the child. |
|
21 | 26 | * @param child the child to add |
|
22 | 27 | */ |
|
23 | 28 | void appendChild(std::unique_ptr<DataSourceItem> child) noexcept; |
|
24 | 29 | |
|
25 | 30 | /** |
|
26 | 31 | * Returns the item's child associated to an index |
|
27 | 32 | * @param childIndex the index to search |
|
28 | 33 | * @return a pointer to the child if index is valid, nullptr otherwise |
|
29 | 34 | */ |
|
30 | 35 | DataSourceItem *child(int childIndex) const noexcept; |
|
31 | 36 | |
|
32 | 37 | int childCount() const noexcept; |
|
33 | 38 | |
|
34 | 39 | /** |
|
35 | 40 | * Get the data associated to an index |
|
36 | 41 | * @param dataIndex the index to search |
|
37 | 42 | * @return the data found if index is valid, default QVariant otherwise |
|
38 | 43 | */ |
|
39 | 44 | QVariant data(int dataIndex) const noexcept; |
|
40 | 45 | |
|
41 | 46 | /** |
|
42 | 47 | * Get the item's parent |
|
43 | 48 | * @return a pointer to the parent if it exists, nullptr if the item is a root |
|
44 | 49 | */ |
|
45 | 50 | DataSourceItem *parentItem() const noexcept; |
|
46 | 51 | |
|
52 | DataSourceItemType type() const noexcept; | |
|
53 | ||
|
47 | 54 | private: |
|
48 | 55 | class DataSourceItemPrivate; |
|
49 | 56 | spimpl::unique_impl_ptr<DataSourceItemPrivate> impl; |
|
50 | 57 | }; |
|
51 | 58 | |
|
52 | 59 | #endif // SCIQLOP_DATASOURCEITEMMODEL_H |
@@ -1,50 +1,56 | |||
|
1 | 1 | #include <DataSource/DataSourceItem.h> |
|
2 | 2 | |
|
3 | 3 | #include <QVector> |
|
4 | 4 | |
|
5 | 5 | struct DataSourceItem::DataSourceItemPrivate { |
|
6 | explicit DataSourceItemPrivate(QVector<QVariant> data) | |
|
7 | : m_Parent{nullptr}, m_Children{}, m_Data{std::move(data)} | |
|
6 | explicit DataSourceItemPrivate(DataSourceItemType type, QVector<QVariant> data) | |
|
7 | : m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)} | |
|
8 | 8 | { |
|
9 | 9 | } |
|
10 | 10 | |
|
11 | 11 | DataSourceItem *m_Parent; |
|
12 | 12 | std::vector<std::unique_ptr<DataSourceItem> > m_Children; |
|
13 | DataSourceItemType m_Type; | |
|
13 | 14 | QVector<QVariant> m_Data; |
|
14 | 15 | }; |
|
15 | 16 | |
|
16 | DataSourceItem::DataSourceItem(QVector<QVariant> data) | |
|
17 | : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(data)} | |
|
17 | DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data) | |
|
18 | : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))} | |
|
18 | 19 | { |
|
19 | 20 | } |
|
20 | 21 | |
|
21 | 22 | void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept |
|
22 | 23 | { |
|
23 | 24 | child->impl->m_Parent = this; |
|
24 | 25 | impl->m_Children.push_back(std::move(child)); |
|
25 | 26 | } |
|
26 | 27 | |
|
27 | 28 | DataSourceItem *DataSourceItem::child(int childIndex) const noexcept |
|
28 | 29 | { |
|
29 | 30 | if (childIndex < 0 || childIndex >= childCount()) { |
|
30 | 31 | return nullptr; |
|
31 | 32 | } |
|
32 | 33 | else { |
|
33 | 34 | return impl->m_Children.at(childIndex).get(); |
|
34 | 35 | } |
|
35 | 36 | } |
|
36 | 37 | |
|
37 | 38 | int DataSourceItem::childCount() const noexcept |
|
38 | 39 | { |
|
39 | 40 | return impl->m_Children.size(); |
|
40 | 41 | } |
|
41 | 42 | |
|
42 | 43 | QVariant DataSourceItem::data(int dataIndex) const noexcept |
|
43 | 44 | { |
|
44 | 45 | return impl->m_Data.value(dataIndex); |
|
45 | 46 | } |
|
46 | 47 | |
|
47 | 48 | DataSourceItem *DataSourceItem::parentItem() const noexcept |
|
48 | 49 | { |
|
49 | 50 | return impl->m_Parent; |
|
50 | 51 | } |
|
52 | ||
|
53 | DataSourceItemType DataSourceItem::type() const noexcept | |
|
54 | { | |
|
55 | return impl->m_Type; | |
|
56 | } |
@@ -1,49 +1,51 | |||
|
1 | 1 | #include <DataSource/DataSourceController.h> |
|
2 | 2 | #include <DataSource/DataSourceItem.h> |
|
3 | 3 | |
|
4 | 4 | #include <QObject> |
|
5 | 5 | #include <QtTest> |
|
6 | 6 | |
|
7 | 7 | #include <memory> |
|
8 | 8 | |
|
9 | 9 | class TestDataSourceController : public QObject { |
|
10 | 10 | Q_OBJECT |
|
11 | 11 | private slots: |
|
12 | 12 | void testRegisterDataSource(); |
|
13 | 13 | void testSetDataSourceItem(); |
|
14 | 14 | }; |
|
15 | 15 | |
|
16 | 16 | void TestDataSourceController::testRegisterDataSource() |
|
17 | 17 | { |
|
18 | 18 | DataSourceController dataSourceController{}; |
|
19 | 19 | |
|
20 | 20 | auto uid = dataSourceController.registerDataSource(QStringLiteral("Source1")); |
|
21 | 21 | QVERIFY(!uid.isNull()); |
|
22 | 22 | } |
|
23 | 23 | |
|
24 | 24 | void TestDataSourceController::testSetDataSourceItem() |
|
25 | 25 | { |
|
26 | 26 | DataSourceController dataSourceController{}; |
|
27 | 27 | |
|
28 | 28 | // Spy to test controllers' signals |
|
29 | 29 | QSignalSpy signalSpy{&dataSourceController, SIGNAL(dataSourceItemSet(const DataSourceItem &))}; |
|
30 | 30 | |
|
31 | 31 | // Create a data source item |
|
32 | 32 | auto source1Name = QStringLiteral("Source1"); |
|
33 | 33 | auto source1Values = QVector<QVariant>{source1Name}; |
|
34 | auto source1Item = std::make_unique<DataSourceItem>(std::move(source1Values)); | |
|
34 | auto source1Item | |
|
35 | = std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT, std::move(source1Values)); | |
|
35 | 36 | |
|
36 | 37 | // Add data source item to the controller and check that a signal has been emitted after setting |
|
37 | 38 | // data source item in the controller |
|
38 | 39 | auto source1Uid = dataSourceController.registerDataSource(source1Name); |
|
39 | 40 | dataSourceController.setDataSourceItem(source1Uid, std::move(source1Item)); |
|
40 | 41 | QCOMPARE(signalSpy.count(), 1); |
|
41 | 42 | |
|
42 | 43 | // Try to a data source item with an unregistered uid and check that no signal has been emitted |
|
43 | 44 | auto unregisteredUid = QUuid::createUuid(); |
|
44 |
dataSourceController.setDataSourceItem( |
|
|
45 | dataSourceController.setDataSourceItem( | |
|
46 | unregisteredUid, std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT)); | |
|
45 | 47 | QCOMPARE(signalSpy.count(), 1); |
|
46 | 48 | } |
|
47 | 49 | |
|
48 | 50 | QTEST_MAIN(TestDataSourceController) |
|
49 | 51 | #include "TestDataSourceController.moc" |
@@ -1,3 +1,6 | |||
|
1 | 1 | # On ignore toutes les règles vera++ pour le fichier spimpl |
|
2 | 2 | Common/spimpl\.h:\d+:.* |
|
3 | 3 | |
|
4 | # Ignore false positive relative to two class definitions in a same file | |
|
5 | DataSourceItem\.h:\d+:.*IPSIS_S01.* | |
|
6 |
@@ -1,8 +1,12 | |||
|
1 | 1 | # On ignore toutes les règles vera++ pour le fichier spimpl |
|
2 | 2 | |
|
3 | 3 | .*IPSIS_S04_METHOD.*found: Q_DECLARE_LOGGING_CATEGORY.* |
|
4 | 4 | .*IPSIS_S04_VARIABLE.*found: impl.* |
|
5 | 5 | |
|
6 | 6 | # Ignore false positive relative to 'noexcept' keyword |
|
7 | 7 | .*IPSIS_S04_VARIABLE.*found: noexcept |
|
8 | 8 | .*IPSIS_S06.*found: noexcept |
|
9 | ||
|
10 | # Ignore false positive relative to 'override' keyword | |
|
11 | .*IPSIS_S04_VARIABLE.*found: override | |
|
12 | .*IPSIS_S06.*found: override |
@@ -1,8 +1,11 | |||
|
1 | # Ignore false positive relative to App macro | |
|
2 | 1 | \.h:\d+:.IPSIS_S04.*found: ui |
|
3 | 2 | qcustomplot\.h:\d+:.IPSIS |
|
4 | 3 | qcustomplot\.cpp:\d+:.IPSIS |
|
4 | ||
|
5 | # Ignore false positive relative to App macro | |
|
5 | 6 | SqpApplication\.h:\d+:.IPSIS_S03.*found: sqpApp |
|
6 | 7 | SqpApplication\.h:\d+:.IPSIS_S04_VARIABLE.*found: sqpApp |
|
7 | 8 | |
|
9 | # Ignore false positive relative to unnamed namespace | |
|
10 | DataSourceTreeWidgetItem\.cpp:\d+:.*IPSIS_F13.* | |
|
8 | 11 |
General Comments 0
You need to be logged in to leave comments.
Login now