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
GenericPropertyFilter()
Definition: generic-property-filter.h:69
virtual ~GenericPropertyFilter()
Definition: generic-property-filter.h:40
The Filter class provides a base class to be used by specialized filters such as GenericCapabilityFil...
Definition: filter.h:37
The SharedPtr class is a pointer to an explicitly shared object.
Definition: shared-ptr.h:39
void addProperty(const QString &propertyName, const QVariant &propertyValue)
Definition: generic-property-filter.h:61
void setProperties(const QVariantMap &filter)
Definition: generic-property-filter.h:66
virtual bool matches(const SharedPtr< T > &t) const
Definition: generic-property-filter.h:44
The GenericPropertyFilter class provides a generic filter object to be used to filter objects by prop...
Definition: generic-property-filter.h:37
virtual bool isValid() const
Definition: generic-property-filter.h:42
QVariantMap filter() const
Definition: generic-property-filter.h:59


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt 0.9.6.1