##// END OF EJS Templates
New data sources system switch complete...
jeandet -
r1495:9c439b3d7daf
parent child
Show More
@@ -2,9 +2,10
2 #include <Data/DataProviderParameters.h>
2 #include <Data/DataProviderParameters.h>
3 #include <Data/DataSeriesType.h>
3 #include <Data/DataSeriesType.h>
4 #include <Data/IDataProvider.h>
4 #include <Data/IDataProvider.h>
5 #include <DataSource/DataSourceController.h>
6 #include <DataSource/DataSourceItem.h>
5 #include <DataSource/DataSourceItem.h>
7 #include <DataSource/DataSourceItemAction.h>
6 #include <DataSource/DataSourceItemAction.h>
7 #include <DataSource/datasources.h>
8
8 #include <QPair>
9 #include <QPair>
9 #include <SqpApplication.h>
10 #include <SqpApplication.h>
10 // must be included last because of Python/Qt definition of slots
11 // must be included last because of Python/Qt definition of slots
@@ -68,8 +69,8 class PyDataProvider : public IDataProvider
68 public:
69 public:
69 PyDataProvider()
70 PyDataProvider()
70 {
71 {
71 auto& dataSourceController = sqpApp->dataSourceController();
72 auto& dataSources = sqpApp->dataSources();
72 dataSourceController.registerProvider(this);
73 dataSources.addProvider(this);
73 }
74 }
74
75
75 virtual ~PyDataProvider() {}
76 virtual ~PyDataProvider() {}
@@ -118,12 +119,12 public:
118
119
119 inline void register_products(const QVector<Product*>& products)
120 inline void register_products(const QVector<Product*>& products)
120 {
121 {
121 auto& dataSourceController = sqpApp->dataSourceController();
122 auto& dataSources = sqpApp->dataSources();
122 auto id = this->id();
123 auto id = this->id();
123 auto data_source_name = this->name();
124 auto data_source_name = this->name();
124 std::for_each(std::cbegin(products), std::cend(products),
125 std::for_each(std::cbegin(products), std::cend(products),
125 [&id, &dataSourceController](const Product* product) {
126 [&id, &dataSources](const Product* product) {
126 dataSourceController.setDataSourceItem(id, product->path, product->metadata);
127 dataSources.addDataSourceItem(id, product->path, product->metadata);
127 });
128 });
128 }
129 }
129 };
130 };
@@ -24,7 +24,6
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>
28 #include <DataSource/DataSourceItem.h>
27 #include <DataSource/DataSourceItem.h>
29 #include <DataSource/DataSourceWidget.h>
28 #include <DataSource/DataSourceWidget.h>
30 #include <Settings/SqpSettingsDialog.h>
29 #include <Settings/SqpSettingsDialog.h>
@@ -114,10 +113,6 MainWindow::MainWindow(QWidget* parent)
114
113
115 // Widgets / controllers connections
114 // Widgets / controllers connections
116
115
117 // DataSource
118 connect(&sqpApp->dataSourceController(), &DataSourceController::dataSourceItemSet,
119 m_Ui->dataSourceWidget, &DataSourceWidget::addDataSource);
120
121 // Time
116 // Time
122 // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
117 // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
123 // SLOT(onTimeToUpdate(DateTimeRange)));
118 // SLOT(onTimeToUpdate(DateTimeRange)));
@@ -1,1 +1,1
1 Subproject commit b081849458c211dcc59f72b11542959db2301162
1 Subproject commit 46467fb43b8d07fe4f4a45df949ec4ae858ccf9d
@@ -3,9 +3,10
3
3
4 #include <QWidget>
4 #include <QWidget>
5
5
6 #include <memory>
6 #include <QSortFilterProxyModel>
7
7
8 namespace Ui {
8 namespace Ui
9 {
9 class DataSourceWidget;
10 class DataSourceWidget;
10 } // Ui
11 } // Ui
11
12
@@ -15,33 +16,20 class DataSourceItem;
15 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
16 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
16 * attached to SciQlop.
17 * attached to SciQlop.
17 */
18 */
18 class DataSourceWidget : public QWidget {
19 class DataSourceWidget : public QWidget
20 {
19 Q_OBJECT
21 Q_OBJECT
20
22
21 public:
23 public:
22 explicit DataSourceWidget(QWidget *parent = 0);
24 explicit DataSourceWidget(QWidget* parent = 0);
23 virtual ~DataSourceWidget() noexcept;
25 virtual ~DataSourceWidget() noexcept;
24
26
25 public slots:
26 /**
27 * Adds a data source. An item associated to the data source is created and then added to the
28 * representation tree
29 * @param dataSource the data source to add. The pointer has to be not null
30 */
31 void addDataSource(DataSourceItem *dataSource) noexcept;
32
33 private:
27 private:
34 void updateTreeWidget() noexcept;
28 void updateTreeWidget() noexcept;
35
29
36 Ui::DataSourceWidget *ui;
30 Ui::DataSourceWidget* ui;
37 std::unique_ptr<DataSourceItem> m_Root;
31 QSortFilterProxyModel m_model_proxy;
38
39 private slots:
40 /// Slot called when the filtering text has changed
41 void filterChanged(const QString &text) noexcept;
42
32
43 /// Slot called when right clicking on an item in the tree (displays a menu)
44 void onTreeMenuRequested(const QPoint &pos) noexcept;
45 };
33 };
46
34
47 #endif // SCIQLOP_DATASOURCEWIDGET_H
35 #endif // SCIQLOP_DATASOURCEWIDGET_H
@@ -22,6 +22,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
22 #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance()))
22 #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance()))
23
23
24 class DataSourceController;
24 class DataSourceController;
25 class DataSources;
25 class NetworkController;
26 class NetworkController;
26 class TimeController;
27 class TimeController;
27 class VariableController;
28 class VariableController;
@@ -68,7 +69,8 public:
68 void initialize();
69 void initialize();
69
70
70 /// Accessors for the differents sciqlop controllers
71 /// Accessors for the differents sciqlop controllers
71 DataSourceController& dataSourceController() noexcept;
72 //DataSourceController& dataSourceController() noexcept;
73 DataSources& dataSources() noexcept;
72 NetworkController& networkController() noexcept;
74 NetworkController& networkController() noexcept;
73 TimeController& timeController() noexcept;
75 TimeController& timeController() noexcept;
74 VariableController2& variableController() noexcept;
76 VariableController2& variableController() noexcept;
@@ -7,9 +7,6 gui_moc_headers = [
7 './include/DragAndDrop/DragDropScroller.h',
7 './include/DragAndDrop/DragDropScroller.h',
8 './include/Settings/SqpSettingsDialog.h',
8 './include/Settings/SqpSettingsDialog.h',
9 './include/Settings/SqpSettingsGeneralWidget.h',
9 './include/Settings/SqpSettingsGeneralWidget.h',
10 './include/DataSource/DataSourceTreeWidgetHelper.h',
11 './include/DataSource/DataSourceTreeWidget.h',
12 './include/DataSource/DataSourceTreeWidgetItem.h',
13 './include/DataSource/DataSourceWidget.h',
10 './include/DataSource/DataSourceWidget.h',
14 './include/Catalogue2/repositoriestreeview.h',
11 './include/Catalogue2/repositoriestreeview.h',
15 './include/Catalogue2/browser.h',
12 './include/Catalogue2/browser.h',
@@ -104,10 +101,7 gui_sources = [
104 './src/DragAndDrop/DragDropGuiController.cpp',
101 './src/DragAndDrop/DragDropGuiController.cpp',
105 './src/Settings/SqpSettingsGeneralWidget.cpp',
102 './src/Settings/SqpSettingsGeneralWidget.cpp',
106 './src/Settings/SqpSettingsDialog.cpp',
103 './src/Settings/SqpSettingsDialog.cpp',
107 './src/DataSource/DataSourceTreeWidgetItem.cpp',
108 './src/DataSource/DataSourceTreeWidgetHelper.cpp',
109 './src/DataSource/DataSourceWidget.cpp',
104 './src/DataSource/DataSourceWidget.cpp',
110 './src/DataSource/DataSourceTreeWidget.cpp',
111 './src/Catalogue2/eventstreeview.cpp',
105 './src/Catalogue2/eventstreeview.cpp',
112 './src/Catalogue2/eventeditor.cpp',
106 './src/Catalogue2/eventeditor.cpp',
113 './src/Catalogue2/repositoriestreeview.cpp',
107 './src/Catalogue2/repositoriestreeview.cpp',
@@ -2,11 +2,10
2
2
3 #include <ui_DataSourceWidget.h>
3 #include <ui_DataSourceWidget.h>
4
4
5 #include <DataSource/DataSourceItem.h>
5 #include <DataSource/datasources.h>
6 #include <DataSource/DataSourceTreeWidgetHelper.h>
6
7 #include <DataSource/DataSourceTreeWidgetItem.h>
7 #include <SqpApplication.h>
8
8
9 #include <QMenu>
10
9
11 namespace
10 namespace
12 {
11 {
@@ -17,47 +16,23 const auto TREE_NB_COLUMNS = 1;
17 /// Header labels for the tree
16 /// Header labels for the tree
18 const auto TREE_HEADER_LABELS = QStringList { QObject::tr("Name") };
17 const auto TREE_HEADER_LABELS = QStringList { QObject::tr("Name") };
19
18
20 /**
21 * Creates the item associated to a data source
22 * @param dataSource the data source for which to create the item
23 * @return the new item
24 */
25 DataSourceTreeWidgetItem* createTreeWidgetItem(DataSourceItem* dataSource)
26 {
27 // Creates item for the data source
28 auto item = new DataSourceTreeWidgetItem { dataSource };
29 // Generates items for the children of the data source
30 std::for_each(dataSource->cbegin(), dataSource->cend(),
31 [&item](const std::unique_ptr<DataSourceItem>& child) {
32 item->addChild(createTreeWidgetItem(child.get()));
33 });
34 return item;
35 }
36
37 } // namespace
19 } // namespace
38
20
39 DataSourceWidget::DataSourceWidget(QWidget* parent)
21 DataSourceWidget::DataSourceWidget(QWidget* parent)
40 : QWidget { parent }
22 : QWidget { parent }
41 , ui { new Ui::DataSourceWidget }
23 , ui { new Ui::DataSourceWidget }
42 , m_Root { std::make_unique<DataSourceItem>(
43 DataSourceItemType::NODE, QStringLiteral("Sources")) }
44 {
24 {
45 ui->setupUi(this);
25 ui->setupUi(this);
46
26 m_model_proxy.setSourceModel(&(sqpApp->dataSources()));
47 // Set tree properties
27 ui->treeView->setModel(&m_model_proxy);
48 ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
28 ui->treeView->setDragEnabled(true);
49 ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
29 m_model_proxy.setFilterRole(Qt::ToolTipRole);
50 ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
30 m_model_proxy.setRecursiveFilteringEnabled(true);
51
52 // Connection to show a menu when right clicking on the tree
53 connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this,
54 &DataSourceWidget::onTreeMenuRequested);
55
31
56 // Connection to filter tree
32 // Connection to filter tree
57 connect(ui->filterLineEdit, &QLineEdit::textChanged, this, &DataSourceWidget::filterChanged);
33 connect(ui->filterLineEdit, &QLineEdit::textChanged, &m_model_proxy, static_cast<void (QSortFilterProxyModel::*)(const QString&)>(
34 &QSortFilterProxyModel::setFilterRegExp));
58
35
59 // First init
60 updateTreeWidget();
61 }
36 }
62
37
63 DataSourceWidget::~DataSourceWidget() noexcept
38 DataSourceWidget::~DataSourceWidget() noexcept
@@ -65,60 +40,3 DataSourceWidget::~DataSourceWidget() noexcept
65 delete ui;
40 delete ui;
66 }
41 }
67
42
68 void DataSourceWidget::addDataSource(DataSourceItem* dataSource) noexcept
69 {
70 // Merges the data source (without taking its root)
71 if (dataSource)
72 {
73 std::for_each(std::cbegin(*dataSource), std::cend(*dataSource),
74 [this](const auto& child) { this->m_Root->merge(*child.get()); });
75 updateTreeWidget();
76 }
77 }
78
79 void DataSourceWidget::updateTreeWidget() noexcept
80 {
81 ui->treeWidget->clear();
82
83 auto rootItem = createTreeWidgetItem(m_Root.get());
84 ui->treeWidget->addTopLevelItem(rootItem);
85 rootItem->setExpanded(true);
86
87 // Sorts tree
88 ui->treeWidget->setSortingEnabled(true);
89 ui->treeWidget->sortByColumn(0, Qt::AscendingOrder);
90 }
91
92 void DataSourceWidget::filterChanged(const QString& text) noexcept
93 {
94 auto validateItem = [&text](const DataSourceTreeWidgetItem& item) {
95 auto regExp = QRegExp { text, Qt::CaseInsensitive, QRegExp::Wildcard };
96
97 // An item is valid if any of its metadata validates the text filter
98 auto itemMetadata = item.data()->data();
99 auto itemMetadataEnd = itemMetadata.cend();
100 auto acceptFilter
101 = [&regExp](const auto& variant) { return variant.toString().contains(regExp); };
102
103 return std::find_if(itemMetadata.cbegin(), itemMetadataEnd, acceptFilter)
104 != itemMetadataEnd;
105 };
106
107 // Applies filter on tree widget
108 DataSourceTreeWidgetHelper::filter(*ui->treeWidget, validateItem);
109 }
110
111 void DataSourceWidget::onTreeMenuRequested(const QPoint& pos) noexcept
112 {
113 // Retrieves the selected item in the tree, and build the menu from its actions
114 if (auto selectedItem = dynamic_cast<DataSourceTreeWidgetItem*>(ui->treeWidget->itemAt(pos)))
115 {
116 QMenu treeMenu {};
117 treeMenu.addActions(selectedItem->actions());
118
119 if (!treeMenu.isEmpty())
120 {
121 treeMenu.exec(QCursor::pos());
122 }
123 }
124 }
@@ -7,10 +7,9
7 #include "Visualization/VisualizationWidget.h"
7 #include "Visualization/VisualizationWidget.h"
8 #include "Visualization/operations/FindVariableOperation.h"
8 #include "Visualization/operations/FindVariableOperation.h"
9
9
10 #include "DataSource/DataSourceController.h"
11 #include "Variable/VariableController2.h"
10 #include "Variable/VariableController2.h"
12
11
13 #include "Common/MimeTypesDef.h"
12 #include "MimeTypes/MimeTypes.h"
14 #include "Common/VisualizationDef.h"
13 #include "Common/VisualizationDef.h"
15
14
16 #include <QDir>
15 #include <QDir>
@@ -252,10 +251,10 bool DragDropGuiController::checkMimeDataForVisualization(
252
251
253 auto result = false;
252 auto result = false;
254
253
255 if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST))
254 if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
256 {
255 {
257 auto variables = sqpApp->variableController().variables(
256 auto variables = sqpApp->variableController().variables(
258 Variable2::IDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
257 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
259
258
260 if (variables.size() == 1)
259 if (variables.size() == 1)
261 {
260 {
@@ -306,10 +305,10 bool DragDropGuiController::checkMimeDataForVisualization(
306 // result = false: cannot drop multiple variables in the visualisation
305 // result = false: cannot drop multiple variables in the visualisation
307 }
306 }
308 }
307 }
309 else if (mimeData->hasFormat(MIME_TYPE_PRODUCT_LIST))
308 else if (mimeData->hasFormat(MIME::MIME_TYPE_PRODUCT_LIST))
310 {
309 {
311 auto productDataList = sqpApp->dataSourceController().productsDataForMimeData(
310 auto productDataList = MIME::decode(
312 mimeData->data(MIME_TYPE_PRODUCT_LIST));
311 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
313 if (productDataList.count() == 1)
312 if (productDataList.count() == 1)
314 {
313 {
315 result = true;
314 result = true;
@@ -3,7 +3,7
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/datasources.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>
@@ -26,7 +26,8 public:
26 // /////////////////////////////// //
26 // /////////////////////////////// //
27
27
28 // VariableController <-> DataSourceController
28 // VariableController <-> DataSourceController
29 connect(&m_DataSourceController, &DataSourceController::createVariable,
29 connect(&m_DataSources, static_cast<void (DataSources::*)(const QString&, const QVariantHash&,
30 std::shared_ptr<IDataProvider>)>(&DataSources::createVariable),
30 [](const QString& variableName, const QVariantHash& variableMetadata,
31 [](const QString& variableName, const QVariantHash& variableMetadata,
31 std::shared_ptr<IDataProvider> variableProvider) {
32 std::shared_ptr<IDataProvider> variableProvider) {
32 sqpApp->variableController().createVariable(variableName, variableMetadata,
33 sqpApp->variableController().createVariable(variableName, variableMetadata,
@@ -34,8 +35,6 public:
34 });
35 });
35
36
36
37
37 m_DataSourceController.moveToThread(&m_DataSourceControllerThread);
38 m_DataSourceControllerThread.setObjectName("DataSourceControllerThread");
39 m_NetworkController.moveToThread(&m_NetworkControllerThread);
38 m_NetworkController.moveToThread(&m_NetworkControllerThread);
40 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
39 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
41
40
@@ -45,20 +44,17 public:
45
44
46 virtual ~SqpApplicationPrivate()
45 virtual ~SqpApplicationPrivate()
47 {
46 {
48 m_DataSourceControllerThread.quit();
49 m_DataSourceControllerThread.wait();
50
47
51 m_NetworkControllerThread.quit();
48 m_NetworkControllerThread.quit();
52 m_NetworkControllerThread.wait();
49 m_NetworkControllerThread.wait();
53 }
50 }
54
51
55 DataSourceController m_DataSourceController;
52 DataSources m_DataSources;
56 std::shared_ptr<VariableController2> m_VariableController;
53 std::shared_ptr<VariableController2> m_VariableController;
57 TimeController m_TimeController;
54 TimeController m_TimeController;
58 NetworkController m_NetworkController;
55 NetworkController m_NetworkController;
59 CatalogueController m_CatalogueController;
56 CatalogueController m_CatalogueController;
60
57
61 QThread m_DataSourceControllerThread;
62 QThread m_NetworkControllerThread;
58 QThread m_NetworkControllerThread;
63
59
64 DragDropGuiController m_DragDropGuiController;
60 DragDropGuiController m_DragDropGuiController;
@@ -77,17 +73,11 SqpApplication::SqpApplication(int& argc, char** argv)
77
73
78 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
74 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
79
75
80 connect(&impl->m_DataSourceControllerThread, &QThread::started, &impl->m_DataSourceController,
81 &DataSourceController::initialize);
82 connect(&impl->m_DataSourceControllerThread, &QThread::finished, &impl->m_DataSourceController,
83 &DataSourceController::finalize);
84
85 connect(&impl->m_NetworkControllerThread, &QThread::started, &impl->m_NetworkController,
76 connect(&impl->m_NetworkControllerThread, &QThread::started, &impl->m_NetworkController,
86 &NetworkController::initialize);
77 &NetworkController::initialize);
87 connect(&impl->m_NetworkControllerThread, &QThread::finished, &impl->m_NetworkController,
78 connect(&impl->m_NetworkControllerThread, &QThread::finished, &impl->m_NetworkController,
88 &NetworkController::finalize);
79 &NetworkController::finalize);
89
80
90 impl->m_DataSourceControllerThread.start();
91 impl->m_NetworkControllerThread.start();
81 impl->m_NetworkControllerThread.start();
92 }
82 }
93
83
@@ -95,9 +85,14 SqpApplication::~SqpApplication() {}
95
85
96 void SqpApplication::initialize() {}
86 void SqpApplication::initialize() {}
97
87
98 DataSourceController& SqpApplication::dataSourceController() noexcept
88 //DataSourceController& SqpApplication::dataSourceController() noexcept
89 //{
90 // return impl->m_DataSourceController;
91 //}
92
93 DataSources& SqpApplication::dataSources() noexcept
99 {
94 {
100 return impl->m_DataSourceController;
95 return impl->m_DataSources;
101 }
96 }
102
97
103 NetworkController& SqpApplication::networkController() noexcept
98 NetworkController& SqpApplication::networkController() noexcept
@@ -2,7 +2,7
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 <MimeTypes/MimeTypes.h>
6
6
7 #include <DragAndDrop/DragDropGuiController.h>
7 #include <DragAndDrop/DragDropGuiController.h>
8 #include <SqpApplication.h>
8 #include <SqpApplication.h>
@@ -80,7 +80,7 void TimeWidget::onTimeUpdateRequested()
80
80
81 void TimeWidget::dragEnterEvent(QDragEnterEvent* event)
81 void TimeWidget::dragEnterEvent(QDragEnterEvent* event)
82 {
82 {
83 if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE))
83 if (event->mimeData()->hasFormat(MIME::MIME_TYPE_TIME_RANGE))
84 {
84 {
85 event->acceptProposedAction();
85 event->acceptProposedAction();
86 setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}");
86 setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}");
@@ -98,9 +98,9 void TimeWidget::dragLeaveEvent(QDragLeaveEvent* event)
98
98
99 void TimeWidget::dropEvent(QDropEvent* event)
99 void TimeWidget::dropEvent(QDropEvent* event)
100 {
100 {
101 if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE))
101 if (event->mimeData()->hasFormat(MIME::MIME_TYPE_TIME_RANGE))
102 {
102 {
103 auto mimeData = event->mimeData()->data(MIME_TYPE_TIME_RANGE);
103 auto mimeData = event->mimeData()->data(MIME::MIME_TYPE_TIME_RANGE);
104 auto timeRange = TimeController::timeRangeForMimeData(mimeData);
104 auto timeRange = TimeController::timeRangeForMimeData(mimeData);
105
105
106 setTimeRange(timeRange);
106 setTimeRange(timeRange);
@@ -142,7 +142,7 void TimeWidget::mouseMoveEvent(QMouseEvent* event)
142
142
143 auto mimeData = new QMimeData;
143 auto mimeData = new QMimeData;
144 auto timeData = TimeController::mimeDataForTimeRange(timeRange());
144 auto timeData = TimeController::mimeDataForTimeRange(timeRange());
145 mimeData->setData(MIME_TYPE_TIME_RANGE, timeData);
145 mimeData->setData(MIME::MIME_TYPE_TIME_RANGE, timeData);
146
146
147 drag->setMimeData(mimeData);
147 drag->setMimeData(mimeData);
148
148
@@ -1,4 +1,4
1 #include <DataSource/DataSourceController.h>
1 #include <DataSource/datasources.h>
2 #include <Variable/RenameVariableDialog.h>
2 #include <Variable/RenameVariableDialog.h>
3 #include <Variable/VariableController2.h>
3 #include <Variable/VariableController2.h>
4 #include <Variable/VariableInspectorWidget.h>
4 #include <Variable/VariableInspectorWidget.h>
@@ -139,8 +139,8 VariableInspectorWidget::VariableInspectorWidget(QWidget* parent)
139
139
140 m_model = new VariableModel2();
140 m_model = new VariableModel2();
141 ui->tableView->setModel(m_model);
141 ui->tableView->setModel(m_model);
142 connect(m_model, &VariableModel2::createVariable, [](const QVariantHash& productData) {
142 connect(m_model, &VariableModel2::createVariable, [](const QString& productPath) {
143 sqpApp->dataSourceController().requestVariable(productData);
143 sqpApp->dataSources().createVariable(productPath);
144 });
144 });
145 auto vc = &(sqpApp->variableController());
145 auto vc = &(sqpApp->variableController());
146 connect(vc, &VariableController2::variableAdded, m_model, &VariableModel2::variableAdded);
146 connect(vc, &VariableController2::variableAdded, m_model, &VariableModel2::variableAdded);
@@ -13,7 +13,7
13
13
14 #include <Actions/ActionsGuiController.h>
14 #include <Actions/ActionsGuiController.h>
15 #include <Actions/FilteringAction.h>
15 #include <Actions/FilteringAction.h>
16 #include <Common/MimeTypesDef.h>
16 #include <MimeTypes/MimeTypes.h>
17 #include <cpp_utils_qt/cpp_utils_qt.hpp>
17 #include <cpp_utils_qt/cpp_utils_qt.hpp>
18 #include <containers/algorithms.hpp>
18 #include <containers/algorithms.hpp>
19 #include <Data/DateTimeRangeHelper.h>
19 #include <Data/DateTimeRangeHelper.h>
@@ -731,17 +731,17 QMimeData* VisualizationGraphWidget::mimeData(const QPoint& position) const
731 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones
731 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones
732 && selectionZoneItemUnderCursor)
732 && selectionZoneItemUnderCursor)
733 {
733 {
734 mimeData->setData(MIME_TYPE_TIME_RANGE,
734 mimeData->setData(MIME::MIME_TYPE_TIME_RANGE,
735 TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
735 TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
736 mimeData->setData(MIME_TYPE_SELECTION_ZONE,
736 mimeData->setData(MIME::MIME_TYPE_SELECTION_ZONE,
737 TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
737 TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
738 }
738 }
739 else
739 else
740 {
740 {
741 mimeData->setData(MIME_TYPE_GRAPH, QByteArray {});
741 mimeData->setData(MIME::MIME_TYPE_GRAPH, QByteArray {});
742
742
743 auto timeRangeData = TimeController::mimeDataForTimeRange(graphRange());
743 auto timeRangeData = TimeController::mimeDataForTimeRange(graphRange());
744 mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData);
744 mimeData->setData(MIME::MIME_TYPE_TIME_RANGE, timeRangeData);
745 }
745 }
746
746
747 return mimeData;
747 return mimeData;
@@ -7,10 +7,10
7
7
8 #include "Visualization/MacScrollBarStyle.h"
8 #include "Visualization/MacScrollBarStyle.h"
9
9
10 #include "DataSource/DataSourceController.h"
10 #include "DataSource/datasources.h"
11 #include "Variable/VariableController2.h"
11 #include "Variable/VariableController2.h"
12
12
13 #include "Common/MimeTypesDef.h"
13 #include "MimeTypes/MimeTypes.h"
14
14
15 #include "DragAndDrop/DragDropGuiController.h"
15 #include "DragAndDrop/DragDropGuiController.h"
16 #include "SqpApplication.h"
16 #include "SqpApplication.h"
@@ -95,13 +95,13 VisualizationTabWidget::VisualizationTabWidget(const QString& name, QWidget* par
95 ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12);
95 ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12);
96 ui->dragDropContainer->layout()->setSpacing(0);
96 ui->dragDropContainer->layout()->setSpacing(0);
97 ui->dragDropContainer->setMimeType(
97 ui->dragDropContainer->setMimeType(
98 MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
98 MIME::MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
99 ui->dragDropContainer->setMimeType(
99 ui->dragDropContainer->setMimeType(
100 MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Inserted);
100 MIME::MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Inserted);
101 ui->dragDropContainer->setMimeType(
101 ui->dragDropContainer->setMimeType(
102 MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
102 MIME::MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
103 ui->dragDropContainer->setMimeType(
103 ui->dragDropContainer->setMimeType(
104 MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
104 MIME::MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
105
105
106 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
106 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
107 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
107 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
@@ -231,24 +231,24 QLayout& VisualizationTabWidget::tabLayout() const noexcept
231
231
232 void VisualizationTabWidget::dropMimeData(int index, const QMimeData* mimeData)
232 void VisualizationTabWidget::dropMimeData(int index, const QMimeData* mimeData)
233 {
233 {
234 if (mimeData->hasFormat(MIME_TYPE_GRAPH))
234 if (mimeData->hasFormat(MIME::MIME_TYPE_GRAPH))
235 {
235 {
236 impl->dropGraph(index, this);
236 impl->dropGraph(index, this);
237 }
237 }
238 else if (mimeData->hasFormat(MIME_TYPE_ZONE))
238 else if (mimeData->hasFormat(MIME::MIME_TYPE_ZONE))
239 {
239 {
240 impl->dropZone(index, this);
240 impl->dropZone(index, this);
241 }
241 }
242 else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST))
242 else if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
243 {
243 {
244 auto variables = sqpApp->variableController().variables(
244 auto variables = sqpApp->variableController().variables(
245 Variable2::IDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
245 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
246 impl->dropVariables(variables, index, this);
246 impl->dropVariables(variables, index, this);
247 }
247 }
248 else if (mimeData->hasFormat(MIME_TYPE_PRODUCT_LIST))
248 else if (mimeData->hasFormat(MIME::MIME_TYPE_PRODUCT_LIST))
249 {
249 {
250 auto productsData = sqpApp->dataSourceController().productsDataForMimeData(
250 auto productsData = MIME::decode(
251 mimeData->data(MIME_TYPE_PRODUCT_LIST));
251 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
252 impl->dropProducts(productsData, index, this);
252 impl->dropProducts(productsData, index, this);
253 }
253 }
254 else
254 else
@@ -409,7 +409,7 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropProducts(
409 },
409 },
410 Qt::QueuedConnection);
410 Qt::QueuedConnection);
411
411
412 auto productData = productsMetaData.first().toHash();
412 auto productPath = productsMetaData.first().toString();
413 QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
413 QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
414 Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
414 Qt::QueuedConnection, Q_ARG(QString, productPath));
415 }
415 }
@@ -6,12 +6,12
6 #include "Visualization/VisualizationWidget.h"
6 #include "Visualization/VisualizationWidget.h"
7 #include "ui_VisualizationZoneWidget.h"
7 #include "ui_VisualizationZoneWidget.h"
8
8
9 #include "Common/MimeTypesDef.h"
9 #include "MimeTypes/MimeTypes.h"
10 #include "Common/VisualizationDef.h"
10 #include "Common/VisualizationDef.h"
11
11
12 #include <Data/DateTimeRange.h>
12 #include <Data/DateTimeRange.h>
13 #include <Data/DateTimeRangeHelper.h>
13 #include <Data/DateTimeRangeHelper.h>
14 #include <DataSource/DataSourceController.h>
14 #include <DataSource/datasources.h>
15 #include <Time/TimeController.h>
15 #include <Time/TimeController.h>
16 #include <Variable/Variable2.h>
16 #include <Variable/Variable2.h>
17 #include <Variable/VariableController2.h>
17 #include <Variable/VariableController2.h>
@@ -102,17 +102,17 VisualizationZoneWidget::VisualizationZoneWidget(const QString& name, QWidget* p
102
102
103 ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Graph);
103 ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Graph);
104 ui->dragDropContainer->setMimeType(
104 ui->dragDropContainer->setMimeType(
105 MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
105 MIME::MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
106 ui->dragDropContainer->setMimeType(
106 ui->dragDropContainer->setMimeType(
107 MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
107 MIME::MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
108 ui->dragDropContainer->setMimeType(
108 ui->dragDropContainer->setMimeType(
109 MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
109 MIME::MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
110 ui->dragDropContainer->setMimeType(
110 ui->dragDropContainer->setMimeType(
111 MIME_TYPE_TIME_RANGE, VisualizationDragDropContainer::DropBehavior::Merged);
111 MIME::MIME_TYPE_TIME_RANGE, VisualizationDragDropContainer::DropBehavior::Merged);
112 ui->dragDropContainer->setMimeType(
112 ui->dragDropContainer->setMimeType(
113 MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
113 MIME::MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
114 ui->dragDropContainer->setMimeType(
114 ui->dragDropContainer->setMimeType(
115 MIME_TYPE_SELECTION_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
115 MIME::MIME_TYPE_SELECTION_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
116 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
116 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
117 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
117 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
118 mimeData, ui->dragDropContainer);
118 mimeData, ui->dragDropContainer);
@@ -124,10 +124,10 VisualizationZoneWidget::VisualizationZoneWidget(const QString& name, QWidget* p
124 return false;
124 return false;
125 }
125 }
126
126
127 if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST))
127 if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
128 {
128 {
129 auto variables = sqpApp->variableController().variables(
129 auto variables = sqpApp->variableController().variables(
130 Variable2::IDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
130 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
131
131
132 if (variables.size() != 1)
132 if (variables.size() != 1)
133 {
133 {
@@ -388,12 +388,12 QMimeData* VisualizationZoneWidget::mimeData(const QPoint& position) const
388 Q_UNUSED(position);
388 Q_UNUSED(position);
389
389
390 auto mimeData = new QMimeData;
390 auto mimeData = new QMimeData;
391 mimeData->setData(MIME_TYPE_ZONE, QByteArray {});
391 mimeData->setData(MIME::MIME_TYPE_ZONE, QByteArray {});
392
392
393 if (auto firstGraph = this->firstGraph())
393 if (auto firstGraph = this->firstGraph())
394 {
394 {
395 auto timeRangeData = TimeController::mimeDataForTimeRange(firstGraph->graphRange());
395 auto timeRangeData = TimeController::mimeDataForTimeRange(firstGraph->graphRange());
396 mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData);
396 mimeData->setData(MIME::MIME_TYPE_TIME_RANGE, timeRangeData);
397 }
397 }
398
398
399 return mimeData;
399 return mimeData;
@@ -486,20 +486,20 void VisualizationZoneWidget::onVariableAboutToBeRemoved(std::shared_ptr<Variabl
486
486
487 void VisualizationZoneWidget::dropMimeData(int index, const QMimeData* mimeData)
487 void VisualizationZoneWidget::dropMimeData(int index, const QMimeData* mimeData)
488 {
488 {
489 if (mimeData->hasFormat(MIME_TYPE_GRAPH))
489 if (mimeData->hasFormat(MIME::MIME_TYPE_GRAPH))
490 {
490 {
491 impl->dropGraph(index, this);
491 impl->dropGraph(index, this);
492 }
492 }
493 else if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST))
493 else if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
494 {
494 {
495 auto variables = sqpApp->variableController().variables(
495 auto variables = sqpApp->variableController().variables(
496 Variable2::IDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
496 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
497 impl->dropVariables(variables, index, this);
497 impl->dropVariables(variables, index, this);
498 }
498 }
499 else if (mimeData->hasFormat(MIME_TYPE_PRODUCT_LIST))
499 else if (mimeData->hasFormat(MIME::MIME_TYPE_PRODUCT_LIST))
500 {
500 {
501 auto products = sqpApp->dataSourceController().productsDataForMimeData(
501 auto products = MIME::decode(
502 mimeData->data(MIME_TYPE_PRODUCT_LIST));
502 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
503 impl->dropProducts(products, index, this);
503 impl->dropProducts(products, index, this);
504 }
504 }
505 else
505 else
@@ -522,22 +522,22 void VisualizationZoneWidget::dropMimeDataOnGraph(
522 return;
522 return;
523 }
523 }
524
524
525 if (mimeData->hasFormat(MIME_TYPE_VARIABLE_LIST))
525 if (mimeData->hasFormat(MIME::MIME_TYPE_VARIABLE_LIST))
526 {
526 {
527 auto variables = sqpApp->variableController().variables(
527 auto variables = sqpApp->variableController().variables(
528 Variable2::IDs(mimeData->data(MIME_TYPE_VARIABLE_LIST)));
528 Variable2::IDs(mimeData->data(MIME::MIME_TYPE_VARIABLE_LIST)));
529 for (const auto& var : variables)
529 for (const auto& var : variables)
530 {
530 {
531 graphWidget->addVariable(var, graphWidget->graphRange());
531 graphWidget->addVariable(var, graphWidget->graphRange());
532 }
532 }
533 }
533 }
534 else if (mimeData->hasFormat(MIME_TYPE_PRODUCT_LIST))
534 else if (mimeData->hasFormat(MIME::MIME_TYPE_PRODUCT_LIST))
535 {
535 {
536 auto products = sqpApp->dataSourceController().productsDataForMimeData(
536 auto products = MIME::decode(
537 mimeData->data(MIME_TYPE_PRODUCT_LIST));
537 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
538
538
539 auto context = new QObject { this };
539 auto context = new QObject { this };
540 auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME_TYPE_TIME_RANGE));
540 auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME::MIME_TYPE_TIME_RANGE));
541 // BTW this is really dangerous, this assumes the next created variable will be this one...
541 // BTW this is really dangerous, this assumes the next created variable will be this one...
542 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
542 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
543 [this, graphWidget, context, range](auto variable) {
543 [this, graphWidget, context, range](auto variable) {
@@ -558,13 +558,13 void VisualizationZoneWidget::dropMimeDataOnGraph(
558 },
558 },
559 Qt::QueuedConnection);
559 Qt::QueuedConnection);
560
560
561 auto productData = products.first().toHash();
561 auto productPath = products.first().toString();
562 QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
562 QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
563 Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
563 Qt::QueuedConnection, Q_ARG(QString, productPath));
564 }
564 }
565 else if (mimeData->hasFormat(MIME_TYPE_TIME_RANGE))
565 else if (mimeData->hasFormat(MIME::MIME_TYPE_TIME_RANGE))
566 {
566 {
567 auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME_TYPE_TIME_RANGE));
567 auto range = TimeController::timeRangeForMimeData(mimeData->data(MIME::MIME_TYPE_TIME_RANGE));
568 graphWidget->setGraphRange(range, true, true);
568 graphWidget->setGraphRange(range, true, true);
569 }
569 }
570 else
570 else
@@ -689,7 +689,7 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropProducts(
689 },
689 },
690 Qt::QueuedConnection);
690 Qt::QueuedConnection);
691
691
692 auto productData = productsData.first().toHash();
692 auto productPath = productsData.first().toString();
693 QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
693 QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
694 Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
694 Qt::QueuedConnection, Q_ARG(QString, productPath));
695 }
695 }
@@ -18,7 +18,7
18 <widget class="QLineEdit" name="filterLineEdit"/>
18 <widget class="QLineEdit" name="filterLineEdit"/>
19 </item>
19 </item>
20 <item row="1" column="0">
20 <item row="1" column="0">
21 <widget class="DataSourceTreeWidget" name="treeWidget">
21 <widget class="QTreeView" name="treeView">
22 <property name="dragEnabled">
22 <property name="dragEnabled">
23 <bool>true</bool>
23 <bool>true</bool>
24 </property>
24 </property>
@@ -28,22 +28,10
28 <property name="selectionMode">
28 <property name="selectionMode">
29 <enum>QAbstractItemView::ExtendedSelection</enum>
29 <enum>QAbstractItemView::ExtendedSelection</enum>
30 </property>
30 </property>
31 <column>
32 <property name="text">
33 <string notr="true">1</string>
34 </property>
35 </column>
36 </widget>
31 </widget>
37 </item>
32 </item>
38 </layout>
33 </layout>
39 </widget>
34 </widget>
40 <customwidgets>
41 <customwidget>
42 <class>DataSourceTreeWidget</class>
43 <extends>QTreeWidget</extends>
44 <header>DataSource/DataSourceTreeWidget.h</header>
45 </customwidget>
46 </customwidgets>
47 <resources/>
35 <resources/>
48 <connections/>
36 <connections/>
49 </ui>
37 </ui>
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now