QAdvanced Item View
0.4
The QAIV (Qt Advanced Item Views) library provides GUI and utility classes extending the capabilities of the Qt item views.
|
The QConditionalDecorationProxyModel class implements a proxy model for conditional decorations. More...
#include <qconditionaldecorationproxymodel.h>
Public Types | |
enum | ItemDataRole { ConditionalDecorationRole = Qt::UserRole + 421, IconSetsRole } |
Public Member Functions | |
QConditionalDecorationProxyModel (QObject *parent=0) | |
~QConditionalDecorationProxyModel () | |
void | addDecoration (int column, QAbstractItemModelDecoration *decoration) |
void | addIcon (const QString &set, const QString &name, const QString &resource) |
void | addIconSet (const QString &name, const QVariantMap icons) |
virtual QVariant | data (const QModelIndex &index, int role) const |
QIcon | icon (const QString &set, const QString &name) const |
QSize | iconSize () const |
int | iconSpacing () const |
QMap< QString, QVariant > | iconSets () const |
bool | restoreState (const QByteArray &state) |
QByteArray | stateState () const |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role) |
void | setIconSize (const QSize &size) |
void | setIconSpacing (int spacing) |
Properties | |
QSize | iconSize |
int | iconSpacing |
The QConditionalDecorationProxyModel class implements a proxy model for conditional decorations.
Lets assume we want to decorate colum 'Maturity Level' in the source model show below:
The code to set up the model and the view would look like this:
To add a decoration, we need to create a QConditionalDecoration and add condition defining the match conditions and values:
For all items matching none of the previously defined conditions, we set a default decoration:
Finally we add the decoration to the proxy model:
After adding the decoration the view is updated and shows the decorations.
Icon Set | Icon Name | Icon |
---|---|---|
emoticons | happy | |
neutral | ||
unhappy | ||
flags | red (on) | |
yellow | ||
green | ||
blue | ||
orange | ||
pink | ||
purple | ||
leds | red (on) | |
yellow (on) | ||
green (on) | ||
blue (on) | ||
orange (on) | ||
white (on) | ||
tags | red (on) | |
yellow | ||
green | ||
blue | ||
orange | ||
pink | ||
purple |
|
explicit |
Constructs a QConditionalDecorationProxyModel with the given parent
.
QConditionalDecorationProxyModel::~QConditionalDecorationProxyModel | ( | ) |
Destroys the QConditionalDecorationProxyModel object.
void QConditionalDecorationProxyModel::addDecoration | ( | int | column, |
QAbstractItemModelDecoration * | decoration | ||
) |
Adds a decoration
for the specified column
.
void QConditionalDecorationProxyModel::addIconSet | ( | const QString & | name, |
const QVariantMap | icons | ||
) |
Adds the icon set name
with the given icons
to the proxy model.
|
virtual |
QSortFilterProxyModel::data()
QIcon QConditionalDecorationProxyModel::icon | ( | const QString & | set, |
const QString & | name | ||
) | const |
Returns the icon specified by the given set
and name
. An invalid QIcon is returned if the iconset set
or the icon name
cannot be retrieved.
QMap< QString, QVariant > QConditionalDecorationProxyModel::iconSets | ( | ) | const |
Returns a map of icon sets defined for this proxy.
QSize QConditionalDecorationProxyModel::iconSize | ( | ) | const |
Returns the size of the icons.
int QConditionalDecorationProxyModel::iconSpacing | ( | ) | const |
Returns the spacing between the icons of an item.
bool QConditionalDecorationProxyModel::restoreState | ( | const QByteArray & | state | ) |
Restores the proxy model's state and decoratrions.
|
virtual |
QSortFilterProxyModel::setData()
void QConditionalDecorationProxyModel::setIconSize | ( | const QSize & | size | ) |
Sets the icon size to size
.
void QConditionalDecorationProxyModel::setIconSpacing | ( | int | spacing | ) |
Sets the spacing between the icons of an item to spacing
.
QByteArray QConditionalDecorationProxyModel::stateState | ( | ) | const |
Saves the proxy model's state and decorations.
|
readwrite |
This property holds the size of item's icons.
|
readwrite |
This property holds the spacing between the icons of an item.