Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
using Data = QVector<QVariant>;
|
||||
using DataList = QVector<Data>;
|
||||
using HeaderList = QVector<QPair<QString, QVariant::Type>>;
|
||||
|
||||
class DataModel: public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DataModel(QObject* parent = nullptr);
|
||||
|
||||
|
||||
//void fillModel(const HeaderList &headerList, const DataList &dataList);
|
||||
void dataListReserve(const int size);
|
||||
void addLine(const Data& data);
|
||||
void addColumn(const QString& columnName, QVariant::Type type);
|
||||
const HeaderList& getHeaderList() const;
|
||||
|
||||
|
||||
|
||||
void setTableName(const QString& tableName);
|
||||
QString getTableName() const;
|
||||
void setEditable(bool editable);
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
|
||||
void deleteLines(const QList<QModelIndex> &affectedRowsList);
|
||||
|
||||
private:
|
||||
HeaderList m_headerList;
|
||||
DataList m_dataList;
|
||||
|
||||
// Threading...
|
||||
HeaderList m_newHeaderList;
|
||||
DataList m_newDataList;
|
||||
|
||||
|
||||
QString m_tableName;
|
||||
Qt::ItemFlags m_flags;
|
||||
|
||||
QAtomicInt m_idle;
|
||||
|
||||
void resetFlags();
|
||||
|
||||
|
||||
public slots:
|
||||
void slotSwapLists();
|
||||
void slotSetData(const QModelIndex &index, const QVariant &value);
|
||||
|
||||
signals:
|
||||
void signalSetData(DataModel*, const QModelIndex &, const QVariant &);
|
||||
};
|
||||
Reference in new issue
Block a user