From 17cb73ee00c876829b135c7cf7817b2657c1ba3c 2017-12-14 16:42:04 From: Thibaud Rabillard Date: 2017-12-14 16:42:04 Subject: [PATCH] Merge branch 'feature/CatalogueGuiPart2' into develop --- diff --git a/gui/include/Catalogue/CatalogueEventsTableModel.h b/gui/include/Catalogue/CatalogueEventsModel.h similarity index 53% rename from gui/include/Catalogue/CatalogueEventsTableModel.h rename to gui/include/Catalogue/CatalogueEventsModel.h index 9bab0a7..bc0bd70 100644 --- a/gui/include/Catalogue/CatalogueEventsTableModel.h +++ b/gui/include/Catalogue/CatalogueEventsModel.h @@ -1,22 +1,31 @@ -#ifndef SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H -#define SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H +#ifndef SCIQLOP_CATALOGUEEVENTSMODEL_H +#define SCIQLOP_CATALOGUEEVENTSMODEL_H #include -#include +#include class DBEvent; +class DBEventProduct; -class CatalogueEventsTableModel : public QAbstractTableModel { +class CatalogueEventsModel : public QAbstractItemModel { public: - CatalogueEventsTableModel(QObject *parent = nullptr); + CatalogueEventsModel(QObject *parent = nullptr); void setEvents(const QVector > &events); - std::shared_ptr getEvent(int row) const; + void addEvent(const std::shared_ptr &event); + void removeEvent(const std::shared_ptr &event); - void addEvent(const std::shared_ptr &events); - void removeEvent(const std::shared_ptr &events); + enum class ItemType { Root, Event, EventProduct }; + ItemType itemTypeOf(const QModelIndex &index) const; + std::shared_ptr getEvent(const QModelIndex &index) const; + std::shared_ptr getParentEvent(const QModelIndex &index) const; + std::shared_ptr getEventProduct(const QModelIndex &index) const; + + void refreshEvent(const std::shared_ptr &event); // Model + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; @@ -29,10 +38,9 @@ public: QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; - private: - class CatalogueEventsTableModelPrivate; - spimpl::unique_impl_ptr impl; + class CatalogueEventsModelPrivate; + spimpl::unique_impl_ptr impl; }; -#endif // SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H +#endif // SCIQLOP_CATALOGUEEVENTSMODEL_H diff --git a/gui/include/Catalogue/CatalogueEventsWidget.h b/gui/include/Catalogue/CatalogueEventsWidget.h index 04fa2af..e7ce270 100644 --- a/gui/include/Catalogue/CatalogueEventsWidget.h +++ b/gui/include/Catalogue/CatalogueEventsWidget.h @@ -7,6 +7,7 @@ class DBCatalogue; class DBEvent; +class DBEventProduct; class VisualizationWidget; namespace Ui { @@ -20,6 +21,10 @@ class CatalogueEventsWidget : public QWidget { signals: void eventsSelected(const QVector > &event); + void eventProductsSelected( + const QVector, std::shared_ptr > > + &eventproducts); + void selectionCleared(); public: explicit CatalogueEventsWidget(QWidget *parent = 0); @@ -27,6 +32,8 @@ public: void setVisualizationWidget(VisualizationWidget *visualization); + void setEventChanges(const std::shared_ptr &event, bool hasChanges); + public slots: void populateWithCatalogues(const QVector > &catalogues); diff --git a/gui/include/Catalogue/CatalogueInspectorWidget.h b/gui/include/Catalogue/CatalogueInspectorWidget.h index c049a81..51c42b9 100644 --- a/gui/include/Catalogue/CatalogueInspectorWidget.h +++ b/gui/include/Catalogue/CatalogueInspectorWidget.h @@ -1,6 +1,7 @@ #ifndef SCIQLOP_CATALOGUEINSPECTORWIDGET_H #define SCIQLOP_CATALOGUEINSPECTORWIDGET_H +#include #include #include @@ -10,10 +11,17 @@ class CatalogueInspectorWidget; class DBCatalogue; class DBEvent; +class DBEventProduct; class CatalogueInspectorWidget : public QWidget { Q_OBJECT +signals: + void catalogueUpdated(const std::shared_ptr &catalogue); + void eventUpdated(const std::shared_ptr &event); + void eventProductUpdated(const std::shared_ptr &event, + const std::shared_ptr &eventProduct); + public: explicit CatalogueInspectorWidget(QWidget *parent = 0); virtual ~CatalogueInspectorWidget(); @@ -24,6 +32,8 @@ public: Page currentPage() const; void setEvent(const std::shared_ptr &event); + void setEventProduct(const std::shared_ptr &event, + const std::shared_ptr &eventProduct); void setCatalogue(const std::shared_ptr &catalogue); public slots: @@ -31,6 +41,9 @@ public slots: private: Ui::CatalogueInspectorWidget *ui; + + class CatalogueInspectorWidgetPrivate; + spimpl::unique_impl_ptr impl; }; #endif // SCIQLOP_CATALOGUEINSPECTORWIDGET_H diff --git a/gui/include/Catalogue/CatalogueSideBarWidget.h b/gui/include/Catalogue/CatalogueSideBarWidget.h index f762c3b..0af2b26 100644 --- a/gui/include/Catalogue/CatalogueSideBarWidget.h +++ b/gui/include/Catalogue/CatalogueSideBarWidget.h @@ -2,6 +2,7 @@ #define SCIQLOP_CATALOGUESIDEBARWIDGET_H #include +#include #include #include @@ -11,6 +12,8 @@ namespace Ui { class CatalogueSideBarWidget; } +Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueSideBarWidget) + class CatalogueSideBarWidget : public QWidget { Q_OBJECT @@ -25,6 +28,8 @@ public: explicit CatalogueSideBarWidget(QWidget *parent = 0); virtual ~CatalogueSideBarWidget(); + void setCatalogueChanges(const std::shared_ptr &catalogue, bool hasChanges); + private: Ui::CatalogueSideBarWidget *ui; diff --git a/gui/include/Catalogue/CatalogueTreeWidgetItem.h b/gui/include/Catalogue/CatalogueTreeWidgetItem.h index 60ea055..a8b4f14 100644 --- a/gui/include/Catalogue/CatalogueTreeWidgetItem.h +++ b/gui/include/Catalogue/CatalogueTreeWidgetItem.h @@ -18,8 +18,13 @@ public: /// Returns the catalogue represented by the item std::shared_ptr catalogue() const; + /// Displays or hides the save and cancel buttons indicating that the catalogue has unsaved + /// changes void setHasChanges(bool value); + /// Refreshes the data displayed by the item from the catalogue + void refresh(); + private: class CatalogueTreeWidgetItemPrivate; spimpl::unique_impl_ptr impl; diff --git a/gui/include/Visualization/VisualizationMultiZoneSelectionDialog.h b/gui/include/Visualization/VisualizationMultiZoneSelectionDialog.h index f3ebcfb..9e17083 100644 --- a/gui/include/Visualization/VisualizationMultiZoneSelectionDialog.h +++ b/gui/include/Visualization/VisualizationMultiZoneSelectionDialog.h @@ -15,7 +15,7 @@ class VisualizationMultiZoneSelectionDialog : public QDialog { public: explicit VisualizationMultiZoneSelectionDialog(QWidget *parent = 0); - ~VisualizationMultiZoneSelectionDialog(); + virtual ~VisualizationMultiZoneSelectionDialog(); void setZones(const QVector &zones); QMap selectedZones() const; diff --git a/gui/meson.build b/gui/meson.build index f7bf8af..727fa0d 100644 --- a/gui/meson.build +++ b/gui/meson.build @@ -108,7 +108,7 @@ gui_sources = [ 'src/Catalogue/CatalogueSideBarWidget.cpp', 'src/Catalogue/CatalogueInspectorWidget.cpp', 'src/Catalogue/CatalogueTreeWidgetItem.cpp', - 'src/Catalogue/CatalogueEventsTableModel.cpp' + 'src/Catalogue/CatalogueEventsModel.cpp' ] gui_inc = include_directories(['include']) diff --git a/gui/src/Catalogue/CatalogueEventsModel.cpp b/gui/src/Catalogue/CatalogueEventsModel.cpp new file mode 100644 index 0000000..ad78d41 --- /dev/null +++ b/gui/src/Catalogue/CatalogueEventsModel.cpp @@ -0,0 +1,381 @@ +#include "Catalogue/CatalogueEventsModel.h" + +#include +#include +#include +#include +#include +#include +#include +#include