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