VariableModel2.h
79 lines
| 2.6 KiB
| text/x-c
|
CLexer
r21 | #ifndef SCIQLOP_VARIABLEMODEL2_H | |||
#define SCIQLOP_VARIABLEMODEL2_H | ||||
#include "CoreGlobal.h" | ||||
r67 | #include <Common/MetaTypes.h> | |||
#include <Common/spimpl.h> | ||||
r21 | #include <Data/DateTimeRange.h> | |||
#include <QAbstractTableModel> | ||||
#include <QLoggingCategory> | ||||
r67 | #include <QUuid> | |||
r21 | ||||
class IDataSeries; | ||||
r67 | class Variable2; | |||
r21 | class VariableController2; | |||
r67 | enum VariableRoles | |||
{ | ||||
ProgressRole = Qt::UserRole | ||||
}; | ||||
r26 | ||||
r21 | /** | |||
r67 | * @brief The VariableModel class aims to hold the variables that have been | |||
* created in SciQlop | ||||
r21 | */ | |||
r67 | class SCIQLOP_CORE_EXPORT VariableModel2 : public QAbstractTableModel | |||
{ | ||||
Q_OBJECT | ||||
// read only mirror of VariableController2 content | ||||
std::vector<std::shared_ptr<Variable2>> _variables; | ||||
r21 | public: | |||
r67 | explicit VariableModel2(QObject* parent = nullptr); | |||
r21 | ||||
r67 | // /////////////////////////// // | |||
// QAbstractTableModel methods // | ||||
// /////////////////////////// // | ||||
r21 | ||||
r67 | virtual int | |||
columnCount(const QModelIndex& parent = QModelIndex{}) const override; | ||||
virtual int | ||||
rowCount(const QModelIndex& parent = QModelIndex{}) const override; | ||||
virtual QVariant data(const QModelIndex& index, | ||||
int role = Qt::DisplayRole) const override; | ||||
virtual QVariant headerData(int section, Qt::Orientation orientation, | ||||
int role = Qt::DisplayRole) const override; | ||||
virtual Qt::ItemFlags flags(const QModelIndex& index) const override; | ||||
r21 | ||||
r67 | // ///////////////// // | |||
// Drag&Drop methods // | ||||
// ///////////////// // | ||||
r21 | ||||
r67 | virtual Qt::DropActions supportedDropActions() const override; | |||
virtual Qt::DropActions supportedDragActions() const override; | ||||
virtual QStringList mimeTypes() const override; | ||||
virtual QMimeData* mimeData(const QModelIndexList& indexes) const override; | ||||
virtual bool canDropMimeData(const QMimeData* data, Qt::DropAction action, | ||||
int row, int column, | ||||
const QModelIndex& parent) const override; | ||||
virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, | ||||
int row, int column, | ||||
const QModelIndex& parent) override; | ||||
const std::vector<std::shared_ptr<Variable2>>& variables() const | ||||
{ | ||||
return _variables; | ||||
} | ||||
r21 | ||||
signals: | ||||
r67 | void createVariable(const QVariantHash& productData); | |||
void asyncChangeRange(const std::shared_ptr<Variable2>& variable, | ||||
const DateTimeRange& r); | ||||
r27 | public slots: | |||
r67 | /// Slot called when data of a variable has been updated | |||
void variableUpdated(QUuid id) noexcept; | ||||
void variableAdded(const std::shared_ptr<Variable2>&); | ||||
void variableDeleted(const std::shared_ptr<Variable2>&); | ||||
r21 | }; | |||
#endif // SCIQLOP_VARIABLEMODEL2_H | ||||