summaryrefslogtreecommitdiffstats
path: root/src/sessiontreemodel.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-18 17:00:16 +0100
committerNils Schwabe2014-03-18 17:00:16 +0100
commita96170231b65358e169b54d126891df884e65ea2 (patch)
tree72f7e8621b77b39ea10e8d35766056e3ebfd6138 /src/sessiontreemodel.cpp
parent- Added IconHolder to cache items (diff)
downloadvmchooser2-a96170231b65358e169b54d126891df884e65ea2.tar.gz
vmchooser2-a96170231b65358e169b54d126891df884e65ea2.tar.xz
vmchooser2-a96170231b65358e169b54d126891df884e65ea2.zip
- removed function to load icons locally
- added function to load icon from a given url (xml parameter)
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r--src/sessiontreemodel.cpp25
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();
+}