summaryrefslogtreecommitdiffstats
path: root/src/sessiontreemodel.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2016-01-20 16:43:34 +0100
committerSimon Rettberg2016-01-20 16:43:34 +0100
commit414c109d650a1014e7b84dfb66a00df420d67c97 (patch)
treeede0c5404aa408cd2bbb626312ed46383c7b13b6 /src/sessiontreemodel.cpp
parentRe-introduce tree structure: Allow server-defined sections (diff)
downloadvmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.tar.gz
vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.tar.xz
vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.zip
Remodel section handling: Use constants
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r--src/sessiontreemodel.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp
index 69c7302..d77555f 100644
--- a/src/sessiontreemodel.cpp
+++ b/src/sessiontreemodel.cpp
@@ -9,10 +9,11 @@
#include "sessiontreeitem.h"
#include "vsession.h"
#include "sessionsiconholder.h"
+#include "globals.h"
SessionTreeModel::SessionTreeModel(QObject *parent)
: QAbstractItemModel(parent) {
- root_ = new SessionTreeItem("dummy");
+ root_ = new SessionTreeItem(SECTION_NULL);
}
SessionTreeModel::~SessionTreeModel() {
@@ -129,11 +130,11 @@ void SessionTreeModel::addItems(const QList<Session*>& sessions) {
foreach (Session* s, sessions) {
bool sectionExists = false;
- QString section(s->section());
+ SectionType section = s->section();
for (int i = 0; i < root_->childCount(); ++i) {
SessionTreeItem* item = root_->child(i);
- if (item->text() == section) {
+ if (item->sectionType() == section) {
parentItem = item;
sectionExists = true;
break;
@@ -192,6 +193,16 @@ QList<Session*> SessionTreeModel::lookForItem(const QString& label) {
}
+QModelIndex SessionTreeModel::getSection(const SectionType type) {
+ for (int i = 0; i < root_->childCount(); ++i) {
+ SessionTreeItem* item = root_->child(i);
+ if (item->sectionType() == type && item->session() == NULL) {
+ return createIndex(i, 0, item);
+ }
+ }
+ return QModelIndex();
+}
+
void SessionTreeModel::updateView() {
emit layoutChanged();
}