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