Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcolumnview_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCOLUMNVIEW_P_H
5#define QCOLUMNVIEW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "qcolumnview.h"
20
21#include <private/qabstractitemview_p.h>
22
23#include <QtCore/qabstractitemmodel.h>
24#if QT_CONFIG(animation)
25#include <QtCore/qpropertyanimation.h>
26#endif
27#include <QtWidgets/qabstractitemdelegate.h>
28#include <QtWidgets/qabstractitemview.h>
29#include <QtWidgets/qstyleditemdelegate.h>
30#include <qlistview.h>
31#include <qevent.h>
32#include <qscrollbar.h>
33
34#include <vector>
35
37
39
41
42public:
43 explicit QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(nullptr) {
44 }
45
47 previewWidget = widget;
48 setMinimumWidth(previewWidget->minimumWidth());
49 }
50
51 void resizeEvent(QResizeEvent * event) override{
52 if (!previewWidget)
53 return;
54 previewWidget->resize(
55 qMax(previewWidget->minimumWidth(), event->size().width()),
56 previewWidget->height());
57 QSize p = viewport()->size();
58 QSize v = previewWidget->size();
59 horizontalScrollBar()->setRange(0, v.width() - p.width());
60 horizontalScrollBar()->setPageStep(p.width());
61 verticalScrollBar()->setRange(0, v.height() - p.height());
62 verticalScrollBar()->setPageStep(p.height());
63
64 QAbstractScrollArea::resizeEvent(event);
65 }
66
67 void scrollContentsBy(int dx, int dy) override
68 {
69 if (!previewWidget)
70 return;
71 scrollDirtyRegion(dx, dy);
72 viewport()->scroll(dx, dy);
73
74 QAbstractItemView::scrollContentsBy(dx, dy);
75 }
76
77 QRect visualRect(const QModelIndex &) const override
78 {
79 return QRect();
80 }
81 void scrollTo(const QModelIndex &, ScrollHint) override
82 {
83 }
84 QModelIndex indexAt(const QPoint &) const override
85 {
86 return QModelIndex();
87 }
88 QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override
89 {
90 return QModelIndex();
91 }
92 int horizontalOffset () const override {
93 return 0;
94 }
95 int verticalOffset () const override {
96 return 0;
97 }
99 {
100 return QRegion();
101 }
102 bool isIndexHidden(const QModelIndex &) const override
103 {
104 return false;
105 }
106 void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) override
107 {
108 }
109private:
110 QWidget *previewWidget;
111};
112
114{
115 Q_DECLARE_PUBLIC(QColumnView)
116
117public:
122
124
126 void closeColumns(const QModelIndex &parent = QModelIndex(), bool build = false);
128 void doLayout();
130 void checkColumnCreation(const QModelIndex &parent);
131
132
133 void gripMoved(int offset);
136 void columnsInserted(const QModelIndex &parent, int start, int end) override;
137
138 QList<QAbstractItemView*> columns;
139 QList<int> columnSizes; // used during init and corner moving
142#if QT_CONFIG(animation)
143 QPropertyAnimation currentAnimation;
144 QMetaObject::Connection animationConnection;
145#endif
146 std::vector<QMetaObject::Connection> gripConnections;
147 using ViewConnections = std::vector<QMetaObject::Connection>;
148 QHash<QAbstractItemView *, ViewConnections> viewConnections;
149
152};
153
158{
159
160public:
163
165 const QStyleOptionViewItem &option,
166 const QModelIndex &index) const override;
167};
168
170
171#endif //QCOLUMNVIEW_P_H
The QAbstractItemView class provides the basic functionality for item view classes.
void scrollDirtyRegion(int dx, int dy)
Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite dir...
CursorAction
This enum describes the different ways to navigate between items,.
ScrollHint
\value EnsureVisible Scroll to ensure that the item is visible.
This is a delegate that will paint the triangle.
QColumnViewDelegate(QObject *parent=nullptr)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
This pure abstract function must be reimplemented if you want to provide custom rendering.
QRegion visualRegionForSelection(const QItemSelection &) const override
Returns the region from the viewport of the items in the given selection.
QColumnViewPreviewColumn(QWidget *parent)
int verticalOffset() const override
Returns the vertical offset of the view.
bool isIndexHidden(const QModelIndex &) const override
Returns true if the item referred to by the given index is hidden in the view, otherwise returns fals...
QRect visualRect(const QModelIndex &) const override
Returns the rectangle on the viewport occupied by the item at index.
void setPreviewWidget(QWidget *widget)
void scrollContentsBy(int dx, int dy) override
QModelIndex indexAt(const QPoint &) const override
Returns the model index of the item at the viewport coordinates point.
void scrollTo(const QModelIndex &, ScrollHint) override
Scrolls the view if necessary to ensure that the item at index is visible.
void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) override
Applies the selection flags to the items in or touched by the rectangle, rect.
void resizeEvent(QResizeEvent *event) override
int horizontalOffset() const override
Returns the horizontal offset of the view.
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction...
QAbstractItemView * createColumn(const QModelIndex &index, bool show)
void setPreviewWidget(QWidget *widget)
void gripMoved(int offset)
QAbstractItemView * previewColumn
QList< QAbstractItemView * > columns
void changeCurrentColumn()
std::vector< QMetaObject::Connection > ViewConnections
QHash< QAbstractItemView *, ViewConnections > viewConnections
void closeColumns(const QModelIndex &parent=QModelIndex(), bool build=false)
void checkColumnCreation(const QModelIndex &parent)
QList< int > columnSizes
void clicked(const QModelIndex &index)
void columnsInserted(const QModelIndex &parent, int start, int end) override
void disconnectView(QAbstractItemView *view)
std::vector< QMetaObject::Connection > gripConnections
\inmodule QtCore
\inmodule QtCore Represents a handle to a signal-slot (or signal-functor) connection.
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
\inmodule QtCore
Definition qsize.h:25
The QStyledItemDelegate class provides display and editing facilities for data items from a model.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QSize size
the size of the widget excluding any window frame
Definition qwidget.h:113
int minimumWidth
the widget's minimum width in pixels
Definition qwidget.h:123
int height
the height of the widget excluding any window frame
Definition qwidget.h:115
void resize(int w, int h)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:883
QOpenGLWidget * widget
[1]
Combined button and popup list for selecting options.
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLsizei const GLfloat * v
[13]
GLuint index
[2]
GLuint GLuint end
GLuint start
GLenum GLuint GLintptr offset
struct _cl_event * event
GLfloat GLfloat p
[1]
GLuint GLenum option
#define Q_AUTOTEST_EXPORT
#define QT_REQUIRE_CONFIG(feature)
view show()
[18] //! [19]
QObject::connect nullptr
view viewport() -> scroll(dx, dy, deviceRect)
QPainter painter(this)
[7]
QQuickView * view
[0]