summaryrefslogtreecommitdiffstats
path: root/src/sessiontreemodel.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-07 17:10:37 +0100
committerNils Schwabe2014-03-07 17:10:37 +0100
commit67756c7ed9a7ecdda141520b47090fe8b57e1eb1 (patch)
tree859a488b83c9d4359714135be8461ea5d9e30c1f /src/sessiontreemodel.cpp
parentAdded function to add info entries if the xml file could not be loaded (diff)
downloadvmchooser2-67756c7ed9a7ecdda141520b47090fe8b57e1eb1.tar.gz
vmchooser2-67756c7ed9a7ecdda141520b47090fe8b57e1eb1.tar.xz
vmchooser2-67756c7ed9a7ecdda141520b47090fe8b57e1eb1.zip
added function: icon fallback if icon is not found locally
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r--src/sessiontreemodel.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp
index d63bab5..d0fc79e 100644
--- a/src/sessiontreemodel.cpp
+++ b/src/sessiontreemodel.cpp
@@ -7,6 +7,7 @@
#include <QtDebug>
#include "sessiontreeitem.h"
+#include "vsession.h"
SessionTreeModel::SessionTreeModel(QObject *parent)
: QAbstractItemModel(parent) {
@@ -57,7 +58,20 @@ QVariant SessionTreeModel::data(const QModelIndex &index, int role) const {
if (QFileInfo(icon).isAbsolute()) {
// try to load icon from file
- return QIcon(icon);
+ QFile iconFile(icon);
+ if (iconFile.exists()) {
+ return QIcon(icon);
+ }
+
+ // fallback to os icon
+ if (s->type() == Session::VSESSION) {
+ const VSession* vs = (VSession*) s;
+ if (vs->getAttribute("os", "param").toLower().startsWith("win")) {
+ return QIcon(":windows");
+ } else {
+ return QIcon(":linux");
+ }
+ }
} else {
// try to load icon from QResource
if (QResource(":" + icon.toLower() + ".svg").isValid()) {