Auto status change to "Under Review"
@@ -72,6 +72,8 public slots: | |||
|
72 | 72 | void initialize(); |
|
73 | 73 | void finalize(); |
|
74 | 74 | |
|
75 | void requestVariable(const QVariantHash &productData); | |
|
76 | ||
|
75 | 77 | signals: |
|
76 | 78 | /// Signal emitted when a structure has been set for a data source |
|
77 | 79 | void dataSourceItemSet(DataSourceItem *dataSourceItem); |
@@ -91,6 +91,14 public: | |||
|
91 | 91 | |
|
92 | 92 | DataSourceItemType type() const noexcept; |
|
93 | 93 | |
|
94 | /** | |
|
95 | * @brief Searches the first child matching the specified data. | |
|
96 | * @param data The data to search. | |
|
97 | * @param recursive So the search recursively. | |
|
98 | * @return the item matching the data or nullptr if it was not found. | |
|
99 | */ | |
|
100 | DataSourceItem *findItem(const QVariantHash &data, bool recursive); | |
|
101 | ||
|
94 | 102 | bool operator==(const DataSourceItem &other); |
|
95 | 103 | bool operator!=(const DataSourceItem &other); |
|
96 | 104 |
@@ -93,6 +93,7 public: | |||
|
93 | 93 | |
|
94 | 94 | signals: |
|
95 | 95 | void abortProgessRequested(std::shared_ptr<Variable> variable); |
|
96 | void requestVariable(const QVariantHash &productData); | |
|
96 | 97 | |
|
97 | 98 | private: |
|
98 | 99 | class VariableModelPrivate; |
@@ -6,6 +6,7 | |||
|
6 | 6 | #include <QMutex> |
|
7 | 7 | #include <QThread> |
|
8 | 8 | |
|
9 | #include <QDataStream> | |
|
9 | 10 | #include <QDir> |
|
10 | 11 | #include <QStandardPaths> |
|
11 | 12 | |
@@ -44,6 +45,20 public: | |||
|
44 | 45 | /// @remarks Data providers are stored as shared_ptr as they can be sent to a variable and |
|
45 | 46 | /// continue to live without necessarily the data source controller |
|
46 | 47 | std::map<QUuid, std::shared_ptr<IDataProvider> > m_DataProviders; |
|
48 | ||
|
49 | // Search for the first datasource item matching the specified data | |
|
50 | DataSourceItem *findDataSourceItem(const QVariantHash &data) | |
|
51 | { | |
|
52 | DataSourceItem *sourceItem = nullptr; | |
|
53 | for (const auto &item : m_DataSourceItems) { | |
|
54 | sourceItem = item.second->findItem(data, true); | |
|
55 | if (sourceItem) { | |
|
56 | break; | |
|
57 | } | |
|
58 | } | |
|
59 | ||
|
60 | return sourceItem; | |
|
61 | } | |
|
47 | 62 | }; |
|
48 | 63 | |
|
49 | 64 | DataSourceController::DataSourceController(QObject *parent) |
@@ -157,6 +172,20 void DataSourceController::finalize() | |||
|
157 | 172 | impl->m_WorkingMutex.unlock(); |
|
158 | 173 | } |
|
159 | 174 | |
|
175 | void DataSourceController::requestVariable(const QVariantHash &productData) | |
|
176 | { | |
|
177 | DataSourceItem *sourceItem = impl->findDataSourceItem(productData); | |
|
178 | ||
|
179 | if (sourceItem) { | |
|
180 | auto sourceName = sourceItem->rootItem().name(); | |
|
181 | auto sourceId = impl->m_DataSources.key(sourceName); | |
|
182 | loadProductItem(sourceId, *sourceItem); | |
|
183 | } | |
|
184 | else { | |
|
185 | qCWarning(LOG_DataSourceController()) << tr("requestVariable, product data not found"); | |
|
186 | } | |
|
187 | } | |
|
188 | ||
|
160 | 189 | void DataSourceController::waitForFinish() |
|
161 | 190 | { |
|
162 | 191 | QMutexLocker locker{&impl->m_WorkingMutex}; |
@@ -123,6 +123,24 DataSourceItemType DataSourceItem::type() const noexcept | |||
|
123 | 123 | return impl->m_Type; |
|
124 | 124 | } |
|
125 | 125 | |
|
126 | DataSourceItem *DataSourceItem::findItem(const QVariantHash &data, bool recursive) | |
|
127 | { | |
|
128 | for (const auto &child : impl->m_Children) { | |
|
129 | if (child->impl->m_Data == data) { | |
|
130 | return child.get(); | |
|
131 | } | |
|
132 | ||
|
133 | if (recursive) { | |
|
134 | auto foundItem = child->findItem(data, true); | |
|
135 | if (foundItem) { | |
|
136 | return foundItem; | |
|
137 | } | |
|
138 | } | |
|
139 | } | |
|
140 | ||
|
141 | return nullptr; | |
|
142 | } | |
|
143 | ||
|
126 | 144 | bool DataSourceItem::operator==(const DataSourceItem &other) |
|
127 | 145 | { |
|
128 | 146 | // Compares items' attributes |
@@ -8,6 +8,7 | |||
|
8 | 8 | |
|
9 | 9 | #include <Data/IDataSeries.h> |
|
10 | 10 | |
|
11 | #include <QDataStream> | |
|
11 | 12 | #include <QMimeData> |
|
12 | 13 | #include <QSize> |
|
13 | 14 | #include <unordered_map> |
@@ -267,7 +268,7 Qt::ItemFlags VariableModel::flags(const QModelIndex &index) const | |||
|
267 | 268 | |
|
268 | 269 | Qt::DropActions VariableModel::supportedDropActions() const |
|
269 | 270 | { |
|
270 | return Qt::MoveAction; | |
|
271 | return Qt::CopyAction | Qt::MoveAction; | |
|
271 | 272 | } |
|
272 | 273 | |
|
273 | 274 | Qt::DropActions VariableModel::supportedDragActions() const |
@@ -304,13 +305,29 QMimeData *VariableModel::mimeData(const QModelIndexList &indexes) const | |||
|
304 | 305 | bool VariableModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, |
|
305 | 306 | int column, const QModelIndex &parent) const |
|
306 | 307 | { |
|
307 | return false; | |
|
308 | // drop of a product | |
|
309 | return data->hasFormat(MIME_TYPE_PRODUCT_LIST); | |
|
308 | 310 | } |
|
309 | 311 | |
|
310 | 312 | bool VariableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, |
|
311 | 313 | const QModelIndex &parent) |
|
312 | 314 | { |
|
313 |
|
|
|
315 | bool dropDone = false; | |
|
316 | ||
|
317 | if (data->hasFormat(MIME_TYPE_PRODUCT_LIST)) { | |
|
318 | QDataStream stream(data->data(MIME_TYPE_PRODUCT_LIST)); | |
|
319 | ||
|
320 | QVariantList productList; | |
|
321 | stream >> productList; | |
|
322 | ||
|
323 | for (auto metaData : productList) { | |
|
324 | emit requestVariable(metaData.toHash()); | |
|
325 | } | |
|
326 | ||
|
327 | dropDone = true; | |
|
328 | } | |
|
329 | ||
|
330 | return dropDone; | |
|
314 | 331 | } |
|
315 | 332 | |
|
316 | 333 | void VariableModel::abortProgress(const QModelIndex &index) |
@@ -129,6 +129,15 DataSourceTreeWidgetItem::DataSourceTreeWidgetItem(QTreeWidget *parent, const Da | |||
|
129 | 129 | auto itemActions = impl->m_Data->actions(); |
|
130 | 130 | std::transform(std::cbegin(itemActions), std::cend(itemActions), |
|
131 | 131 | std::back_inserter(impl->m_Actions), createTreeAction); |
|
132 | ||
|
133 | // Sets the flags of the items | |
|
134 | auto flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; | |
|
135 | if (data->type() == DataSourceItemType::COMPONENT | |
|
136 | || data->type() == DataSourceItemType::PRODUCT) { | |
|
137 | flags |= Qt::ItemIsDragEnabled; | |
|
138 | } | |
|
139 | ||
|
140 | setFlags(flags); | |
|
132 | 141 | } |
|
133 | 142 | |
|
134 | 143 | const DataSourceItem *DataSourceTreeWidgetItem::data() const |
@@ -8,6 +8,7 | |||
|
8 | 8 | #include <Time/TimeController.h> |
|
9 | 9 | #include <Variable/Variable.h> |
|
10 | 10 | #include <Variable/VariableController.h> |
|
11 | #include <Variable/VariableModel.h> | |
|
11 | 12 | #include <Visualization/VisualizationController.h> |
|
12 | 13 | |
|
13 | 14 | Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication") |
@@ -34,6 +35,9 public: | |||
|
34 | 35 | SLOT(createVariable(const QString &, const QVariantHash &, |
|
35 | 36 | std::shared_ptr<IDataProvider>))); |
|
36 | 37 | |
|
38 | connect(m_VariableController->variableModel(), &VariableModel::requestVariable, | |
|
39 | m_DataSourceController.get(), &DataSourceController::requestVariable); | |
|
40 | ||
|
37 | 41 | // VariableController <-> VisualizationController |
|
38 | 42 | connect(m_VariableController.get(), |
|
39 | 43 | SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), |
@@ -294,6 +294,7 void VisualizationTabWidget::VisualizationTabWidgetPrivate::dropVariables( | |||
|
294 | 294 | << tr("VisualizationTabWidget::dropVariables, dropping multiple variables, operation " |
|
295 | 295 | "aborted."); |
|
296 | 296 | return; |
|
297 | } | |
|
297 | 298 | |
|
298 | 299 | tabWidget->createZone(variables, index); |
|
299 | 300 | } |
General Comments 1
You need to be logged in to leave comments.
Login now