mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Create a delegate to display custom data
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1b8f7f53f2
commit
3b0936eca3
2 changed files with 27 additions and 0 deletions
|
@ -476,3 +476,21 @@ QSize HTMLDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModel
|
|||
doc.setTextWidth(options.rect.width());
|
||||
return QSize(doc.idealWidth(), doc.size().height());
|
||||
}
|
||||
|
||||
LocationFilterDelegate::LocationFilterDelegate(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
painter->save();
|
||||
painter->drawText(QPoint(0, 0), index.data().toString());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSize LocationFilterDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QSize size;
|
||||
size.setWidth(option.rect.width());
|
||||
size.setHeight(20);
|
||||
}
|
||||
|
|
|
@ -129,4 +129,13 @@ public:
|
|||
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
class LocationFilterDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LocationFilterDelegate(QObject *parent = 0);
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // MODELDELEGATES_H
|
||||
|
|
Loading…
Reference in a new issue