File indexing completed on 2024-06-23 04:42:35

0001 // SPDX-FileCopyrightText: 2021 Waqar Ahmed <waqar.17a@gmail.com>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 #include <QSortFilterProxyModel>
0005 
0006 class CommandBarFilterModel final : public QSortFilterProxyModel
0007 {
0008     Q_OBJECT
0009     Q_PROPERTY(QString filterString READ filterString WRITE setFilterString NOTIFY filterStringChanged)
0010 public:
0011     explicit CommandBarFilterModel(QObject *parent = nullptr);
0012 
0013     QString filterString() const;
0014 
0015     void setFilterString(const QString &string);
0016 
0017 Q_SIGNALS:
0018     void filterStringChanged();
0019 
0020 protected:
0021     bool lessThan(const QModelIndex &sourceLeft, const QModelIndex &sourceRight) const override;
0022 
0023     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
0024 
0025 private:
0026     QString m_pattern;
0027 };