Changeset 7eed752 in subsurface


Ignore:
Timestamp:
Dec 24, 2017, 8:24:11 AM (4 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
668635e
Parents:
1a4e7ad0
git-author:
Berthold Stoeger <bstoeger@…> (12/23/17 05:55:59)
git-committer:
Dirk Hohndel <dirk@…> (12/24/17 08:24:11)
Message:

Fold MultiFilterInterface? into FilterModelBase?

There were two classes, MultiFilterInterface? and FiterModelBase?.
The latter derives from the former and from QStringListModel.
The former was not used anywhere else. Moreover, in contradiction
to its name, MultiFilterInterface? is not an interface (in the Java
sense), because it actually has (non-virtual) data members. All in
all, the data model is very weird.

Merge these two classes, since there seems to be no gain whatsoever
from keeping MultiFilterInterface? separate.

Signed-off-by: Berthold Stoeger <bstoeger@…>

Location:
qt-models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • qt-models/filtermodels.cpp

    r935fb3c r7eed752  
    8080
    8181FilterModelBase::FilterModelBase(QObject *parent) : QStringListModel(parent)
     82                                                  , anyChecked(false)
    8283{
    8384}
     
    402403                return showTrip;
    403404        }
    404         Q_FOREACH (MultiFilterInterface *model, models) {
     405        Q_FOREACH (FilterModelBase *model, models) {
    405406                if (!model->doFilter(d, index0, sourceModel()))
    406407                        shouldShow = false;
     
    457458}
    458459
    459 void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model)
     460void MultiFilterSortModel::addFilterModel(FilterModelBase *model)
    460461{
    461462        QAbstractItemModel *itemModel = dynamic_cast<QAbstractItemModel *>(model);
     
    465466}
    466467
    467 void MultiFilterSortModel::removeFilterModel(MultiFilterInterface *model)
     468void MultiFilterSortModel::removeFilterModel(FilterModelBase *model)
    468469{
    469470        QAbstractItemModel *itemModel = dynamic_cast<QAbstractItemModel *>(model);
     
    476477{
    477478        justCleared = true;
    478         Q_FOREACH (MultiFilterInterface *iface, models) {
     479        Q_FOREACH (FilterModelBase *iface, models) {
    479480                iface->clearFilter();
    480481        }
  • qt-models/filtermodels.h

    r24c72cb r7eed752  
    88#include <vector>
    99
    10 class MultiFilterInterface {
     10class FilterModelBase : public QStringListModel {
    1111public:
    12         MultiFilterInterface() : anyChecked(false) {}
    1312        virtual bool doFilter(struct dive *d, QModelIndex &index0, QAbstractItemModel *sourceModel) const = 0;
    1413        virtual void clearFilter() = 0;
    1514        std::vector<char> checkState;
    1615        bool anyChecked;
    17 };
    18 
    19 class FilterModelBase : public QStringListModel, public MultiFilterInterface {
    2016protected:
    2117        explicit FilterModelBase(QObject *parent = 0);
     
    9894        static MultiFilterSortModel *instance();
    9995        virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
    100         void addFilterModel(MultiFilterInterface *model);
    101         void removeFilterModel(MultiFilterInterface *model);
     96        void addFilterModel(FilterModelBase *model);
     97        void removeFilterModel(FilterModelBase *model);
    10298        int divesDisplayed;
    10399public
     
    112108private:
    113109        MultiFilterSortModel(QObject *parent = 0);
    114         QList<MultiFilterInterface *> models;
     110        QList<FilterModelBase *> models;
    115111        bool justCleared;
    116112        struct dive_site *curr_dive_site;
Note: See TracChangeset for help on using the changeset viewer.