186 lines
5.3 KiB
C++
Executable File
186 lines
5.3 KiB
C++
Executable File
/**
|
|
* Model for logistical terms table
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by hjl, SLSE, 2017-01-13
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <CodificationManagement/logger.h>
|
|
#include <CodificationManagement/cod_dtc.h>
|
|
|
|
|
|
namespace CodificationManagement
|
|
{
|
|
|
|
class LogisticalTermsModel final : public QAbstractTableModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit LogisticalTermsModel(QWidget *parent);
|
|
|
|
/**
|
|
* 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<CodificationManagement::Interface::Dtc> &dtc,
|
|
int codificationDataId,
|
|
bool isEditMode = false);
|
|
|
|
/**
|
|
* set the horizontal and vertical header to zero
|
|
*/
|
|
void resetHeader();
|
|
|
|
/**
|
|
* set the 5x5 code matrix to zero
|
|
*/
|
|
void resetMatrix();
|
|
|
|
/**
|
|
* 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);
|
|
|
|
/**
|
|
* set matrix values
|
|
* @param data reference to int data set of matrix values
|
|
* @return Returns true on success, otherwise false
|
|
*/
|
|
bool setMatrixValuesCSV(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;
|
|
|
|
/**
|
|
* get matrix data in csv format
|
|
* @param -
|
|
* @return Returns matrix data in csv format;
|
|
*/
|
|
QString getMatrixDataCSVString() 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
|
|
* get vertical header in csv forma
|
|
* @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 section, 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;
|
|
|
|
/**
|
|
* split the 'inString' into 'row' substrings, where parts in quotation marks are not split
|
|
* @param inString input string
|
|
* @return stringlist of substrings. in case of an error the list will be empty.
|
|
*/
|
|
QStringList splitQuotedStringToRows(const QString &str);
|
|
|
|
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);
|
|
|
|
|
|
// /**
|
|
// * split the 'inString' into 'row' substrings, where parts in quotation marks are not split
|
|
// * @param inString input string
|
|
// * @return stringlist of substrings. in case of an error the list will be empty.
|
|
// */
|
|
// QStringList splitQuotedStringToRows(const QString &str);
|
|
|
|
|
|
private:
|
|
|
|
QVector<QVector<QString>> m_matrix; ///< Hold the logistical terms table (without row/column select index fields)
|
|
|
|
QVector <QChar> m_RowSelectionValues; ///< Hold the row selection index field character
|
|
QVector <QChar> m_ColumnSelectionValues; ///< Hold the column selection index field character
|
|
|
|
std::shared_ptr<CodificationManagement::Interface::Dtc> 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
|
|
|