diff options
author | Arno <am@disconnect.de> | 2010-12-27 15:52:30 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-12-27 15:52:30 +0100 |
commit | 51f830068cb6b4847468aced1aa654932c39bf80 (patch) | |
tree | 0eff6453050a77999577310746e24f6182493cf3 /smtreemodel.cpp | |
parent | 7bb7295a9033c0a6729b301e7c9b76393539e29a (diff) | |
download | SheMov-51f830068cb6b4847468aced1aa654932c39bf80.tar.gz SheMov-51f830068cb6b4847468aced1aa654932c39bf80.tar.bz2 SheMov-51f830068cb6b4847468aced1aa654932c39bf80.zip |
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.
Diffstat (limited to 'smtreemodel.cpp')
-rw-r--r-- | smtreemodel.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/smtreemodel.cpp b/smtreemodel.cpp index 2712cef..8b51bab 100644 --- a/smtreemodel.cpp +++ b/smtreemodel.cpp @@ -6,9 +6,11 @@ */ #include <QIcon> +#include <QSettings> #include "smtreemodel.h" #include "smtreeitem.h" +#include "smglobals.h" SmTreeModel::SmTreeModel(const QStringList &headers, QObject *parent) : QAbstractItemModel(parent), mRootItem(0){ mHeaders = headers; @@ -16,6 +18,10 @@ SmTreeModel::SmTreeModel(const QStringList &headers, QObject *parent) : QAbstrac mHeaderData.insert(mHeaders.at(i), i); } mRootItem = new SmTreeItem(headers.count()); + QSettings s; + QString iconName = s.value("ui/foldericon", "Dildo").toString(); + const QHash<QString, QString> icons = SmGlobals::instance()->icons(); + mDecorationIcon = QIcon(icons.value(iconName)); } SmTreeModel::~SmTreeModel(){ @@ -98,7 +104,7 @@ QVariant SmTreeModel::data(const QModelIndex &index, int role) const{ } if(role == Qt::DecorationRole){ if(index.column() == 0){ - return QIcon(":/dildo.png"); + return mDecorationIcon; } } return QVariant(); |