summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-12-08 16:48:18 (GMT)
committerSwift Review <review@swift.im>2014-05-26 14:40:44 (GMT)
commit168538129a69fa37a19e768149b32ca262bb85a3 (patch)
tree70881bbddc7561f2139f9d2ec32c7a5d357a8909 /Swift/Controllers
parent3a2c03a97576b2839eeba3015ccebde769263d09 (diff)
downloadswift-168538129a69fa37a19e768149b32ca262bb85a3.zip
swift-168538129a69fa37a19e768149b32ca262bb85a3.tar.bz2
Add QtFilterWidget, a general live-filtering composite widget for QtTreeWidgets.
Change-Id: I39d1ae718890d15ffacde6d482b5435cc05330ec License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/Roster/FuzzyRosterFilter.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/Swift/Controllers/Roster/FuzzyRosterFilter.h b/Swift/Controllers/Roster/FuzzyRosterFilter.h
new file mode 100644
index 0000000..6710084
--- /dev/null
+++ b/Swift/Controllers/Roster/FuzzyRosterFilter.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013 Tobias Markmann
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#pragma once
+
+#include <string>
+
+#include <Swift/Controllers/ContactSuggester.h>
+#include <Swift/Controllers/Roster/ContactRosterItem.h>
+#include <Swift/Controllers/Roster/RosterItem.h>
+#include <Swift/Controllers/Roster/RosterFilter.h>
+
+namespace Swift {
+
+class FuzzyRosterFilter : public RosterFilter {
+ public:
+ FuzzyRosterFilter(const std::string& query) : query_(query) { }
+ virtual ~FuzzyRosterFilter() {}
+ virtual bool operator() (RosterItem* item) const {
+ ContactRosterItem *contactItem = dynamic_cast<ContactRosterItem*>(item);
+ if (contactItem) {
+ const bool itemMatched = ContactSuggester::fuzzyMatch(contactItem->getDisplayName(), query_) || ContactSuggester::fuzzyMatch(contactItem->getDisplayJID(), query_);
+ return !itemMatched;
+ } else {
+ return false;
+ }
+ }
+
+ private:
+ std::string query_;
+};
+
+}
+
+