##// END OF EJS Templates
New data sources system switch complete...
jeandet -
r1495:9c439b3d7daf
parent child
Show More
@@ -2,9 +2,10
2 2 #include <Data/DataProviderParameters.h>
3 3 #include <Data/DataSeriesType.h>
4 4 #include <Data/IDataProvider.h>
5 #include <DataSource/DataSourceController.h>
6 5 #include <DataSource/DataSourceItem.h>
7 6 #include <DataSource/DataSourceItemAction.h>
7 #include <DataSource/datasources.h>
8
8 9 #include <QPair>
9 10 #include <SqpApplication.h>
10 11 // must be included last because of Python/Qt definition of slots
@@ -68,8 +69,8 class PyDataProvider : public IDataProvider
68 69 public:
69 70 PyDataProvider()
70 71 {
71 auto& dataSourceController = sqpApp->dataSourceController();
72 dataSourceController.registerProvider(this);
72 auto& dataSources = sqpApp->dataSources();
73 dataSources.addProvider(this);
73 74 }
74 75
75 76 virtual ~PyDataProvider() {}
@@ -118,12 +119,12 public:
118 119
119 120 inline void register_products(const QVector<Product*>& products)
120 121 {
121 auto& dataSourceController = sqpApp->dataSourceController();
122 auto& dataSources = sqpApp->dataSources();
122 123 auto id = this->id();
123 124 auto data_source_name = this->name();
124 125 std::for_each(std::cbegin(products), std::cend(products),
125 [&id, &dataSourceController](const Product* product) {
126 dataSourceController.setDataSourceItem(id, product->path, product->metadata);
126 [&id, &dataSources](const Product* product) {
127 dataSources.addDataSourceItem(id, product->path, product->metadata);
127 128 });
128 129 }
129 130 };
@@ -24,7 +24,6
24 24
25 25 #include <Catalogue/CatalogueController.h>
26 26 #include <Catalogue2/browser.h>
27 #include <DataSource/DataSourceController.h>
28 27 #include <DataSource/DataSourceItem.h>
29 28 #include <DataSource/DataSourceWidget.h>
30 29 #include <Settings/SqpSettingsDialog.h>
@@ -114,10 +113,6 MainWindow::MainWindow(QWidget* parent)
114 113
115 114 // Widgets / controllers connections
116 115
117 // DataSource
118 connect(&sqpApp->dataSourceController(), &DataSourceController::dataSourceItemSet,
119 m_Ui->dataSourceWidget, &DataSourceWidget::addDataSource);
120
121 116 // Time
122 117 // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
123 118 // SLOT(onTimeToUpdate(DateTimeRange)));
@@ -1,1 +1,1
1 Subproject commit b081849458c211dcc59f72b11542959db2301162
1 Subproject commit 46467fb43b8d07fe4f4a45df949ec4ae858ccf9d
@@ -3,9 +3,10
3 3
4 4 #include <QWidget>
5 5
6 #include <memory>
6 #include <QSortFilterProxyModel>
7 7
8 namespace Ui {
8 namespace Ui
9 {
9 10 class DataSourceWidget;
10 11 } // Ui
11 12
@@ -15,33 +16,20 class DataSourceItem;
15 16 * @brief The DataSourceWidget handles the graphical representation (as a tree) of the data sources
16 17 * attached to SciQlop.
17 18 */
18 class DataSourceWidget : public QWidget {
19 class DataSourceWidget : public QWidget
20 {
19 21 Q_OBJECT
20 22
21 23 public:
22 24 explicit DataSourceWidget(QWidget *parent = 0);
23 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 27 private:
34 28 void updateTreeWidget() noexcept;
35 29
36 30 Ui::DataSourceWidget *ui;
37 std::unique_ptr<DataSourceItem> m_Root;
38
39 private slots:
40 /// Slot called when the filtering text has changed
41 void filterChanged(const QString &text) noexcept;
31 QSortFilterProxyModel m_model_proxy;
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 35 #endif // SCIQLOP_DATASOURCEWIDGET_H
@@ -22,6 +22,7 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
22 22 #define sqpApp (static_cast<SqpApplication*>(QCoreApplication::instance()))
23 23
24 24 class DataSourceController;
25 class DataSources;
25 26 class NetworkController;
26 27 class TimeController;
27 28 class VariableController;
@@ -68,7 +69,8 public:
68 69 void initialize();
69 70
70 71 /// Accessors for the differents sciqlop controllers
71 DataSourceController& dataSourceController() noexcept;
72 //DataSourceController& dataSourceController() noexcept;
73 DataSources& dataSources() noexcept;
72 74 NetworkController& networkController() noexcept;
73 75 TimeController& timeController() noexcept;
74 76 VariableController2& variableController() noexcept;
@@ -7,9 +7,6 gui_moc_headers = [
7 7 './include/DragAndDrop/DragDropScroller.h',
8 8 './include/Settings/SqpSettingsDialog.h',
9 9 './include/Settings/SqpSettingsGeneralWidget.h',
10 './include/DataSource/DataSourceTreeWidgetHelper.h',
11 './include/DataSource/DataSourceTreeWidget.h',
12 './include/DataSource/DataSourceTreeWidgetItem.h',
13 10 './include/DataSource/DataSourceWidget.h',
14 11 './include/Catalogue2/repositoriestreeview.h',
15 12 './include/Catalogue2/browser.h',
@@ -104,10 +101,7 gui_sources = [
104 101 './src/DragAndDrop/DragDropGuiController.cpp',
105 102 './src/Settings/SqpSettingsGeneralWidget.cpp',
106 103 './src/Settings/SqpSettingsDialog.cpp',
107 './src/DataSource/DataSourceTreeWidgetItem.cpp',
108 './src/DataSource/DataSourceTreeWidgetHelper.cpp',
109 104 './src/DataSource/DataSourceWidget.cpp',
110 './src/DataSource/DataSourceTreeWidget.cpp',
111 105 './src/Catalogue2/eventstreeview.cpp',
112 106 './src/Catalogue2/eventeditor.cpp',
113 107 './src/Catalogue2/repositoriestreeview.cpp',
@@ -2,11 +2,10
2 2
3 3 #include <ui_DataSourceWidget.h>
4 4
5 #include <DataSource/DataSourceItem.h>
6 #include <DataSource/DataSourceTreeWidgetHelper.h>
7 #include <DataSource/DataSourceTreeWidgetItem.h>
5 #include <DataSource/datasources.h>
6
7 #include <SqpApplication.h>
8 8
9 #include <QMenu>
10 9
11 10 namespace
12 11 {
@@ -17,47 +16,23 const auto TREE_NB_COLUMNS = 1;
17 16 /// Header labels for the tree
18 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 19 } // namespace
38 20
39 21 DataSourceWidget::DataSourceWidget(QWidget* parent)
40 22 : QWidget { parent }
41 23 , ui { new Ui::DataSourceWidget }
42 , m_Root { std::make_unique<DataSourceItem>(
43 DataSourceItemType::NODE, QStringLiteral("Sources")) }
44 24 {
45 25 ui->setupUi(this);
46
47 // Set tree properties
48 ui->treeWidget->setColumnCount(TREE_NB_COLUMNS);
49 ui->treeWidget->setHeaderLabels(TREE_HEADER_LABELS);
50 ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
51
52 // Connection to show a menu when right clicking on the tree
53 connect(ui->treeWidget, &QTreeWidget::customContextMenuRequested, this,
54 &DataSourceWidget::onTreeMenuRequested);
26 m_model_proxy.setSourceModel(&(sqpApp->dataSources()));
27 ui->treeView->setModel(&m_model_proxy);
28 ui->treeView->setDragEnabled(true);
29 m_model_proxy.setFilterRole(Qt::ToolTipRole);
30 m_model_proxy.setRecursiveFilteringEnabled(true);
55 31
56 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 38 DataSourceWidget::~DataSourceWidget() noexcept
@@ -65,60 +40,3 DataSourceWidget::~DataSourceWidget() noexcept
65 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 7 #include "Visualization/VisualizationWidget.h"
8 8 #include "Visualization/operations/FindVariableOperation.h"
9 9
10 #include "DataSource/DataSourceController.h"
11 10 #include "Variable/VariableController2.h"
12 11
13 #include "Common/MimeTypesDef.h"
12 #include "MimeTypes/MimeTypes.h"
14 13 #include "Common/VisualizationDef.h"
15 14
16 15 #include <QDir>
@@ -252,10 +251,10 bool DragDropGuiController::checkMimeDataForVisualization(
252 251
253 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 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 259 if (variables.size() == 1)
261 260 {
@@ -306,10 +305,10 bool DragDropGuiController::checkMimeDataForVisualization(
306 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(
312 mimeData->data(MIME_TYPE_PRODUCT_LIST));
310 auto productDataList = MIME::decode(
311 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
313 312 if (productDataList.count() == 1)
314 313 {
315 314 result = true;
@@ -3,7 +3,7
3 3 #include <Actions/ActionsGuiController.h>
4 4 #include <Catalogue/CatalogueController.h>
5 5 #include <Data/IDataProvider.h>
6 #include <DataSource/DataSourceController.h>
6 #include <DataSource/datasources.h>
7 7 #include <DragAndDrop/DragDropGuiController.h>
8 8 #include <Network/NetworkController.h>
9 9 #include <QThread>
@@ -26,7 +26,8 public:
26 26 // /////////////////////////////// //
27 27
28 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 31 [](const QString& variableName, const QVariantHash& variableMetadata,
31 32 std::shared_ptr<IDataProvider> variableProvider) {
32 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 38 m_NetworkController.moveToThread(&m_NetworkControllerThread);
40 39 m_NetworkControllerThread.setObjectName("NetworkControllerThread");
41 40
@@ -45,20 +44,17 public:
45 44
46 45 virtual ~SqpApplicationPrivate()
47 46 {
48 m_DataSourceControllerThread.quit();
49 m_DataSourceControllerThread.wait();
50 47
51 48 m_NetworkControllerThread.quit();
52 49 m_NetworkControllerThread.wait();
53 50 }
54 51
55 DataSourceController m_DataSourceController;
52 DataSources m_DataSources;
56 53 std::shared_ptr<VariableController2> m_VariableController;
57 54 TimeController m_TimeController;
58 55 NetworkController m_NetworkController;
59 56 CatalogueController m_CatalogueController;
60 57
61 QThread m_DataSourceControllerThread;
62 58 QThread m_NetworkControllerThread;
63 59
64 60 DragDropGuiController m_DragDropGuiController;
@@ -77,17 +73,11 SqpApplication::SqpApplication(int& argc, char** argv)
77 73
78 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 76 connect(&impl->m_NetworkControllerThread, &QThread::started, &impl->m_NetworkController,
86 77 &NetworkController::initialize);
87 78 connect(&impl->m_NetworkControllerThread, &QThread::finished, &impl->m_NetworkController,
88 79 &NetworkController::finalize);
89 80
90 impl->m_DataSourceControllerThread.start();
91 81 impl->m_NetworkControllerThread.start();
92 82 }
93 83
@@ -95,9 +85,14 SqpApplication::~SqpApplication() {}
95 85
96 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 98 NetworkController& SqpApplication::networkController() noexcept
@@ -2,7 +2,7
2 2 #include "ui_TimeWidget.h"
3 3
4 4 #include <Common/DateUtils.h>
5 #include <Common/MimeTypesDef.h>
5 #include <MimeTypes/MimeTypes.h>
6 6
7 7 #include <DragAndDrop/DragDropGuiController.h>
8 8 #include <SqpApplication.h>
@@ -80,7 +80,7 void TimeWidget::onTimeUpdateRequested()
80 80
81 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 85 event->acceptProposedAction();
86 86 setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}");
@@ -98,9 +98,9 void TimeWidget::dragLeaveEvent(QDragLeaveEvent* event)
98 98
99 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 104 auto timeRange = TimeController::timeRangeForMimeData(mimeData);
105 105
106 106 setTimeRange(timeRange);
@@ -142,7 +142,7 void TimeWidget::mouseMoveEvent(QMouseEvent* event)
142 142
143 143 auto mimeData = new QMimeData;
144 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 147 drag->setMimeData(mimeData);
148 148
@@ -1,4 +1,4
1 #include <DataSource/DataSourceController.h>
1 #include <DataSource/datasources.h>
2 2 #include <Variable/RenameVariableDialog.h>
3 3 #include <Variable/VariableController2.h>
4 4 #include <Variable/VariableInspectorWidget.h>
@@ -139,8 +139,8 VariableInspectorWidget::VariableInspectorWidget(QWidget* parent)
139 139
140 140 m_model = new VariableModel2();
141 141 ui->tableView->setModel(m_model);
142 connect(m_model, &VariableModel2::createVariable, [](const QVariantHash& productData) {
143 sqpApp->dataSourceController().requestVariable(productData);
142 connect(m_model, &VariableModel2::createVariable, [](const QString& productPath) {
143 sqpApp->dataSources().createVariable(productPath);
144 144 });
145 145 auto vc = &(sqpApp->variableController());
146 146 connect(vc, &VariableController2::variableAdded, m_model, &VariableModel2::variableAdded);
@@ -13,7 +13,7
13 13
14 14 #include <Actions/ActionsGuiController.h>
15 15 #include <Actions/FilteringAction.h>
16 #include <Common/MimeTypesDef.h>
16 #include <MimeTypes/MimeTypes.h>
17 17 #include <cpp_utils_qt/cpp_utils_qt.hpp>
18 18 #include <containers/algorithms.hpp>
19 19 #include <Data/DateTimeRangeHelper.h>
@@ -731,17 +731,17 QMimeData* VisualizationGraphWidget::mimeData(const QPoint& position) const
731 731 if (sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones
732 732 && selectionZoneItemUnderCursor)
733 733 {
734 mimeData->setData(MIME_TYPE_TIME_RANGE,
734 mimeData->setData(MIME::MIME_TYPE_TIME_RANGE,
735 735 TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
736 mimeData->setData(MIME_TYPE_SELECTION_ZONE,
736 mimeData->setData(MIME::MIME_TYPE_SELECTION_ZONE,
737 737 TimeController::mimeDataForTimeRange(selectionZoneItemUnderCursor->range()));
738 738 }
739 739 else
740 740 {
741 mimeData->setData(MIME_TYPE_GRAPH, QByteArray {});
741 mimeData->setData(MIME::MIME_TYPE_GRAPH, QByteArray {});
742 742
743 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 747 return mimeData;
@@ -7,10 +7,10
7 7
8 8 #include "Visualization/MacScrollBarStyle.h"
9 9
10 #include "DataSource/DataSourceController.h"
10 #include "DataSource/datasources.h"
11 11 #include "Variable/VariableController2.h"
12 12
13 #include "Common/MimeTypesDef.h"
13 #include "MimeTypes/MimeTypes.h"
14 14
15 15 #include "DragAndDrop/DragDropGuiController.h"
16 16 #include "SqpApplication.h"
@@ -95,13 +95,13 VisualizationTabWidget::VisualizationTabWidget(const QString& name, QWidget* par
95 95 ui->dragDropContainer->layout()->setContentsMargins(0, 0, 0, 12);
96 96 ui->dragDropContainer->layout()->setSpacing(0);
97 97 ui->dragDropContainer->setMimeType(
98 MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
98 MIME::MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
99 99 ui->dragDropContainer->setMimeType(
100 MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Inserted);
100 MIME::MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Inserted);
101 101 ui->dragDropContainer->setMimeType(
102 MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
102 MIME::MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
103 103 ui->dragDropContainer->setMimeType(
104 MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
104 MIME::MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::Inserted);
105 105
106 106 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
107 107 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
@@ -231,24 +231,24 QLayout& VisualizationTabWidget::tabLayout() const noexcept
231 231
232 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 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 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 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 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(
251 mimeData->data(MIME_TYPE_PRODUCT_LIST));
250 auto productsData = MIME::decode(
251 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
252 252 impl->dropProducts(productsData, index, this);
253 253 }
254 254 else
@@ -409,7 +409,7 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropProducts(
409 409 },
410 410 Qt::QueuedConnection);
411 411
412 auto productData = productsMetaData.first().toHash();
413 QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
414 Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
412 auto productPath = productsMetaData.first().toString();
413 QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
414 Qt::QueuedConnection, Q_ARG(QString, productPath));
415 415 }
@@ -6,12 +6,12
6 6 #include "Visualization/VisualizationWidget.h"
7 7 #include "ui_VisualizationZoneWidget.h"
8 8
9 #include "Common/MimeTypesDef.h"
9 #include "MimeTypes/MimeTypes.h"
10 10 #include "Common/VisualizationDef.h"
11 11
12 12 #include <Data/DateTimeRange.h>
13 13 #include <Data/DateTimeRangeHelper.h>
14 #include <DataSource/DataSourceController.h>
14 #include <DataSource/datasources.h>
15 15 #include <Time/TimeController.h>
16 16 #include <Variable/Variable2.h>
17 17 #include <Variable/VariableController2.h>
@@ -102,17 +102,17 VisualizationZoneWidget::VisualizationZoneWidget(const QString& name, QWidget* p
102 102
103 103 ui->dragDropContainer->setPlaceHolderType(DragDropGuiController::PlaceHolderType::Graph);
104 104 ui->dragDropContainer->setMimeType(
105 MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
105 MIME::MIME_TYPE_GRAPH, VisualizationDragDropContainer::DropBehavior::Inserted);
106 106 ui->dragDropContainer->setMimeType(
107 MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
107 MIME::MIME_TYPE_VARIABLE_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
108 108 ui->dragDropContainer->setMimeType(
109 MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
109 MIME::MIME_TYPE_PRODUCT_LIST, VisualizationDragDropContainer::DropBehavior::InsertedAndMerged);
110 110 ui->dragDropContainer->setMimeType(
111 MIME_TYPE_TIME_RANGE, VisualizationDragDropContainer::DropBehavior::Merged);
111 MIME::MIME_TYPE_TIME_RANGE, VisualizationDragDropContainer::DropBehavior::Merged);
112 112 ui->dragDropContainer->setMimeType(
113 MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
113 MIME::MIME_TYPE_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
114 114 ui->dragDropContainer->setMimeType(
115 MIME_TYPE_SELECTION_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
115 MIME::MIME_TYPE_SELECTION_ZONE, VisualizationDragDropContainer::DropBehavior::Forbidden);
116 116 ui->dragDropContainer->setAcceptMimeDataFunction([this](auto mimeData) {
117 117 return sqpApp->dragDropGuiController().checkMimeDataForVisualization(
118 118 mimeData, ui->dragDropContainer);
@@ -124,10 +124,10 VisualizationZoneWidget::VisualizationZoneWidget(const QString& name, QWidget* p
124 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 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 132 if (variables.size() != 1)
133 133 {
@@ -388,12 +388,12 QMimeData* VisualizationZoneWidget::mimeData(const QPoint& position) const
388 388 Q_UNUSED(position);
389 389
390 390 auto mimeData = new QMimeData;
391 mimeData->setData(MIME_TYPE_ZONE, QByteArray {});
391 mimeData->setData(MIME::MIME_TYPE_ZONE, QByteArray {});
392 392
393 393 if (auto firstGraph = this->firstGraph())
394 394 {
395 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 399 return mimeData;
@@ -486,20 +486,20 void VisualizationZoneWidget::onVariableAboutToBeRemoved(std::shared_ptr<Variabl
486 486
487 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 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 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 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(
502 mimeData->data(MIME_TYPE_PRODUCT_LIST));
501 auto products = MIME::decode(
502 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
503 503 impl->dropProducts(products, index, this);
504 504 }
505 505 else
@@ -522,22 +522,22 void VisualizationZoneWidget::dropMimeDataOnGraph(
522 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 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 529 for (const auto& var : variables)
530 530 {
531 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(
537 mimeData->data(MIME_TYPE_PRODUCT_LIST));
536 auto products = MIME::decode(
537 mimeData->data(MIME::MIME_TYPE_PRODUCT_LIST));
538 538
539 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 541 // BTW this is really dangerous, this assumes the next created variable will be this one...
542 542 connect(&sqpApp->variableController(), &VariableController2::variableAdded, context,
543 543 [this, graphWidget, context, range](auto variable) {
@@ -558,13 +558,13 void VisualizationZoneWidget::dropMimeDataOnGraph(
558 558 },
559 559 Qt::QueuedConnection);
560 560
561 auto productData = products.first().toHash();
562 QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
563 Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
561 auto productPath = products.first().toString();
562 QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
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 568 graphWidget->setGraphRange(range, true, true);
569 569 }
570 570 else
@@ -689,7 +689,7 void VisualizationZoneWidget::VisualizationZoneWidgetPrivate::dropProducts(
689 689 },
690 690 Qt::QueuedConnection);
691 691
692 auto productData = productsData.first().toHash();
693 QMetaObject::invokeMethod(&sqpApp->dataSourceController(), "requestVariable",
694 Qt::QueuedConnection, Q_ARG(QVariantHash, productData));
692 auto productPath = productsData.first().toString();
693 QMetaObject::invokeMethod(&sqpApp->dataSources(), "createVariable",
694 Qt::QueuedConnection, Q_ARG(QString, productPath));
695 695 }
@@ -18,7 +18,7
18 18 <widget class="QLineEdit" name="filterLineEdit"/>
19 19 </item>
20 20 <item row="1" column="0">
21 <widget class="DataSourceTreeWidget" name="treeWidget">
21 <widget class="QTreeView" name="treeView">
22 22 <property name="dragEnabled">
23 23 <bool>true</bool>
24 24 </property>
@@ -28,22 +28,10
28 28 <property name="selectionMode">
29 29 <enum>QAbstractItemView::ExtendedSelection</enum>
30 30 </property>
31 <column>
32 <property name="text">
33 <string notr="true">1</string>
34 </property>
35 </column>
36 31 </widget>
37 32 </item>
38 33 </layout>
39 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 35 <resources/>
48 36 <connections/>
49 37 </ui>
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now