summaryrefslogtreecommitdiffstats
path: root/qt-ui/filtermodels.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-11-13 16:34:55 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-13 12:01:56 -0800
commitdfea10fbb80710d7faf8fe7a1cee1ab8eea57384 (patch)
tree443de2b1e567437955168930e2993667e0e19188 /qt-ui/filtermodels.cpp
parent10fecefddd809bddd46e50fcc7a7438d8257174d (diff)
downloadsubsurface-dfea10fbb80710d7faf8fe7a1cee1ab8eea57384.tar.gz
Create a CREATE_INSTANCE_METHOD macro
This is just to simplify the creation of more filters. more macros will be used, because I tend to abuse them. 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.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/qt-ui/filtermodels.cpp b/qt-ui/filtermodels.cpp
index 3dabc80cc..a60b2c04f 100644
--- a/qt-ui/filtermodels.cpp
+++ b/qt-ui/filtermodels.cpp
@@ -4,14 +4,21 @@
#include "mainwindow.h"
#include "display.h"
-TagFilterModel::TagFilterModel(QObject *parent) : QStringListModel(parent)
-{
+#define CREATE_INSTANCE_METHOD( CLASS ) \
+CLASS *CLASS::instance() \
+{ \
+ static CLASS *self = new CLASS(); \
+ return self; \
}
-TagFilterModel *TagFilterModel::instance()
+CREATE_INSTANCE_METHOD(TagFilterModel);
+CREATE_INSTANCE_METHOD(BuddyFilterModel);
+CREATE_INSTANCE_METHOD(LocationFilterModel);
+
+#undef CREATE_INSTANCE_METHOD
+
+TagFilterModel::TagFilterModel(QObject *parent) : QStringListModel(parent)
{
- static TagFilterModel *self = new TagFilterModel();
- return self;
}
QVariant TagFilterModel::data(const QModelIndex &index, int role) const
@@ -126,12 +133,6 @@ BuddyFilterModel::BuddyFilterModel(QObject *parent) : QStringListModel(parent)
{
}
-BuddyFilterModel *BuddyFilterModel::instance()
-{
- static BuddyFilterModel *self = new BuddyFilterModel();
- return self;
-}
-
bool BuddyFilterModel::doFilter(dive *d, QModelIndex &index0, QAbstractItemModel *sourceModel) const
{
// If there's nothing checked, this should show everything
@@ -316,12 +317,6 @@ Qt::ItemFlags LocationFilterModel::flags(const QModelIndex &index) const
return QStringListModel::flags(index) | Qt::ItemIsUserCheckable;
}
-LocationFilterModel *LocationFilterModel::instance()
-{
- static LocationFilterModel *self = new LocationFilterModel();
- return self;
-}
-
void LocationFilterModel::repopulate()
{
QStringList list;