File indexing completed on 2024-05-12 15:54:24
0001 /* 0002 * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved. 0003 * 0004 * This file is part of the KGantt library. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef KGANTTFORWARDINGPROXYMODEL_H 0021 #define KGANTTFORWARDINGPROXYMODEL_H 0022 0023 #include <QAbstractProxyModel> 0024 0025 #include "kganttglobal.h" 0026 0027 namespace KGantt { 0028 class KGANTT_EXPORT ForwardingProxyModel : public QAbstractProxyModel { 0029 Q_OBJECT 0030 Q_DISABLE_COPY(ForwardingProxyModel) 0031 public: 0032 /*! Constructor. Creates a new ForwardingProxyModel with 0033 * parent \a parent 0034 */ 0035 explicit ForwardingProxyModel( QObject* parent = nullptr ); 0036 virtual ~ForwardingProxyModel(); 0037 0038 /*! Converts indexes in the source model to indexes in the proxy model */ 0039 /*reimp*/ QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const override; 0040 0041 /*! Converts indexes in the proxy model to indexes in the source model */ 0042 /*reimp*/ QModelIndex mapToSource ( const QModelIndex & proxyIndex ) const override; 0043 0044 /*! Sets the model to be used as the source model for this proxy. 0045 * The proxy does not take ownership of the model. 0046 * \see QAbstractProxyModel::setSourceModel 0047 */ 0048 /*reimp*/ void setSourceModel( QAbstractItemModel* model ) override; 0049 0050 /*! \see QAbstractItemModel::index */ 0051 /*reimp*/ QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override; 0052 0053 /*! \see QAbstractItemModel::parent */ 0054 /*reimp*/ QModelIndex parent( const QModelIndex& idx ) const override; 0055 0056 /*! \see QAbstractItemModel::rowCount */ 0057 /*reimp*/ int rowCount( const QModelIndex& idx = QModelIndex() ) const override; 0058 0059 /*! \see QAbstractItemModel::columnCount */ 0060 /*reimp*/ int columnCount( const QModelIndex& idx = QModelIndex() ) const override; 0061 0062 /*! \see QAbstractItemModel::setData */ 0063 /*reimp*/ bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override; 0064 0065 /*reimp*/ QMimeData *mimeData(const QModelIndexList &indexes) const override; 0066 /*reimp*/ bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; 0067 /*reimp*/ QStringList mimeTypes() const override; 0068 /*reimp*/ Qt::DropActions supportedDropActions() const override; 0069 0070 protected Q_SLOTS: 0071 /*! Called when the source model is about to be reset. 0072 * \sa QAbstractItemModel::modelAboutToBeReset() 0073 */ 0074 virtual void sourceModelAboutToBeReset(); 0075 0076 /*! Called when the source model is reset 0077 * \sa QAbstractItemModel::modelReset() 0078 */ 0079 virtual void sourceModelReset(); 0080 0081 /*! Called just before the layout of the source model is changed. 0082 * \sa QAbstractItemModel::layoutAboutToBeChanged() 0083 */ 0084 virtual void sourceLayoutAboutToBeChanged(); 0085 0086 /*! Called when the layout of the source model has changed. 0087 * \sa QAbstractItemModel::layoutChanged() 0088 */ 0089 virtual void sourceLayoutChanged(); 0090 0091 /*! Called when the data in an existing item in the source model changes. 0092 * \sa QAbstractItemModel::dataChanged() 0093 */ 0094 virtual void sourceDataChanged( const QModelIndex& from, const QModelIndex& to ); 0095 0096 /*! Called just before columns are inserted into the source model. 0097 * \sa QAbstractItemModel::columnsAboutToBeInserted() 0098 */ 0099 virtual void sourceColumnsAboutToBeInserted( const QModelIndex& idx, int start, int end ); 0100 0101 /*! Called after columns have been inserted into the source model. 0102 * \sa QAbstractItemModel::columnsInserted() 0103 */ 0104 virtual void sourceColumnsInserted( const QModelIndex& idx, int start, int end ); 0105 0106 /*! Called just before columns are removed from the source model. 0107 * \sa QAbstractItemModel::columnsAboutToBeRemoved() 0108 */ 0109 virtual void sourceColumnsAboutToBeRemoved( const QModelIndex& idx, int start, int end ); 0110 0111 /*! Called after columns have been removed from the source model. 0112 * \sa QAbstractItemModel::columnsRemoved() 0113 */ 0114 virtual void sourceColumnsRemoved( const QModelIndex& idx, int start, int end ); 0115 0116 0117 /*! Called just before rows are inserted into the source model. 0118 * \sa QAbstractItemModel::rowsAboutToBeInserted() 0119 */ 0120 virtual void sourceRowsAboutToBeInserted( const QModelIndex& idx, int start, int end ); 0121 0122 /*! Called after rows have been inserted into the source model. 0123 * \sa QAbstractItemModel::rowsInserted() 0124 */ 0125 virtual void sourceRowsInserted( const QModelIndex& idx, int start, int end ); 0126 0127 /*! Called just before rows are removed from the source model. 0128 * \sa QAbstractItemModel::rowsAboutToBeRemoved() 0129 */ 0130 virtual void sourceRowsAboutToBeRemoved( const QModelIndex&, int start, int end ); 0131 0132 /*! Called after rows have been removed from the source model. 0133 * \sa QAbstractItemModel::rowsRemoved() 0134 */ 0135 virtual void sourceRowsRemoved( const QModelIndex&, int start, int end ); 0136 }; 0137 } 0138 0139 #endif /* KGANTTFORWARDINGPROXYMODEL_H */ 0140