@@ -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 | -- This file is a part of the QLop Software |
|
2 | -- This file is a part of the QLop Software | |
3 | -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS |
|
3 | -- Copyright (C) 2015, 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 <QProcessEnvironment> |
|
23 | #include <QProcessEnvironment> | |
24 | #include <QThread> |
|
24 | #include <QThread> | |
25 | #include <SqpApplication.h> |
|
25 | #include <SqpApplication.h> | |
26 | #include <qglobal.h> |
|
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 | int main(int argc, char *argv[]) |
|
38 | int main(int argc, char *argv[]) | |
29 | { |
|
39 | { | |
30 | SqpApplication a{argc, argv}; |
|
40 | SqpApplication a{argc, argv}; | |
31 | SqpApplication::setOrganizationName("LPP"); |
|
41 | SqpApplication::setOrganizationName("LPP"); | |
32 | SqpApplication::setOrganizationDomain("lpp.fr"); |
|
42 | SqpApplication::setOrganizationDomain("lpp.fr"); | |
33 | SqpApplication::setApplicationName("SciQLop"); |
|
43 | SqpApplication::setApplicationName("SciQLop"); | |
34 | MainWindow w; |
|
44 | MainWindow w; | |
35 | w.show(); |
|
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 | return a.exec(); |
|
58 | return a.exec(); | |
38 | } |
|
59 | } |
@@ -1,118 +1,128 | |||||
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 | ||||
|
25 | #include <DataSource/DataSourceController.h> | |||
|
26 | #include <DataSource/DataSourceWidget.h> | |||
|
27 | #include <SqpApplication.h> | |||
|
28 | ||||
24 | #include <QAction> |
|
29 | #include <QAction> | |
25 | #include <QDate> |
|
30 | #include <QDate> | |
26 | #include <QDateTime> |
|
31 | #include <QDateTime> | |
27 | #include <QDir> |
|
32 | #include <QDir> | |
28 | #include <QFileDialog> |
|
33 | #include <QFileDialog> | |
29 | //#include <omp.h> |
|
34 | //#include <omp.h> | |
30 | //#include <network/filedownloader.h> |
|
35 | //#include <network/filedownloader.h> | |
31 | //#include <qlopdatabase.h> |
|
36 | //#include <qlopdatabase.h> | |
32 | //#include <qlopsettings.h> |
|
37 | //#include <qlopsettings.h> | |
33 | //#include <qlopgui.h> |
|
38 | //#include <qlopgui.h> | |
34 | //#include <spacedata.h> |
|
39 | //#include <spacedata.h> | |
35 | //#include "qlopcore.h" |
|
40 | //#include "qlopcore.h" | |
36 | //#include "qlopcodecmanager.h" |
|
41 | //#include "qlopcodecmanager.h" | |
37 | //#include "cdfcodec.h" |
|
42 | //#include "cdfcodec.h" | |
38 | //#include "amdatxtcodec.h" |
|
43 | //#include "amdatxtcodec.h" | |
39 | //#include <qlopplotmanager.h> |
|
44 | //#include <qlopplotmanager.h> | |
40 | #include <QAction> |
|
45 | #include <QAction> | |
41 | #include <QToolBar> |
|
46 | #include <QToolBar> | |
42 | #include <memory.h> |
|
47 | #include <memory.h> | |
43 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_Ui(new Ui::MainWindow) |
|
48 | MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_Ui(new Ui::MainWindow) | |
44 | { |
|
49 | { | |
45 | m_Ui->setupUi(this); |
|
50 | m_Ui->setupUi(this); | |
46 |
|
51 | |||
47 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); |
|
52 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); | |
48 | leftSidePane->addAction("ACTION L1"); |
|
53 | leftSidePane->addAction("ACTION L1"); | |
49 | leftSidePane->addAction("ACTION L2"); |
|
54 | leftSidePane->addAction("ACTION L2"); | |
50 | leftSidePane->addAction("ACTION L3"); |
|
55 | leftSidePane->addAction("ACTION L3"); | |
51 |
|
56 | |||
52 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); |
|
57 | auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane(); | |
53 | rightSidePane->addAction("ACTION R1"); |
|
58 | rightSidePane->addAction("ACTION R1"); | |
54 | rightSidePane->addAction("ACTION R2"); |
|
59 | rightSidePane->addAction("ACTION R2"); | |
55 | rightSidePane->addAction("ACTION R3"); |
|
60 | rightSidePane->addAction("ACTION R3"); | |
56 |
|
61 | |||
57 | this->menuBar()->addAction("File"); |
|
62 | this->menuBar()->addAction("File"); | |
58 | auto mainToolBar = this->addToolBar("MainToolBar"); |
|
63 | auto mainToolBar = this->addToolBar("MainToolBar"); | |
59 | mainToolBar->addAction("A1"); |
|
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 | /* QLopGUI::registerMenuBar(menuBar()); |
|
70 | /* QLopGUI::registerMenuBar(menuBar()); | |
61 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
|
71 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); | |
62 | this->m_progressWidget = new QWidget(); |
|
72 | this->m_progressWidget = new QWidget(); | |
63 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); |
|
73 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); | |
64 | this->m_progressWidget->setLayout(this->m_progressLayout); |
|
74 | this->m_progressWidget->setLayout(this->m_progressLayout); | |
65 | this->m_progressWidget->setWindowModality(Qt::WindowModal); |
|
75 | this->m_progressWidget->setWindowModality(Qt::WindowModal); | |
66 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); |
|
76 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); | |
67 | for(int i=0;i<OMP_THREADS;i++) |
|
77 | for(int i=0;i<OMP_THREADS;i++) | |
68 | { |
|
78 | { | |
69 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); |
|
79 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); | |
70 | this->m_progress.last()->setMinimum(0); |
|
80 | this->m_progress.last()->setMinimum(0); | |
71 | this->m_progress.last()->setMaximum(100); |
|
81 | this->m_progress.last()->setMaximum(100); | |
72 | this->m_progressLayout->addWidget(this->m_progress.last()); |
|
82 | this->m_progressLayout->addWidget(this->m_progress.last()); | |
73 | this->m_progressWidget->hide(); |
|
83 | this->m_progressWidget->hide(); | |
74 | this->m_progressThreadIds[i] = -1; |
|
84 | this->m_progressThreadIds[i] = -1; | |
75 | } |
|
85 | } | |
76 | this->m_progressWidget->setWindowTitle("Loading File"); |
|
86 | this->m_progressWidget->setWindowTitle("Loading File"); | |
77 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() |
|
87 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() | |
78 | << QLopCore::self() |
|
88 | << QLopCore::self() | |
79 | << QLopPlotManager::self() |
|
89 | << QLopPlotManager::self() | |
80 | << QLopCodecManager::self() |
|
90 | << QLopCodecManager::self() | |
81 | << FileDownloader::self() |
|
91 | << FileDownloader::self() | |
82 | << QLopDataBase::self() |
|
92 | << QLopDataBase::self() | |
83 | << SpaceData::self(); |
|
93 | << SpaceData::self(); | |
84 |
|
94 | |||
85 | CDFCodec::registerToManager(); |
|
95 | CDFCodec::registerToManager(); | |
86 | AMDATXTCodec::registerToManager(); |
|
96 | AMDATXTCodec::registerToManager(); | |
87 |
|
97 | |||
88 |
|
98 | |||
89 | for(int i=0;i<ServicesToLoad.count();i++) |
|
99 | for(int i=0;i<ServicesToLoad.count();i++) | |
90 | { |
|
100 | { | |
91 | qDebug()<<ServicesToLoad.at(i)->serviceName(); |
|
101 | qDebug()<<ServicesToLoad.at(i)->serviceName(); | |
92 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI |
|
102 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI | |
93 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); |
|
103 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); | |
94 | if(wdgt) |
|
104 | if(wdgt) | |
95 | { |
|
105 | { | |
96 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
106 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); | |
97 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); |
|
107 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); | |
98 | } |
|
108 | } | |
99 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); |
|
109 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); | |
100 | }*/ |
|
110 | }*/ | |
101 | } |
|
111 | } | |
102 |
|
112 | |||
103 | MainWindow::~MainWindow() |
|
113 | MainWindow::~MainWindow() | |
104 | { |
|
114 | { | |
105 | } |
|
115 | } | |
106 |
|
116 | |||
107 |
|
117 | |||
108 | void MainWindow::changeEvent(QEvent *e) |
|
118 | void MainWindow::changeEvent(QEvent *e) | |
109 | { |
|
119 | { | |
110 | QMainWindow::changeEvent(e); |
|
120 | QMainWindow::changeEvent(e); | |
111 | switch (e->type()) { |
|
121 | switch (e->type()) { | |
112 | case QEvent::LanguageChange: |
|
122 | case QEvent::LanguageChange: | |
113 | m_Ui->retranslateUi(this); |
|
123 | m_Ui->retranslateUi(this); | |
114 | break; |
|
124 | break; | |
115 | default: |
|
125 | default: | |
116 | break; |
|
126 | break; | |
117 | } |
|
127 | } | |
118 | } |
|
128 | } |
@@ -1,208 +1,214 | |||||
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>QLop</string> |
|
14 | <string>QLop</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>3</number> |
|
37 | <number>3</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="QWidget" name="leftInspectorWidget" native="true"> |
|
52 | <widget class="QWidget" name="leftInspectorWidget" native="true"> | |
53 | <layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
53 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | |
54 | <property name="spacing"> |
|
54 | <property name="spacing"> | |
55 | <number>3</number> |
|
55 | <number>3</number> | |
56 | </property> |
|
56 | </property> | |
57 | <property name="leftMargin"> |
|
57 | <property name="leftMargin"> | |
58 | <number>0</number> |
|
58 | <number>0</number> | |
59 | </property> |
|
59 | </property> | |
60 | <property name="topMargin"> |
|
60 | <property name="topMargin"> | |
61 | <number>0</number> |
|
61 | <number>0</number> | |
62 | </property> |
|
62 | </property> | |
63 | <property name="rightMargin"> |
|
63 | <property name="rightMargin"> | |
64 | <number>0</number> |
|
64 | <number>0</number> | |
65 | </property> |
|
65 | </property> | |
66 | <property name="bottomMargin"> |
|
66 | <property name="bottomMargin"> | |
67 | <number>0</number> |
|
67 | <number>0</number> | |
68 | </property> |
|
68 | </property> | |
69 | <item> |
|
69 | <item> | |
70 | <widget class="QWidget" name="widget" native="true"> |
|
70 | <widget class="QWidget" name="widget" native="true"> | |
71 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
71 | <layout class="QVBoxLayout" name="verticalLayout"> | |
72 | <property name="spacing"> |
|
72 | <property name="spacing"> | |
73 | <number>3</number> |
|
73 | <number>3</number> | |
74 | </property> |
|
74 | </property> | |
75 | <property name="leftMargin"> |
|
75 | <property name="leftMargin"> | |
76 | <number>0</number> |
|
76 | <number>0</number> | |
77 | </property> |
|
77 | </property> | |
78 | <property name="topMargin"> |
|
78 | <property name="topMargin"> | |
79 | <number>0</number> |
|
79 | <number>0</number> | |
80 | </property> |
|
80 | </property> | |
81 | <property name="rightMargin"> |
|
81 | <property name="rightMargin"> | |
82 | <number>0</number> |
|
82 | <number>0</number> | |
83 | </property> |
|
83 | </property> | |
84 | <property name="bottomMargin"> |
|
84 | <property name="bottomMargin"> | |
85 | <number>0</number> |
|
85 | <number>0</number> | |
86 | </property> |
|
86 | </property> | |
87 | <item> |
|
87 | <item> | |
88 |
<widget class=" |
|
88 | <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/> | |
89 | </item> |
|
89 | </item> | |
90 | <item> |
|
90 | <item> | |
91 | <widget class="QWidget" name="dateTimeWidget" native="true"/> |
|
91 | <widget class="QWidget" name="dateTimeWidget" native="true"/> | |
92 | </item> |
|
92 | </item> | |
93 | <item> |
|
93 | <item> | |
94 | <widget class="QWidget" name="variableInspectorWidget" native="true"/> |
|
94 | <widget class="QWidget" name="variableInspectorWidget" native="true"/> | |
95 | </item> |
|
95 | </item> | |
96 | </layout> |
|
96 | </layout> | |
97 | </widget> |
|
97 | </widget> | |
98 | </item> |
|
98 | </item> | |
99 | <item> |
|
99 | <item> | |
100 | <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"> |
|
100 | <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"> | |
101 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
|
101 | <layout class="QVBoxLayout" name="verticalLayout_2"> | |
102 | <property name="spacing"> |
|
102 | <property name="spacing"> | |
103 | <number>3</number> |
|
103 | <number>3</number> | |
104 | </property> |
|
104 | </property> | |
105 | <property name="leftMargin"> |
|
105 | <property name="leftMargin"> | |
106 | <number>0</number> |
|
106 | <number>0</number> | |
107 | </property> |
|
107 | </property> | |
108 | <property name="topMargin"> |
|
108 | <property name="topMargin"> | |
109 | <number>0</number> |
|
109 | <number>0</number> | |
110 | </property> |
|
110 | </property> | |
111 | <property name="rightMargin"> |
|
111 | <property name="rightMargin"> | |
112 | <number>0</number> |
|
112 | <number>0</number> | |
113 | </property> |
|
113 | </property> | |
114 | <property name="bottomMargin"> |
|
114 | <property name="bottomMargin"> | |
115 | <number>0</number> |
|
115 | <number>0</number> | |
116 | </property> |
|
116 | </property> | |
117 | </layout> |
|
117 | </layout> | |
118 | </widget> |
|
118 | </widget> | |
119 | </item> |
|
119 | </item> | |
120 | </layout> |
|
120 | </layout> | |
121 | </widget> |
|
121 | </widget> | |
122 | </item> |
|
122 | </item> | |
123 | <item> |
|
123 | <item> | |
124 | <widget class="VisualizationWidget" name="view" native="true"/> |
|
124 | <widget class="VisualizationWidget" name="view" native="true"/> | |
125 | </item> |
|
125 | </item> | |
126 | <item> |
|
126 | <item> | |
127 | <widget class="QWidget" name="rightInspectorWidget" native="true"> |
|
127 | <widget class="QWidget" name="rightInspectorWidget" native="true"> | |
128 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
|
128 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | |
129 | <property name="spacing"> |
|
129 | <property name="spacing"> | |
130 | <number>3</number> |
|
130 | <number>3</number> | |
131 | </property> |
|
131 | </property> | |
132 | <property name="leftMargin"> |
|
132 | <property name="leftMargin"> | |
133 | <number>0</number> |
|
133 | <number>0</number> | |
134 | </property> |
|
134 | </property> | |
135 | <property name="topMargin"> |
|
135 | <property name="topMargin"> | |
136 | <number>0</number> |
|
136 | <number>0</number> | |
137 | </property> |
|
137 | </property> | |
138 | <property name="rightMargin"> |
|
138 | <property name="rightMargin"> | |
139 | <number>0</number> |
|
139 | <number>0</number> | |
140 | </property> |
|
140 | </property> | |
141 | <property name="bottomMargin"> |
|
141 | <property name="bottomMargin"> | |
142 | <number>0</number> |
|
142 | <number>0</number> | |
143 | </property> |
|
143 | </property> | |
144 | <item> |
|
144 | <item> | |
145 | <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/> |
|
145 | <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/> | |
146 | </item> |
|
146 | </item> | |
147 | <item> |
|
147 | <item> | |
148 | <widget class="QWidget" name="widget_2" native="true"> |
|
148 | <widget class="QWidget" name="widget_2" native="true"> | |
149 | <layout class="QVBoxLayout" name="verticalLayout_3"> |
|
149 | <layout class="QVBoxLayout" name="verticalLayout_3"> | |
150 | <property name="spacing"> |
|
150 | <property name="spacing"> | |
151 | <number>3</number> |
|
151 | <number>3</number> | |
152 | </property> |
|
152 | </property> | |
153 | <property name="leftMargin"> |
|
153 | <property name="leftMargin"> | |
154 | <number>0</number> |
|
154 | <number>0</number> | |
155 | </property> |
|
155 | </property> | |
156 | <property name="topMargin"> |
|
156 | <property name="topMargin"> | |
157 | <number>0</number> |
|
157 | <number>0</number> | |
158 | </property> |
|
158 | </property> | |
159 | <property name="rightMargin"> |
|
159 | <property name="rightMargin"> | |
160 | <number>0</number> |
|
160 | <number>0</number> | |
161 | </property> |
|
161 | </property> | |
162 | <property name="bottomMargin"> |
|
162 | <property name="bottomMargin"> | |
163 | <number>0</number> |
|
163 | <number>0</number> | |
164 | </property> |
|
164 | </property> | |
165 | <item> |
|
165 | <item> | |
166 | <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/> |
|
166 | <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/> | |
167 | </item> |
|
167 | </item> | |
168 | <item> |
|
168 | <item> | |
169 | <widget class="QWidget" name="catalogWidget" native="true"/> |
|
169 | <widget class="QWidget" name="catalogWidget" native="true"/> | |
170 | </item> |
|
170 | </item> | |
171 | </layout> |
|
171 | </layout> | |
172 | </widget> |
|
172 | </widget> | |
173 | </item> |
|
173 | </item> | |
174 | </layout> |
|
174 | </layout> | |
175 | </widget> |
|
175 | </widget> | |
176 | </item> |
|
176 | </item> | |
177 | </layout> |
|
177 | </layout> | |
178 | </widget> |
|
178 | </widget> | |
179 | <widget class="QMenuBar" name="menuBar"> |
|
179 | <widget class="QMenuBar" name="menuBar"> | |
180 | <property name="geometry"> |
|
180 | <property name="geometry"> | |
181 | <rect> |
|
181 | <rect> | |
182 | <x>0</x> |
|
182 | <x>0</x> | |
183 | <y>0</y> |
|
183 | <y>0</y> | |
184 | <width>800</width> |
|
184 | <width>800</width> | |
185 | <height>26</height> |
|
185 | <height>26</height> | |
186 | </rect> |
|
186 | </rect> | |
187 | </property> |
|
187 | </property> | |
188 | </widget> |
|
188 | </widget> | |
189 | <widget class="QStatusBar" name="statusBar"/> |
|
189 | <widget class="QStatusBar" name="statusBar"/> | |
190 | </widget> |
|
190 | </widget> | |
191 | <layoutdefault spacing="6" margin="11"/> |
|
191 | <layoutdefault spacing="6" margin="11"/> | |
192 | <customwidgets> |
|
192 | <customwidgets> | |
193 | <customwidget> |
|
193 | <customwidget> | |
194 | <class>VisualizationWidget</class> |
|
194 | <class>VisualizationWidget</class> | |
195 | <extends>QWidget</extends> |
|
195 | <extends>QWidget</extends> | |
196 | <header location="global">visualization/VisualizationWidget.h</header> |
|
196 | <header location="global">visualization/VisualizationWidget.h</header> | |
197 | <container>1</container> |
|
197 | <container>1</container> | |
198 | </customwidget> |
|
198 | </customwidget> | |
199 | <customwidget> |
|
199 | <customwidget> | |
200 | <class>SqpSidePane</class> |
|
200 | <class>SqpSidePane</class> | |
201 | <extends>QWidget</extends> |
|
201 | <extends>QWidget</extends> | |
202 | <header location="global">sidepane/SqpSidePane.h</header> |
|
202 | <header location="global">sidepane/SqpSidePane.h</header> | |
203 | <container>1</container> |
|
203 | <container>1</container> | |
204 | </customwidget> |
|
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 | </customwidgets> |
|
211 | </customwidgets> | |
206 | <resources/> |
|
212 | <resources/> | |
207 | <connections/> |
|
213 | <connections/> | |
208 | </ui> |
|
214 | </ui> |
@@ -1,61 +1,61 | |||||
1 | #ifndef SCIQLOP_DATASOURCECONTROLLER_H |
|
1 | #ifndef SCIQLOP_DATASOURCECONTROLLER_H | |
2 | #define SCIQLOP_DATASOURCECONTROLLER_H |
|
2 | #define SCIQLOP_DATASOURCECONTROLLER_H | |
3 |
|
3 | |||
4 | #include <QLoggingCategory> |
|
4 | #include <QLoggingCategory> | |
5 | #include <QObject> |
|
5 | #include <QObject> | |
6 | #include <QUuid> |
|
6 | #include <QUuid> | |
7 |
|
7 | |||
8 | #include <Common/spimpl.h> |
|
8 | #include <Common/spimpl.h> | |
9 |
|
9 | |||
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController) |
|
10 | Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController) | |
11 |
|
11 | |||
12 | class DataSourceItem; |
|
12 | class DataSourceItem; | |
13 |
|
13 | |||
14 | /** |
|
14 | /** | |
15 | * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This |
|
15 | * @brief The DataSourceController class aims to make the link between SciQlop and its plugins. This | |
16 | * is the intermediate class that SciQlop has to use in the way to connect a data source. Please |
|
16 | * is the intermediate class that SciQlop has to use in the way to connect a data source. Please | |
17 | * first use register method to initialize a plugin specified by its metadata name (JSON plugin |
|
17 | * first use register method to initialize a plugin specified by its metadata name (JSON plugin | |
18 | * source) then others specifics method will be able to access it. You can load a data source driver |
|
18 | * source) then others specifics method will be able to access it. You can load a data source driver | |
19 | * plugin then create a data source. |
|
19 | * plugin then create a data source. | |
20 | */ |
|
20 | */ | |
21 | class DataSourceController : public QObject { |
|
21 | class DataSourceController : public QObject { | |
22 | Q_OBJECT |
|
22 | Q_OBJECT | |
23 | public: |
|
23 | public: | |
24 | explicit DataSourceController(QObject *parent = 0); |
|
24 | explicit DataSourceController(QObject *parent = 0); | |
25 | virtual ~DataSourceController(); |
|
25 | virtual ~DataSourceController(); | |
26 |
|
26 | |||
27 | /** |
|
27 | /** | |
28 | * Registers a data source. The method delivers a unique id that can be used afterwards to |
|
28 | * Registers a data source. The method delivers a unique id that can be used afterwards to | |
29 | * access to the data source properties (structure, connection parameters, data provider, etc.) |
|
29 | * access to the data source properties (structure, connection parameters, data provider, etc.) | |
30 | * @param dataSourceName the name of the data source |
|
30 | * @param dataSourceName the name of the data source | |
31 | * @return the unique id with which the data source has been registered |
|
31 | * @return the unique id with which the data source has been registered | |
32 | */ |
|
32 | */ | |
33 | QUuid registerDataSource(const QString &dataSourceName) noexcept; |
|
33 | QUuid registerDataSource(const QString &dataSourceName) noexcept; | |
34 |
|
34 | |||
35 | /** |
|
35 | /** | |
36 | * Sets the structure of a data source. The controller takes ownership of the structure. |
|
36 | * Sets the structure of a data source. The controller takes ownership of the structure. | |
37 | * @param dataSourceUid the unique id with which the data source has been registered into the |
|
37 | * @param dataSourceUid the unique id with which the data source has been registered into the | |
38 | * controller. If it is invalid, the method has no effect. |
|
38 | * controller. If it is invalid, the method has no effect. | |
39 | * @param dataSourceItem the structure of the data source |
|
39 | * @param dataSourceItem the structure of the data source | |
40 | * @sa registerDataSource() |
|
40 | * @sa registerDataSource() | |
41 | */ |
|
41 | */ | |
42 | void setDataSourceItem(const QUuid &dataSourceUid, |
|
42 | void setDataSourceItem(const QUuid &dataSourceUid, | |
43 | std::unique_ptr<DataSourceItem> dataSourceItem) noexcept; |
|
43 | std::unique_ptr<DataSourceItem> dataSourceItem) noexcept; | |
44 |
|
44 | |||
45 | public slots: |
|
45 | public slots: | |
46 | /// Manage init/end of the controller |
|
46 | /// Manage init/end of the controller | |
47 | void initialize(); |
|
47 | void initialize(); | |
48 | void finalize(); |
|
48 | void finalize(); | |
49 |
|
49 | |||
50 | signals: |
|
50 | signals: | |
51 | /// Signal emitted when a structure has been set for a data source |
|
51 | /// Signal emitted when a structure has been set for a data source | |
52 |
void dataSourceItemSet( |
|
52 | void dataSourceItemSet(DataSourceItem &dataSourceItem); | |
53 |
|
53 | |||
54 | private: |
|
54 | private: | |
55 | void waitForFinish(); |
|
55 | void waitForFinish(); | |
56 |
|
56 | |||
57 | class DataSourceControllerPrivate; |
|
57 | class DataSourceControllerPrivate; | |
58 | spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl; |
|
58 | spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl; | |
59 | }; |
|
59 | }; | |
60 |
|
60 | |||
61 | #endif // SCIQLOP_DATASOURCECONTROLLER_H |
|
61 | #endif // SCIQLOP_DATASOURCECONTROLLER_H |
@@ -1,52 +1,59 | |||||
1 | #ifndef SCIQLOP_DATASOURCEITEM_H |
|
1 | #ifndef SCIQLOP_DATASOURCEITEM_H | |
2 | #define SCIQLOP_DATASOURCEITEM_H |
|
2 | #define SCIQLOP_DATASOURCEITEM_H | |
3 |
|
3 | |||
4 | #include <Common/spimpl.h> |
|
4 | #include <Common/spimpl.h> | |
5 |
|
5 | |||
6 | #include <QVariant> |
|
6 | #include <QVariant> | |
7 | #include <QVector> |
|
7 | #include <QVector> | |
8 |
|
8 | |||
9 | /** |
|
9 | /** | |
|
10 | * Possible types of an item | |||
|
11 | */ | |||
|
12 | enum class DataSourceItemType { NODE, PRODUCT }; | |||
|
13 | ||||
|
14 | /** | |||
10 | * @brief The DataSourceItem class aims to represent a structure element of a data source. |
|
15 | * @brief The DataSourceItem class aims to represent a structure element of a data source. | |
11 | * A data source has a tree structure that is made up of a main DataSourceItem object (root) |
|
16 | * A data source has a tree structure that is made up of a main DataSourceItem object (root) | |
12 | * containing other DataSourceItem objects (children). |
|
17 | * containing other DataSourceItem objects (children). | |
13 | * For each DataSourceItem can be associated a set of data representing it. |
|
18 | * For each DataSourceItem can be associated a set of data representing it. | |
14 | */ |
|
19 | */ | |
15 | class DataSourceItem { |
|
20 | class DataSourceItem { | |
16 | public: |
|
21 | public: | |
17 | explicit DataSourceItem(QVector<QVariant> data = {}); |
|
22 | explicit DataSourceItem(DataSourceItemType type, QVector<QVariant> data = {}); | |
18 |
|
23 | |||
19 | /** |
|
24 | /** | |
20 | * Adds a child to the item. The item takes ownership of the child. |
|
25 | * Adds a child to the item. The item takes ownership of the child. | |
21 | * @param child the child to add |
|
26 | * @param child the child to add | |
22 | */ |
|
27 | */ | |
23 | void appendChild(std::unique_ptr<DataSourceItem> child) noexcept; |
|
28 | void appendChild(std::unique_ptr<DataSourceItem> child) noexcept; | |
24 |
|
29 | |||
25 | /** |
|
30 | /** | |
26 | * Returns the item's child associated to an index |
|
31 | * Returns the item's child associated to an index | |
27 | * @param childIndex the index to search |
|
32 | * @param childIndex the index to search | |
28 | * @return a pointer to the child if index is valid, nullptr otherwise |
|
33 | * @return a pointer to the child if index is valid, nullptr otherwise | |
29 | */ |
|
34 | */ | |
30 | DataSourceItem *child(int childIndex) const noexcept; |
|
35 | DataSourceItem *child(int childIndex) const noexcept; | |
31 |
|
36 | |||
32 | int childCount() const noexcept; |
|
37 | int childCount() const noexcept; | |
33 |
|
38 | |||
34 | /** |
|
39 | /** | |
35 | * Get the data associated to an index |
|
40 | * Get the data associated to an index | |
36 | * @param dataIndex the index to search |
|
41 | * @param dataIndex the index to search | |
37 | * @return the data found if index is valid, default QVariant otherwise |
|
42 | * @return the data found if index is valid, default QVariant otherwise | |
38 | */ |
|
43 | */ | |
39 | QVariant data(int dataIndex) const noexcept; |
|
44 | QVariant data(int dataIndex) const noexcept; | |
40 |
|
45 | |||
41 | /** |
|
46 | /** | |
42 | * Get the item's parent |
|
47 | * Get the item's parent | |
43 | * @return a pointer to the parent if it exists, nullptr if the item is a root |
|
48 | * @return a pointer to the parent if it exists, nullptr if the item is a root | |
44 | */ |
|
49 | */ | |
45 | DataSourceItem *parentItem() const noexcept; |
|
50 | DataSourceItem *parentItem() const noexcept; | |
46 |
|
51 | |||
|
52 | DataSourceItemType type() const noexcept; | |||
|
53 | ||||
47 | private: |
|
54 | private: | |
48 | class DataSourceItemPrivate; |
|
55 | class DataSourceItemPrivate; | |
49 | spimpl::unique_impl_ptr<DataSourceItemPrivate> impl; |
|
56 | spimpl::unique_impl_ptr<DataSourceItemPrivate> impl; | |
50 | }; |
|
57 | }; | |
51 |
|
58 | |||
52 | #endif // SCIQLOP_DATASOURCEITEMMODEL_H |
|
59 | #endif // SCIQLOP_DATASOURCEITEMMODEL_H |
@@ -1,50 +1,56 | |||||
1 | #include <DataSource/DataSourceItem.h> |
|
1 | #include <DataSource/DataSourceItem.h> | |
2 |
|
2 | |||
3 | #include <QVector> |
|
3 | #include <QVector> | |
4 |
|
4 | |||
5 | struct DataSourceItem::DataSourceItemPrivate { |
|
5 | struct DataSourceItem::DataSourceItemPrivate { | |
6 | explicit DataSourceItemPrivate(QVector<QVariant> data) |
|
6 | explicit DataSourceItemPrivate(DataSourceItemType type, QVector<QVariant> data) | |
7 | : m_Parent{nullptr}, m_Children{}, m_Data{std::move(data)} |
|
7 | : m_Parent{nullptr}, m_Children{}, m_Type{type}, m_Data{std::move(data)} | |
8 | { |
|
8 | { | |
9 | } |
|
9 | } | |
10 |
|
10 | |||
11 | DataSourceItem *m_Parent; |
|
11 | DataSourceItem *m_Parent; | |
12 | std::vector<std::unique_ptr<DataSourceItem> > m_Children; |
|
12 | std::vector<std::unique_ptr<DataSourceItem> > m_Children; | |
|
13 | DataSourceItemType m_Type; | |||
13 | QVector<QVariant> m_Data; |
|
14 | QVector<QVariant> m_Data; | |
14 | }; |
|
15 | }; | |
15 |
|
16 | |||
16 | DataSourceItem::DataSourceItem(QVector<QVariant> data) |
|
17 | DataSourceItem::DataSourceItem(DataSourceItemType type, QVector<QVariant> data) | |
17 | : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(data)} |
|
18 | : impl{spimpl::make_unique_impl<DataSourceItemPrivate>(type, std::move(data))} | |
18 | { |
|
19 | { | |
19 | } |
|
20 | } | |
20 |
|
21 | |||
21 | void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept |
|
22 | void DataSourceItem::appendChild(std::unique_ptr<DataSourceItem> child) noexcept | |
22 | { |
|
23 | { | |
23 | child->impl->m_Parent = this; |
|
24 | child->impl->m_Parent = this; | |
24 | impl->m_Children.push_back(std::move(child)); |
|
25 | impl->m_Children.push_back(std::move(child)); | |
25 | } |
|
26 | } | |
26 |
|
27 | |||
27 | DataSourceItem *DataSourceItem::child(int childIndex) const noexcept |
|
28 | DataSourceItem *DataSourceItem::child(int childIndex) const noexcept | |
28 | { |
|
29 | { | |
29 | if (childIndex < 0 || childIndex >= childCount()) { |
|
30 | if (childIndex < 0 || childIndex >= childCount()) { | |
30 | return nullptr; |
|
31 | return nullptr; | |
31 | } |
|
32 | } | |
32 | else { |
|
33 | else { | |
33 | return impl->m_Children.at(childIndex).get(); |
|
34 | return impl->m_Children.at(childIndex).get(); | |
34 | } |
|
35 | } | |
35 | } |
|
36 | } | |
36 |
|
37 | |||
37 | int DataSourceItem::childCount() const noexcept |
|
38 | int DataSourceItem::childCount() const noexcept | |
38 | { |
|
39 | { | |
39 | return impl->m_Children.size(); |
|
40 | return impl->m_Children.size(); | |
40 | } |
|
41 | } | |
41 |
|
42 | |||
42 | QVariant DataSourceItem::data(int dataIndex) const noexcept |
|
43 | QVariant DataSourceItem::data(int dataIndex) const noexcept | |
43 | { |
|
44 | { | |
44 | return impl->m_Data.value(dataIndex); |
|
45 | return impl->m_Data.value(dataIndex); | |
45 | } |
|
46 | } | |
46 |
|
47 | |||
47 | DataSourceItem *DataSourceItem::parentItem() const noexcept |
|
48 | DataSourceItem *DataSourceItem::parentItem() const noexcept | |
48 | { |
|
49 | { | |
49 | return impl->m_Parent; |
|
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 | #include <DataSource/DataSourceController.h> |
|
1 | #include <DataSource/DataSourceController.h> | |
2 | #include <DataSource/DataSourceItem.h> |
|
2 | #include <DataSource/DataSourceItem.h> | |
3 |
|
3 | |||
4 | #include <QObject> |
|
4 | #include <QObject> | |
5 | #include <QtTest> |
|
5 | #include <QtTest> | |
6 |
|
6 | |||
7 | #include <memory> |
|
7 | #include <memory> | |
8 |
|
8 | |||
9 | class TestDataSourceController : public QObject { |
|
9 | class TestDataSourceController : public QObject { | |
10 | Q_OBJECT |
|
10 | Q_OBJECT | |
11 | private slots: |
|
11 | private slots: | |
12 | void testRegisterDataSource(); |
|
12 | void testRegisterDataSource(); | |
13 | void testSetDataSourceItem(); |
|
13 | void testSetDataSourceItem(); | |
14 | }; |
|
14 | }; | |
15 |
|
15 | |||
16 | void TestDataSourceController::testRegisterDataSource() |
|
16 | void TestDataSourceController::testRegisterDataSource() | |
17 | { |
|
17 | { | |
18 | DataSourceController dataSourceController{}; |
|
18 | DataSourceController dataSourceController{}; | |
19 |
|
19 | |||
20 | auto uid = dataSourceController.registerDataSource(QStringLiteral("Source1")); |
|
20 | auto uid = dataSourceController.registerDataSource(QStringLiteral("Source1")); | |
21 | QVERIFY(!uid.isNull()); |
|
21 | QVERIFY(!uid.isNull()); | |
22 | } |
|
22 | } | |
23 |
|
23 | |||
24 | void TestDataSourceController::testSetDataSourceItem() |
|
24 | void TestDataSourceController::testSetDataSourceItem() | |
25 | { |
|
25 | { | |
26 | DataSourceController dataSourceController{}; |
|
26 | DataSourceController dataSourceController{}; | |
27 |
|
27 | |||
28 | // Spy to test controllers' signals |
|
28 | // Spy to test controllers' signals | |
29 | QSignalSpy signalSpy{&dataSourceController, SIGNAL(dataSourceItemSet(const DataSourceItem &))}; |
|
29 | QSignalSpy signalSpy{&dataSourceController, SIGNAL(dataSourceItemSet(const DataSourceItem &))}; | |
30 |
|
30 | |||
31 | // Create a data source item |
|
31 | // Create a data source item | |
32 | auto source1Name = QStringLiteral("Source1"); |
|
32 | auto source1Name = QStringLiteral("Source1"); | |
33 | auto source1Values = QVector<QVariant>{source1Name}; |
|
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 | // Add data source item to the controller and check that a signal has been emitted after setting |
|
37 | // Add data source item to the controller and check that a signal has been emitted after setting | |
37 | // data source item in the controller |
|
38 | // data source item in the controller | |
38 | auto source1Uid = dataSourceController.registerDataSource(source1Name); |
|
39 | auto source1Uid = dataSourceController.registerDataSource(source1Name); | |
39 | dataSourceController.setDataSourceItem(source1Uid, std::move(source1Item)); |
|
40 | dataSourceController.setDataSourceItem(source1Uid, std::move(source1Item)); | |
40 | QCOMPARE(signalSpy.count(), 1); |
|
41 | QCOMPARE(signalSpy.count(), 1); | |
41 |
|
42 | |||
42 | // Try to a data source item with an unregistered uid and check that no signal has been emitted |
|
43 | // Try to a data source item with an unregistered uid and check that no signal has been emitted | |
43 | auto unregisteredUid = QUuid::createUuid(); |
|
44 | auto unregisteredUid = QUuid::createUuid(); | |
44 |
dataSourceController.setDataSourceItem( |
|
45 | dataSourceController.setDataSourceItem( | |
|
46 | unregisteredUid, std::make_unique<DataSourceItem>(DataSourceItemType::PRODUCT)); | |||
45 | QCOMPARE(signalSpy.count(), 1); |
|
47 | QCOMPARE(signalSpy.count(), 1); | |
46 | } |
|
48 | } | |
47 |
|
49 | |||
48 | QTEST_MAIN(TestDataSourceController) |
|
50 | QTEST_MAIN(TestDataSourceController) | |
49 | #include "TestDataSourceController.moc" |
|
51 | #include "TestDataSourceController.moc" |
@@ -1,3 +1,6 | |||||
1 | # On ignore toutes les règles vera++ pour le fichier spimpl |
|
1 | # On ignore toutes les règles vera++ pour le fichier spimpl | |
2 | Common/spimpl\.h:\d+:.* |
|
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 | # On ignore toutes les règles vera++ pour le fichier spimpl |
|
1 | # On ignore toutes les règles vera++ pour le fichier spimpl | |
2 |
|
2 | |||
3 | .*IPSIS_S04_METHOD.*found: Q_DECLARE_LOGGING_CATEGORY.* |
|
3 | .*IPSIS_S04_METHOD.*found: Q_DECLARE_LOGGING_CATEGORY.* | |
4 | .*IPSIS_S04_VARIABLE.*found: impl.* |
|
4 | .*IPSIS_S04_VARIABLE.*found: impl.* | |
5 |
|
5 | |||
6 | # Ignore false positive relative to 'noexcept' keyword |
|
6 | # Ignore false positive relative to 'noexcept' keyword | |
7 | .*IPSIS_S04_VARIABLE.*found: noexcept |
|
7 | .*IPSIS_S04_VARIABLE.*found: noexcept | |
8 | .*IPSIS_S06.*found: noexcept |
|
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 | \.h:\d+:.IPSIS_S04.*found: ui |
|
1 | \.h:\d+:.IPSIS_S04.*found: ui | |
3 | qcustomplot\.h:\d+:.IPSIS |
|
2 | qcustomplot\.h:\d+:.IPSIS | |
4 | qcustomplot\.cpp:\d+:.IPSIS |
|
3 | qcustomplot\.cpp:\d+:.IPSIS | |
|
4 | ||||
|
5 | # Ignore false positive relative to App macro | |||
5 | SqpApplication\.h:\d+:.IPSIS_S03.*found: sqpApp |
|
6 | SqpApplication\.h:\d+:.IPSIS_S03.*found: sqpApp | |
6 | SqpApplication\.h:\d+:.IPSIS_S04_VARIABLE.*found: sqpApp |
|
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