File indexing completed on 2024-02-18 15:43:48

0001 /*
0002    SPDX-FileCopyrightText: 2020 Olivier de Gaalon <olivier.jg@gmail.com>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QAbstractItemModel>
0010 
0011 #include "libruqolacore_export.h"
0012 
0013 class LIBRUQOLACORE_EXPORT AccountsChannelsModel : public QAbstractItemModel
0014 {
0015 public:
0016     explicit AccountsChannelsModel(QObject *parent = nullptr);
0017     ~AccountsChannelsModel() override;
0018 
0019     QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
0020     QModelIndex parent(const QModelIndex &child) const override;
0021     int rowCount(const QModelIndex &parent = {}) const override;
0022     int columnCount(const QModelIndex &parent = {}) const override;
0023     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0024 
0025 private:
0026     [[nodiscard]] LIBRUQOLACORE_NO_EXPORT QModelIndex modelRoot(QAbstractItemModel *model) const;
0027     LIBRUQOLACORE_NO_EXPORT QAbstractItemModel *rootModel(const QModelIndex &root) const;
0028     LIBRUQOLACORE_NO_EXPORT void mapModelToIndex(QAbstractItemModel *model, const std::function<QModelIndex()> &root);
0029     LIBRUQOLACORE_NO_EXPORT void unproxyModel(QAbstractItemModel *model);
0030 
0031     struct ProxyIndex {
0032         QAbstractItemModel *model = nullptr;
0033         std::function<QModelIndex()> root;
0034     };
0035     QVector<ProxyIndex> mProxied;
0036 };