summaryrefslogtreecommitdiffstats
path: root/qt-ui/filtermodels.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-11-13 16:51:48 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-13 12:03:30 -0800
commit51f8010c9b21f75aa5a51c1d3bcd85c22c8793cf (patch)
treec30cd1e8756b61a4b4f77cac38ff076fce7c1ef0 /qt-ui/filtermodels.cpp
parent76e1fe3ee774a5177481e6233b87a9133a7b77b5 (diff)
downloadsubsurface-51f8010c9b21f75aa5a51c1d3bcd85c22c8793cf.tar.gz
Call all common methods once per class in an easy way.
New method to simplify the creation of 4 of the common methods for each filter in an easy way. There are a few other methods that I'm also thinking on how to do this. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/filtermodels.cpp')
-rw-r--r--qt-ui/filtermodels.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/qt-ui/filtermodels.cpp b/qt-ui/filtermodels.cpp
index 557460b3e..71fa8f8cd 100644
--- a/qt-ui/filtermodels.cpp
+++ b/qt-ui/filtermodels.cpp
@@ -11,13 +11,6 @@ CLASS *CLASS::instance() \
return self; \
}
-CREATE_INSTANCE_METHOD(TagFilterModel);
-CREATE_INSTANCE_METHOD(BuddyFilterModel);
-CREATE_INSTANCE_METHOD(LocationFilterModel);
-CREATE_INSTANCE_METHOD(MultiFilterSortModel);
-
-#undef CREATE_INSTANCE_METHOD
-
#define CREATE_MODEL_SET_DATA_METHOD( CLASS ) \
bool CLASS::setData(const QModelIndex &index, const QVariant &value, int role) \
{ \
@@ -36,12 +29,6 @@ bool CLASS::setData(const QModelIndex &index, const QVariant &value, int role) \
return false; \
}
-CREATE_MODEL_SET_DATA_METHOD(TagFilterModel);
-CREATE_MODEL_SET_DATA_METHOD(BuddyFilterModel);
-CREATE_MODEL_SET_DATA_METHOD(LocationFilterModel);
-
-#undef CREATE_MODEL_SET_DATA_METHOD
-
#define CREATE_CLEAR_FILTER_METHOD( CLASS ) \
void CLASS::clearFilter() \
{ \
@@ -51,21 +38,22 @@ void CLASS::clearFilter() \
emit dataChanged(createIndex(0,0), createIndex(rowCount()-1, 0)); \
}
-CREATE_CLEAR_FILTER_METHOD(TagFilterModel);
-CREATE_CLEAR_FILTER_METHOD(BuddyFilterModel);
-CREATE_CLEAR_FILTER_METHOD(LocationFilterModel);
-
-#undef CREATE_CLEAR_FILTER_METHOD
-
#define CREATE_FLAGS_METHOD( CLASS ) \
Qt::ItemFlags CLASS::flags(const QModelIndex &index) const \
{ \
return QStringListModel::flags(index) | Qt::ItemIsUserCheckable; \
}
-CREATE_FLAGS_METHOD(TagFilterModel);
-CREATE_FLAGS_METHOD(BuddyFilterModel);
-CREATE_FLAGS_METHOD(LocationFilterModel);
+#define CREATE_COMMON_METHODS_FOR_FILTER( CLASS ) \
+CREATE_FLAGS_METHOD( CLASS ); \
+CREATE_CLEAR_FILTER_METHOD( CLASS ); \
+CREATE_MODEL_SET_DATA_METHOD( CLASS ); \
+CREATE_INSTANCE_METHOD( CLASS )
+
+CREATE_COMMON_METHODS_FOR_FILTER(TagFilterModel);
+CREATE_COMMON_METHODS_FOR_FILTER(BuddyFilterModel);
+CREATE_COMMON_METHODS_FOR_FILTER(LocationFilterModel);
+CREATE_INSTANCE_METHOD(MultiFilterSortModel);
TagFilterModel::TagFilterModel(QObject *parent) : QStringListModel(parent)
{