1 /************************************************************************** 2 * Otter Browser: Web browser controlled by the user, not vice-versa. 3 * Copyright (C) 2015 Piotr Wójcik <chocimier@tlen.pl> 4 * Copyright (C) 2015 - 2017 Michal Dutkiewicz aka Emdek <michal@emdek.pl> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 **************************************************************************/ 20 21 #ifndef OTTER_PROXYMODEL_H 22 #define OTTER_PROXYMODEL_H 23 24 #include <QtCore/QIdentityProxyModel> 25 #include <QtGui/QStandardItemModel> 26 27 namespace Otter 28 { 29 30 class ProxyModel final : public QIdentityProxyModel 31 { 32 Q_OBJECT 33 34 public: 35 explicit ProxyModel(QStandardItemModel *model, const QVector<QPair<QString, int> > &mapping, QObject *parent = nullptr); 36 37 QMimeData* mimeData(const QModelIndexList &indexes) const override; 38 QVariant data(const QModelIndex &index, int role) const override; 39 QVariant headerData(int section, Qt::Orientation orientation, int role) const override; 40 QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override; 41 QModelIndex sibling(int row, int column, const QModelIndex &index) const override; 42 Qt::ItemFlags flags(const QModelIndex &index) const override; 43 int columnCount(const QModelIndex &parent) const override; 44 int rowCount(const QModelIndex &parent) const override; 45 bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override; 46 47 private: 48 QStandardItemModel *m_model; 49 QVector<QPair<QString, int> > m_mapping; 50 QMap<int, QMap<int, QVariant> > m_headerData; 51 }; 52 53 } 54 55 #endif 56