Changeset View
Changeset View
Standalone View
Standalone View
src/core/model/accountschannelsmodel.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (c) 2020 Olivier de Gaalon <olivier.jg@gmail.com> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or modify | ||||
5 | it under the terms of the GNU Library General Public License as published | ||||
6 | by the Free Software Foundation; either version 2 of the License or | ||||
7 | ( at your option ) version 3 or, at the discretion of KDE e.V. | ||||
8 | ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. | ||||
9 | | ||||
10 | This library is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | Library General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU Library General Public License | ||||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef ACCOUNTSCHANNELSMODEL_H | ||||
22 | #define ACCOUNTSCHANNELSMODEL_H | ||||
23 | | ||||
24 | #include <QAbstractItemModel> | ||||
25 | #include <QPointer> | ||||
26 | | ||||
27 | #include "libruqolacore_export.h" | ||||
28 | | ||||
29 | class RocketChatAccount; | ||||
30 | class RoomFilterProxyModel; | ||||
31 | | ||||
32 | class LIBRUQOLACORE_EXPORT AccountsChannelsModel : public QAbstractItemModel | ||||
33 | { | ||||
34 | public: | ||||
35 | explicit AccountsChannelsModel(QObject *parent = nullptr); | ||||
36 | | ||||
37 | QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override; | ||||
38 | QModelIndex parent(const QModelIndex &child) const override; | ||||
39 | int rowCount(const QModelIndex &parent = {}) const override; | ||||
40 | int columnCount(const QModelIndex &parent = {}) const override; | ||||
41 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||||
42 | | ||||
43 | private: | ||||
44 | QModelIndex modelRoot(QAbstractItemModel *model) const; | ||||
45 | QAbstractItemModel *rootModel(const QModelIndex &root) const; | ||||
46 | void proxyModel(QAbstractItemModel *model, const std::function<QModelIndex()> &root); | ||||
47 | void unproxyModel(QAbstractItemModel *model); | ||||
48 | | ||||
49 | struct ProxyIndex | ||||
50 | { | ||||
51 | QAbstractItemModel *model; | ||||
52 | std::function<QModelIndex()> root; | ||||
53 | }; | ||||
54 | QVector<ProxyIndex> mProxied; | ||||
55 | }; | ||||
56 | | ||||
57 | #endif // ACCOUNTSCHANNELSMODEL_H |