generic-property-filter.h Source File

| Home · All Classes · All Namespaces · Modules · Functions · Files

generic-property-filter.h
1
23 #ifndef _TelepathyQt_generic_property_filter_h_HEADER_GUARD_
24 #define _TelepathyQt_generic_property_filter_h_HEADER_GUARD_
25
26 #ifndef IN_TP_QT_HEADER
27 #error IN_TP_QT_HEADER
28 #endif
29
30 #include <TelepathyQt/Filter>
31 #include <TelepathyQt/Types>
32
33 namespace Tp
34 {
35
36 template <class T>
37 class GenericPropertyFilter : public Filter<T>
38 {
39 public:
40 inline virtual ~GenericPropertyFilter() { }
41
42 inline virtual bool isValid() const { return true; }
43
44 inline virtual bool matches(const SharedPtr<T> &t) const
45 {
46 for (QVariantMap::const_iterator i = mFilter.constBegin();
47 i != mFilter.constEnd(); ++i) {
48 QString propertyName = i.key();
49 QVariant propertyValue = i.value();
50
51 if (t->property(propertyName.toLatin1().constData()) != propertyValue) {
52 return false;
53 }
54 }
55
56 return true;
57 }
58
59 inline QVariantMap filter() const { return mFilter; }
60
61 inline void addProperty(const QString &propertyName, const QVariant &propertyValue)
62 {
63 mFilter.insert(propertyName, propertyValue);
64 }
65
66 inline void setProperties(const QVariantMap &filter) { mFilter = filter; }
67
68 protected:
69 inline GenericPropertyFilter() : Filter<T>() { }
70
71 private:
72 QVariantMap mFilter;
73 };
74
75 } // Tp
76
77 #endif
Tp::GenericPropertyFilter::GenericPropertyFilter
GenericPropertyFilter()
Definition: generic-property-filter.h:69
Tp::GenericPropertyFilter::~GenericPropertyFilter
virtual ~GenericPropertyFilter()
Definition: generic-property-filter.h:40
Tp::Filter
The Filter class provides a base class to be used by specialized filters such as GenericCapabilityFil...
Definition: filter.h:37
Tp::SharedPtr
The SharedPtr class is a pointer to an explicitly shared object.
Definition: shared-ptr.h:39
Tp::GenericPropertyFilter::addProperty
void addProperty(const QString &propertyName, const QVariant &propertyValue)
Definition: generic-property-filter.h:61
Tp::GenericPropertyFilter::setProperties
void setProperties(const QVariantMap &filter)
Definition: generic-property-filter.h:66
Tp::GenericPropertyFilter::matches
virtual bool matches(const SharedPtr< T > &t) const
Definition: generic-property-filter.h:44
Tp::GenericPropertyFilter
The GenericPropertyFilter class provides a generic filter object to be used to filter objects by prop...
Definition: generic-property-filter.h:37
Tp::GenericPropertyFilter::isValid
virtual bool isValid() const
Definition: generic-property-filter.h:42
Tp::GenericPropertyFilter::filter
QVariantMap filter() const
Definition: generic-property-filter.h:59