VariableModel.h
70 lines
| 2.1 KiB
| text/x-c
|
CLexer
|
r112 | #ifndef SCIQLOP_VARIABLEMODEL_H | ||
#define SCIQLOP_VARIABLEMODEL_H | ||||
r228 | ||||
#include <Data/SqpDateTime.h> | ||||
|
r112 | |||
|
r149 | #include <QAbstractTableModel> | ||
|
r112 | #include <QLoggingCategory> | ||
|
r368 | #include <Common/MetaTypes.h> | ||
r228 | #include <Common/spimpl.h> | |||
|
r112 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel) | ||
r401 | enum VariableRoles { progressRole = Qt::UserRole }; | |||
|
r165 | class IDataSeries; | ||
|
r112 | class Variable; | ||
/** | ||||
* @brief The VariableModel class aims to hold the variables that have been created in SciQlop | ||||
*/ | ||||
|
r149 | class VariableModel : public QAbstractTableModel { | ||
|
r112 | public: | ||
|
r149 | explicit VariableModel(QObject *parent = nullptr); | ||
|
r112 | |||
/** | ||||
* Creates a new variable in the model | ||||
* @param name the name of the new variable | ||||
r228 | * @param dateTime the dateTime of the new variable | |||
|
r165 | * @return the pointer to the new variable | ||
|
r112 | */ | ||
r319 | std::shared_ptr<Variable> createVariable(const QString &name, | |||
const SqpDateTime &dateTime) noexcept; | ||||
|
r112 | |||
|
r332 | /** | ||
* Deletes a variable from the model, if it exists | ||||
* @param variable the variable to delete | ||||
*/ | ||||
void deleteVariable(std::shared_ptr<Variable> variable) noexcept; | ||||
r401 | ||||
|
r246 | std::shared_ptr<Variable> variable(int index) const; | ||
r401 | void setDataProgress(std::shared_ptr<Variable> variable, double progress); | |||
|
r149 | // /////////////////////////// // | ||
// QAbstractTableModel methods // | ||||
// /////////////////////////// // | ||||
r401 | ||||
|
r149 | 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; | ||||
|
r112 | private: | ||
class VariableModelPrivate; | ||||
spimpl::unique_impl_ptr<VariableModelPrivate> impl; | ||||
|
r368 | |||
private slots: | ||||
/// Slot called when data of a variable has been updated | ||||
void onVariableUpdated() noexcept; | ||||
|
r112 | }; | ||
|
r368 | // Registers QVector<int> metatype so it can be used in VariableModel::dataChanged() signal | ||
SCIQLOP_REGISTER_META_TYPE(QVECTOR_INT_REGISTRY, QVector<int>) | ||||
|
r112 | #endif // SCIQLOP_VARIABLEMODEL_H | ||