summaryrefslogtreecommitdiff
path: root/src/backend/bookshelfmodel/btbookshelffiltermodel.h
blob: e440c693eda02c1192b58655a560d26319db5ba8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*********
*
* In the name of the Father, and of the Son, and of the Holy Spirit.
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
**********/

#ifndef BTBOOKSHELFFILTERMODEL_H
#define BTBOOKSHELFFILTERMODEL_H

#include <QSortFilterProxyModel>

#include "backend/drivers/cswordmoduleinfo.h"


class BtBookshelfFilterModel: public QSortFilterProxyModel {
    Q_OBJECT
    public:
        BtBookshelfFilterModel(QObject *parent = 0);
        virtual ~BtBookshelfFilterModel();

        // Common methods:
        inline bool enabled() const {
            return m_enabled;
        }

        virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;

        // Name filter:
        inline int nameFilterRole() const {
            return m_nameFilterRole;
        }

        inline int nameFilterKeyColumn() const {
            return m_nameFilterColumn;
        }

        inline const QString &nameFilter() const {
            return m_nameFilter;
        }

        inline const Qt::CaseSensitivity nameFilterCase() const {
            return m_nameFilterCase;
        }

        // Hidden filter:
        int hiddenFilterRole() const {
            return m_hiddenFilterRole;
        }

        int hiddenFilterKeyColumn() const {
            return m_hiddenFilterColumn;
        }

        inline bool showHidden() const {
            return m_showHidden;
        }

        inline bool showShown() const {
            return m_showShown;
        }

        // Category filter:
        int categoryFilterRole() const {
            return m_categoryFilterRole;
        }

        int categoryFilterKeyColumn() const {
            return m_categoryFilterColumn;
        }

        inline CSwordModuleInfo::Categories shownCategories() const {
            return m_categoryFilter;
        }

    public slots:
        void setEnabled(bool enable);

        // Name filter:
        void setNameFilterRole(int role);
        void setNameFilterKeyColumn(int column);
        void setNameFilterFixedString(const QString &nameFilter);
        void setNameFilterCase(Qt::CaseSensitivity value);

        // Hidden filter:
        void setHiddenFilterRole(int role);
        void setHiddenFilterKeyColumn(int column);
        void setShowHidden(bool show);
        void setShowShown(bool show);

        // Category filter:
        void setCategoryFilterRole(int role);
        void setCategoryFilterKeyColumn(int column);
        void setShownCategories(const CSwordModuleInfo::Categories &categories);

    protected:
        bool nameFilterAcceptsRow(int row, const QModelIndex &parent) const;
        bool hiddenFilterAcceptsRow(int row, const QModelIndex &parent) const;
        bool categoryFilterAcceptsRow(int row, const QModelIndex &parent) const;

    protected:
        bool m_enabled;

        // Name filter:
        QString m_nameFilter;
        int m_nameFilterRole;
        int m_nameFilterColumn;
        Qt::CaseSensitivity  m_nameFilterCase;

        // Hidden filter:
        int m_hiddenFilterRole;
        int m_hiddenFilterColumn;
        bool m_showHidden;
        bool m_showShown;

        // Categories filter:
        CSwordModuleInfo::Categories m_categoryFilter;
        int m_categoryFilterRole;
        int m_categoryFilterColumn;
};

#endif // BTBOOKSHELFFILTERMODEL_H