File indexing completed on 2024-11-24 04:50:43

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