Qt Model Utilities
2.0.3
A set of utilities for the model/view framework of Qt
|
This proxy model provides an extra row and column to handle user insertions. More...
Public Types | |
enum | InsertDirection { NoInsert = 0x0 , InsertRow = 0x1 , InsertColumn = 0x2 } |
Public Slots | |
virtual bool | commitColumn () |
virtual bool | commitRow () |
Signals | |
void | dataForCornerChanged (const QVector< int > &roles) |
void | extraDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >()) |
void | insertDirectionChanged (InsertDirections direction) |
void | mergeDisplayEditChanged (bool separate) |
Public Member Functions | |
InsertProxyModel (QObject *parent=Q_NULLPTR) | |
~InsertProxyModel () | |
QModelIndex | buddy (const QModelIndex &index) const Q_DECL_OVERRIDE |
int | columnCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE |
QVariant | data (const QModelIndex &proxyIndex, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE |
virtual QVariant | dataForCorner (int role=Qt::DisplayRole) const |
Qt::ItemFlags | flags (const QModelIndex &index) const Q_DECL_OVERRIDE |
bool | hasChildren (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE |
bool | insertColumns (int column, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE |
InsertDirections | insertDirection () const |
bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE |
QMap< int, QVariant > | itemData (const QModelIndex &index) const Q_DECL_OVERRIDE |
QModelIndex | mapFromSource (const QModelIndex &sourceIndex) const Q_DECL_OVERRIDE |
QModelIndex | mapToSource (const QModelIndex &proxyIndex) const Q_DECL_OVERRIDE |
bool | mergeDisplayEdit () const |
bool | moveColumns (const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) Q_DECL_OVERRIDE |
bool | moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) Q_DECL_OVERRIDE |
QModelIndex | parent (const QModelIndex &index) const Q_DECL_OVERRIDE |
bool | removeColumns (int column, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE |
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE |
int | rowCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) Q_DECL_OVERRIDE |
virtual void | setDataForCorner (const QVariant &value, int role=Qt::EditRole) |
bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) Q_DECL_OVERRIDE |
void | setInsertDirection (const InsertDirections &direction) |
bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) Q_DECL_OVERRIDE |
void | setMergeDisplayEdit (bool val) |
void | setSourceModel (QAbstractItemModel *newSourceModel) Q_DECL_OVERRIDE |
void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) Q_DECL_OVERRIDE |
Protected Member Functions | |
InsertProxyModel (InsertProxyModelPrivate &dptr, QObject *parent) | |
virtual Qt::ItemFlags | flagForExtra (bool isRow, int section) const |
flag function for the extra row or column More... | |
virtual bool | validColumn () const |
Returns true if the extra column can be merged in the main model. More... | |
virtual bool | validRow () const |
Returns true if the extra row can be merged in the main model. More... | |
Properties | |
InsertDirections | insertDirection |
This property determines if the extra row, column or both are displayed. More... | |
bool | mergeDisplayEdit |
This property determines if the Qt::DisplayRole and Qt::EditRole should be merged in the extra row/column. More... | |
This proxy model provides an extra row and column to handle user insertions.
This proxy will add an extra row, column or both to allow users to insert new sections with a familiar interface.
You can use setInsertDirection to determine whether to show an extra row or column. By default, this model will behave as QIdentityProxyModel
You can either call commitRow/commitColumn or reimplement validRow/validColumn to decide when a row/column should be added to the main model.
|
explicit |
Constructs a new proxy model with the given parent.
InsertProxyModel::~InsertProxyModel | ( | ) |
Destructor
QModelIndex InsertProxyModel::buddy | ( | const QModelIndex & | index | ) | const |
Reimplemented from base class
int InsertProxyModel::columnCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Reimplemented from base class
|
virtualslot |
Adds the extra column to the source model
|
virtualslot |
Adds the extra row to the source model
QVariant InsertProxyModel::data | ( | const QModelIndex & | proxyIndex, |
int | role = Qt::DisplayRole |
||
) | const |
Reimplemented from base class
|
virtual |
Gets the data for the corner cell at the intersection between the extra row and extra column
|
signal |
This signal is emitted whenever the data for the corner at the intersection of the extra row and column is changed
|
signal |
Same as dataChanged but is emitted only for the extra row/column
|
protectedvirtual |
flag function for the extra row or column
If isRow is true this method is referring to the extra row, otherwise it will be the extra column, section then determines the row or column this flag refers to
Qt::ItemFlags InsertProxyModel::flags | ( | const QModelIndex & | index | ) | const |
Reimplemented from base class
bool InsertProxyModel::hasChildren | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Reimplemented from base class
QVariant InsertProxyModel::headerData | ( | int | section, |
Qt::Orientation | orientation, | ||
int | role = Qt::DisplayRole |
||
) | const |
Reimplemented from base class
QModelIndex InsertProxyModel::index | ( | int | row, |
int | column, | ||
const QModelIndex & | parent = QModelIndex() |
||
) | const |
Reimplemented from base class
bool InsertProxyModel::insertColumns | ( | int | column, |
int | count, | ||
const QModelIndex & | parent = QModelIndex() |
||
) |
Reimplemented from base class
bool InsertProxyModel::insertRows | ( | int | row, |
int | count, | ||
const QModelIndex & | parent = QModelIndex() |
||
) |
Reimplemented from base class
QModelIndex InsertProxyModel::mapFromSource | ( | const QModelIndex & | sourceIndex | ) | const |
Reimplemented from base class
QModelIndex InsertProxyModel::mapToSource | ( | const QModelIndex & | proxyIndex | ) | const |
Reimplemented from base class
bool InsertProxyModel::moveColumns | ( | const QModelIndex & | sourceParent, |
int | sourceColumn, | ||
int | count, | ||
const QModelIndex & | destinationParent, | ||
int | destinationChild | ||
) |
Reimplemented from base class
bool InsertProxyModel::moveRows | ( | const QModelIndex & | sourceParent, |
int | sourceRow, | ||
int | count, | ||
const QModelIndex & | destinationParent, | ||
int | destinationChild | ||
) |
Reimplemented from base class
QModelIndex InsertProxyModel::parent | ( | const QModelIndex & | index | ) | const |
Reimplemented from base class
bool InsertProxyModel::removeColumns | ( | int | column, |
int | count, | ||
const QModelIndex & | parent = QModelIndex() |
||
) |
Reimplemented from base class
bool InsertProxyModel::removeRows | ( | int | row, |
int | count, | ||
const QModelIndex & | parent = QModelIndex() |
||
) |
Reimplemented from base class
int InsertProxyModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Reimplemented from base class
bool InsertProxyModel::setData | ( | const QModelIndex & | index, |
const QVariant & | value, | ||
int | role = Qt::EditRole |
||
) |
Reimplemented from base class
|
virtual |
Set the data for the corner cell at the intersection between the extra row and extra column
bool InsertProxyModel::setHeaderData | ( | int | section, |
Qt::Orientation | orientation, | ||
const QVariant & | value, | ||
int | role = Qt::EditRole |
||
) |
Reimplemented from base class
bool InsertProxyModel::setItemData | ( | const QModelIndex & | index, |
const QMap< int, QVariant > & | roles | ||
) |
Reimplemented from base class
If the map contains both Qt::DisplayRole and Qt::EditRole and mergeDisplayEdit is set to true, the value of Qt::DisplayRole will prevail.
void InsertProxyModel::setSourceModel | ( | QAbstractItemModel * | newSourceModel | ) |
Reimplemented from base class
void InsertProxyModel::sort | ( | int | column, |
Qt::SortOrder | order = Qt::AscendingOrder |
||
) |
Reimplemented from base class
|
protectedvirtual |
Returns true if the extra column can be merged in the main model.
The default implementation never commits the column to the model.
If, for example, you want the row to be added to the source model as soon as there's any data in the Qt::DisplayRole of any cell you can repliement this method as:
|
protectedvirtual |
Returns true if the extra row can be merged in the main model.
The default implementation never commits the row to the model.
If, for example, you want the row to be added to the source model as soon as there's any data in the Qt::DisplayRole of any cell you can repliement this method as:
|
readwrite |
This property determines if the extra row, column or both are displayed.
|
readwrite |
This property determines if the Qt::DisplayRole and Qt::EditRole should be merged in the extra row/column.
By default the two roles are one and the same you can use this property to separate them. If there's any data in the role when you set this property to false it will be duplicated for both roles. If there is data both in Qt::DisplayRole and Qt::EditRole when you set this property to true Qt::DisplayRole will prevail. This property only affects the extra row/column. Data in the source model is not affected.