File indexing completed on 2024-10-06 04:55:04

0001 /*
0002     SPDX-FileCopyrightText: 2014 David Rosca <nowrep@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include <BluezQt/DevicesModel>
0010 #include <QSortFilterProxyModel>
0011 
0012 #include <qqmlregistration.h>
0013 
0014 class DevicesProxyModel : public QSortFilterProxyModel
0015 {
0016     Q_OBJECT
0017     QML_ELEMENT
0018 
0019 public:
0020     enum AdditionalRoles {
0021         SectionRole = BluezQt::DevicesModel::LastRole + 10,
0022         DeviceFullNameRole = BluezQt::DevicesModel::LastRole + 11,
0023     };
0024 
0025     explicit DevicesProxyModel(QObject *parent = nullptr);
0026 
0027     QHash<int, QByteArray> roleNames() const override;
0028     QVariant data(const QModelIndex &index, int role) const override;
0029     bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
0030     bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
0031 
0032     Q_INVOKABLE QString adapterHciString(const QString &ubi) const;
0033 
0034 private:
0035     bool duplicateIndexAddress(const QModelIndex &idx) const;
0036 };