SelectionEditorFactory + ItemModel + ItemModelFactory combination is working
in new EditTableWidget (EditTableWidget is very much WIP)
This commit is contained in:
parent
e44f73166f
commit
742fd0a4d3
19 changed files with 419 additions and 80 deletions
64
pglab/EditColumnTableModel.h
Normal file
64
pglab/EditColumnTableModel.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#ifndef EDITCOLUMNTABLEMODEL_H
|
||||
#define EDITCOLUMNTABLEMODEL_H
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include "Pgsql_oids.h"
|
||||
|
||||
|
||||
class Column {
|
||||
public:
|
||||
QString name;
|
||||
Oid type = InvalidOid;
|
||||
int length = -1; // varchar, date/time, numeric (precision)
|
||||
int scale = -1; // numeric scale
|
||||
Oid collate = InvalidOid;
|
||||
bool notNull = true;
|
||||
QString def;
|
||||
int primaryKey = 0;
|
||||
bool unique = false;
|
||||
QString comment;
|
||||
};
|
||||
|
||||
|
||||
class EditColumnTableModel: public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns : int {
|
||||
NameCol = 0,
|
||||
TypeCol,
|
||||
LengthCol,
|
||||
ScaleCol,
|
||||
CollateCol,
|
||||
NotNullCol,
|
||||
DefaultCol,
|
||||
PrimaryKeyCol,
|
||||
UniqueCol,
|
||||
CommentCol,
|
||||
|
||||
colCount
|
||||
};
|
||||
|
||||
EditColumnTableModel(QObject *parent = nullptr);
|
||||
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &) const override;
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
|
||||
public slots:
|
||||
// virtual bool submit() override;
|
||||
// virtual void revert() override;
|
||||
|
||||
private:
|
||||
using ColumnList = std::vector<Column>;
|
||||
|
||||
ColumnList m_data; ///< Better call it data as columns would be confusing
|
||||
};
|
||||
|
||||
|
||||
#endif // EDITCOLUMNTABLEMODEL_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue