LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
fixedstringfilterproxymodel.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <QProperty>
12#include <QSortFilterProxyModel>
13#include "modelsconfig.h"
14
15namespace LC::Util
16{
17 class UTIL_MODELS_API FixedStringFilterProxyModel : public QSortFilterProxyModel
18 {
19 QStringMatcher Filter_;
20 QList<int> Columns_ {};
21 QList<int> Roles_ { Qt::DisplayRole };
22
23 QPropertyNotifier FilterRegexGuard_;
24 QPropertyNotifier FilterKeyColumnGuard_;
25 public:
26 explicit FixedStringFilterProxyModel (QObject* = nullptr);
27 explicit FixedStringFilterProxyModel (Qt::CaseSensitivity, QObject* = nullptr);
28
29 void SetFilterString (const QString&);
30 QString GetFilterString () const;
31
32 bool IsFilterSet () const;
33
34 void SetCaseSensitivity (Qt::CaseSensitivity);
35 Qt::CaseSensitivity GetCaseSensitivity () const;
36
37 void SetFilterRoles (const QList<int>&);
39
40 void SetFilterColumns (const QList<int>&);
42 protected:
43 bool IsMatch (const QString&) const;
44
45 /* Called by `SetFilterString()` within the `beginFilterChange()`/`endFilterChange()` pair.
46 *
47 * Override this function to update any custom filtering dependent on the filter string
48 * in your subclass.
49 */
50 virtual void UpdateDerivedFilter (const QString&);
51
52 bool filterAcceptsRow (int row, const QModelIndex& parent) const override;
53 private:
54 using QSortFilterProxyModel::setFilterFixedString;
55 };
56}
bool filterAcceptsRow(int row, const QModelIndex &parent) const override
#define UTIL_MODELS_API