From 51f830068cb6b4847468aced1aa654932c39bf80 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 27 Dec 2010 15:52:30 +0100 Subject: Made all icons in qresource available for UI Every registered icon can be chosen as Qt::DecorationRole for all models at once. Suitable icons must be added to SmGlobals::mIcons. Key is a descriptive text, value is the icon path. To make things easier SmTreeModel got two new member functions: -QIcon decorationIcon() returning the current Icon -void setDecorationIcon() to set the current Icon The current Icon is initialized in the constructor from QSettings - ui/iconfolder To update the TreeViews connected to the FileSystemModel a little hack is needed: Just set the QFileIconProvider again. This causes the Model to update connected views. --- mappingtablewidget.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mappingtablewidget.h') diff --git a/mappingtablewidget.h b/mappingtablewidget.h index 34b877a..38c4fe1 100644 --- a/mappingtablewidget.h +++ b/mappingtablewidget.h @@ -51,10 +51,15 @@ class MappingTableItemModel : public QStringListModel { //data + flags virtual QVariant data(const QModelIndex &index, int role) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const; + void setDecorationIcon(const QIcon &icon) { mDecorationIcon = icon; } + const QIcon decorationIcon() const { return mDecorationIcon; } //find int lowerBound(const QString &value) const; QModelIndex find(const QString &value) const; + + private: + QIcon mDecorationIcon; }; #endif // MAPPINGTABLEWIDGET_H -- cgit v1.2.3-70-g09d2