diff options
author | Nils Schwabe | 2014-03-07 16:23:16 +0100 |
---|---|---|
committer | Nils Schwabe | 2014-03-07 16:23:16 +0100 |
commit | 56d213b3c8984ef033784e60fccf25d3cfbdbb13 (patch) | |
tree | ac6fdf1487a2051a702b58cae349cd6c6e3d6e84 /src/sessiontreemodel.cpp | |
parent | fixed umlauts in xml (diff) | |
download | vmchooser2-56d213b3c8984ef033784e60fccf25d3cfbdbb13.tar.gz vmchooser2-56d213b3c8984ef033784e60fccf25d3cfbdbb13.tar.xz vmchooser2-56d213b3c8984ef033784e60fccf25d3cfbdbb13.zip |
Added function to add info entries if the xml file could not be loaded
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r-- | src/sessiontreemodel.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp index 12eebf5..d63bab5 100644 --- a/src/sessiontreemodel.cpp +++ b/src/sessiontreemodel.cpp @@ -4,6 +4,7 @@ #include <QIcon> #include <QResource> #include <QString> +#include <QtDebug> #include "sessiontreeitem.h" @@ -160,3 +161,49 @@ void SessionTreeModel::addItems(const QList<Session*>& sessions, parentItem->appendChild(new SessionTreeItem(s, parentItem)); } } + +void SessionTreeModel::addLabelItem(const QString& label, const QString& section) { + SessionTreeItem* parentItem; + + bool sectionExists = false; + + for (int i = 0; i < root_->childCount(); ++i) { + SessionTreeItem* item = root_->child(i); + if (item->text() == section) { + parentItem = item; + sectionExists = true; + break; + } + } + + if (!sectionExists) { + parentItem = new SessionTreeItem(section, root_); + root_->appendChild(parentItem); + } + + parentItem->appendChild(new SessionTreeItem(label, parentItem)); +} + +void SessionTreeModel::removeItem(const QString& name, const QString& section) { + SessionTreeItem* parentItem; + + bool sectionExists = false; + + for (int i = 0; i < root_->childCount(); ++i) { + SessionTreeItem* item = root_->child(i); + if (item->text() == section) { + parentItem = item; + sectionExists = true; + break; + } + } + + if (sectionExists) { + for (int i = 0; i < parentItem->childCount(); ++i) { + SessionTreeItem* item = parentItem->child(i); + if (item->text() == name) { + parentItem->removeChild(item); + } + } + } +} |