Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2b30811d authored by Laurent Montel's avatar Laurent Montel 😁

Remove QT_CHECK

parent 216b1268
......@@ -34,32 +34,6 @@
#include <KLocalizedString>
#include <QToolButton>
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
SearchFilterProxyModel::SearchFilterProxyModel(QObject *parent)
: KRecursiveFilterProxyModel(parent)
{
}
void SearchFilterProxyModel::setSearchPattern(const QString &pattern)
{
if (mPattern != pattern) {
mPattern = pattern;
invalidate();
}
}
bool SearchFilterProxyModel::acceptRow(int sourceRow, const QModelIndex &sourceParent) const
{
QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);
if (!mPattern.isEmpty()) {
const QString text = sourceIndex.data(Qt::DisplayRole).toString();
return text.contains(mPattern, Qt::CaseInsensitive);
} else {
return true;
}
}
#endif
SelectImapFolderWidget::SelectImapFolderWidget(const KSieveUi::SieveImapAccountSettings &account, QWidget *parent)
: QWidget(parent)
......@@ -91,15 +65,10 @@ SelectImapFolderWidget::SelectImapFolderWidget(const KSieveUi::SieveImapAccountS
mTreeView = new SelectImapFolderTreeView(this);
mTreeView->setObjectName(QStringLiteral("treeview"));
mTreeView->header()->hide();
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
mFilter = new SearchFilterProxyModel(this);
mFilter->setSourceModel(mModel);
#else
mFilter = new QSortFilterProxyModel(this);
mFilter->setFilterCaseSensitivity(Qt::CaseInsensitive);
mFilter->setRecursiveFilteringEnabled(true);
mFilter->setSourceModel(mModel);
#endif
mTreeView->setModel(mFilter);
connect(mTreeView, &QTreeView::doubleClicked, this, &SelectImapFolderWidget::slotDoubleClicked);
......@@ -126,11 +95,7 @@ void SelectImapFolderWidget::slotModelLoaded(QStandardItemModel *model, bool suc
void SelectImapFolderWidget::slotSearchPattern(const QString &pattern)
{
mTreeView->expandAll();
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
mFilter->setSearchPattern(pattern);
#else
mFilter->setFilterFixedString(pattern);
#endif
}
void SelectImapFolderWidget::slotDoubleClicked(const QModelIndex &index)
......
......@@ -29,24 +29,6 @@ class QStandardItemModel;
class QLineEdit;
class SelectImapFolderTreeView;
class QSortFilterProxyModel;
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
#include <KRecursiveFilterProxyModel>
class SearchFilterProxyModel : public KRecursiveFilterProxyModel
{
Q_OBJECT
public:
explicit SearchFilterProxyModel(QObject *parent = nullptr);
public Q_SLOTS:
void setSearchPattern(const QString &pattern);
protected:
bool acceptRow(int sourceRow, const QModelIndex &sourceParent) const override;
private:
QString mPattern;
};
#endif
class SelectImapFolderWidget : public QWidget
{
......@@ -73,11 +55,7 @@ private:
QLineEdit *mSearchLineEdit = nullptr;
SelectImapFolderTreeView *mTreeView = nullptr;
QStandardItemModel *mModel = nullptr;
#if (QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
SearchFilterProxyModel *mFilter = nullptr;
#else
QSortFilterProxyModel *mFilter = nullptr;
#endif
};
#endif // SELECTIMAPFOLDERWIDGET_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment