~ubuntu-branches/ubuntu/trusty/bibletime/trusty

« back to all changes in this revision

Viewing changes to src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Marsden
  • Date: 2009-11-18 17:30:00 UTC
  • mfrom: (1.3.4 upstream) (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20091118173000-endkhjz5qai88tvr
Tags: 2.4-1
* New upstream version 2.4
* debian/control: 
  - Replace incorrect bibletime-data Depends on lib4qt-gui
    with bibletime Depends on libqtgui4 (>= 4.4.0). (Closes: #556209).
  - Add Build-depends: on zlib1g-dev and libcurl4-gnutls-dev 
    (Closes: #556805).

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
14
14
 
 
15
#include "backend/bookshelfmodel/btbookshelfmodel.h"
 
16
 
 
17
 
15
18
BtModuleNameFilterProxyModel::BtModuleNameFilterProxyModel(QObject *parent)
16
 
    : QSortFilterProxyModel(parent), m_enabled(true)
17
 
{
 
19
        : QSortFilterProxyModel(parent), m_enabled(true) {
 
20
    setFilterRole(BtBookshelfModel::ModuleNameRole);
18
21
    setFilterCaseSensitivity(Qt::CaseInsensitive);
19
22
}
20
23
 
23
26
}
24
27
 
25
28
bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
26
 
                                                    const QModelIndex &p) const
27
 
{
 
29
        const QModelIndex &p) const {
28
30
    if (!m_enabled) return true;
29
31
 
30
32
    const QAbstractItemModel *m(sourceModel());
31
33
    Q_ASSERT(m != 0);
32
34
 
33
 
    QModelIndex itemIndex(m->index(row, 0, p));
 
35
    QModelIndex itemIndex(m->index(row, filterKeyColumn(), p));
34
36
    int numChildren(m->rowCount(itemIndex));
35
37
    if (numChildren == 0) {
36
38
        return QSortFilterProxyModel::filterAcceptsRow(row, p);
37
 
    } else {
 
39
    }
 
40
    else {
38
41
        for (int i(0); i < numChildren; i++) {
39
42
            if (filterAcceptsRow(i, itemIndex)) return true;
40
43
        }