Changeset View
Changeset View
Standalone View
Standalone View
resources/ews/ewssubscriptionwidget.cpp
Show All 18 Lines | |||||
19 | 19 | | |||
20 | #include "ewssubscriptionwidget.h" | 20 | #include "ewssubscriptionwidget.h" | ||
21 | 21 | | |||
22 | #include <QCheckBox> | 22 | #include <QCheckBox> | ||
23 | #include <QHBoxLayout> | 23 | #include <QHBoxLayout> | ||
24 | #include <QHeaderView> | 24 | #include <QHeaderView> | ||
25 | #include <QLineEdit> | 25 | #include <QLineEdit> | ||
26 | #include <QPushButton> | 26 | #include <QPushButton> | ||
27 | #include <QSortFilterProxyModel> | ||||
27 | #include <QStandardItemModel> | 28 | #include <QStandardItemModel> | ||
28 | #include <QTreeView> | 29 | #include <QTreeView> | ||
29 | #include <QVBoxLayout> | 30 | #include <QVBoxLayout> | ||
30 | 31 | | |||
31 | #include <KMessageWidget> | 32 | #include <KMessageWidget> | ||
32 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
33 | #include <KRecursiveFilterProxyModel> | | |||
34 | #include "ewsclient.h" | 34 | #include "ewsclient.h" | ||
35 | #include "ewsfindfolderrequest.h" | 35 | #include "ewsfindfolderrequest.h" | ||
36 | #include "ewssubscribedfoldersjob.h" | 36 | #include "ewssubscribedfoldersjob.h" | ||
37 | #include "ewssettings.h" | 37 | #include "ewssettings.h" | ||
38 | 38 | | |||
39 | class EwsSubscriptionFilterModel : public KRecursiveFilterProxyModel | 39 | class EwsSubscriptionFilterModel : public QSortFilterProxyModel | ||
40 | { | 40 | { | ||
41 | Q_OBJECT | 41 | Q_OBJECT | ||
42 | public: | 42 | public: | ||
43 | explicit EwsSubscriptionFilterModel(QObject *parent = nullptr); | 43 | explicit EwsSubscriptionFilterModel(QObject *parent = nullptr); | ||
44 | ~EwsSubscriptionFilterModel() override; | 44 | ~EwsSubscriptionFilterModel() override; | ||
45 | public Q_SLOTS: | 45 | public Q_SLOTS: | ||
46 | void setFilterSelected(bool enabled); | 46 | void setFilterSelected(bool enabled); | ||
47 | protected: | 47 | protected: | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 75 | public: | |||
90 | EwsSubscriptionFilterModel *mFilterModel = nullptr; | 90 | EwsSubscriptionFilterModel *mFilterModel = nullptr; | ||
91 | EwsSettings *mSettings = nullptr; | 91 | EwsSettings *mSettings = nullptr; | ||
92 | 92 | | |||
93 | EwsSubscriptionWidget *q_ptr = nullptr; | 93 | EwsSubscriptionWidget *q_ptr = nullptr; | ||
94 | Q_DECLARE_PUBLIC(EwsSubscriptionWidget) | 94 | Q_DECLARE_PUBLIC(EwsSubscriptionWidget) | ||
95 | }; | 95 | }; | ||
96 | 96 | | |||
97 | EwsSubscriptionFilterModel::EwsSubscriptionFilterModel(QObject *parent) | 97 | EwsSubscriptionFilterModel::EwsSubscriptionFilterModel(QObject *parent) | ||
98 | : KRecursiveFilterProxyModel(parent) | 98 | : QSortFilterProxyModel(parent) | ||
99 | , mFilterSelected(false) | 99 | , mFilterSelected(false) | ||
100 | { | 100 | { | ||
101 | setRecursiveFilteringEnabled(true); | ||||
101 | } | 102 | } | ||
102 | 103 | | |||
103 | EwsSubscriptionFilterModel::~EwsSubscriptionFilterModel() | 104 | EwsSubscriptionFilterModel::~EwsSubscriptionFilterModel() | ||
104 | { | 105 | { | ||
105 | } | 106 | } | ||
106 | 107 | | |||
107 | bool EwsSubscriptionFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const | 108 | bool EwsSubscriptionFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const | ||
108 | { | 109 | { | ||
109 | bool show = true; | 110 | bool show = true; | ||
110 | if (mFilterSelected) { | 111 | if (mFilterSelected) { | ||
111 | QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent); | 112 | QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent); | ||
112 | 113 | | |||
113 | show = sourceIndex.data(Qt::CheckStateRole).toInt() == Qt::Checked; | 114 | show = sourceIndex.data(Qt::CheckStateRole).toInt() == Qt::Checked; | ||
114 | show |= hasCheckedChildren(sourceIndex); | 115 | show |= hasCheckedChildren(sourceIndex); | ||
115 | } | 116 | } | ||
116 | 117 | | |||
117 | if (!show) { | 118 | if (!show) { | ||
118 | return false; | 119 | return false; | ||
119 | } else { | 120 | } else { | ||
120 | return KRecursiveFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); | 121 | return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); | ||
121 | } | 122 | } | ||
122 | } | 123 | } | ||
123 | 124 | | |||
124 | bool EwsSubscriptionFilterModel::hasCheckedChildren(const QModelIndex &index) const | 125 | bool EwsSubscriptionFilterModel::hasCheckedChildren(const QModelIndex &index) const | ||
125 | { | 126 | { | ||
126 | QModelIndex child; | 127 | QModelIndex child; | ||
127 | int row = 0; | 128 | int row = 0; | ||
128 | child = sourceModel()->index(row, 0, index); | 129 | child = sourceModel()->index(row, 0, index); | ||
▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines |