/** * Model for numeral code table * $Id$ * $HeadURL$ * $Author$ * Created by hjl, SLSE, 2016-12-09 */ #pragma once #include #include #include namespace CodificationManagement { class NumeralCodeModel final : public QAbstractTableModel { Q_OBJECT public: explicit NumeralCodeModel(QWidget *parent); ~NumeralCodeModel() = default; /** * init model internal data matrix * @param dtc access to Data Topic Client * @param codificationDataId id of the used codification data set * @param isEditMode true means model used for edit, otherwise used for show only * in edit mode non update will be done by external data change * @return Returns true on success, otherwise false */ bool init(const std::shared_ptr &dtc, int codificationDataId, bool isEditMode = false); /** * set the horizontal and vertical header to zero */ void resetHeader(); /** * set column selection values * @param data refernce to character set of column selection values * @return Returns true on success, otherwise false */ bool setColumnSelectionValuesCSV(const QString &csvData); /** * set row selection values * @param data reference to character set of row selection values * @return Returns true on success, otherwise false */ bool setRowSelectionValuesCSV(const QString &csvData); /** * get horizontal header in csv format * @param - * @return Returns horizontal header in csv format; */ QString getHorizontalHeaderCSVString() const; /** * get vertical header in csv format * @param - * @return Returns vertical header in csv format; */ QString getVerticalHeaderCSVString() const; /** * set/get edit mode flag used for internal data handling * @param isEditMode true means set edit mode * @return Returns true if edit mode is set, otherwise false */ void setEditMode(bool isEditMode); bool isEditMode() const; /** * get the row count (MVC-model) * @param ModelIndex * @return int Returns the count */ int rowCount(const QModelIndex &parent = QModelIndex()) const override; /** * get the row column (MVC-model) * @param ModelIndex * @return int Returns the count */ int columnCount(const QModelIndex &parent = QModelIndex()) const override; /** * get the header data (MVC-model) * @param section (column) * @param Qt::Orientation * @param role * @return QVariant */ QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; /** * get the data (MVC-model) * @param QModelIndex * @return QVariant */ QVariant data(const QModelIndex &index, int role) const override; /** * set the data (MVC-model) * @param QModelIndex * @return bool Returns true if successfull, otherwise returns false */ bool setData(const QModelIndex &index, const QVariant &value, int role) override; /** * get flags for the given QModelIndex (MVC-model) * @param ModelIndex * @return flags Returns the flags */ Qt::ItemFlags flags(const QModelIndex &index) const override; Q_SIGNALS: /** * emits when data was changed (used to enable add/okay button) */ void dataModified(); private Q_SLOTS: void onCodificationDataChanged(const CodificationManagement::CodificationData &data, DataModification modType); private: /** * init the constant 13x13 code matrix */ void initMatrix(); QVector m_MatrixNumeralSet; ///< Numeral Set 0-9 QVector m_MatrixCharacterSet1; ///< Character set 1 A-Z 26 Character QVector m_MatrixCharacterSet2; ///< Character set 2 especially 12 Character D...U QChar m_matrix[13][13]; ///< Hold the numeral code table (without row/column selcet index fields) QVector m_RowSelectionValues; ///< Hold the row selection index field character QVector m_ColumnSelectionValues; ///< Hold the column selection index field character std::shared_ptr m_dtc; int m_codificationDataId; ///< Id of the used codification data set bool m_isEditMode; ///< Hold the dialog mode setting; if true the indices in row 0 and column 0 can be modified NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility }; } //namespace CodificationManagement