#pragma once // Qt #include // Local #include "modeldataitem.h" namespace osdev { namespace components { namespace datamodels { /*! * \brief The TableModelBase class is the generic way of presenting a table in memory. * It can be attached to different view-objects in a GUI. */ class TableModelBase : public QAbstractTableModel { Q_OBJECT public: TableModelBase(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; void addHeaderColumn(const QString &headerName, const QString &db_field_name = QString()); QStringList getHeaderNames(); QString getHeaderFieldByName( const QString &headerName) const; QString getHeaderColumnByField( const QString &db_field_name ) const; QString getHeaderFieldByIndex( int index ) const; QString getHeaderNameByIndex( int index ) const; int getHeaderIndexByName( const QString &header_name ) const; bool setHeaderData( int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole ) override; void setKeyFields( const QStringList &key_fields ); const QStringList& getKeyFields() { return m_keyFields; } // void fillList(const &DataObject &data_object); // void addRecord(const ModelDataItem &data_item); void clear(); QString exportDataAsString(); QStringList exportDataAsList(); signals: void signalHideLoading(); private: // Members ( Giggity! ) QStringList m_keyFields; QList> m_headers; QStringList m_keyList; QHash m_qhModelData; }; } // End namespace datamodels } // End namespace components } // End namespace osdev