##// END OF EJS Templates
Merge branch 'feature/FixCatalogue' into develop
perrinel -
r1319:989011859ba2 merge
parent child
Show More
@@ -5,6 +5,10
5 5
6 6 #include <QDateTime>
7 7
8 /// Format for datetimes
9 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
10 const auto DATETIME_FORMAT_ONE_LINE = QStringLiteral("dd/MM/yyyy hh:mm:ss:zzz");
11
8 12 /**
9 13 * Utility class with methods for dates
10 14 */
@@ -290,6 +290,14 void CatalogueController::saveCatalogue(std::shared_ptr<DBCatalogue> catalogue)
290 290 {
291 291 impl->saveCatalogue(catalogue, true);
292 292 impl->m_KeysWithChanges.remove(impl->catalogueUniqueKey(catalogue));
293
294 // remove key of events of the catalogue
295 if (catalogue->getType() == CatalogueType::STATIC) {
296 auto events = this->retrieveEventsFromCatalogue(catalogue);
297 for (auto event : events) {
298 impl->m_KeysWithChanges.remove(impl->eventUniqueKey(event));
299 }
300 }
293 301 }
294 302
295 303 void CatalogueController::discardCatalogue(std::shared_ptr<DBCatalogue> catalogue, bool &removed)
@@ -52,9 +52,6 const auto COLUMN_PROPERTIES = QHash<int, ColumnProperties>{
52 52 {UNIT_COLUMN, {QObject::tr("Unit")}}, {MISSION_COLUMN, {QObject::tr("Mission")}},
53 53 {PLUGIN_COLUMN, {QObject::tr("Plugin")}}};
54 54
55 /// Format for datetimes
56 const auto DATETIME_FORMAT = QStringLiteral("dd/MM/yyyy \nhh:mm:ss:zzz");
57
58 55 QString uniqueName(const QString &defaultName,
59 56 const std::vector<std::shared_ptr<Variable> > &variables)
60 57 {
@@ -30,6 +30,8 signals:
30 30 void selectionZoneAdded(const std::shared_ptr<DBEvent> &event, const QString &productId,
31 31 VisualizationSelectionZoneItem *selectionZone);
32 32
33 void eventCataloguesModified(const QVector<std::shared_ptr<DBCatalogue> > &catalogues);
34
33 35 public:
34 36 explicit CatalogueEventsWidget(QWidget *parent = 0);
35 37 virtual ~CatalogueEventsWidget();
@@ -38,6 +40,7 public:
38 40
39 41 void addEvent(const std::shared_ptr<DBEvent> &event);
40 42 void setEventChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges);
43 void setEventsChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges);
41 44
42 45 QVector<std::shared_ptr<DBCatalogue> > displayedCatalogues() const;
43 46 bool isAllEventsDisplayed() const;
@@ -51,6 +54,11 public slots:
51 54 void clear();
52 55 void refresh();
53 56
57 // QWidget interface
58 protected:
59 void keyPressEvent(QKeyEvent *event);
60
61
54 62 private:
55 63 Ui::CatalogueEventsWidget *ui;
56 64
@@ -24,6 +24,7 signals:
24 24 void allEventsSelected();
25 25 void trashSelected();
26 26 void selectionCleared();
27 void catalogueSaved(const std::shared_ptr<DBCatalogue> &catalogue);
27 28
28 29 public:
29 30 explicit CatalogueSideBarWidget(QWidget *parent = 0);
@@ -35,6 +36,10 public:
35 36
36 37 QVector<std::shared_ptr<DBCatalogue> > getCatalogues(const QString &repository) const;
37 38
39 // QWidget interface
40 protected:
41 void keyPressEvent(QKeyEvent *event);
42
38 43 private slots:
39 44 void emitSelection();
40 45
1 NO CONTENT: modified file chmod 100644 => 100755, binary diff hidden
@@ -48,13 +48,23 struct CatalogueEventsModel::CatalogueEventsModelPrivate {
48 48 case CatalogueEventsModel::Column::Name:
49 49 return event->getName();
50 50 case CatalogueEventsModel::Column::TStart:
51 return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTStart())
52 : QVariant{};
51 return nbEventProducts(event) > 0
52 ? DateUtils::dateTime(event->getTStart())
53 .toString(DATETIME_FORMAT_ONE_LINE)
54 : QVariant{};
53 55 case CatalogueEventsModel::Column::TEnd:
54 return nbEventProducts(event) > 0 ? DateUtils::dateTime(event->getTEnd())
55 : QVariant{};
56 case CatalogueEventsModel::Column::Product:
57 return QString::number(nbEventProducts(event)) + " product(s)";
56 return nbEventProducts(event) > 0
57 ? DateUtils::dateTime(event->getTEnd())
58 .toString(DATETIME_FORMAT_ONE_LINE)
59 : QVariant{};
60 case CatalogueEventsModel::Column::Product: {
61 auto eventProducts = event->getEventProducts();
62 QStringList eventProductList;
63 for (auto evtProduct : eventProducts) {
64 eventProductList << evtProduct.getProductId();
65 }
66 return eventProductList.join(";");
67 }
58 68 case CatalogueEventsModel::Column::Tags: {
59 69 QString tagList;
60 70 auto tags = event->getTags();
@@ -99,9 +109,11 struct CatalogueEventsModel::CatalogueEventsModelPrivate {
99 109 case CatalogueEventsModel::Column::Name:
100 110 return eventProduct->getProductId();
101 111 case CatalogueEventsModel::Column::TStart:
102 return DateUtils::dateTime(eventProduct->getTStart());
112 return DateUtils::dateTime(eventProduct->getTStart())
113 .toString(DATETIME_FORMAT_ONE_LINE);
103 114 case CatalogueEventsModel::Column::TEnd:
104 return DateUtils::dateTime(eventProduct->getTEnd());
115 return DateUtils::dateTime(eventProduct->getTEnd())
116 .toString(DATETIME_FORMAT_ONE_LINE);
105 117 case CatalogueEventsModel::Column::Product:
106 118 return eventProduct->getProductId();
107 119 case CatalogueEventsModel::Column::Tags:
@@ -19,14 +19,12
19 19
20 20 #include <QDialog>
21 21 #include <QDialogButtonBox>
22 #include <QKeyEvent>
22 23 #include <QListWidget>
23 24 #include <QMessageBox>
24 25
25 26 Q_LOGGING_CATEGORY(LOG_CatalogueEventsWidget, "CatalogueEventsWidget")
26 27
27 /// Fixed size of the validation column
28 const auto VALIDATION_COLUMN_SIZE = 35;
29
30 28 /// Percentage added to the range of a event when it is displayed
31 29 const auto EVENT_RANGE_MARGE = 30; // in %
32 30
@@ -354,6 +352,7 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
354 352 ui->treeView->setDragDropMode(QAbstractItemView::DragDrop);
355 353 ui->treeView->setDragEnabled(true);
356 354
355
357 356 connect(ui->btnTime, &QToolButton::clicked, [this](auto checked) {
358 357 if (checked) {
359 358 ui->btnChart->setChecked(false);
@@ -384,17 +383,37 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
384 383
385 384 if (!events.isEmpty() && eventProducts.isEmpty()) {
386 385
387 if (QMessageBox::warning(this, tr("Remove Event(s)"),
388 tr("The selected event(s) will be permanently removed "
389 "from the repository!\nAre you sure you want to continue?"),
390 QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
391 == QMessageBox::Yes) {
386 auto canRemoveEvent
387 = !this->isAllEventsDisplayed()
388 || (QMessageBox::warning(
389 this, tr("Remove Event(s)"),
390 tr("The selected event(s) will be permanently removed "
391 "from the repository!\nAre you sure you want to continue?"),
392 QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
393 == QMessageBox::Yes);
392 394
395 if (canRemoveEvent) {
393 396 for (auto event : events) {
394 sqpApp->catalogueController().removeEvent(event);
395 impl->removeEvent(event, ui->treeView);
397 if (this->isAllEventsDisplayed()) {
398 sqpApp->catalogueController().removeEvent(event);
399 impl->removeEvent(event, ui->treeView);
400 }
401 else {
402 QVector<std::shared_ptr<DBCatalogue> > modifiedCatalogues;
403 for (auto catalogue : this->displayedCatalogues()) {
404 if (catalogue->removeEvent(event->getUniqId())) {
405 sqpApp->catalogueController().updateCatalogue(catalogue);
406 modifiedCatalogues << catalogue;
407 }
408 }
409 if (!modifiedCatalogues.empty()) {
410 emit eventCataloguesModified(modifiedCatalogues);
411 }
412 }
413 impl->m_Model->removeEvent(event);
396 414 }
397 415
416
398 417 emit this->eventsRemoved(events);
399 418 }
400 419 }
@@ -427,11 +446,13 CatalogueEventsWidget::CatalogueEventsWidget(QWidget *parent)
427 446 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Tags,
428 447 QHeaderView::Stretch);
429 448 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Validation,
430 QHeaderView::Fixed);
449 QHeaderView::ResizeToContents);
431 450 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::Name,
432 451 QHeaderView::Interactive);
433 ui->treeView->header()->resizeSection((int)CatalogueEventsModel::Column::Validation,
434 VALIDATION_COLUMN_SIZE);
452 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::TStart,
453 QHeaderView::ResizeToContents);
454 ui->treeView->header()->setSectionResizeMode((int)CatalogueEventsModel::Column::TEnd,
455 QHeaderView::ResizeToContents);
435 456 ui->treeView->header()->setSortIndicatorShown(true);
436 457
437 458 connect(impl->m_Model, &CatalogueEventsModel::modelSorted, [this]() {
@@ -489,6 +510,8 void CatalogueEventsWidget::setEventChanges(const std::shared_ptr<DBEvent> &even
489 510 emitSelection();
490 511 });
491 512 ui->treeView->setIndexWidget(validationIndex, widget);
513 ui->treeView->header()->resizeSection((int)CatalogueEventsModel::Column::Validation,
514 QHeaderView::ResizeToContents);
492 515 }
493 516 }
494 517 else {
@@ -592,3 +615,15 void CatalogueEventsWidget::emitSelection()
592 615 emit selectionCleared();
593 616 }
594 617 }
618
619
620 void CatalogueEventsWidget::keyPressEvent(QKeyEvent *event)
621 {
622 switch (event->key()) {
623 case Qt::Key_Delete: {
624 ui->btnRemove->click();
625 }
626 default:
627 break;
628 }
629 }
@@ -76,6 +76,9 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
76 76 ui->events->clear();
77 77 });
78 78
79 connect(ui->catalogues, &CatalogueSideBarWidget::catalogueSaved, ui->events,
80 &CatalogueEventsWidget::refresh);
81
79 82 // Updates the inspectot when something is selected in the events
80 83 connect(ui->events, &CatalogueEventsWidget::eventsSelected, [this](auto events) {
81 84 if (events.count() == 1) {
@@ -135,6 +138,13 CatalogueExplorer::CatalogueExplorer(QWidget *parent)
135 138 sqpApp->catalogueController().updateEventProduct(eventProduct);
136 139 ui->events->setEventChanges(event, true);
137 140 });
141
142 connect(ui->events, &CatalogueEventsWidget::eventCataloguesModified,
143 [this](const QVector<std::shared_ptr<DBCatalogue> > &catalogues) {
144 for (auto catalogue : catalogues) {
145 ui->catalogues->setCatalogueChanges(catalogue, true);
146 }
147 });
138 148 }
139 149
140 150 CatalogueExplorer::~CatalogueExplorer()
@@ -3,7 +3,6
3 3 #include <QBoxLayout>
4 4 #include <QToolButton>
5 5
6 const auto VALIDATION_BUTTON_ICON_SIZE = 12;
7 6
8 7 QWidget *CatalogueExplorerHelper::buildValidationWidget(QWidget *parent, std::function<void()> save,
9 8 std::function<void()> discard)
@@ -11,22 +10,21 QWidget *CatalogueExplorerHelper::buildValidationWidget(QWidget *parent, std::fu
11 10 auto widget = new QWidget{parent};
12 11
13 12 auto layout = new QHBoxLayout{widget};
14 layout->setContentsMargins(0, 0, 0, 0);
15 layout->setSpacing(0);
16 13
17 14 auto btnValid = new QToolButton{widget};
18 15 btnValid->setIcon(QIcon{":/icones/save"});
19 btnValid->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE});
20 16 btnValid->setAutoRaise(true);
21 17 QObject::connect(btnValid, &QToolButton::clicked, save);
22 18 layout->addWidget(btnValid);
23 19
24 20 auto btnDiscard = new QToolButton{widget};
25 21 btnDiscard->setIcon(QIcon{":/icones/discard"});
26 btnDiscard->setIconSize(QSize{VALIDATION_BUTTON_ICON_SIZE, VALIDATION_BUTTON_ICON_SIZE});
27 22 btnDiscard->setAutoRaise(true);
28 23 QObject::connect(btnDiscard, &QToolButton::clicked, discard);
29 24 layout->addWidget(btnDiscard);
30 25
26 layout->setContentsMargins(0, 0, 0, 0);
27 layout->setSpacing(0);
28
31 29 return widget;
32 30 }
@@ -28,6 +28,9 CatalogueInspectorWidget::CatalogueInspectorWidget(QWidget *parent)
28 28
29 29 impl->connectCatalogueUpdateSignals(this, ui);
30 30 impl->connectEventUpdateSignals(this, ui);
31
32 ui->dateTimeEventTStart->setDisplayFormat(DATETIME_FORMAT);
33 ui->dateTimeEventTEnd->setDisplayFormat(DATETIME_FORMAT);
31 34 }
32 35
33 36 CatalogueInspectorWidget::~CatalogueInspectorWidget()
@@ -148,8 +151,14 void CatalogueInspectorWidget::setEvent(const std::shared_ptr<DBEvent> &event)
148 151 ui->leEventName->setEnabled(true);
149 152 ui->leEventName->setText(event->getName());
150 153 ui->leEventProduct->setEnabled(false);
151 ui->leEventProduct->setText(
152 QString::number(event->getEventProducts().size()).append(" product(s)"));
154
155 auto eventProducts = event->getEventProducts();
156 QStringList eventProductList;
157 for (auto evtProduct : eventProducts) {
158 eventProductList << evtProduct.getProductId();
159 }
160
161 ui->leEventProduct->setText(eventProductList.join(";"));
153 162
154 163 QString tagList;
155 164 auto tags = event->getTagsNames();
@@ -12,6 +12,7
12 12 #include <ComparaisonPredicate.h>
13 13 #include <DBCatalogue.h>
14 14
15 #include <QKeyEvent>
15 16 #include <QMenu>
16 17 #include <QMessageBox>
17 18 #include <QMimeData>
@@ -110,7 +111,8 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
110 111
111 112 ui->treeView->header()->setStretchLastSection(false);
112 113 ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
113 ui->treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
114 ui->treeView->header()->setSectionResizeMode((int)CatalogueTreeModel::Column::Name,
115 QHeaderView::Stretch);
114 116
115 117 connect(ui->treeView, &QTreeView::clicked, this, &CatalogueSideBarWidget::emitSelection);
116 118 connect(ui->treeView->selectionModel(), &QItemSelectionModel::currentChanged, this,
@@ -175,6 +177,7 CatalogueSideBarWidget::CatalogueSideBarWidget(QWidget *parent)
175 177 catalogueToItem.second,
176 178 impl->m_TreeModel->indexOf(catalogueToItem.second->parent()));
177 179 }
180 emitSelection();
178 181 }
179 182 }
180 183 });
@@ -393,6 +396,7 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::setHasChanges(
393 396 [this, validationIndex, sideBarWidget, catalogue]() {
394 397 if (catalogue) {
395 398 sqpApp->catalogueController().saveCatalogue(catalogue);
399 emit sideBarWidget->catalogueSaved(catalogue);
396 400 }
397 401 setHasChanges(false, validationIndex, sideBarWidget);
398 402 },
@@ -413,6 +417,8 void CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::setHasChanges(
413 417 }
414 418 });
415 419 sideBarWidget->ui->treeView->setIndexWidget(validationIndex, widget);
420 sideBarWidget->ui->treeView->header()->resizeSection(
421 (int)CatalogueTreeModel::Column::Validation, QHeaderView::ResizeToContents);
416 422 }
417 423 }
418 424 else {
@@ -427,3 +433,15 bool CatalogueSideBarWidget::CatalogueSideBarWidgetPrivate::hasChanges(const QMo
427 433 auto validationIndex = index.sibling(index.row(), (int)CatalogueTreeModel::Column::Validation);
428 434 return treeView->indexWidget(validationIndex) != nullptr;
429 435 }
436
437
438 void CatalogueSideBarWidget::keyPressEvent(QKeyEvent *event)
439 {
440 switch (event->key()) {
441 case Qt::Key_Delete: {
442 ui->btnRemove->click();
443 }
444 default:
445 break;
446 }
447 }
@@ -111,16 +111,13 bool CatalogueTreeItem::dropMimeData(const QMimeData *data, Qt::DropAction actio
111 111 if (action == Qt::MoveAction) {
112 112 for (auto catalogue : sourceCatalogues) {
113 113 catalogue->removeEvent(event->getUniqId());
114 sqpApp->catalogueController().updateCatalogue(catalogue);
114 115 }
115 116 }
116 117
117 118 impl->m_Catalogue->addEvent(event->getUniqId());
119 sqpApp->catalogueController().updateCatalogue(impl->m_Catalogue);
118 120 }
119
120 for (auto catalogue : sourceCatalogues) {
121 sqpApp->catalogueController().updateCatalogue(catalogue);
122 }
123 sqpApp->catalogueController().updateCatalogue(impl->m_Catalogue);
124 121 }
125 122
126 123 std::shared_ptr<DBCatalogue> CatalogueTreeItem::catalogue() const
@@ -13,8 +13,6 Q_LOGGING_CATEGORY(LOG_AxisRenderingUtils, "AxisRenderingUtils")
13 13
14 14 namespace {
15 15
16 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss:zzz");
17
18 16 /// Format for datetimes on a axis
19 17 const auto DATETIME_TICKER_FORMAT = QStringLiteral("yyyy/MM/dd \nhh:mm:ss");
20 18
@@ -4,7 +4,7
4 4 #include "Common/DateUtils.h"
5 5 #include "Visualization/VisualizationSelectionZoneItem.h"
6 6
7 const auto DATETIME_FORMAT = QStringLiteral("yyyy/MM/dd hh:mm:ss");
7 const auto DATETIME_FORMAT_S = QStringLiteral("yyyy/MM/dd hh:mm:ss");
8 8
9 9 struct VisualizationMultiZoneSelectionDialog::VisualizationMultiZoneSelectionDialogPrivate {
10 10 QVector<VisualizationSelectionZoneItem *> m_Zones;
@@ -46,9 +46,9 void VisualizationMultiZoneSelectionDialog::setZones(
46 46 }
47 47
48 48 auto range = zone->range();
49 name += DateUtils::dateTime(range.m_TStart).toString(DATETIME_FORMAT);
49 name += DateUtils::dateTime(range.m_TStart).toString(DATETIME_FORMAT_S);
50 50 name += " - ";
51 name += DateUtils::dateTime(range.m_TEnd).toString(DATETIME_FORMAT);
51 name += DateUtils::dateTime(range.m_TEnd).toString(DATETIME_FORMAT_S);
52 52
53 53 auto item = new QListWidgetItem(name, ui->listWidget);
54 54 item->setSelected(zone->selected());
@@ -270,10 +270,10 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
270 270 break;
271 271 }
272 272 graphChild->setFlags(GraphFlag::DisableAll);
273 qCDebug(LOG_VisualizationZoneWidget())
274 << tr("TORM: Range before: ") << graphChild->graphRange();
275 qCDebug(LOG_VisualizationZoneWidget())
276 << tr("TORM: Range after : ") << graphChildRange;
273 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
274 << graphChild->graphRange();
275 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
276 << graphChildRange;
277 277 qCDebug(LOG_VisualizationZoneWidget())
278 278 << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
279 279 graphChild->setGraphRange(graphChildRange);
@@ -139,7 +139,6
139 139 </widget>
140 140 <resources>
141 141 <include location="../../resources/sqpguiresources.qrc"/>
142 <include location="../../resources/sqpguiresources.qrc"/>
143 142 </resources>
144 143 <connections/>
145 144 </ui>
General Comments 0
You need to be logged in to leave comments. Login now