1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QCOLUMNVIEW_P_H
#define QCOLUMNVIEW_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcolumnview.h"
#include <private/qabstractitemview_p.h>
#include <QtCore/qabstractitemmodel.h>
#if QT_CONFIG(animation)
#include <QtCore/qpropertyanimation.h>
#endif
#include <QtWidgets/qabstractitemdelegate.h>
#include <QtWidgets/qabstractitemview.h>
#include <QtWidgets/qstyleditemdelegate.h>
#include <qlistview.h>
#include <qevent.h>
#include <qscrollbar.h>
QT_REQUIRE_CONFIG(columnview);
QT_BEGIN_NAMESPACE
class QColumnViewPreviewColumn : public QAbstractItemView {
public:
explicit QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(nullptr) {
}
void setPreviewWidget(QWidget *widget) {
previewWidget = widget;
setMinimumWidth(previewWidget->minimumWidth());
}
void resizeEvent(QResizeEvent * event) override{
if (!previewWidget)
return;
previewWidget->resize(
qMax(previewWidget->minimumWidth(), event->size().width()),
previewWidget->height());
QSize p = viewport()->size();
QSize v = previewWidget->size();
horizontalScrollBar()->setRange(0, v.width() - p.width());
horizontalScrollBar()->setPageStep(p.width());
verticalScrollBar()->setRange(0, v.height() - p.height());
verticalScrollBar()->setPageStep(p.height());
QAbstractScrollArea::resizeEvent(event);
}
void scrollContentsBy(int dx, int dy) override
{
if (!previewWidget)
return;
scrollDirtyRegion(dx, dy);
viewport()->scroll(dx, dy);
QAbstractItemView::scrollContentsBy(dx, dy);
}
QRect visualRect(const QModelIndex &) const override
{
return QRect();
}
void scrollTo(const QModelIndex &, ScrollHint) override
{
}
QModelIndex indexAt(const QPoint &) const override
{
return QModelIndex();
}
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override
{
return QModelIndex();
}
int horizontalOffset () const override {
return 0;
}
int verticalOffset () const override {
return 0;
}
QRegion visualRegionForSelection(const QItemSelection &) const override
{
return QRegion();
}
bool isIndexHidden(const QModelIndex &) const override
{
return false;
}
void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) override
{
}
private:
QWidget *previewWidget;
};
class Q_AUTOTEST_EXPORT QColumnViewPrivate : public QAbstractItemViewPrivate
{
Q_DECLARE_PUBLIC(QColumnView)
public:
QColumnViewPrivate();
~QColumnViewPrivate();
void initialize();
QAbstractItemView *createColumn(const QModelIndex &index, bool show);
void updateScrollbars();
void closeColumns(const QModelIndex &parent = QModelIndex(), bool build = false);
void doLayout();
void setPreviewWidget(QWidget *widget);
void checkColumnCreation(const QModelIndex &parent);
void _q_gripMoved(int offset);
void _q_changeCurrentColumn();
void _q_clicked(const QModelIndex &index);
void _q_columnsInserted(const QModelIndex &parent, int start, int end) override;
QList<QAbstractItemView*> columns;
QList<int> columnSizes; // used during init and corner moving
bool showResizeGrips;
int offset;
#if QT_CONFIG(animation)
QPropertyAnimation currentAnimation;
#endif
QWidget *previewWidget;
QAbstractItemView *previewColumn;
};
/*!
* This is a delegate that will paint the triangle
*/
class QColumnViewDelegate : public QStyledItemDelegate
{
public:
explicit QColumnViewDelegate(QObject *parent = nullptr) : QStyledItemDelegate(parent) {}
~QColumnViewDelegate() {}
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const override;
};
QT_END_NAMESPACE
#endif //QCOLUMNVIEW_P_H
|