summaryrefslogtreecommitdiffstats
path: root/src/sessiontreemodel.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-20 18:47:48 +0100
committerNils Schwabe2014-03-20 18:47:48 +0100
commitf3a0b4d09379e63a26ec410088617fe20d5cd27f (patch)
treee34adf2e0bf92ad5e0e03602c0d6060efbcdbead /src/sessiontreemodel.cpp
parentremoved the file and path option for XMLs (diff)
downloadvmchooser2-f3a0b4d09379e63a26ec410088617fe20d5cd27f.tar.gz
vmchooser2-f3a0b4d09379e63a26ec410088617fe20d5cd27f.tar.xz
vmchooser2-f3a0b4d09379e63a26ec410088617fe20d5cd27f.zip
- added tab view
- added filter box
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r--src/sessiontreemodel.cpp73
1 files changed, 17 insertions, 56 deletions
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp
index 177049d..2078aaa 100644
--- a/src/sessiontreemodel.cpp
+++ b/src/sessiontreemodel.cpp
@@ -150,77 +150,38 @@ QModelIndex SessionTreeModel::parent(const QModelIndex &index) const {
return createIndex(parentItem->row(), 0, parentItem);
}
-void SessionTreeModel::addItems(const QList<Session*>& sessions,
- 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);
- }
-
+void SessionTreeModel::addItems(const QList<Session*>& sessions) {
foreach (Session* s, sessions) {
- parentItem->appendChild(new SessionTreeItem(s, parentItem));
+ root_->appendChild(new SessionTreeItem(s, root_));
}
}
-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::addLabelItem(const QString& label) {
+ root_->appendChild(new SessionTreeItem(label, root_));
}
-void SessionTreeModel::removeItem(const QString& name, const QString& section) {
- SessionTreeItem* parentItem;
-
- bool sectionExists = false;
-
+void SessionTreeModel::removeItem(const QString& name) {
for (int i = 0; i < root_->childCount(); ++i) {
SessionTreeItem* item = root_->child(i);
- if (item->text() == section) {
- parentItem = item;
- sectionExists = true;
- break;
+ if (item->text() == name) {
+ root_->removeChild(item);
}
}
+}
+
+QList<Session*> SessionTreeModel::lookForItem(const QString& label) {
+ QList<Session*> result;
- if (sectionExists) {
- for (int i = 0; i < parentItem->childCount(); ++i) {
- SessionTreeItem* item = parentItem->child(i);
- if (item->text() == name) {
- parentItem->removeChild(item);
- }
+ for (int i = 0; i < root_->childCount(); ++i) {
+ SessionTreeItem* item = root_->child(i);
+ if (item->session()->shortDescription().contains(label, Qt::CaseInsensitive)) {
+ result.append(const_cast<Session*>(item->session()));
}
}
+ return result;
}
void SessionTreeModel::updateView() {
emit layoutChanged();
}
+