From c6a0f624e7cb7c9ae35a49bdb550243fcd1fecd5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 4 Jan 2016 15:54:11 +0100 Subject: Icons in tabs, configurable default tab --- src/sessiontreemodel.cpp | 68 ++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/sessiontreemodel.cpp') diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp index aaf47b9..cf4f2cf 100644 --- a/src/sessiontreemodel.cpp +++ b/src/sessiontreemodel.cpp @@ -135,46 +135,46 @@ void SessionTreeModel::addLabelItem(const QString& label) { } void SessionTreeModel::removeItem(const QString& name) { - for (int i = 0; i < root_->childCount(); ++i) { - SessionTreeItem* item = root_->child(i); - if (item->text() == name) { - root_->removeChild(item); - } - } + for (int i = 0; i < root_->childCount(); ++i) { + SessionTreeItem* item = root_->child(i); + if (item->text() == name) { + root_->removeChild(item); + } + } } QList SessionTreeModel::lookForItem(const QString& label) { - QList result; - - if (label.startsWith("\"")) { - QString searchTerm = label; - searchTerm.remove(0, 1); - if (label.endsWith("\"")) { - searchTerm.chop(1); - } - QList items; - items.append(searchTerm); - for (int i = 0; i < root_->childCount(); ++i) { - SessionTreeItem* item = root_->child(i); - if (item->session()->containsKeywords(items)) { - result.append(const_cast(item->session())); - } - } - } else { - QList items = label.split(" ", QString::SkipEmptyParts); - for (int i = 0; i < root_->childCount(); ++i) { - SessionTreeItem* item = root_->child(i); - if (item->session()->containsKeywords(items)) { - result.append(const_cast(item->session())); - } - } - } - - return result; + QList result; + + if (label.startsWith("\"")) { + QString searchTerm = label; + searchTerm.remove(0, 1); + if (label.endsWith("\"")) { + searchTerm.chop(1); + } + QList items; + items.append(searchTerm); + for (int i = 0; i < root_->childCount(); ++i) { + SessionTreeItem* item = root_->child(i); + if (item->session() != NULL && item->session()->containsKeywords(items)) { + result.append(const_cast(item->session())); + } + } + } else { + QList items = label.split(" ", QString::SkipEmptyParts); + for (int i = 0; i < root_->childCount(); ++i) { + SessionTreeItem* item = root_->child(i); + if (item->session() != NULL && item->session()->containsKeywords(items)) { + result.append(const_cast(item->session())); + } + } + } + + return result; } void SessionTreeModel::updateView() { - emit layoutChanged(); + emit layoutChanged(); } -- cgit v1.2.3-55-g7522