Files
qt5-legatus-legacy/Lts/Plugins/CodificationManagement/Test/cod_numeral_code_model.h
T
2026-08-13 18:33:10 +02:00

137 lines
3.8 KiB
C++
Executable File

/**
* Model for numeral code table
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-11-02
*/
#pragma once
#include <QAbstractTableModel>
namespace NGL
{
class INGLLogger;
}
class NumeralCodeModel final : public QAbstractTableModel
{
Q_OBJECT
public:
explicit NumeralCodeModel(QWidget *parent);
~NumeralCodeModel();
/**
* init model internal data matrix
* @param -
* @return Returns true on success, otherwise false
*/
bool init();
/**
* set column selection values
* @param data refernce to character set of column selection values
* @return Returns true on success, otherwise false
*/
bool setColumnSelectionValues(const QVector<char> &data);
bool setColumnSelectionValuesCSV(const QVector<char> &csvData);
/**
* set model internal data matrix
* @param data reference to character set of row selection values
* @return Returns true on success, otherwise false
*/
bool setRowSelectionValues(const QVector<char> &data);
bool setRowSelectionValuesCSV(const QVector<char> &csvData);
/**
* get horizontal header in csv format
* @param -
* @return Returns horizontal header in csv format; (vectorsize must be 26).
*/
QVector <char> getHorizontalHeaderCSV() const;
/**
* get vertical header in csv format
* @param -
* @return Returns vertical header in csv format; (vectorsize must be 26).
*/
QVector <char> getVerticalHeaderCSV() 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;
private:
/**
* init the constant 13x13 code matrix
* @param ModelIndex
* @return flags Returns the flags
*/
bool initMatrix();
QVector <char> m_MatrixNumeralSet; ///< Numeral Set 0-9
QVector <char> m_MatrixCharacterSet1; ///< Character set 1 A-Z 26 Character
QVector <char> m_MatrixCharacterSet2; ///< Character set 2 especially 12 Character D...U
char m_matrix[13][13]; ///< Hold the numeral code table (without row/column selcet index fields)
QVector <char> m_RowSelectionValues; ///< Hold the row selcetion index field character
QVector <char> m_ColumnSelectionValues; ///< Hold the column selcetion index field character
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
};