7#if QT_CONFIG(columnview)
70#if QT_CONFIG(animation)
74 currentAnimation.setTargetObject(hbar);
75 currentAnimation.setPropertyName(
"value");
84#if QT_CONFIG(animation)
101 d->clearConnections();
115 if (
d->showResizeGrips == visible)
117 d->showResizeGrips = visible;
118 d->gripConnections.clear();
122 view->setCornerWidget(grip);
123 d->gripConnections.push_back(
129 view->setCornerWidget(
nullptr);
138 return d->showResizeGrips;
166 if (
view->selectionModel())
172 d->updateScrollbars();
190 for (
int i = 0;
i <
d->columns.size(); ++
i) {
191 QPoint topLeft =
d->columns.at(
i)->frameGeometry().topLeft();
192 QPoint adjustedPoint(point.
x() - topLeft.
x(), point.
y() - topLeft.
y());
205 if (!
index.isValid())
209 for (
int i = 0;
i <
d->columns.size(); ++
i) {
211 if (!
rect.isNull()) {
225 if (
d->columns.isEmpty() || dx == 0)
229 for (
int i = 0;
i <
d->columns.size(); ++
i)
230 d->columns.at(
i)->move(
d->columns.at(
i)->x() + dx, 0);
232 QAbstractItemView::scrollContentsBy(dx, dy);
242 if (!
index.isValid() ||
d->columns.isEmpty())
245#if QT_CONFIG(animation)
249 d->currentAnimation.stop();
253 d->closeColumns(
index,
true);
257 int currentColumn = 0;
259 while (currentColumn < d->columns.size()) {
260 if (indexParent ==
d->columns.at(currentColumn)->rootIndex())
262 leftEdge +=
d->columns.at(currentColumn)->width();
267 if (currentColumn ==
d->columns.size())
270 int indexColumn = currentColumn;
272 int visibleWidth =
d->columns.at(currentColumn)->width();
274 if (currentColumn + 1 <
d->columns.size()) {
276 visibleWidth +=
d->columns.at(currentColumn)->width();
279 int rightEdge = leftEdge + visibleWidth;
281 leftEdge =
viewport()->width() - leftEdge;
282 rightEdge = leftEdge - visibleWidth;
283 qSwap(rightEdge, leftEdge);
289 d->columns.at(indexColumn)->scrollTo(
index);
290 d->changeCurrentColumn();
294 int newScrollbarValue = 0;
298 newScrollbarValue =
viewport()->size().width() - leftEdge;
306 newScrollbarValue = rightEdge -
viewport()->size().width();
309 newScrollbarValue = leftEdge;
313#if QT_CONFIG(animation)
315 d->currentAnimation.setDuration(animationDuration);
316 d->currentAnimation.setEndValue(newScrollbarValue);
317 d->currentAnimation.start();
321 horizontalScrollBar()->setValue(newScrollbarValue);
345 switch (cursorAction) {
348 return (current.
parent());
353 if (
model()->hasChildren(current))
372 d->updateScrollbars();
374 int diff =
event->oldSize().width() -
event->size().width();
375 if (diff < 0 && horizontalScrollBar()->
isVisible()
376 && horizontalScrollBar()->
value() == horizontalScrollBar()->
maximum()) {
377 horizontalScrollBar()->setMaximum(horizontalScrollBar()->
maximum() + diff);
389#if QT_CONFIG(animation)
395 int horizontalLength = 0;
398 if (horizontalLength <= 0)
403 if (horizontalLength < viewportSize.
width() && hbar->value() == 0) {
404 hbar->setRange(0, 0);
406 int visibleLength =
qMin(horizontalLength +
q->horizontalOffset(), viewportSize.
width());
407 int hiddenLength = horizontalLength - visibleLength;
408 if (hiddenLength != hbar->maximum())
409 hbar->setRange(0, hiddenLength);
412 int pageStepSize =
columns.
at(0)->width();
413 if (pageStepSize != hbar->pageStep())
414 hbar->setPageStep(pageStepSize);
416 bool visible = (hbar->maximum() > 0);
417 if (visible != hbar->isVisible())
418 hbar->setVisible(visible);
452 for (
int i = 0;
i < ranges; ++
i) {
460 if (firstIdx == lastIdx)
465 return firstRegion.united(lastRegion);
483 for (
int i = 0;
i <
d->columns.size(); ++
i) {
485 d->columns.at(
i)->setSelectionModel(newSelectionModel);
499 for (
int i = 0;
i <
d->columns.size(); ++
i) {
516 if (
q->isRightToLeft())
521 if (!found &&
columns.
at(
i)->cornerWidget() == grip) {
524 if (
q->isRightToLeft())
550 bool clearAll = !parent.
isValid();
551 bool passThroughRoot =
false;
553 QList<QModelIndex> dirsToAppend;
556 int currentColumn = -1;
558 while (currentColumn == -1 && parentIndex.
isValid()) {
561 parentIndex = parentIndex.
parent();
562 if (
root == parentIndex)
563 passThroughRoot =
true;
572 if (currentColumn == -1)
573 dirsToAppend.append(parentIndex);
578 if (!clearAll && !passThroughRoot && currentColumn == -1)
581 if (currentColumn == -1 && parent.
isValid())
585 bool alreadyExists =
false;
590 if (viewingParent || viewingChild) {
592 alreadyExists =
true;
600 notShownAnymore->setVisible(
false);
602 notShownAnymore->deleteLater();
613 while (!dirsToAppend.isEmpty()) {
615 if (!dirsToAppend.isEmpty())
616 newView->setCurrentIndex(dirsToAppend.constLast());
619 if (build && !alreadyExists)
644 if (
q->selectionModel() && columnClicked) {
646 if (columnClicked->selectionModel()->isSelected(
index))
648 q->selectionModel()->setCurrentIndex(
index,
flags);
694 view->setCornerWidget(grip);
705 if (
q->isRightToLeft())
770 column->setMinimumWidth(100);
773#if QT_CONFIG(draganddrop)
774 column->setDragDropMode(dragDropMode());
775 column->setDragDropOverwriteMode(dragDropOverwriteMode());
776 column->setDropIndicatorShown(showDropIndicator());
792 for (
auto i =
d->rowDelegates.cbegin(),
end =
d->rowDelegates.cend();
i !=
end; ++
i)
793 column->setItemDelegateForRow(
i.key(),
i.value());
797 column->setItemDelegate(
d->itemDelegate);
809 return d->previewWidget;
864 const int count =
qMin(listCount,
d->columns.size());
866 d->columns.at(
i)->resize(
list.
at(
i),
d->columns.at(
i)->height());
870 d->columnSizes.reserve(listCount);
871 for (;
i < listCount; ++
i)
884 const int columnCount =
d->columns.
size();
886 for (
int i = 0;
i < columnCount; ++
i)
897 d_func()->checkColumnCreation(parent);
913 if (currentParent == previous.
parent()
914 &&
model()->hasChildren(current) &&
model()->hasChildren(previous)) {
915 for (
int i = 0;
i <
d->columns.size(); ++
i) {
916 if (currentParent ==
d->columns.at(
i)->rootIndex()) {
917 if (
d->columns.size() >
i + 1) {
928 if (currentParent == previous) {
929 for (
int i = 0;
i <
d->columns.size(); ++
i) {
930 if (currentParent ==
d->columns.at(
i)->rootIndex()) {
932 if (
d->columns.size() <
i + 2) {
933 d->createColumn(current,
false);
940 d->closeColumns(current,
true);
942 if (!
model()->hasChildren(current))
970 q->setFocusProxy(parentColumn);
977 replacementSelectionModel->setCurrentIndex(
979 replacementSelectionModel->select(
982 view->setSelectionModel(replacementSelectionModel);
986 if (newRootIndex.isValid())
987 view->setCurrentIndex(newRootIndex);
994 parentColumn->setSelectionModel(
q->selectionModel());
996 if (currentColumn > 0) {
997 parentColumn =
columns.
at(currentColumn - 1);
998 if (parentColumn->currentIndex() != current.
parent())
1021 if (indexList.size() >= 1)
1022 parent = indexList.at(0).
parent();
1023 if (indexList.size() == 1) {
1024 parent = indexList.at(0);
1025 if (!
model()->hasChildren(parent))
1026 parent = parent.
parent();
1033 model()->columnCount(parent) - 1,
1044,showResizeGrips(true)
1078 if (
view->rootIndex() == parent) {
1100 int viewportHeight =
viewport->height();
1103 if (
q->isRightToLeft()) {
1117 x += currentColumnWidth;
1130 const QStyleOptionViewItem &
option,
1143 opt.showDecorationSelected =
true;
1165#include "moc_qcolumnview.cpp"
void finished()
QAbstractAnimation emits this signal after the animation has stopped and has reached the end.
The QAbstractItemDelegate class is used to display and edit data items from a model.
virtual Q_INVOKABLE bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns {true} if parent has any children; otherwise returns {false}.
virtual Q_INVOKABLE void fetchMore(const QModelIndex &parent)
Fetches any available data for the items with the parent specified by the parent index.
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
QPointer< QAbstractItemDelegate > itemDelegate
virtual void columnsInserted(const QModelIndex &parent, int start, int end)
QPersistentModelIndex root
QAbstractItemModel * model
The QAbstractItemView class provides the basic functionality for item view classes.
void activated(const QModelIndex &index)
This signal is emitted when the item specified by index is activated by the user.
QAbstractItemModel * model() const
Returns the model that this view is presenting.
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
void doubleClicked(const QModelIndex &index)
This signal is emitted when a mouse button is double-clicked.
virtual void setSelectionModel(QItemSelectionModel *selectionModel)
Sets the current selection model to the given selectionModel.
ScrollMode verticalScrollMode
how the view scrolls its contents in the vertical direction
void entered(const QModelIndex &index)
This signal is emitted when the mouse cursor enters the item specified by index.
bool hasAutoScroll() const
bool tabKeyNavigation
whether item navigation with tab and backtab is enabled.
QModelIndex currentIndex() const
Returns the model index of the current item.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
EditTriggers editTriggers
which actions will initiate item editing
ScrollMode horizontalScrollMode
how the view scrolls its contents in the horizontal direction
virtual void setRootIndex(const QModelIndex &index)
Sets the root item to the item at the given index.
Qt::TextElideMode textElideMode
the position of the "..." in elided text.
QModelIndex rootIndex() const
Returns the model index of the model's root item.
QSize iconSize
the size of items' icons
virtual int horizontalOffset() const =0
Returns the horizontal offset of the view.
SelectionMode selectionMode
which selection mode the view operates in
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
This slot is called when a new item becomes the current item.
bool alternatingRowColors
whether to draw the background using alternating colors
void resizeEvent(QResizeEvent *event) override
This function is called with the given event when a resize event is sent to the widget.
void pressed(const QModelIndex &index)
This signal is emitted when a mouse button is pressed.
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
This slot is called when rows are inserted.
void clicked(const QModelIndex &index)
This signal is emitted when a mouse button is left-clicked.
QItemSelectionModel * selectionModel() const
Returns the current selection model.
void setSelectionMode(QAbstractItemView::SelectionMode mode)
SelectionBehavior selectionBehavior
which selection behavior the view uses
static QStyle * style()
Returns the application's style object.
This is a delegate that will paint the triangle.
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.
void gripMoved(int offset)
QAbstractItemView * createColumn(const QModelIndex &index, bool show)
void setPreviewWidget(QWidget *widget)
void gripMoved(int offset)
QAbstractItemView * previewColumn
QList< QAbstractItemView * > columns
void changeCurrentColumn()
QHash< QAbstractItemView *, ViewConnections > viewConnections
void closeColumns(const QModelIndex &parent=QModelIndex(), bool build=false)
void checkColumnCreation(const QModelIndex &parent)
void clicked(const QModelIndex &index)
void columnsInserted(const QModelIndex &parent, int start, int end) override
void disconnectView(QAbstractItemView *view)
std::vector< QMetaObject::Connection > gripConnections
int verticalOffset() const override
Returns the vertical offset of the view.
void setPreviewWidget(QWidget *widget)
void scrollContentsBy(int dx, int dy) override
QModelIndex indexAt(const QPoint &point) const override
Returns the model index of the item at the viewport coordinates point.
virtual QAbstractItemView * createColumn(const QModelIndex &rootIndex)
QColumnView(QWidget *parent=nullptr)
void selectAll() override
Selects all items in the view.
void setRootIndex(const QModelIndex &index) override
Sets the root item to the item at the given index.
QRegion visualRegionForSelection(const QItemSelection &selection) const override
Returns the region from the viewport of the items in the given selection.
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction...
void setSelectionModel(QItemSelectionModel *selectionModel) override
Sets the current selection model to the given selectionModel.
QRect visualRect(const QModelIndex &index) const override
Returns the rectangle on the viewport occupied by the item at index.
void updatePreviewWidget(const QModelIndex &index)
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override
This slot is called when a new item becomes the current item.
void setResizeGripsVisible(bool visible)
void rowsInserted(const QModelIndex &parent, int start, int end) override
This slot is called when rows are inserted.
void scrollTo(const QModelIndex &index, ScrollHint hint=EnsureVisible) override
Scrolls the view if necessary to ensure that the item at index is visible.
void resizeEvent(QResizeEvent *event) override
bool isIndexHidden(const QModelIndex &index) const override
Returns true if the item referred to by the given index is hidden in the view, otherwise returns fals...
void setColumnWidths(const QList< int > &list)
void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override
Applies the selection flags to the items in or touched by the rectangle, rect.
int horizontalOffset() const override
Returns the horizontal offset of the view.
QSize sizeHint() const override
void initializeColumn(QAbstractItemView *column) const
void setModel(QAbstractItemModel *model) override
Sets the model for the view to present.
QWidget * previewWidget() const
QList< int > columnWidths() const
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
iterator erase(const_iterator it)
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
QModelIndexList selectedIndexes
virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Selects the model item index using the specified command, and emits selectionChanged().
virtual void clear()
Clears the selection model.
int bottom() const
Returns the row index corresponding to the lowermost selected row in the selection range.
int top() const
Returns the row index corresponding to the uppermost selected row in the selection range.
The QListView class provides a list or icon view onto a model.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void removeAt(qsizetype i)
const T & constLast() const noexcept
const_reference at(qsizetype i) const noexcept
const T & constFirst() const noexcept
void reserve(qsizetype size)
void removeLast() noexcept
void resize(qsizetype size)
void append(parameter_type t)
constexpr int row() const noexcept
Returns the row this model index refers to.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr int column() const noexcept
Returns the column this model index refers to.
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
void setParent(QObject *parent)
Makes the object a child of parent.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void deleteLater()
\threadsafe
The QPainter class performs low-level painting on widgets and other paint devices.
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr void translate(int dx, int dy) noexcept
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
The QRegion class specifies a clip region for a painter.
The QResizeEvent class contains event parameters for resize events.
constexpr int width() const noexcept
Returns the width.
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
@ SH_Widget_Animation_Duration
@ PE_IndicatorColumnViewArrow
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Renders the delegate using the given painter and style option for the item specified by index.
int x
the x position of the window's geometry
int width
the width of the window's geometry
void setMinimumWidth(int w)
void setGeometry(int posx, int posy, int w, int h)
Sets the geometry of the window, excluding its window frame, to a rectangle constructed from posx,...
int minimumWidth
the minimum width of the window's geometry
void setVisible(bool visible)
int height
the height of the window's geometry
EGLImageKHR int int EGLuint64KHR * modifiers
QSet< QString >::iterator it
QVector3D maximum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
Combined button and popup list for selecting options.
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
static jboolean copy(JNIEnv *, jobject)
DBusConnection * connection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLenum GLuint GLintptr offset
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)
QSqlQueryModel * model
[16]
myObject disconnect()
[26]
view viewport() -> scroll(dx, dy, deviceRect)
QItemSelection * selection
[0]