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

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 KGANTTABSTRACTROWCONTROLLER_H
0021 #define KGANTTABSTRACTROWCONTROLLER_H
0022 
0023 #include <QPair>
0024 #include "kganttglobal.h"
0025 
0026 QT_BEGIN_NAMESPACE
0027 class QModelIndex;
0028 QT_END_NAMESPACE
0029 
0030 namespace KGantt {
0031 
0032 
0033     /*!\class KGantt::AbstractRowController kganttabstractrowcontroller.h KGanttAbstractRowController
0034      * \ingroup KGantt
0035      * \brief Abstract baseclass for row controllers. A row controller is used
0036      * by the GraphicsView to nagivate the model and to determine the
0037      * row geometries
0038      */
0039     class KGANTT_EXPORT AbstractRowController {
0040     public:
0041         /*! Constructor. Does nothing */
0042         AbstractRowController();
0043 
0044         /*! Destructor. Does nothing */
0045         virtual ~AbstractRowController();
0046 
0047         /*!\fn virtual int AbstractRowController::headerHeight() const = 0
0048          * \returns The height of the header part of the view.
0049          *
0050          * Implement this to control how much space is reserved at
0051          * the top of the view for a header
0052          */
0053         virtual int headerHeight() const = 0;
0054         virtual int maximumItemHeight() const = 0;
0055 
0056 
0057         /*!\fn virtual int AbstractRowController::totalHeight() const = 0
0058         * \returns the total height of the rows. For uniformly sized rows that would be
0059         * number_of_rows*row_height.
0060         */
0061         virtual int totalHeight() const = 0;
0062 
0063         /*!\fn virtual bool AbstractRowController::isRowVisible( const QModelIndex& idx ) const
0064          * \returns true if the row containing index \a idx is visible
0065          * in the view.
0066          *
0067          * Implement this to allow KGantt to optimize how items on
0068          * screen are created. It is not harmful to always return true here,
0069          * but the View will not perform optimally.
0070          */
0071         virtual bool isRowVisible( const QModelIndex& idx ) const = 0;
0072         virtual bool isRowExpanded( const QModelIndex& idx ) const = 0;
0073 
0074         /*!\fn virtual Span AbstractRowController::rowGeometry( const QModelIndex& idx ) const
0075          * \returns A Span consisting of the row offset and height for the row
0076          * containing \a idx. A simple implementation might look like
0077          *
0078          * \code
0079          * Span MyRowCtrlr::rowGeometry(const QModelIndex& idx)
0080          * {
0081          *      return Span(idx.row()*10,10);
0082          * }
0083          * \endcode
0084          */
0085         virtual Span rowGeometry( const QModelIndex& idx ) const = 0;
0086 
0087         virtual QModelIndex indexAt( int height ) const = 0;
0088 
0089         /*!\fn virtual QModelIndex AbstractRowController::indexAbove( const QModelIndex& idx ) const
0090          *\returns The modelindex for the previous row before \a idx.
0091          *
0092          *\see QTreeView::indexAbove
0093          */
0094         virtual QModelIndex indexAbove( const QModelIndex& idx ) const = 0;
0095 
0096 
0097         /*!\fn virtual QModelIndex AbstractRowController::indexBelow( const QModelIndex& idx ) const
0098          *\returns The modelindex for the next row after \a idx.
0099          *
0100          *\see QTreeView::indexBelow
0101          */
0102         virtual QModelIndex indexBelow( const QModelIndex& idx ) const = 0;
0103     };
0104 }
0105 
0106 #endif /* KGANTTABSTRACTROWCONTROLLER_H */
0107