KD Chart 2  [rev.2.7]
kdganttlistviewrowcontroller.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
24 #include "kdganttlistviewrowcontroller_p.h"
25 
26 #include <QAbstractProxyModel>
27 #include <QScrollBar>
28 
29 #include <cassert>
30 
31 using namespace KDGantt;
32 
41  : _d( new Private(lv,proxy) )
42 {
43 }
44 
46 {
47  delete _d; _d = 0;
48 }
49 
50 #define d d_func()
51 
53 {
54  return d->listview->viewport()->y()-d->listview->frameWidth();
55 }
56 
58 {
59  return d->listview->fontMetrics().height();
60 }
61 
63 {
64  return d->listview->verticalScrollBar()->maximum()+d->listview->viewport()->height();
65 }
66 
67 bool ListViewRowController::isRowVisible( const QModelIndex& _idx ) const
68 {
69  const QModelIndex idx = d->proxy->mapToSource( _idx );
70  assert( idx.isValid() ? ( idx.model() == d->listview->model() ):( true ) );
71  return d->listview->visualRect(idx).isValid();
72 }
73 
74 bool ListViewRowController::isRowExpanded( const QModelIndex& _idx ) const
75 {
76  Q_UNUSED(_idx);
77 
78  return false;
79 }
80 
81 Span ListViewRowController::rowGeometry( const QModelIndex& _idx ) const
82 {
83  const QModelIndex idx = d->proxy->mapToSource( _idx );
84  assert( idx.isValid() ? ( idx.model() == d->listview->model() ):( true ) );
85  QRect r = d->listview->visualRect(idx).translated( QPoint( 0,
86  static_cast<Private::HackListView*>(d->listview)->verticalOffset() ) );
87  return Span( r.y(), r.height() );
88 }
89 
90 QModelIndex ListViewRowController::indexAt( int height ) const
91 {
92  return d->proxy->mapFromSource( d->listview->indexAt( QPoint( 1,height ) ) );
93 }
94 
95 QModelIndex ListViewRowController::indexAbove( const QModelIndex& _idx ) const
96 {
97  const QModelIndex idx = d->proxy->mapToSource( _idx );
98  return d->proxy->mapFromSource( idx.sibling( idx.row()-1, idx.column()) );
99 }
100 
101 QModelIndex ListViewRowController::indexBelow( const QModelIndex& _idx ) const
102 {
103  const QModelIndex idx = d->proxy->mapToSource( _idx );
104  if ( !idx.isValid() || idx.column()!=0 ) return QModelIndex();
105  if ( idx.model()->rowCount(idx.parent())<idx.row()+1 ) return QModelIndex();
106  return d->proxy->mapFromSource( idx.sibling( idx.row()+1, idx.column()) );
107 }
108 
QModelIndex indexAbove(const QModelIndex &idx) const override
QModelIndex indexAt(int height) const override
bool isRowVisible(const QModelIndex &idx) const override
A class representing a start point and a length.
Class only listed here to document inheritance of some KDChart classes.
Span rowGeometry(const QModelIndex &idx) const override
bool isRowExpanded(const QModelIndex &idx) const override
QModelIndex indexBelow(const QModelIndex &idx) const override
ListViewRowController(QListView *lv, QAbstractProxyModel *proxy)

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/

https://www.kdab.com/development-resources/qt-tools/kd-chart/