VariableModel.h
80 lines
| 2.4 KiB
| text/x-c
|
CLexer
Alexandre Leroux
|
r112 | #ifndef SCIQLOP_VARIABLEMODEL_H | ||
#define SCIQLOP_VARIABLEMODEL_H | ||||
Alexandre Leroux
|
r461 | #include "CoreGlobal.h" | ||
r228 | ||||
r512 | #include <Data/SqpRange.h> | |||
Alexandre Leroux
|
r112 | |||
Alexandre Leroux
|
r149 | #include <QAbstractTableModel> | ||
Alexandre Leroux
|
r112 | #include <QLoggingCategory> | ||
Alexandre Leroux
|
r368 | #include <Common/MetaTypes.h> | ||
r228 | #include <Common/spimpl.h> | |||
Alexandre Leroux
|
r112 | Q_DECLARE_LOGGING_CATEGORY(LOG_VariableModel) | ||
r402 | enum VariableRoles { ProgressRole = Qt::UserRole }; | |||
r401 | ||||
Alexandre Leroux
|
r165 | class IDataSeries; | ||
Alexandre Leroux
|
r112 | class Variable; | ||
/** | ||||
* @brief The VariableModel class aims to hold the variables that have been created in SciQlop | ||||
*/ | ||||
Alexandre Leroux
|
r461 | class SCIQLOP_CORE_EXPORT VariableModel : public QAbstractTableModel { | ||
r422 | Q_OBJECT | |||
Alexandre Leroux
|
r112 | public: | ||
Alexandre Leroux
|
r149 | explicit VariableModel(QObject *parent = nullptr); | ||
Alexandre Leroux
|
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 | |||
Alexandre Leroux
|
r410 | * @param metadata the metadata associated to the new variable | ||
Alexandre Leroux
|
r165 | * @return the pointer to the new variable | ||
Alexandre Leroux
|
r112 | */ | ||
r512 | std::shared_ptr<Variable> createVariable(const QString &name, const SqpRange &dateTime, | |||
Alexandre Leroux
|
r410 | const QVariantHash &metadata) noexcept; | ||
Alexandre Leroux
|
r112 | |||
Alexandre Leroux
|
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 | ||||
Alexandre Leroux
|
r246 | std::shared_ptr<Variable> variable(int index) const; | ||
r401 | void setDataProgress(std::shared_ptr<Variable> variable, double progress); | |||
r422 | ||||
Alexandre Leroux
|
r149 | // /////////////////////////// // | ||
// QAbstractTableModel methods // | ||||
// /////////////////////////// // | ||||
r401 | ||||
Alexandre Leroux
|
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; | ||||
r422 | ||||
void abortProgress(const QModelIndex &index); | ||||
signals: | ||||
void abortProgessRequested(std::shared_ptr<Variable> variable); | ||||
Alexandre Leroux
|
r112 | private: | ||
class VariableModelPrivate; | ||||
spimpl::unique_impl_ptr<VariableModelPrivate> impl; | ||||
Alexandre Leroux
|
r368 | |||
private slots: | ||||
/// Slot called when data of a variable has been updated | ||||
void onVariableUpdated() noexcept; | ||||
Alexandre Leroux
|
r112 | }; | ||
Alexandre Leroux
|
r368 | // Registers QVector<int> metatype so it can be used in VariableModel::dataChanged() signal | ||
SCIQLOP_REGISTER_META_TYPE(QVECTOR_INT_REGISTRY, QVector<int>) | ||||
Alexandre Leroux
|
r112 | #endif // SCIQLOP_VARIABLEMODEL_H | ||