File indexing completed on 2024-05-12 15:54:29

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 KGANTTSUMMARYHANDLINGPROXYMODEL_H
0021 #define KGANTTSUMMARYHANDLINGPROXYMODEL_H
0022 
0023 #include "kganttforwardingproxymodel.h"
0024 
0025 namespace KGantt {
0026 
0027 
0028     /*!\class KGantt::SummaryHandlingProxyModel
0029      * \brief Proxy model that supports summary gantt items.
0030      *
0031      * This proxy model provides the functionality of summary items.
0032      * A summary item is an item with type KGantt::TypeSummary and
0033      * zero or more children in the model that it summarizes.
0034      * GraphicsView itself does not dictate any policy for summary items,
0035      * instead the logic for making the summary items start and end points
0036      * span it's children is provided by this proxy.
0037      *
0038      * The start and end times of a summary is the min/max of the
0039      * start/end times of it's children.
0040      *
0041      * \see GraphicsView::setModel
0042      */
0043     class KGANTT_EXPORT SummaryHandlingProxyModel : public ForwardingProxyModel {
0044         Q_OBJECT
0045         KGANTT_DECLARE_PRIVATE_BASE_POLYMORPHIC( SummaryHandlingProxyModel )
0046     public:
0047 
0048 
0049         /*! Constructor. Creates a new SummaryHandlingProxyModel with
0050          * parent \a parent
0051          */
0052         explicit SummaryHandlingProxyModel( QObject* parent = nullptr );
0053         virtual ~SummaryHandlingProxyModel();
0054 
0055 
0056 
0057         /*! Sets the model to be used as the source model for this proxy.
0058          * The proxy does not take ownership of the model.
0059          * \see QAbstractProxyModel::setSourceModel
0060          */
0061         /*reimp*/ void setSourceModel( QAbstractItemModel* model ) override;
0062 
0063 
0064 
0065         /*! \see QAbstractItemModel::data */
0066         /*reimp*/ QVariant data( const QModelIndex& proxyIndex, int role = Qt::DisplayRole) const override;
0067 
0068 
0069         /*! \see QAbstractItemModel::setData */
0070         /*reimp*/ bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override;
0071 
0072 
0073 
0074         /*! \see QAbstractItemModel::flags */
0075         /*reimp*/ Qt::ItemFlags flags( const QModelIndex& idx ) const override;
0076 
0077     protected:
0078         /*reimp*/ void sourceModelReset() override;
0079         /*reimp*/ void sourceLayoutChanged() override;
0080         /*reimp*/ void sourceDataChanged( const QModelIndex& from, const QModelIndex& to ) override;
0081         /*reimp*/ void sourceColumnsAboutToBeInserted( const QModelIndex& idx, int start, int end ) override;
0082         /*reimp*/ void sourceColumnsAboutToBeRemoved( const QModelIndex& idx, int start, int end ) override;
0083         /*reimp*/ void sourceRowsAboutToBeInserted( const QModelIndex& idx, int start, int end ) override;
0084         /*reimp*/ void sourceRowsAboutToBeRemoved( const QModelIndex&, int start, int end ) override;
0085     };
0086 }
0087 
0088 #endif /* KGANTTSUMMARYHANDLINGPROXYMODEL_H */
0089