From c352dc0e2afa14eb5a6284c23d6d12c97a3befa4 2017-12-14 16:34:35 From: Thibaud Rabillard Date: 2017-12-14 16:34:35 Subject: [PATCH] Change the event model to a treeview model + update the last version of CatalogueAPI --- diff --git a/gui/include/Catalogue/CatalogueEventsTableModel.h b/gui/include/Catalogue/CatalogueEventsModel.h similarity index 76% rename from gui/include/Catalogue/CatalogueEventsTableModel.h rename to gui/include/Catalogue/CatalogueEventsModel.h index 31ce383..1b44d79 100644 --- a/gui/include/Catalogue/CatalogueEventsTableModel.h +++ b/gui/include/Catalogue/CatalogueEventsModel.h @@ -1,24 +1,27 @@ -#ifndef SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H -#define SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H +#ifndef SCIQLOP_CATALOGUEEVENTSMODEL_H +#define SCIQLOP_CATALOGUEEVENTSMODEL_H #include -#include +#include class DBEvent; -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 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; @@ -31,10 +34,9 @@ public: QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; - private: class CatalogueEventsTableModelPrivate; spimpl::unique_impl_ptr impl; }; -#endif // SCIQLOP_CATALOGUEEVENTSTABLEMODEL_H +#endif // SCIQLOP_CATALOGUEEVENTSMODEL_H 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/CatalogueEventsTableModel.cpp b/gui/src/Catalogue/CatalogueEventsModel.cpp similarity index 50% rename from gui/src/Catalogue/CatalogueEventsTableModel.cpp rename to gui/src/Catalogue/CatalogueEventsModel.cpp index c7c1b11..173f4e8 100644 --- a/gui/src/Catalogue/CatalogueEventsTableModel.cpp +++ b/gui/src/Catalogue/CatalogueEventsModel.cpp @@ -1,18 +1,28 @@ -#include "Catalogue/CatalogueEventsTableModel.h" +#include "Catalogue/CatalogueEventsModel.h" #include #include #include +#include #include #include -#include #include #include