##// END OF EJS Templates
small gui improvements
trabillard -
r1293:7c4b1f434cd6
parent child
Show More
@@ -1,418 +1,420
1 1 #include "Catalogue/CatalogueEventsWidget.h"
2 2 #include "ui_CatalogueEventsWidget.h"
3 3
4 4 #include <Catalogue/CatalogueController.h>
5 5 #include <Catalogue/CatalogueEventsModel.h>
6 6 #include <Catalogue/CatalogueExplorerHelper.h>
7 7 #include <CatalogueDao.h>
8 8 #include <DBCatalogue.h>
9 9 #include <SqpApplication.h>
10 10 #include <Visualization/VisualizationTabWidget.h>
11 11 #include <Visualization/VisualizationWidget.h>
12 12 #include <Visualization/VisualizationZoneWidget.h>
13 13
14 14 #include <QDialog>
15 15 #include <QDialogButtonBox>
16 16 #include <QListWidget>
17 17
18 18 Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget")
19 19
20 20 /// Fixed size of the validation column
21 21 const auto VALIDATION_COLUMN_SIZE = 35;
22 22
23 23 struct CatalogueEventsWidget::CatalogueEventsWidgetPrivate {
24 24
25 25 CatalogueEventsModel *m_Model = nullptr;
26 26 QStringList m_ZonesForTimeMode;
27 27 QString m_ZoneForGraphMode;
28 28 QVector<std::shared_ptr<DBCatalogue> > m_DisplayedCatalogues;
29 29
30 30 VisualizationWidget *m_VisualizationWidget = nullptr;
31 31
32 32 void setEvents(const QVector<std::shared_ptr<DBEvent> > &events, CatalogueEventsWidget *widget)
33 33 {
34 34 widget->ui->treeView->setSortingEnabled(false);
35 35 m_Model->setEvents(events);
36 36 widget->ui->treeView->setSortingEnabled(true);
37 37
38 38 for (auto event : events) {
39 39 if (sqpApp->catalogueController().eventHasChanges(event)) {
40 40 auto index = m_Model->indexOf(event);
41 41 widget->setEventChanges(event, true);
42 42 }
43 43 }
44 44 }
45 45
46 46 void addEvent(const std::shared_ptr<DBEvent> &event, QTreeView *treeView)
47 47 {
48 48 treeView->setSortingEnabled(false);
49 49 m_Model->addEvent(event);
50 50 treeView->setSortingEnabled(true);
51 51 }
52 52
53 53 void removeEvent(const std::shared_ptr<DBEvent> &event, QTreeView *treeView)
54 54 {
55 55 treeView->setSortingEnabled(false);
56 56 m_Model->removeEvent(event);
57 57 treeView->setSortingEnabled(true);
58 58 }
59 59
60 60 QStringList getAvailableVisualizationZoneList() const
61 61 {
62 62 if (m_VisualizationWidget) {
63 63 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
64 64 return tab->availableZoneWidgets();
65 65 }
66 66 }
67 67
68 68 return QStringList{};
69 69 }
70 70
71 71 QStringList selectZone(QWidget *parent, const QStringList &selectedZones,
72 72 bool allowMultiSelection, const QPoint &location)
73 73 {
74 74 auto availableZones = getAvailableVisualizationZoneList();
75 75 if (availableZones.isEmpty()) {
76 76 return QStringList{};
77 77 }
78 78
79 79 QDialog d(parent, Qt::Tool);
80 80 d.setWindowTitle("Choose a zone");
81 81 auto layout = new QVBoxLayout{&d};
82 82 layout->setContentsMargins(0, 0, 0, 0);
83 83 auto listWidget = new QListWidget{&d};
84 84 layout->addWidget(listWidget);
85 85
86 86 QSet<QListWidgetItem *> checkedItems;
87 87 for (auto zone : availableZones) {
88 88 auto item = new QListWidgetItem{zone};
89 89 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
90 90 if (selectedZones.contains(zone)) {
91 91 item->setCheckState(Qt::Checked);
92 92 checkedItems << item;
93 93 }
94 94 else {
95 95 item->setCheckState(Qt::Unchecked);
96 96 }
97 97
98 98 listWidget->addItem(item);
99 99 }
100 100
101 101 auto buttonBox = new QDialogButtonBox{QDialogButtonBox::Ok, &d};
102 102 layout->addWidget(buttonBox);
103 103
104 104 QObject::connect(buttonBox, &QDialogButtonBox::accepted, &d, &QDialog::accept);
105 105 QObject::connect(buttonBox, &QDialogButtonBox::rejected, &d, &QDialog::reject);
106 106
107 107 QObject::connect(listWidget, &QListWidget::itemChanged,
108 108 [&checkedItems, allowMultiSelection, listWidget](auto item) {
109 109 if (item->checkState() == Qt::Checked) {
110 110 if (!allowMultiSelection) {
111 111 for (auto checkedItem : checkedItems) {
112 112 listWidget->blockSignals(true);
113 113 checkedItem->setCheckState(Qt::Unchecked);
114 114 listWidget->blockSignals(false);
115 115 }
116 116
117 117 checkedItems.clear();
118 118 }
119 119 checkedItems << item;
120 120 }
121 121 else {
122 122 checkedItems.remove(item);
123 123 }
124 124 });
125 125
126 126 QStringList result;
127 127
128 128 d.setMinimumWidth(120);
129 129 d.resize(d.minimumSizeHint());
130 130 d.move(location);
131 131 if (d.exec() == QDialog::Accepted) {
132 132 for (auto item : checkedItems) {
133 133 result += item->text();
134 134 }
135 135 }
136 136 else {
137 137 result = selectedZones;
138 138 }
139 139
140 140 return result;
141 141 }
142 142
143 143 void updateForTimeMode(QTreeView *treeView)
144 144 {
145 145 auto selectedRows = treeView->selectionModel()->selectedRows();
146 146
147 147 if (selectedRows.count() == 1) {
148 148 auto event = m_Model->getEvent(selectedRows.first());
149 149 if (event) {
150 150 if (m_VisualizationWidget) {
151 151 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
152 152
153 153 for (auto zoneName : m_ZonesForTimeMode) {
154 154 if (auto zone = tab->getZoneWithName(zoneName)) {
155 155 SqpRange eventRange;
156 156 eventRange.m_TStart = event->getTStart();
157 157 eventRange.m_TEnd = event->getTEnd();
158 158 zone->setZoneRange(eventRange);
159 159 }
160 160 }
161 161 }
162 162 else {
163 163 qCWarning(LOG_CatalogueEventsWidget())
164 164 << "updateTimeZone: no tab found in the visualization";
165 165 }
166 166 }
167 167 else {
168 168 qCWarning(LOG_CatalogueEventsWidget())
169 169 << "updateTimeZone: visualization widget not found";
170 170 }
171 171 }
172 172 }
173 173 else {
174 174 qCWarning(LOG_CatalogueEventsWidget())
175 175 << "updateTimeZone: not compatible with multiple events selected";
176 176 }
177 177 }
178 178
179 179 void updateForGraphMode(QTreeView *treeView)
180 180 {
181 181 auto selectedRows = treeView->selectionModel()->selectedRows();
182 182
183 183 if (selectedRows.count() == 1) {
184 184 auto event = m_Model->getEvent(selectedRows.first());
185 185 if (m_VisualizationWidget) {
186 186 if (auto tab = m_VisualizationWidget->currentTabWidget()) {
187 187 if (auto zone = tab->getZoneWithName(m_ZoneForGraphMode)) {
188 188 // TODO
189 189 }
190 190 }
191 191 else {
192 192 qCWarning(LOG_CatalogueEventsWidget())
193 193 << "updateGraphMode: no tab found in the visualization";
194 194 }
195 195 }
196 196 else {
197 197 qCWarning(LOG_CatalogueEventsWidget())
198 198 << "updateGraphMode: visualization widget not found";
199 199 }
200 200 }
201 201 else {
202 202 qCWarning(LOG_CatalogueEventsWidget())
203 203 << "updateGraphMode: not compatible with multiple events selected";
204 204 }
205 205 }
206 206 };
207 207
208 208 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
209 209 : QWidget(parent),
210 210 ui(new Ui::CatalogueEventsWidget),
211 211 impl{spimpl::make_unique_impl<CatalogueEventsWidgetPrivate>()}
212 212 {
213 213 ui->setupUi(this);
214 214
215 215 impl->m_Model = new CatalogueEventsModel{this};
216 216 ui->treeView->setModel(impl->m_Model);
217 217
218 218 ui->treeView->setSortingEnabled(true);
219 219 ui->treeView->setDragDropMode(QAbstractItemView::DragDrop);
220 220 ui->treeView->setDragEnabled(true);
221 221
222 222 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
223 223 if (checked) {
224 224 ui->btnChart->setChecked(false);
225 225 impl->m_ZonesForTimeMode
226 226 = impl->selectZone(this, impl->m_ZonesForTimeMode, true,
227 227 this->mapToGlobal(ui->btnTime->frameGeometry().center()));
228 228
229 229 impl->updateForTimeMode(ui->treeView);
230 230 }
231 231 });
232 232
233 233 connect(ui->btnChart, &QToolButton::clicked, [this](auto checked) {
234 234 if (checked) {
235 235 ui->btnTime->setChecked(false);
236 236 impl->m_ZoneForGraphMode
237 237 = impl->selectZone(this, {impl->m_ZoneForGraphMode}, false,
238 238 this->mapToGlobal(ui->btnChart->frameGeometry().center()))
239 239 .value(0);
240 240
241 241 impl->updateForGraphMode(ui->treeView);
242 242 }
243 243 });
244 244
245 245 auto emitSelection = [this]() {
246 246 QVector<std::shared_ptr<DBEvent> > events;
247 247 QVector<QPair<std::shared_ptr<DBEvent>, std::shared_ptr<DBEventProduct> > > eventProducts;
248 248
249 249 for (auto rowIndex : ui->treeView->selectionModel()->selectedRows()) {
250 250
251 251 auto itemType = impl->m_Model->itemTypeOf(rowIndex);
252 252 if (itemType == CatalogueEventsModel::ItemType::Event) {
253 253 events << impl->m_Model->getEvent(rowIndex);
254 254 }
255 255 else if (itemType == CatalogueEventsModel::ItemType::EventProduct) {
256 256 eventProducts << qMakePair(impl->m_Model->getParentEvent(rowIndex),
257 257 impl->m_Model->getEventProduct(rowIndex));
258 258 }
259 259 }
260 260
261 261 if (!events.isEmpty() && eventProducts.isEmpty()) {
262 262 emit this->eventsSelected(events);
263 263 }
264 264 else if (events.isEmpty() && !eventProducts.isEmpty()) {
265 265 emit this->eventProductsSelected(eventProducts);
266 266 }
267 267 else {
268 268 emit this->selectionCleared();
269 269 }
270 270 };
271 271
272 272 connect(ui->treeView, &QTreeView::clicked, emitSelection);
273 273 connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, emitSelection);
274 274
275 275 connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, [this]() {
276 276 auto isNotMultiSelection = ui->treeView->selectionModel()->selectedRows().count() <= 1;
277 277 ui->btnChart->setEnabled(isNotMultiSelection);
278 278 ui->btnTime->setEnabled(isNotMultiSelection);
279 279
280 280 if (isNotMultiSelection && ui->btnTime->isChecked()) {
281 281 impl->updateForTimeMode(ui->treeView);
282 282 }
283 283 else if (isNotMultiSelection && ui->btnChart->isChecked()) {
284 284 impl->updateForGraphMode(ui->treeView);
285 285 }
286 286 });
287 287
288 288 ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
289 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Name,
289 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Tags,
290 290 QHeaderView::Stretch);
291 291 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Validation,
292 292 QHeaderView::Fixed);
293 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Name,
294 QHeaderView::Interactive);
293 295 ui->treeView->header()->resizeSection((int)CatalogueEventsModel::Column::Validation,
294 296 VALIDATION_COLUMN_SIZE);
295 297 ui->treeView->header()->setSortIndicatorShown(true);
296 298
297 299 connect(impl->m_Model, &CatalogueEventsModel::modelSorted, [this]() {
298 300 auto allEvents = impl->m_Model->events();
299 301 for (auto event : allEvents) {
300 302 setEventChanges(event, sqpApp->catalogueController().eventHasChanges(event));
301 303 }
302 304 });
303 305
304 306 populateWithAllEvents();
305 307 }
306 308
307 309 CatalogueEventsWidget::~CatalogueEventsWidget()
308 310 {
309 311 delete ui;
310 312 }
311 313
312 314 void CatalogueEventsWidget::setVisualizationWidget(VisualizationWidget *visualization)
313 315 {
314 316 impl->m_VisualizationWidget = visualization;
315 317 }
316 318
317 319 void CatalogueEventsWidget::addEvent(const std::shared_ptr<DBEvent> &event)
318 320 {
319 321 impl->addEvent(event, ui->treeView);
320 322 }
321 323
322 324 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges)
323 325 {
324 326 impl->m_Model->refreshEvent(event);
325 327
326 328 auto eventIndex = impl->m_Model->indexOf(event);
327 329 auto validationIndex
328 330 = eventIndex.sibling(eventIndex.row(), (int)CatalogueEventsModel::Column::Validation);
329 331
330 332 if (validationIndex.isValid()) {
331 333 if (hasChanges) {
332 334 if (ui->treeView->indexWidget(validationIndex) == nullptr) {
333 335 auto widget = CatalogueExplorerHelper::buildValidationWidget(
334 336 ui->treeView,
335 337 [this, event]() {
336 338 sqpApp->catalogueController().saveEvent(event);
337 339 setEventChanges(event, false);
338 340 },
339 341 [this, event]() { setEventChanges(event, false); });
340 342 ui->treeView->setIndexWidget(validationIndex, widget);
341 343 }
342 344 }
343 345 else {
344 346 // Note: the widget is destroyed
345 347 ui->treeView->setIndexWidget(validationIndex, nullptr);
346 348 }
347 349 }
348 350 else {
349 351 qCWarning(LOG_CatalogueEventsWidget())
350 352 << "setEventChanges: the event is not displayed in the model.";
351 353 }
352 354 }
353 355
354 356 QVector<std::shared_ptr<DBCatalogue> > CatalogueEventsWidget::displayedCatalogues() const
355 357 {
356 358 return impl->m_DisplayedCatalogues;
357 359 }
358 360
359 361 bool CatalogueEventsWidget::isAllEventsDisplayed() const
360 362 {
361 363 return impl->m_DisplayedCatalogues.isEmpty() && !impl->m_Model->events().isEmpty();
362 364 }
363 365
364 366 bool CatalogueEventsWidget::isEventDisplayed(const std::shared_ptr<DBEvent> &event) const
365 367 {
366 368 return impl->m_Model->indexOf(event).isValid();
367 369 }
368 370
369 371 void CatalogueEventsWidget::populateWithCatalogues(
370 372 const QVector<std::shared_ptr<DBCatalogue> > &catalogues)
371 373 {
372 374 impl->m_DisplayedCatalogues = catalogues;
373 375
374 376 QSet<QUuid> eventIds;
375 377 QVector<std::shared_ptr<DBEvent> > events;
376 378
377 379 for (auto catalogue : catalogues) {
378 380 auto catalogueEvents = sqpApp->catalogueController().retrieveEventsFromCatalogue(catalogue);
379 381 for (auto event : catalogueEvents) {
380 382 if (!eventIds.contains(event->getUniqId())) {
381 383 events << event;
382 384 eventIds.insert(event->getUniqId());
383 385 }
384 386 }
385 387 }
386 388
387 389 impl->setEvents(events, this);
388 390 }
389 391
390 392 void CatalogueEventsWidget::populateWithAllEvents()
391 393 {
392 394 impl->m_DisplayedCatalogues.clear();
393 395
394 396 auto allEvents = sqpApp->catalogueController().retrieveAllEvents();
395 397
396 398 QVector<std::shared_ptr<DBEvent> > events;
397 399 for (auto event : allEvents) {
398 400 events << event;
399 401 }
400 402
401 403 impl->setEvents(events, this);
402 404 }
403 405
404 406 void CatalogueEventsWidget::clear()
405 407 {
406 408 impl->m_DisplayedCatalogues.clear();
407 409 impl->setEvents({}, this);
408 410 }
409 411
410 412 void CatalogueEventsWidget::refresh()
411 413 {
412 414 if (impl->m_DisplayedCatalogues.isEmpty()) {
413 415 populateWithAllEvents();
414 416 }
415 417 else {
416 418 populateWithCatalogues(impl->m_DisplayedCatalogues);
417 419 }
418 420 }
@@ -1,211 +1,211
1 1 #include "Catalogue/CatalogueInspectorWidget.h"
2 2 #include "ui_CatalogueInspectorWidget.h"
3 3
4 4 #include <Common/DateUtils.h>
5 5 #include <DBCatalogue.h>
6 6 #include <DBEvent.h>
7 7 #include <DBEventProduct.h>
8 8 #include <DBTag.h>
9 9
10 10 struct CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate {
11 11 std::shared_ptr<DBCatalogue> m_DisplayedCatalogue = nullptr;
12 12 std::shared_ptr<DBEvent> m_DisplayedEvent = nullptr;
13 13 std::shared_ptr<DBEventProduct> m_DisplayedEventProduct = nullptr;
14 14
15 15 void connectCatalogueUpdateSignals(CatalogueInspectorWidget *inspector,
16 16 Ui::CatalogueInspectorWidget *ui);
17 17 void connectEventUpdateSignals(CatalogueInspectorWidget *inspector,
18 18 Ui::CatalogueInspectorWidget *ui);
19 19 };
20 20
21 21 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
22 22 : QWidget(parent),
23 23 ui(new Ui::CatalogueInspectorWidget),
24 24 impl{spimpl::make_unique_impl<CatalogueInspectorWidgetPrivate>()}
25 25 {
26 26 ui->setupUi(this);
27 27 showPage(Page::Empty);
28 28
29 29 impl->connectCatalogueUpdateSignals(this, ui);
30 30 impl->connectEventUpdateSignals(this, ui);
31 31 }
32 32
33 33 CatalogueInspectorWidget::~CatalogueInspectorWidget()
34 34 {
35 35 delete ui;
36 36 }
37 37
38 38 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectCatalogueUpdateSignals(
39 39 CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
40 40 {
41 41 connect(ui->leCatalogueName, &QLineEdit::editingFinished, [ui, inspector, this]() {
42 42 if (ui->leCatalogueName->text() != m_DisplayedCatalogue->getName()) {
43 43 m_DisplayedCatalogue->setName(ui->leCatalogueName->text());
44 44 emit inspector->catalogueUpdated(m_DisplayedCatalogue);
45 45 }
46 46 });
47 47
48 48 connect(ui->leCatalogueAuthor, &QLineEdit::editingFinished, [ui, inspector, this]() {
49 49 if (ui->leCatalogueAuthor->text() != m_DisplayedCatalogue->getAuthor()) {
50 50 m_DisplayedCatalogue->setAuthor(ui->leCatalogueAuthor->text());
51 51 emit inspector->catalogueUpdated(m_DisplayedCatalogue);
52 52 }
53 53 });
54 54 }
55 55
56 56 void CatalogueInspectorWidget::CatalogueInspectorWidgetPrivate::connectEventUpdateSignals(
57 57 CatalogueInspectorWidget *inspector, Ui::CatalogueInspectorWidget *ui)
58 58 {
59 59 connect(ui->leEventName, &QLineEdit::editingFinished, [ui, inspector, this]() {
60 60 if (ui->leEventName->text() != m_DisplayedEvent->getName()) {
61 61 m_DisplayedEvent->setName(ui->leEventName->text());
62 62 emit inspector->eventUpdated(m_DisplayedEvent);
63 63 }
64 64 });
65 65
66 66 connect(ui->leEventTags, &QLineEdit::editingFinished, [ui, inspector, this]() {
67 67 auto tags = ui->leEventTags->text().split(QRegExp("\\s+"));
68 68 std::list<QString> tagNames;
69 69 for (auto tag : tags) {
70 70 tagNames.push_back(tag);
71 71 }
72 72
73 73 if (m_DisplayedEvent->getTagsNames() != tagNames) {
74 74 m_DisplayedEvent->setTagsNames(tagNames);
75 75 emit inspector->eventUpdated(m_DisplayedEvent);
76 76 }
77 77 });
78 78
79 79 connect(ui->leEventProduct, &QLineEdit::editingFinished, [ui, inspector, this]() {
80 80 if (ui->leEventProduct->text() != m_DisplayedEventProduct->getProductId()) {
81 81 auto oldProductId = m_DisplayedEventProduct->getProductId();
82 82 m_DisplayedEventProduct->setProductId(ui->leEventProduct->text());
83 83
84 84 auto eventProducts = m_DisplayedEvent->getEventProducts();
85 85 for (auto &eventProduct : eventProducts) {
86 86 if (eventProduct.getProductId() == oldProductId) {
87 87 eventProduct.setProductId(m_DisplayedEventProduct->getProductId());
88 88 }
89 89 }
90 90 m_DisplayedEvent->setEventProducts(eventProducts);
91 91
92 92 emit inspector->eventUpdated(m_DisplayedEvent);
93 93 }
94 94 });
95 95
96 96 connect(ui->dateTimeEventTStart, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
97 97 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTStart->dateTime());
98 98 if (time != m_DisplayedEventProduct->getTStart()) {
99 99 m_DisplayedEventProduct->setTStart(time);
100 100
101 101 auto eventProducts = m_DisplayedEvent->getEventProducts();
102 102 for (auto &eventProduct : eventProducts) {
103 103 if (eventProduct.getProductId() == m_DisplayedEventProduct->getProductId()) {
104 104 eventProduct.setTStart(m_DisplayedEventProduct->getTStart());
105 105 }
106 106 }
107 107 m_DisplayedEvent->setEventProducts(eventProducts);
108 108
109 109 emit inspector->eventUpdated(m_DisplayedEvent);
110 110 }
111 111 });
112 112
113 113 connect(ui->dateTimeEventTEnd, &QDateTimeEdit::editingFinished, [ui, inspector, this]() {
114 114 auto time = DateUtils::secondsSinceEpoch(ui->dateTimeEventTEnd->dateTime());
115 115 if (time != m_DisplayedEventProduct->getTEnd()) {
116 116 m_DisplayedEventProduct->setTEnd(time);
117 117
118 118 auto eventProducts = m_DisplayedEvent->getEventProducts();
119 119 for (auto &eventProduct : eventProducts) {
120 120 if (eventProduct.getProductId() == m_DisplayedEventProduct->getProductId()) {
121 121 eventProduct.setTEnd(m_DisplayedEventProduct->getTEnd());
122 122 }
123 123 }
124 124 m_DisplayedEvent->setEventProducts(eventProducts);
125 125
126 126 emit inspector->eventUpdated(m_DisplayedEvent);
127 127 }
128 128 });
129 129 }
130 130
131 131 void CatalogueInspectorWidget::showPage(CatalogueInspectorWidget::Page page)
132 132 {
133 133 ui->stackedWidget->setCurrentIndex(static_cast<int>(page));
134 134 }
135 135
136 136 CatalogueInspectorWidget::Page CatalogueInspectorWidget::currentPage() const
137 137 {
138 138 return static_cast<Page>(ui->stackedWidget->currentIndex());
139 139 }
140 140
141 141 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event)
142 142 {
143 143 impl->m_DisplayedEvent = event;
144 144
145 145 blockSignals(true);
146 146
147 147 showPage(Page::EventProperties);
148 148 ui->leEventName->setEnabled(true);
149 149 ui->leEventName->setText(event->getName());
150 150 ui->leEventProduct->setEnabled(false);
151 151 ui->leEventProduct->setText(
152 152 QString::number(event->getEventProducts().size()).append(" product(s)"));
153 153
154 154 QString tagList;
155 155 auto tags = event->getTagsNames();
156 156 for (auto tag : tags) {
157 157 tagList += tag;
158 158 tagList += ' ';
159 159 }
160 160
161 161 ui->leEventTags->setEnabled(true);
162 162 ui->leEventTags->setText(tagList);
163 163
164 164 ui->dateTimeEventTStart->setEnabled(false);
165 165 ui->dateTimeEventTEnd->setEnabled(false);
166 166
167 167 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(event->getTStart()));
168 168 ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(event->getTEnd()));
169 169
170 170 blockSignals(false);
171 171 }
172 172
173 173 void CatalogueInspectorWidget::setEventProduct(const std::shared_ptr<DBEvent> &event,
174 174 const std::shared_ptr<DBEventProduct> &eventProduct)
175 175 {
176 176
177 177 impl->m_DisplayedEvent = event;
178 178 impl->m_DisplayedEventProduct = eventProduct;
179 179
180 180 blockSignals(true);
181 181
182 182 showPage(Page::EventProperties);
183 183 ui->leEventName->setEnabled(false);
184 184 ui->leEventName->setText(event->getName());
185 ui->leEventProduct->setEnabled(true);
185 ui->leEventProduct->setEnabled(false);
186 186 ui->leEventProduct->setText(eventProduct->getProductId());
187 187
188 188 ui->leEventTags->setEnabled(false);
189 189 ui->leEventTags->clear();
190 190
191 191 ui->dateTimeEventTStart->setEnabled(true);
192 192 ui->dateTimeEventTEnd->setEnabled(true);
193 193
194 194 ui->dateTimeEventTStart->setDateTime(DateUtils::dateTime(eventProduct->getTStart()));
195 195 ui->dateTimeEventTEnd->setDateTime(DateUtils::dateTime(eventProduct->getTEnd()));
196 196
197 197 blockSignals(false);
198 198 }
199 199
200 200 void CatalogueInspectorWidget::setCatalogue(const std::shared_ptr<DBCatalogue> &catalogue)
201 201 {
202 202 impl->m_DisplayedCatalogue = catalogue;
203 203
204 204 blockSignals(true);
205 205
206 206 showPage(Page::CatalogueProperties);
207 207 ui->leCatalogueName->setText(catalogue->getName());
208 208 ui->leCatalogueAuthor->setText(catalogue->getAuthor());
209 209
210 210 blockSignals(false);
211 211 }
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

Status change > Approved

You need to be logged in to leave comments. Login now