KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
kdgantttreeviewrowcontroller.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
12#include "kdgantttreeviewrowcontroller_p.h"
13
14#include <QAbstractProxyModel>
15#include <QHeaderView>
16#include <QScrollBar>
17
18#include <cassert>
19
20using namespace KDGantt;
21
27TreeViewRowController::TreeViewRowController(QTreeView *tv,
29 : _d(new Private)
30{
31 _d->treeview = static_cast<Private::HackTreeView *>(tv);
32 _d->proxy = proxy;
33}
34
36{
37 delete _d;
38 _d = nullptr;
39}
40
41#define d d_func()
42
44{
45 // return d->treeview->header()->sizeHint().height();
46 return d->treeview->viewport()->y() - d->treeview->frameWidth();
47}
48
50{
51 return d->treeview->fontMetrics().height();
52}
53
55{
56 return d->treeview->verticalScrollBar()->maximum() + d->treeview->viewport()->height();
57}
58
60{
61 // qDebug() << _idx.model()<<d->proxy << d->treeview->model();
62 const QModelIndex idx = d->proxy->mapToSource(_idx);
63 assert(idx.isValid() ? (idx.model() == d->treeview->model()) : (true));
64 return d->treeview->visualRect(idx).isValid();
65}
66
68{
69 const QModelIndex idx = d->proxy->mapToSource(_idx);
70 assert(idx.isValid() ? (idx.model() == d->treeview->model()) : (true));
71 return d->treeview->isExpanded(idx);
72}
73
75{
76 const QModelIndex idx = d->proxy->mapToSource(_idx);
77 assert(idx.isValid() ? (idx.model() == d->treeview->model()) : (true));
78 QRect r = d->treeview->visualRect(idx).translated(QPoint(0, d->treeview->verticalOffset()));
79 return Span(r.y(), r.height());
80}
81
83{
84 /* using indexAt( QPoint ) won't work here, since it does hit detection
85 * against the actual item text/icon, so we would return wrong values
86 * for items with no text etc.
87 *
88 * The code below could cache for performance, but currently it doesn't
89 * seem to be the performance bottleneck at all.
90 */
91 if (!d->treeview->model())
92 return QModelIndex();
93 int y = d->treeview->verticalOffset();
94 QModelIndex idx = d->treeview->model()->index(0, 0, d->treeview->rootIndex());
95 do {
96 if (y >= height)
97 break;
98 y += d->treeview->rowHeight(idx);
99 idx = d->treeview->indexBelow(idx);
100 } while (idx.isValid());
101 return d->proxy->mapFromSource(idx);
102}
103
105{
106 const QModelIndex idx = d->proxy->mapToSource(_idx);
107 return d->proxy->mapFromSource(d->treeview->indexAbove(idx));
108}
109
111{
112 const QModelIndex idx = d->proxy->mapToSource(_idx);
113 return d->proxy->mapFromSource(d->treeview->indexBelow(idx));
114}
A class representing a start point and a length.
bool isRowExpanded(const QModelIndex &idx) const override
QModelIndex indexBelow(const QModelIndex &idx) const override
bool isRowVisible(const QModelIndex &idx) const override
QModelIndex indexAbove(const QModelIndex &idx) const override
QModelIndex indexAt(int height) const override
Span rowGeometry(const QModelIndex &idx) const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
bool isValid() const const
const QAbstractItemModel * model() const const
int height() const const
QRect translated(int dx, int dy) const const
int y() const const

© 2001 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/
Generated on Thu Apr 11 2024 00:04:50 for KD Chart API Documentation by doxygen 1.9.8