summaryrefslogtreecommitdiffstats
path: root/src/sessiontreemodel.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-21 17:30:03 +0100
committerNils Schwabe2014-03-21 17:30:03 +0100
commitb72f1d53558344392daa916f69ece7db8c7a9d89 (patch)
treeeb40fbd424b7f51c9ae3b34a6e09088e151985b9 /src/sessiontreemodel.cpp
parent- display the keywords in the desciption box (diff)
downloadvmchooser2-b72f1d53558344392daa916f69ece7db8c7a9d89.tar.gz
vmchooser2-b72f1d53558344392daa916f69ece7db8c7a9d89.tar.xz
vmchooser2-b72f1d53558344392daa916f69ece7db8c7a9d89.zip
added functionality to filter box
Diffstat (limited to 'src/sessiontreemodel.cpp')
-rw-r--r--src/sessiontreemodel.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/sessiontreemodel.cpp b/src/sessiontreemodel.cpp
index 2078aaa..722850e 100644
--- a/src/sessiontreemodel.cpp
+++ b/src/sessiontreemodel.cpp
@@ -172,13 +172,33 @@ void SessionTreeModel::removeItem(const QString& name) {
QList<Session*> SessionTreeModel::lookForItem(const QString& label) {
QList<Session*> result;
- 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()));
+ if (label.startsWith("\"")) {
+ QString searchTerm = label;
+ searchTerm.remove(0, 1);
+ if (label.endsWith("\"")) {
+ searchTerm.chop(1);
+ }
+ QList<QString> 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<Session*>(item->session()));
+ }
+ }
+ } else {
+ QList<QString> 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<Session*>(item->session()));
+ }
}
}
+
return result;
+
}
void SessionTreeModel::updateView() {