CatalogueEventsModel.h
68 lines
| 2.7 KiB
| text/x-c
|
CLexer
r1182 | #ifndef SCIQLOP_CATALOGUEEVENTSMODEL_H | |||
#define SCIQLOP_CATALOGUEEVENTSMODEL_H | ||||
r1163 | ||||
#include <Common/spimpl.h> | ||||
r1182 | #include <QAbstractItemModel> | |||
r1194 | #include <QLoggingCategory> | |||
#include <unordered_set> | ||||
r1163 | ||||
r1176 | class DBEvent; | |||
r1183 | class DBEventProduct; | |||
r1163 | ||||
r1194 | Q_DECLARE_LOGGING_CATEGORY(LOG_CatalogueEventsModel) | |||
r1182 | class CatalogueEventsModel : public QAbstractItemModel { | |||
r1194 | Q_OBJECT | |||
signals: | ||||
void modelSorted(); | ||||
r1163 | public: | |||
r1182 | CatalogueEventsModel(QObject *parent = nullptr); | |||
r1163 | ||||
r1194 | enum class Column { Name, TStart, TEnd, Tags, Product, Validation, NbColumn }; | |||
r1176 | void setEvents(const QVector<std::shared_ptr<DBEvent> > &events); | |||
r1181 | void addEvent(const std::shared_ptr<DBEvent> &event); | |||
void removeEvent(const std::shared_ptr<DBEvent> &event); | ||||
r1194 | QVector<std::shared_ptr<DBEvent> > events() const; | |||
r1181 | ||||
r1183 | enum class ItemType { Root, Event, EventProduct }; | |||
ItemType itemTypeOf(const QModelIndex &index) const; | ||||
std::shared_ptr<DBEvent> getEvent(const QModelIndex &index) const; | ||||
std::shared_ptr<DBEvent> getParentEvent(const QModelIndex &index) const; | ||||
std::shared_ptr<DBEventProduct> getEventProduct(const QModelIndex &index) const; | ||||
r1194 | /// Refresh the data for the specified event | |||
r1277 | void refreshEvent(const std::shared_ptr<DBEvent> &event, bool refreshEventProducts = false); | |||
r1163 | ||||
r1194 | /// Returns a QModelIndex which represent the specified event | |||
QModelIndex indexOf(const std::shared_ptr<DBEvent> &event) const; | ||||
/// Marks a change flag on the specified event to allow sorting on the validation column | ||||
void setEventHasChanges(const std::shared_ptr<DBEvent> &event, bool hasChanges); | ||||
/// Returns true if the specified event has unsaved changes | ||||
bool eventsHasChanges(const std::shared_ptr<DBEvent> &event) const; | ||||
r1163 | // Model | |||
r1182 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; | |||
QModelIndex parent(const QModelIndex &index) const; | ||||
r1163 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | |||
int columnCount(const QModelIndex &parent = QModelIndex()) const override; | ||||
Qt::ItemFlags flags(const QModelIndex &index) const override; | ||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||||
QVariant headerData(int section, Qt::Orientation orientation, | ||||
int role = Qt::DisplayRole) const override; | ||||
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; | ||||
r1166 | Qt::DropActions supportedDragActions() const override; | |||
QStringList mimeTypes() const override; | ||||
QMimeData *mimeData(const QModelIndexList &indexes) const override; | ||||
r1163 | private: | |||
r1183 | class CatalogueEventsModelPrivate; | |||
spimpl::unique_impl_ptr<CatalogueEventsModelPrivate> impl; | ||||
r1163 | }; | |||
r1182 | #endif // SCIQLOP_CATALOGUEEVENTSMODEL_H | |||