From f3a0b4d09379e63a26ec410088617fe20d5cd27f Mon Sep 17 00:00:00 2001 From: Nils Schwabe Date: Thu, 20 Mar 2014 18:47:48 +0100 Subject: - added tab view - added filter box --- src/sessiontreemodel.cpp | 73 +++++++++++------------------------------------- 1 file changed, 17 insertions(+), 56 deletions(-) (limited to 'src/sessiontreemodel.cpp') 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& 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& 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 SessionTreeModel::lookForItem(const QString& label) { + QList 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(item->session())); } } + return result; } void SessionTreeModel::updateView() { emit layoutChanged(); } + -- cgit v1.2.3-55-g7522