MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9
   Home · All Classes · All Namespaces · Modules · Functions · Files

generic-property-filter.h

00001 
00023 #ifndef _TelepathyQt4_generic_property_filter_h_HEADER_GUARD_
00024 #define _TelepathyQt4_generic_property_filter_h_HEADER_GUARD_
00025 
00026 #ifndef IN_TELEPATHY_QT4_HEADER
00027 #error IN_TELEPATHY_QT4_HEADER
00028 #endif
00029 
00030 #include <TelepathyQt4/Filter>
00031 #include <TelepathyQt4/Types>
00032 
00033 namespace Tp
00034 {
00035 
00036 template <class T>
00037 class GenericPropertyFilter : public Filter<T>
00038 {
00039 public:
00040     inline virtual ~GenericPropertyFilter() { }
00041 
00042     inline virtual bool isValid() const { return true; }
00043 
00044     inline virtual bool matches(const SharedPtr<T> &t) const
00045     {
00046         for (QVariantMap::const_iterator i = mFilter.constBegin();
00047                 i != mFilter.constEnd(); ++i) {
00048             QString propertyName = i.key();
00049             QVariant propertyValue = i.value();
00050 
00051             if (t->property(propertyName.toLatin1().constData()) != propertyValue) {
00052                 return false;
00053             }
00054         }
00055 
00056         return true;
00057     }
00058 
00059     inline QVariantMap filter() const { return mFilter; }
00060 
00061     inline void addProperty(const QString &propertyName, const QVariant &propertyValue)
00062     {
00063         mFilter.insert(propertyName, propertyValue);
00064     }
00065 
00066     inline void setProperties(const QVariantMap &filter) { mFilter = filter; }
00067 
00068 protected:
00069     inline GenericPropertyFilter() : Filter<T>() { }
00070 
00071 private:
00072     QVariantMap mFilter;
00073 };
00074 
00075 } // Tp
00076 
00077 #endif

Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.6.5