Qt Model Utilities
2.0.3
A set of utilities for the model/view framework of Qt
|
This is a full implementation for generic use of the QAbstractItemModel
interface.
More...
Signals | |
void | mergeDisplayEditChanged (bool val) |
void | sortRoleChanged (int val) |
Public Member Functions | |
GenericModel (QObject *parent=Q_NULLPTR) | |
~GenericModel () | |
bool | clearItemData (const QModelIndex &index) override |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
bool | hasChildren (const QModelIndex &parent=QModelIndex()) const override |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
bool | insertColumns (int column, int count, const QModelIndex &parent=QModelIndex()) override |
bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
QMap< int, QVariant > | itemData (const QModelIndex &index) const override |
bool | mergeDisplayEdit () const |
QMimeData * | mimeData (const QModelIndexList &indexes) const override |
QStringList | mimeTypes () const override |
bool | moveColumns (const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild) override |
bool | moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override |
void | multiData (const QModelIndex &index, QModelRoleDataSpan roleDataSpan) const override |
QModelIndex | parent (const QModelIndex &index) const override |
bool | removeColumns (int column, int count, const QModelIndex &parent=QModelIndex()) override |
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) override |
QHash< int, QByteArray > | roleNames () const override |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
virtual bool | setFlags (const QModelIndex &index, Qt::ItemFlags flags) |
bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) override |
bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) override |
void | setMergeDisplayEdit (bool val) |
void | setRoleNames (const QHash< int, QByteArray > &rNames) |
Sets the role names. More... | |
void | setSortRole (int role) |
bool | setSpan (const QModelIndex &index, const QSize &size) |
Set the amount of rows and columns an item should occupy. More... | |
void | sort (int column, const QModelIndex &parent, Qt::SortOrder order=Qt::AscendingOrder, bool recursive=true) |
Sorts all children of parent by column in the given order. More... | |
void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override |
int | sortRole () const |
QSize | span (const QModelIndex &index) const override |
Qt::DropActions | supportedDragActions () const override |
Qt::DropActions | supportedDropActions () const override |
Protected Member Functions | |
GenericModel (GenericModelPrivate &dptr, QObject *parent) | |
virtual bool | mimeForValue (QMimeData *data, const QVariant &value) const |
Stores the /a value in the appropriate mime type of /a data. More... | |
Properties | |
bool | mergeDisplayEdit |
This property determines if the Qt::DisplayRole and Qt::EditRole should be merged in the extra row/column. More... | |
int | sortRole |
the item role that is used to query the source model's data when sorting items More... | |
This is a full implementation for generic use of the QAbstractItemModel
interface.
The model can replace QStandardItemModel
depending only on Qt Core.
|
explicit |
Constructs a new model with the given parent.
GenericModel::~GenericModel | ( | ) |
Destructor
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
protectedvirtual |
Stores the /a value in the appropriate mime type of /a data.
Returns true if the data has been stored. Reimplement to support custom types.
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
virtual |
Set the item flags for a specific index
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
If mergeDisplayEdit is true (the default) and roles contains valuer for both Qt::EditRole and Qt::DisplayRole the latter will prevail
void GenericModel::setRoleNames | ( | const QHash< int, QByteArray > & | rNames | ) |
Sets the role names.
This method is a setter for roleNames() allowing you to customise the role names without subclassing the model.
Pass an empty rNames to revert to the default role names
bool GenericModel::setSpan | ( | const QModelIndex & | index, |
const QSize & | size | ||
) |
Set the amount of rows and columns an item should occupy.
At the moment no view provided by Qt supports this
void GenericModel::sort | ( | int | column, |
const QModelIndex & | parent, | ||
Qt::SortOrder | order = Qt::AscendingOrder , |
||
bool | recursive = true |
||
) |
Sorts all children of parent by column in the given order.
The role used for the sorting is determined by sortRole. If recursive is set to true the sorting will propagate down the hierarchy of the model
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
At the moment no view provided by Qt supports this
|
override |
Reimplemented from base class
|
override |
Reimplemented from base class
|
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 true it will be duplicated for both roles. If there is data both in Qt::DisplayRole and Qt::EditRole when you set this property to false Qt::DisplayRole will prevail.
|
readwrite |
the item role that is used to query the source model's data when sorting items
The default value is Qt::DisplayRole.