1 /* 2 widget3dview.h 3 4 This file is part of GammaRay, the Qt application inspection and 5 manipulation tool. 6 7 Copyright (C) 2011-2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com 8 Author: Daniel Vrátil <daniel.vratil@kdab.com> 9 10 Licensees holding valid commercial KDAB GammaRay licenses may use this file in 11 accordance with GammaRay Commercial License Agreement provided with the Software. 12 13 Contact info@kdab.com if any conditions of this licensing are not clear to you. 14 15 This program is free software; you can redistribute it and/or modify 16 it under the terms of the GNU General Public License as published by 17 the Free Software Foundation, either version 2 of the License, or 18 (at your option) any later version. 19 20 This program is distributed in the hope that it will be useful, 21 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 GNU General Public License for more details. 24 25 You should have received a copy of the GNU General Public License 26 along with this program. If not, see <http://www.gnu.org/licenses/>. 27 */ 28 29 #ifndef WIDGET3DWINDOWMODEL_H 30 #define WIDGET3DWINDOWMODEL_H 31 32 #include <QAbstractProxyModel> 33 #include <QPersistentModelIndex> 34 35 #include "widget3dmodel.h" 36 37 namespace GammaRay { 38 39 class Widget3DWindowModel : public QAbstractProxyModel 40 { 41 Q_OBJECT 42 43 public: 44 explicit Widget3DWindowModel(QObject *parent = nullptr); 45 ~Widget3DWindowModel(); 46 47 void setSourceModel(QAbstractItemModel *sourceModel_) override; 48 49 int rowCount(const QModelIndex &parent) const override; 50 int columnCount(const QModelIndex &parent) const override; 51 QModelIndex index(int row, int column, const QModelIndex & parent) const override; 52 QModelIndex parent(const QModelIndex &child) const override; 53 54 QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; 55 QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; 56 57 private Q_SLOTS: 58 void sourceModelRowsInserted(const QModelIndex &parent, int first, int last); 59 void sourceModelRowsRemoved(); 60 void sourceModelReset(); 61 62 private: 63 class WindowNode; 64 65 void populate(); 66 QModelIndex indexForNode(WindowNode *node) const; 67 68 QVector<WindowNode*> mNodes; 69 }; 70 71 } 72 73 #endif 74