diff options
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r-- | src/sessiontreemodel.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp index 9bc13f6..6208606 100644 --- a/src/sessiontreemodel.cpp +++ b/src/sessiontreemodel.cpp @@ -13,7 +13,7 @@ SessionTreeModel::SessionTreeModel(QObject *parent) : QAbstractItemModel(parent) { root_ = new SessionTreeItem("dummy"); - iconHolder = new SessionsIconHolder(); + iconHolder = new SessionsIconHolder(*this); } SessionTreeModel::~SessionTreeModel() { @@ -57,16 +57,12 @@ QVariant SessionTreeModel::data(const QModelIndex &index, int role) const { if (index.column() == 0) { // TODO: is this line needed? QString icon(s->icon()); - if (QFileInfo(icon).isAbsolute()) { - // try to load icon from file - QIcon file_icon = iconHolder->getIconFromFile(icon); - if (!file_icon.name().isEmpty()) { - return file_icon; - } + // check if attribute is a valid url: + if (icon.startsWith("http://")) { // try to load icon from url - QIcon url_icon = iconHolder->getIconFromURL(icon); - if (!url_icon.name().isEmpty()) { + QIcon url_icon = iconHolder->getIcon(QUrl(icon)); + if (!url_icon.isNull()) { return url_icon; } @@ -74,15 +70,14 @@ QVariant SessionTreeModel::data(const QModelIndex &index, int role) const { if (s->type() == Session::VSESSION) { const VSession* vs = (VSession*) s; if (vs->getAttribute("os", "param").toLower().startsWith("win")) { - return iconHolder->getIconFromResource("windows"); + return iconHolder->getIcon("windows"); } else { - return iconHolder->getIconFromResource("linux"); + return iconHolder->getIcon("linux"); } } } else { // try to load icon from QResource - qDebug() << icon; - return iconHolder->getIconFromResource(icon); + return iconHolder->getIcon(icon); } } } @@ -223,3 +218,7 @@ void SessionTreeModel::removeItem(const QString& name, const QString& section) { } } } + +void SessionTreeModel::updateView() { + emit layoutChanged(); +} |