summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-08-09 16:48:09 +0200
committerTreeki <treeki@gmail.com>2012-08-09 16:48:09 +0200
commit6025cf1356f25727cb8a04eed413d87720b2fb1f (patch)
tree33878d2fbdfc5473ea7457167d2060c45093dd4c
parent3b2fb505d58f28f0ce9b4de121f12fc924c1ec0c (diff)
downloadLayoutStudio-6025cf1356f25727cb8a04eed413d87720b2fb1f.tar.gz
LayoutStudio-6025cf1356f25727cb8a04eed413d87720b2fb1f.zip
forgot to commit this when I last worked on it :x
-rw-r--r--lsglobals.cpp12
-rw-r--r--lsglobals.h2
-rw-r--r--lsscenemodel.cpp10
-rw-r--r--lsscenemodel.h3
-rw-r--r--lyt/pane.h2
5 files changed, 14 insertions, 15 deletions
diff --git a/lsglobals.cpp b/lsglobals.cpp
index 2ad83ca..07f505e 100644
--- a/lsglobals.cpp
+++ b/lsglobals.cpp
@@ -19,7 +19,6 @@
bool LSGlobals::m_loaded = false;
QHash<QString, QIcon> LSGlobals::m_icons;
-QHash<QString, QString> LSGlobals::m_pane_icon_names;
bool LSGlobals::setup() {
@@ -35,13 +34,6 @@ bool LSGlobals::setup() {
loadIcon("bounding");
loadIcon("window");
- // Set up pane type mapping
- m_pane_icon_names["pan1"] = "pane";
- m_pane_icon_names["pic1"] = "picture";
- m_pane_icon_names["txt1"] = "textbox";
- m_pane_icon_names["bnd1"] = "bounding";
- m_pane_icon_names["wnd1"] = "window";
-
m_loaded = true;
@@ -58,7 +50,3 @@ bool LSGlobals::loadIcon(QString name) {
QIcon LSGlobals::getIcon(QString name) {
return m_icons.value(name);
}
-
-QIcon LSGlobals::getIconForPaneType(QString type) {
- return m_icons.value(m_pane_icon_names.value(type));
-}
diff --git a/lsglobals.h b/lsglobals.h
index 3588474..342384b 100644
--- a/lsglobals.h
+++ b/lsglobals.h
@@ -26,13 +26,11 @@ public:
static bool setup();
static QIcon getIcon(QString name);
- static QIcon getIconForPaneType(QString type);
private:
static bool m_loaded;
static QHash<QString, QIcon> m_icons;
- static QHash<QString, QString> m_pane_icon_names;
static bool loadIcon(QString name);
};
diff --git a/lsscenemodel.cpp b/lsscenemodel.cpp
index 7450368..38da4e7 100644
--- a/lsscenemodel.cpp
+++ b/lsscenemodel.cpp
@@ -1,9 +1,16 @@
#include "lsscenemodel.h"
+#include "lsglobals.h"
LSSceneModel::LSSceneModel(LYTLayout *layout, QObject *parent) :
QAbstractItemModel(parent)
{
m_layout = layout;
+
+ m_paneIcons[LYTPane::PaneType] = LSGlobals::getIcon("pane");
+ m_paneIcons[LYTPane::PictureType] = LSGlobals::getIcon("picture");
+ m_paneIcons[LYTPane::TextBoxType] = LSGlobals::getIcon("textbox");
+ m_paneIcons[LYTPane::WindowType] = LSGlobals::getIcon("window");
+ m_paneIcons[LYTPane::BoundingType] = LSGlobals::getIcon("bounding");
}
@@ -45,6 +52,7 @@ int LSSceneModel::rowCount(const QModelIndex &parent) const {
}
int LSSceneModel::columnCount(const QModelIndex &parent) const {
+ (void)parent;
return 1;
}
@@ -54,6 +62,8 @@ QVariant LSSceneModel::data(const QModelIndex &index, int role) const {
switch (role) {
case Qt::DisplayRole:
return pane->name;
+ case Qt::DecorationRole:
+ return m_paneIcons[pane->type()];
}
}
return QVariant();
diff --git a/lsscenemodel.h b/lsscenemodel.h
index 3a26fc1..00cb736 100644
--- a/lsscenemodel.h
+++ b/lsscenemodel.h
@@ -2,6 +2,7 @@
#define LSSCENEMODEL_H
#include <QAbstractItemModel>
+#include <QIcon>
#include "lyt/layout.h"
class LSSceneModel : public QAbstractItemModel {
@@ -19,6 +20,8 @@ public:
private:
LYTLayout *m_layout;
+
+ QIcon m_paneIcons[LYTPane::PaneTypeCount];
signals:
diff --git a/lyt/pane.h b/lyt/pane.h
index 0d9936b..24d4a41 100644
--- a/lyt/pane.h
+++ b/lyt/pane.h
@@ -36,7 +36,7 @@ public:
virtual Magic magic() const;
enum PaneTypes {
- PaneType = 0, PictureType, TextBoxType, WindowType, BoundingType
+ PaneType = 0, PictureType, TextBoxType, WindowType, BoundingType, PaneTypeCount
};
virtual void writeToDataStream(QDataStream &out) const;