diff options
author | Treeki <treeki@gmail.com> | 2012-08-18 04:29:13 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-08-18 04:29:13 +0200 |
commit | a55b7493b1bd54e9d1231fa18300e0f882700fe3 (patch) | |
tree | ed1e1eb8da7a10b49278e3a0801980d0663ea201 /lsscenemodel.cpp | |
parent | 56bf2bd3ff73fc3cd86dcb4f4cd1e42016522bea (diff) | |
download | LayoutStudio-a55b7493b1bd54e9d1231fa18300e0f882700fe3.tar.gz LayoutStudio-a55b7493b1bd54e9d1231fa18300e0f882700fe3.zip |
made pane visibility part of the scene graph tree
Diffstat (limited to '')
-rw-r--r-- | lsscenemodel.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/lsscenemodel.cpp b/lsscenemodel.cpp index acb059c..1e55cdd 100644 --- a/lsscenemodel.cpp +++ b/lsscenemodel.cpp @@ -1,8 +1,8 @@ #include "lsscenemodel.h" #include "lsglobals.h" -LSSceneModel::LSSceneModel(LYTLayout *layout, QObject *parent) : - QAbstractItemModel(parent) +LSSceneModel::LSSceneModel(LYTLayout *layout, bool exposeVisibility, QObject *parent) : + QAbstractItemModel(parent), m_exposesVisibility(exposeVisibility) { m_layout = layout; @@ -72,19 +72,41 @@ QVariant LSSceneModel::data(const QModelIndex &index, int role) const { case Qt::DecorationRole: return m_paneIcons[pane->type()]; } + + if (m_exposesVisibility && role == Qt::CheckStateRole) { + return pane->visible ? Qt::Checked : Qt::Unchecked; + } } return QVariant(); } +bool LSSceneModel::setData(const QModelIndex &index, const QVariant &value, int role) { + if (m_exposesVisibility && role == Qt::CheckStateRole) { + LYTPane *pane = (LYTPane*)index.internalPointer(); + + bool newVisible = value.toBool(); + if (pane->visible != newVisible) { + pane->visible = newVisible; + emit dataChanged(index, index); + emit paneVisibilityChanged(); + } + } + + return false; +} + Qt::ItemFlags LSSceneModel::flags(const QModelIndex &index) const { Qt::ItemFlags flag; flag = Qt::ItemIsEnabled | Qt::ItemIsSelectable | - Qt::ItemIsDropEnabled | Qt::ItemIsEditable; + Qt::ItemIsDropEnabled; if (index.isValid() && index.parent().isValid()) flag |= Qt::ItemIsDragEnabled; + if (m_exposesVisibility) + flag |= Qt::ItemIsUserCheckable; + return flag; } |