File indexing completed on 2024-05-19 04:22:22

0001 /*
0002  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
0003  *
0004  * This file is part of the KGantt library.
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #ifndef KGANTTFORWARDINGPROXYMODEL_H
0010 #define KGANTTFORWARDINGPROXYMODEL_H
0011 
0012 #include <QAbstractProxyModel>
0013 
0014 #include "kganttglobal.h"
0015 
0016 namespace KGantt {
0017     class KGANTT_EXPORT ForwardingProxyModel : public QAbstractProxyModel {
0018         Q_OBJECT
0019         Q_DISABLE_COPY(ForwardingProxyModel)
0020     public:
0021         /*! Constructor. Creates a new ForwardingProxyModel with
0022          * parent \a parent
0023          */
0024         explicit ForwardingProxyModel( QObject* parent = nullptr );
0025         ~ForwardingProxyModel() override;
0026 
0027         /*! Converts indexes in the source model to indexes in the proxy model */
0028         /*reimp*/ QModelIndex mapFromSource ( const QModelIndex & sourceIndex ) const override;
0029 
0030         /*! Converts indexes in the proxy model to indexes in the source model */
0031         /*reimp*/ QModelIndex mapToSource ( const QModelIndex & proxyIndex ) const override;
0032 
0033         /*! Sets the model to be used as the source model for this proxy.
0034          * The proxy does not take ownership of the model.
0035          * \see QAbstractProxyModel::setSourceModel
0036          */
0037         /*reimp*/ void setSourceModel( QAbstractItemModel* model ) override;
0038 
0039         /*! \see QAbstractItemModel::index */
0040         /*reimp*/ QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
0041 
0042         /*! \see QAbstractItemModel::parent */
0043         /*reimp*/ QModelIndex parent( const QModelIndex& idx ) const override;
0044 
0045         /*! \see QAbstractItemModel::rowCount */
0046         /*reimp*/ int rowCount( const QModelIndex& idx = QModelIndex() ) const override;
0047 
0048         /*! \see QAbstractItemModel::columnCount */
0049         /*reimp*/ int columnCount( const QModelIndex& idx = QModelIndex() ) const override;
0050 
0051         /*! \see QAbstractItemModel::setData */
0052         /*reimp*/ bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override;
0053 
0054         /*reimp*/ QMimeData *mimeData(const QModelIndexList &indexes) const override;
0055         /*reimp*/ bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
0056         /*reimp*/ QStringList mimeTypes() const override;
0057         /*reimp*/ Qt::DropActions supportedDropActions() const override;
0058     
0059     protected Q_SLOTS:
0060         /*! Called when the source model is about to be reset.
0061          * \sa QAbstractItemModel::modelAboutToBeReset()
0062          */
0063         virtual void sourceModelAboutToBeReset();
0064 
0065         /*! Called when the source model is reset
0066          * \sa QAbstractItemModel::modelReset()
0067          */
0068         virtual void sourceModelReset();
0069 
0070         /*! Called just before the layout of the source model is changed.
0071          * \sa QAbstractItemModel::layoutAboutToBeChanged()
0072          */
0073         virtual void sourceLayoutAboutToBeChanged();
0074 
0075         /*! Called when the layout of the source model has changed.
0076          * \sa QAbstractItemModel::layoutChanged()
0077          */
0078         virtual void sourceLayoutChanged();
0079 
0080         /*! Called when the data in an existing item in the source model changes.
0081          * \sa QAbstractItemModel::dataChanged()
0082          */
0083         virtual void sourceDataChanged( const QModelIndex& from, const QModelIndex& to );
0084 
0085         /*! Called just before columns are inserted into the source model.
0086          * \sa QAbstractItemModel::columnsAboutToBeInserted()
0087          */
0088         virtual void sourceColumnsAboutToBeInserted( const QModelIndex& idx, int start, int end );
0089 
0090         /*! Called after columns have been inserted into the source model.
0091          * \sa QAbstractItemModel::columnsInserted()
0092          */
0093         virtual void sourceColumnsInserted( const QModelIndex& idx, int start, int end );
0094 
0095         /*! Called just before columns are removed from the source model.
0096          * \sa QAbstractItemModel::columnsAboutToBeRemoved()
0097          */
0098         virtual void sourceColumnsAboutToBeRemoved( const QModelIndex& idx, int start, int end );
0099 
0100         /*! Called after columns have been removed from the source model.
0101          * \sa QAbstractItemModel::columnsRemoved()
0102          */
0103         virtual void sourceColumnsRemoved( const QModelIndex& idx, int start, int end );
0104 
0105 
0106         /*! Called just before rows are inserted into the source model.
0107          * \sa QAbstractItemModel::rowsAboutToBeInserted()
0108          */
0109         virtual void sourceRowsAboutToBeInserted( const QModelIndex& idx, int start, int end );
0110 
0111         /*! Called after rows have been inserted into the source model.
0112          * \sa QAbstractItemModel::rowsInserted()
0113          */
0114         virtual void sourceRowsInserted( const QModelIndex& idx, int start, int end );
0115 
0116         /*! Called just before rows are removed from the source model.
0117          * \sa QAbstractItemModel::rowsAboutToBeRemoved()
0118          */
0119         virtual void sourceRowsAboutToBeRemoved( const QModelIndex&, int start, int end );
0120 
0121         /*! Called after rows have been removed from the source model.
0122          * \sa QAbstractItemModel::rowsRemoved()
0123          */
0124         virtual void sourceRowsRemoved( const QModelIndex&, int start, int end );
0125     };
0126 }
0127 
0128 #endif /* KGANTTFORWARDINGPROXYMODEL_H */
0129