diff options
author | Simon Rettberg | 2016-01-20 16:43:34 +0100 |
---|---|---|
committer | Simon Rettberg | 2016-01-20 16:43:34 +0100 |
commit | 414c109d650a1014e7b84dfb66a00df420d67c97 (patch) | |
tree | ede0c5404aa408cd2bbb626312ed46383c7b13b6 /src/sessiontreeitem.cpp | |
parent | Re-introduce tree structure: Allow server-defined sections (diff) | |
download | vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.tar.gz vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.tar.xz vmchooser2-414c109d650a1014e7b84dfb66a00df420d67c97.zip |
Remodel section handling: Use constants
Diffstat (limited to 'src/sessiontreeitem.cpp')
-rw-r--r-- | src/sessiontreeitem.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/src/sessiontreeitem.cpp b/src/sessiontreeitem.cpp index bdc3edf..65deae8 100644 --- a/src/sessiontreeitem.cpp +++ b/src/sessiontreeitem.cpp @@ -1,12 +1,33 @@ #include "sessiontreeitem.h" -SessionTreeItem::SessionTreeItem(const Session* session, - SessionTreeItem *parent) - : parent_(parent), session_(session) { +QString SessionTreeItem::typeToName(const SectionType type) { + switch (type) { + case SECTION_FOR_LOCATION: + return QObject::tr("Working environments for this room"); + case SECTION_TEMPLATES: + return QObject::tr("Templates"); + case SECTION_GENERIC: + return QObject::tr("Working environments"); + case SECTION_XSESSION: + return QObject::tr("X-Sessions"); + case SECTION_NULL: + return "<null>"; + default: + break; + } + return "Missing case for SectionType"; +} + +SessionTreeItem::SessionTreeItem(const Session* session, SessionTreeItem *parent) + : parent_(parent), session_(session), sectionType_(session->section()), text_(session->shortDescription()) { +} + +SessionTreeItem::SessionTreeItem(const SectionType type, SessionTreeItem *parent) + : parent_(parent), session_(NULL), sectionType_(type), text_(typeToName(type)) { } SessionTreeItem::SessionTreeItem(const QString& text, SessionTreeItem *parent) - : parent_(parent), session_(NULL), text_(text) { + : parent_(parent), session_(NULL), sectionType_(SECTION_NULL), text_(text) { } SessionTreeItem::~SessionTreeItem() { @@ -18,7 +39,7 @@ void SessionTreeItem::appendChild(SessionTreeItem *item) { } void SessionTreeItem::removeChild(SessionTreeItem *item) { - children_.removeOne(item); + children_.removeOne(item); } SessionTreeItem *SessionTreeItem::child(int row) { @@ -29,10 +50,6 @@ int SessionTreeItem::childCount() const { return children_.count(); } -int SessionTreeItem::columnCount() const { - return 1; -} - SessionTreeItem *SessionTreeItem::parent() { return parent_; } @@ -45,10 +62,3 @@ int SessionTreeItem::row() const { return 0; } -const Session* SessionTreeItem::session() const { - return session_; -} - -const QString SessionTreeItem::text() const { - return text_; -} |