Auto status change to "Under Review"
@@ -64,8 +64,11 public: | |||||
64 | */ |
|
64 | */ | |
65 | void loadProductItem(const QUuid &dataSourceUid, const DataSourceItem &productItem) noexcept; |
|
65 | void loadProductItem(const QUuid &dataSourceUid, const DataSourceItem &productItem) noexcept; | |
66 |
|
66 | |||
67 | QByteArray mimeDataForProductsData(const QVariantList &productsData) const; |
|
67 | /// Returns the MIME data associated to a list of product meta data | |
68 | QVariantList productsDataForMimeData(const QByteArray &mimeData) const; |
|
68 | static QByteArray mimeDataForProductsData(const QVariantList &productsData); | |
|
69 | ||||
|
70 | /// Returns the list of meta data contained in a MIME data | |||
|
71 | static QVariantList productsDataForMimeData(const QByteArray &mimeData); | |||
69 |
|
72 | |||
70 | public slots: |
|
73 | public slots: | |
71 | /// Manage init/end of the controller |
|
74 | /// Manage init/end of the controller |
@@ -23,6 +23,12 public: | |||||
23 |
|
23 | |||
24 | SqpRange dateTime() const noexcept; |
|
24 | SqpRange dateTime() const noexcept; | |
25 |
|
25 | |||
|
26 | /// Returns the MIME data associated to a time range | |||
|
27 | static QByteArray mimeDataForTimeRange(const SqpRange &timeRange); | |||
|
28 | ||||
|
29 | /// Returns the time range contained in a MIME data | |||
|
30 | static SqpRange timeRangeForMimeData(const QByteArray &mimeData); | |||
|
31 | ||||
26 | signals: |
|
32 | signals: | |
27 | /// Signal emitted to notify that time parameters has beed updated |
|
33 | /// Signal emitted to notify that time parameters has beed updated | |
28 | void timeUpdated(SqpRange time); |
|
34 | void timeUpdated(SqpRange time); |
@@ -68,7 +68,10 public: | |||||
68 | */ |
|
68 | */ | |
69 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; |
|
69 | void deleteVariables(const QVector<std::shared_ptr<Variable> > &variables) noexcept; | |
70 |
|
70 | |||
|
71 | /// Returns the MIME data associated to a list of variables | |||
71 | QByteArray mimeDataForVariables(const QList<std::shared_ptr<Variable> > &variables) const; |
|
72 | QByteArray mimeDataForVariables(const QList<std::shared_ptr<Variable> > &variables) const; | |
|
73 | ||||
|
74 | /// Returns the list of variables contained in a MIME data | |||
72 | QList<std::shared_ptr<Variable> > variablesForMimeData(const QByteArray &mimeData) const; |
|
75 | QList<std::shared_ptr<Variable> > variablesForMimeData(const QByteArray &mimeData) const; | |
73 |
|
76 | |||
74 | static AcquisitionZoomType getZoomType(const SqpRange &range, const SqpRange &oldRange); |
|
77 | static AcquisitionZoomType getZoomType(const SqpRange &range, const SqpRange &oldRange); |
@@ -139,7 +139,7 void DataSourceController::loadProductItem(const QUuid &dataSourceUid, | |||||
139 | } |
|
139 | } | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 |
QByteArray DataSourceController::mimeDataForProductsData(const QVariantList &productsData) |
|
142 | QByteArray DataSourceController::mimeDataForProductsData(const QVariantList &productsData) | |
143 | { |
|
143 | { | |
144 | QByteArray encodedData; |
|
144 | QByteArray encodedData; | |
145 | QDataStream stream{&encodedData, QIODevice::WriteOnly}; |
|
145 | QDataStream stream{&encodedData, QIODevice::WriteOnly}; | |
@@ -149,7 +149,7 QByteArray DataSourceController::mimeDataForProductsData(const QVariantList &pro | |||||
149 | return encodedData; |
|
149 | return encodedData; | |
150 | } |
|
150 | } | |
151 |
|
151 | |||
152 |
QVariantList DataSourceController::productsDataForMimeData(const QByteArray &mimeData) |
|
152 | QVariantList DataSourceController::productsDataForMimeData(const QByteArray &mimeData) | |
153 | { |
|
153 | { | |
154 | QDataStream stream{mimeData}; |
|
154 | QDataStream stream{mimeData}; | |
155 |
|
155 |
@@ -1,5 +1,7 | |||||
1 | #include "Time/TimeController.h" |
|
1 | #include "Time/TimeController.h" | |
2 |
|
2 | |||
|
3 | #include <QDataStream> | |||
|
4 | ||||
3 | Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController") |
|
5 | Q_LOGGING_CATEGORY(LOG_TimeController, "TimeController") | |
4 |
|
6 | |||
5 | struct TimeController::TimeControllerPrivate { |
|
7 | struct TimeController::TimeControllerPrivate { | |
@@ -18,6 +20,26 SqpRange TimeController::dateTime() const noexcept | |||||
18 | return impl->m_DateTime; |
|
20 | return impl->m_DateTime; | |
19 | } |
|
21 | } | |
20 |
|
22 | |||
|
23 | QByteArray TimeController::mimeDataForTimeRange(const SqpRange &timeRange) | |||
|
24 | { | |||
|
25 | QByteArray encodedData; | |||
|
26 | QDataStream stream{&encodedData, QIODevice::WriteOnly}; | |||
|
27 | ||||
|
28 | stream << timeRange.m_TStart << timeRange.m_TEnd; | |||
|
29 | ||||
|
30 | return encodedData; | |||
|
31 | } | |||
|
32 | ||||
|
33 | SqpRange TimeController::timeRangeForMimeData(const QByteArray &mimeData) | |||
|
34 | { | |||
|
35 | QDataStream stream{mimeData}; | |||
|
36 | ||||
|
37 | SqpRange timeRange; | |||
|
38 | stream >> timeRange.m_TStart >> timeRange.m_TEnd; | |||
|
39 | ||||
|
40 | return timeRange; | |||
|
41 | } | |||
|
42 | ||||
21 | void TimeController::onTimeToUpdate(SqpRange dateTime) |
|
43 | void TimeController::onTimeToUpdate(SqpRange dateTime) | |
22 | { |
|
44 | { | |
23 | impl->m_DateTime = dateTime; |
|
45 | impl->m_DateTime = dateTime; |
@@ -8,7 +8,9 | |||||
8 |
|
8 | |||
9 | #include <Data/IDataSeries.h> |
|
9 | #include <Data/IDataSeries.h> | |
10 |
|
10 | |||
11 | #include <QDataStream> |
|
11 | #include <DataSource/DataSourceController.h> | |
|
12 | #include <Time/TimeController.h> | |||
|
13 | ||||
12 | #include <QMimeData> |
|
14 | #include <QMimeData> | |
13 | #include <QSize> |
|
15 | #include <QSize> | |
14 | #include <unordered_map> |
|
16 | #include <unordered_map> | |
@@ -278,7 +280,7 Qt::DropActions VariableModel::supportedDragActions() const | |||||
278 |
|
280 | |||
279 | QStringList VariableModel::mimeTypes() const |
|
281 | QStringList VariableModel::mimeTypes() const | |
280 | { |
|
282 | { | |
281 | return {MIME_TYPE_VARIABLE_LIST}; |
|
283 | return {MIME_TYPE_VARIABLE_LIST, MIME_TYPE_TIME_RANGE}; | |
282 | } |
|
284 | } | |
283 |
|
285 | |||
284 | QMimeData *VariableModel::mimeData(const QModelIndexList &indexes) const |
|
286 | QMimeData *VariableModel::mimeData(const QModelIndexList &indexes) const | |
@@ -287,17 +289,31 QMimeData *VariableModel::mimeData(const QModelIndexList &indexes) const | |||||
287 |
|
289 | |||
288 | QList<std::shared_ptr<Variable> > variableList; |
|
290 | QList<std::shared_ptr<Variable> > variableList; | |
289 |
|
291 | |||
|
292 | ||||
|
293 | SqpRange firstTimeRange; | |||
290 | for (const auto &index : indexes) { |
|
294 | for (const auto &index : indexes) { | |
291 | if (index.column() == 0) { // only the first column |
|
295 | if (index.column() == 0) { // only the first column | |
292 | auto variable = impl->m_Variables.at(index.row()); |
|
296 | auto variable = impl->m_Variables.at(index.row()); | |
293 | if (variable.get() && index.isValid()) { |
|
297 | if (variable.get() && index.isValid()) { | |
|
298 | ||||
|
299 | if (variableList.isEmpty()) { | |||
|
300 | // Gets the range of the first variable | |||
|
301 | firstTimeRange = std::move(variable->range()); | |||
|
302 | } | |||
|
303 | ||||
294 | variableList << variable; |
|
304 | variableList << variable; | |
295 | } |
|
305 | } | |
296 | } |
|
306 | } | |
297 | } |
|
307 | } | |
298 |
|
308 | |||
299 | auto encodedData = impl->m_VariableController->mimeDataForVariables(variableList); |
|
309 | auto variablesEncodedData = impl->m_VariableController->mimeDataForVariables(variableList); | |
300 | mimeData->setData(MIME_TYPE_VARIABLE_LIST, encodedData); |
|
310 | mimeData->setData(MIME_TYPE_VARIABLE_LIST, variablesEncodedData); | |
|
311 | ||||
|
312 | if (variableList.count() == 1) { | |||
|
313 | // No time range MIME data if multiple variables are dragged | |||
|
314 | auto timeEncodedData = TimeController::mimeDataForTimeRange(firstTimeRange); | |||
|
315 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeEncodedData); | |||
|
316 | } | |||
301 |
|
317 | |||
302 | return mimeData; |
|
318 | return mimeData; | |
303 | } |
|
319 | } | |
@@ -315,10 +331,9 bool VariableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, i | |||||
315 | auto dropDone = false; |
|
331 | auto dropDone = false; | |
316 |
|
332 | |||
317 | if (data->hasFormat(MIME_TYPE_PRODUCT_LIST)) { |
|
333 | if (data->hasFormat(MIME_TYPE_PRODUCT_LIST)) { | |
318 | QDataStream stream(data->data(MIME_TYPE_PRODUCT_LIST)); |
|
|||
319 |
|
334 | |||
320 |
|
|
335 | auto productList | |
321 | stream >> productList; |
|
336 | = DataSourceController::productsDataForMimeData(data->data(MIME_TYPE_PRODUCT_LIST)); | |
322 |
|
337 | |||
323 | for (auto metaData : productList) { |
|
338 | for (auto metaData : productList) { | |
324 | emit requestVariable(metaData.toHash()); |
|
339 | emit requestVariable(metaData.toHash()); |
@@ -16,6 +16,8 public: | |||||
16 | explicit TimeWidget(QWidget *parent = 0); |
|
16 | explicit TimeWidget(QWidget *parent = 0); | |
17 | virtual ~TimeWidget(); |
|
17 | virtual ~TimeWidget(); | |
18 |
|
18 | |||
|
19 | void setTimeRange(SqpRange time); | |||
|
20 | ||||
19 | signals: |
|
21 | signals: | |
20 | /// Signal emitted when the time parameters has beed updated |
|
22 | /// Signal emitted when the time parameters has beed updated | |
21 | void timeUpdated(SqpRange time); |
|
23 | void timeUpdated(SqpRange time); | |
@@ -24,6 +26,11 public slots: | |||||
24 | /// slot called when time parameters update has ben requested |
|
26 | /// slot called when time parameters update has ben requested | |
25 | void onTimeUpdateRequested(); |
|
27 | void onTimeUpdateRequested(); | |
26 |
|
28 | |||
|
29 | protected: | |||
|
30 | void dragEnterEvent(QDragEnterEvent *event) override; | |||
|
31 | void dragLeaveEvent(QDragLeaveEvent *event) override; | |||
|
32 | void dropEvent(QDropEvent *event) override; | |||
|
33 | ||||
27 |
|
34 | |||
28 | private: |
|
35 | private: | |
29 | Ui::TimeWidget *ui; |
|
36 | Ui::TimeWidget *ui; |
@@ -2,9 +2,15 | |||||
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> | |||
|
6 | ||||
5 | #include <SqpApplication.h> |
|
7 | #include <SqpApplication.h> | |
6 | #include <Time/TimeController.h> |
|
8 | #include <Time/TimeController.h> | |
7 |
|
9 | |||
|
10 | #include <QDragEnterEvent> | |||
|
11 | #include <QDropEvent> | |||
|
12 | #include <QMimeData> | |||
|
13 | ||||
8 | TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget} |
|
14 | TimeWidget::TimeWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::TimeWidget} | |
9 | { |
|
15 | { | |
10 | ui->setupUi(this); |
|
16 | ui->setupUi(this); | |
@@ -41,6 +47,15 TimeWidget::~TimeWidget() | |||||
41 | delete ui; |
|
47 | delete ui; | |
42 | } |
|
48 | } | |
43 |
|
49 | |||
|
50 | void TimeWidget::setTimeRange(SqpRange time) | |||
|
51 | { | |||
|
52 | auto startDateTime = DateUtils::dateTime(time.m_TStart); | |||
|
53 | auto endDateTime = DateUtils::dateTime(time.m_TEnd); | |||
|
54 | ||||
|
55 | ui->startDateTimeEdit->setDateTime(startDateTime); | |||
|
56 | ui->endDateTimeEdit->setDateTime(endDateTime); | |||
|
57 | } | |||
|
58 | ||||
44 | void TimeWidget::onTimeUpdateRequested() |
|
59 | void TimeWidget::onTimeUpdateRequested() | |
45 | { |
|
60 | { | |
46 | auto dateTime = SqpRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), |
|
61 | auto dateTime = SqpRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), | |
@@ -48,3 +63,34 void TimeWidget::onTimeUpdateRequested() | |||||
48 |
|
63 | |||
49 | emit timeUpdated(std::move(dateTime)); |
|
64 | emit timeUpdated(std::move(dateTime)); | |
50 | } |
|
65 | } | |
|
66 | ||||
|
67 | void TimeWidget::dragEnterEvent(QDragEnterEvent *event) | |||
|
68 | { | |||
|
69 | if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) { | |||
|
70 | event->acceptProposedAction(); | |||
|
71 | setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}"); | |||
|
72 | } | |||
|
73 | else { | |||
|
74 | event->ignore(); | |||
|
75 | } | |||
|
76 | } | |||
|
77 | ||||
|
78 | void TimeWidget::dragLeaveEvent(QDragLeaveEvent *event) | |||
|
79 | { | |||
|
80 | setStyleSheet(QString()); | |||
|
81 | } | |||
|
82 | ||||
|
83 | void TimeWidget::dropEvent(QDropEvent *event) | |||
|
84 | { | |||
|
85 | if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) { | |||
|
86 | auto mimeData = event->mimeData()->data(MIME_TYPE_TIME_RANGE); | |||
|
87 | auto timeRange = TimeController::timeRangeForMimeData(mimeData); | |||
|
88 | ||||
|
89 | setTimeRange(timeRange); | |||
|
90 | } | |||
|
91 | else { | |||
|
92 | event->ignore(); | |||
|
93 | } | |||
|
94 | ||||
|
95 | setStyleSheet(QString()); | |||
|
96 | } |
@@ -12,6 +12,7 | |||||
12 | #include <DragDropHelper.h> |
|
12 | #include <DragDropHelper.h> | |
13 | #include <Settings/SqpSettingsDefs.h> |
|
13 | #include <Settings/SqpSettingsDefs.h> | |
14 | #include <SqpApplication.h> |
|
14 | #include <SqpApplication.h> | |
|
15 | #include <Time/TimeController.h> | |||
15 | #include <Variable/Variable.h> |
|
16 | #include <Variable/Variable.h> | |
16 | #include <Variable/VariableController.h> |
|
17 | #include <Variable/VariableController.h> | |
17 |
|
18 | |||
@@ -235,6 +236,9 QMimeData *VisualizationGraphWidget::mimeData() const | |||||
235 | auto mimeData = new QMimeData; |
|
236 | auto mimeData = new QMimeData; | |
236 | mimeData->setData(MIME_TYPE_GRAPH, QByteArray{}); |
|
237 | mimeData->setData(MIME_TYPE_GRAPH, QByteArray{}); | |
237 |
|
238 | |||
|
239 | auto timeRangeData = TimeController::mimeDataForTimeRange(graphRange()); | |||
|
240 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData); | |||
|
241 | ||||
238 | return mimeData; |
|
242 | return mimeData; | |
239 | } |
|
243 | } | |
240 |
|
244 |
@@ -10,6 +10,7 | |||||
10 | #include "Common/VisualizationDef.h" |
|
10 | #include "Common/VisualizationDef.h" | |
11 |
|
11 | |||
12 | #include <Data/SqpRange.h> |
|
12 | #include <Data/SqpRange.h> | |
|
13 | #include <Time/TimeController.h> | |||
13 | #include <Variable/Variable.h> |
|
14 | #include <Variable/Variable.h> | |
14 | #include <Variable/VariableController.h> |
|
15 | #include <Variable/VariableController.h> | |
15 |
|
16 | |||
@@ -71,6 +72,21 struct VisualizationZoneWidget::VisualizationZoneWidgetPrivate { | |||||
71 | QUuid m_SynchronisationGroupId; |
|
72 | QUuid m_SynchronisationGroupId; | |
72 | std::unique_ptr<IGraphSynchronizer> m_Synchronizer; |
|
73 | std::unique_ptr<IGraphSynchronizer> m_Synchronizer; | |
73 |
|
74 | |||
|
75 | // Returns the first graph in the zone or nullptr if there is no graph inside | |||
|
76 | VisualizationGraphWidget *firstGraph(const VisualizationZoneWidget *zoneWidget) const | |||
|
77 | { | |||
|
78 | VisualizationGraphWidget *firstGraph = nullptr; | |||
|
79 | auto layout = zoneWidget->ui->dragDropContainer->layout(); | |||
|
80 | if (layout->count() > 0) { | |||
|
81 | if (auto visualizationGraphWidget | |||
|
82 | = qobject_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) { | |||
|
83 | firstGraph = visualizationGraphWidget; | |||
|
84 | } | |||
|
85 | } | |||
|
86 | ||||
|
87 | return firstGraph; | |||
|
88 | } | |||
|
89 | ||||
74 | void dropGraph(int index, VisualizationZoneWidget *zoneWidget); |
|
90 | void dropGraph(int index, VisualizationZoneWidget *zoneWidget); | |
75 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, |
|
91 | void dropVariables(const QList<std::shared_ptr<Variable> > &variables, int index, | |
76 | VisualizationZoneWidget *zoneWidget); |
|
92 | VisualizationZoneWidget *zoneWidget); | |
@@ -238,15 +254,9 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V | |||||
238 | &VisualizationZoneWidget::onVariableAboutToBeRemoved); |
|
254 | &VisualizationZoneWidget::onVariableAboutToBeRemoved); | |
239 |
|
255 | |||
240 | auto range = SqpRange{}; |
|
256 | auto range = SqpRange{}; | |
241 |
|
257 | if (auto firstGraph = impl->firstGraph(this)) { | ||
242 | // Apply visitor to graph children |
|
|||
243 | auto layout = ui->dragDropContainer->layout(); |
|
|||
244 | if (layout->count() > 0) { |
|
|||
245 | // Case of a new graph in a existant zone |
|
258 | // Case of a new graph in a existant zone | |
246 | if (auto visualizationGraphWidget |
|
259 | range = firstGraph->graphRange(); | |
247 | = dynamic_cast<VisualizationGraphWidget *>(layout->itemAt(0)->widget())) { |
|
|||
248 | range = visualizationGraphWidget->graphRange(); |
|
|||
249 | } |
|
|||
250 | } |
|
260 | } | |
251 | else { |
|
261 | else { | |
252 | // Case of a new graph as the first of the zone |
|
262 | // Case of a new graph as the first of the zone | |
@@ -333,6 +343,11 QMimeData *VisualizationZoneWidget::mimeData() const | |||||
333 | auto mimeData = new QMimeData; |
|
343 | auto mimeData = new QMimeData; | |
334 | mimeData->setData(MIME_TYPE_ZONE, QByteArray{}); |
|
344 | mimeData->setData(MIME_TYPE_ZONE, QByteArray{}); | |
335 |
|
345 | |||
|
346 | if (const auto firstGraph = impl->firstGraph(this)) { | |||
|
347 | auto timeRangeData = TimeController::mimeDataForTimeRange(firstGraph->graphRange()); | |||
|
348 | mimeData->setData(MIME_TYPE_TIME_RANGE, timeRangeData); | |||
|
349 | } | |||
|
350 | ||||
336 | return mimeData; |
|
351 | return mimeData; | |
337 | } |
|
352 | } | |
338 |
|
353 |
@@ -16,9 +16,15 | |||||
16 | <verstretch>0</verstretch> |
|
16 | <verstretch>0</verstretch> | |
17 | </sizepolicy> |
|
17 | </sizepolicy> | |
18 | </property> |
|
18 | </property> | |
|
19 | <property name="acceptDrops"> | |||
|
20 | <bool>true</bool> | |||
|
21 | </property> | |||
19 | <property name="windowTitle"> |
|
22 | <property name="windowTitle"> | |
20 | <string>Form</string> |
|
23 | <string>Form</string> | |
21 | </property> |
|
24 | </property> | |
|
25 | <property name="styleSheet"> | |||
|
26 | <string notr="true">b</string> | |||
|
27 | </property> | |||
22 | <layout class="QHBoxLayout" name="horizontalLayout_2"> |
|
28 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | |
23 | <item> |
|
29 | <item> | |
24 | <widget class="QLabel" name="label"> |
|
30 | <widget class="QLabel" name="label"> |
General Comments 3
Pull request updated. Auto status change to "Under Review"
Changed commits: * 1 added * 0 removed Changed files: * A core/tests/meson.build
You need to be logged in to leave comments.
Login now