##// END OF EJS Templates
graph mode with a "New Zone"
trabillard -
r1377:13ac2b0ff0d5
parent child
Show More
@@ -30,6 +30,8 Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget")
30 /// Percentage added to the range of a event when it is displayed
30 /// Percentage added to the range of a event when it is displayed
31 const auto EVENT_RANGE_MARGE = 30; // in %
31 const auto EVENT_RANGE_MARGE = 30; // in %
32
32
33 const QString NEW_ZONE_TEXT = QStringLiteral("New Zone");
34
33 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
35 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
34
36
35 CatalogueEventsModel *m_Model = nullptr;
37 CatalogueEventsModel *m_Model = nullptr;
@@ -82,19 +84,25 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
82 }
84 }
83
85
84 QStringList selectZone(QWidget *parent, const QStringList &selectedZones,
86 QStringList selectZone(QWidget *parent, const QStringList &selectedZones,
85 bool allowMultiSelection, const QPoint &location)
87 bool allowMultiSelection, bool addNewZoneOption, const QPoint &location)
86 {
88 {
87 auto availableZones = getAvailableVisualizationZoneList();
89 auto availableZones = getAvailableVisualizationZoneList();
88 if (availableZones.isEmpty()) {
90 if (!addNewZoneOption && availableZones.isEmpty()) {
89 return QStringList{};
91 return QStringList{};
90 }
92 }
91
93
92 QActionGroup actionGroup{parent};
94 QActionGroup actionGroup{parent};
93 actionGroup.setExclusive(!allowMultiSelection);
95 actionGroup.setExclusive(!allowMultiSelection);
94
96
97 QVector<QAction *> zoneActions;
98
95 QMenu selectionMenu{parent};
99 QMenu selectionMenu{parent};
100
101 if (addNewZoneOption) {
102 availableZones.prepend(NEW_ZONE_TEXT);
103 }
104
96 selectionMenu.addSeparator();
105 selectionMenu.addSeparator();
97 QVector<QAction *> zoneActions;
98 for (auto zone : availableZones) {
106 for (auto zone : availableZones) {
99 auto zoneAction = selectionMenu.addAction(zone);
107 auto zoneAction = selectionMenu.addAction(zone);
100 zoneAction->setCheckable(true);
108 zoneAction->setCheckable(true);
@@ -103,11 +111,11 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
103 zoneActions << zoneAction;
111 zoneActions << zoneAction;
104 }
112 }
105
113
106 auto action = selectionMenu.exec(QCursor::pos());
114 auto resultAction = selectionMenu.exec(QCursor::pos());
107
115
108 QStringList result;
116 QStringList result;
109
117
110 if (action == nullptr) {
118 if (resultAction == nullptr) {
111 result = selectedZones;
119 result = selectedZones;
112 }
120 }
113 else {
121 else {
@@ -222,8 +230,9 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
222 return;
230 return;
223 }
231 }
224
232
233 auto isNewZone = m_ZoneForGraphMode == NEW_ZONE_TEXT;
225 auto zone = tab->getZoneWithName(m_ZoneForGraphMode);
234 auto zone = tab->getZoneWithName(m_ZoneForGraphMode);
226 if (!zone) {
235 if (!isNewZone && !zone) {
227 qCWarning(LOG_CatalogueEventsWidget()) << "updateGraphMode: zone not found";
236 qCWarning(LOG_CatalogueEventsWidget()) << "updateGraphMode: zone not found";
228 return;
237 return;
229 }
238 }
@@ -240,7 +249,15 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
240 m_CustomGraphs.clear();
249 m_CustomGraphs.clear();
241
250
242 // Closes the remaining graphs inside the zone
251 // Closes the remaining graphs inside the zone
252 if (zone) {
243 zone->closeAllGraphs();
253 zone->closeAllGraphs();
254 }
255
256 // Creates the zone if needed
257 if (isNewZone) {
258 zone = tab->createEmptyZone(0);
259 m_ZoneForGraphMode = zone->name();
260 }
244
261
245 // Calculates the range of each graph which will be created
262 // Calculates the range of each graph which will be created
246 auto graphRange = getGraphRanges(event);
263 auto graphRange = getGraphRanges(event);
@@ -327,7 +344,7 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
327 if (checked) {
344 if (checked) {
328 ui->btnChart->setChecked(false);
345 ui->btnChart->setChecked(false);
329 impl->m_ZonesForTimeMode
346 impl->m_ZonesForTimeMode
330 = impl->selectZone(this, impl->m_ZonesForTimeMode, true,
347 = impl->selectZone(this, impl->m_ZonesForTimeMode, true, false,
331 this->mapToGlobal(ui->btnTime->frameGeometry().center()));
348 this->mapToGlobal(ui->btnTime->frameGeometry().center()));
332
349
333 impl->updateForTimeMode(ui->treeView);
350 impl->updateForTimeMode(ui->treeView);
@@ -337,8 +354,9 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
337 connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) {
354 connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) {
338 if (checked) {
355 if (checked) {
339 ui->btnTime->setChecked(false);
356 ui->btnTime->setChecked(false);
357
340 impl->m_ZoneForGraphMode
358 impl->m_ZoneForGraphMode
341 = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false,
359 = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false, true,
342 this->mapToGlobal(ui->btnChart->frameGeometry().center()))
360 this->mapToGlobal(ui->btnChart->frameGeometry().center()))
343 .value(0);
361 .value(0);
344
362
General Comments 0
You need to be logged in to leave comments. Login now