KGantt

kganttlistviewrowcontroller.cpp
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KGantt library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#include "kganttlistviewrowcontroller.h"
10#include "kganttlistviewrowcontroller_p.h"
11
12#include <QAbstractProxyModel>
13#include <QScrollBar>
14
15#include <cassert>
16
17using namespace KGantt;
18
19
20
21ListViewRowController::ListViewRowController( QListView* lv, QAbstractProxyModel* proxy )
22 : _d( new Private(lv,proxy) )
23{
24}
25
26ListViewRowController::~ListViewRowController()
27{
28 delete _d; _d = nullptr;
29}
30
31#define d d_func()
32
34{
35 return d->listview->viewport()->y()-d->listview->frameWidth();
36}
37
38int ListViewRowController::maximumItemHeight() const
39{
40 return d->listview->fontMetrics().height();
41}
42
44{
45 return d->listview->verticalScrollBar()->maximum()+d->listview->viewport()->height();
46}
47
49{
50 const QModelIndex idx = d->proxy->mapToSource( _idx );
51 assert( idx.isValid() ? ( idx.model() == d->listview->model() ):( true ) );
52 return d->listview->visualRect(idx).isValid();
53}
54
55bool ListViewRowController::isRowExpanded( const QModelIndex& _idx ) const
56{
57 Q_UNUSED(_idx);
58
59 return false;
60}
61
63{
64 const QModelIndex idx = d->proxy->mapToSource( _idx );
65 assert( idx.isValid() ? ( idx.model() == d->listview->model() ):( true ) );
66 QRect r = d->listview->visualRect(idx).translated( QPoint( 0,
67 static_cast<Private::HackListView*>(d->listview)->verticalOffset() ) );
68 return Span( r.y(), r.height() );
69}
70
71QModelIndex ListViewRowController::indexAt( int height ) const
72{
73 return d->proxy->mapFromSource( d->listview->indexAt( QPoint( 1,height ) ) );
74}
75
77{
78 const QModelIndex idx = d->proxy->mapToSource( _idx );
79 return d->proxy->mapFromSource( idx.sibling( idx.row()-1, idx.column()) );
80}
81
83{
84 const QModelIndex idx = d->proxy->mapToSource( _idx );
85 if ( !idx.isValid() || idx.column()!=0 ) return QModelIndex();
86 if ( idx.model()->rowCount(idx.parent())<idx.row()+1 ) return QModelIndex();
87 return d->proxy->mapFromSource( idx.sibling( idx.row()+1, idx.column()) );
88}
89
QModelIndex indexAbove(const QModelIndex &idx) const override
Span rowGeometry(const QModelIndex &idx) const override
QModelIndex indexBelow(const QModelIndex &idx) const override
bool isRowVisible(const QModelIndex &idx) const override
A class representing a start point and a length.
Global namespace.
virtual int rowCount(const QModelIndex &parent) const const=0
int column() const const
bool isValid() const const
const QAbstractItemModel * model() const const
QModelIndex parent() const const
int row() const const
QModelIndex sibling(int row, int column) const const
int height() const const
QRect translated(const QPoint &offset) const const
int y() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:56:31 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.