7#if QT_CONFIG(columnview)
70#if QT_CONFIG(animation)
72 currentAnimation.setTargetObject(hbar);
73 currentAnimation.setPropertyName(
"value");
98 if (
d->showResizeGrips == visible)
100 d->showResizeGrips = visible;
101 for (
int i = 0;
i <
d->columns.size(); ++
i) {
105 view->setCornerWidget(grip);
109 view->setCornerWidget(
nullptr);
118 return d->showResizeGrips;
146 if (
view->selectionModel())
152 d->updateScrollbars();
170 for (
int i = 0;
i <
d->columns.size(); ++
i) {
171 QPoint topLeft =
d->columns.at(
i)->frameGeometry().topLeft();
172 QPoint adjustedPoint(point.
x() - topLeft.
x(), point.
y() - topLeft.
y());
185 if (!
index.isValid())
189 for (
int i = 0;
i <
d->columns.size(); ++
i) {
191 if (!
rect.isNull()) {
192 rect.translate(
d->columns.at(
i)->frameGeometry().topLeft());
205 if (
d->columns.isEmpty() || dx == 0)
209 for (
int i = 0;
i <
d->columns.size(); ++
i)
210 d->columns.at(
i)->move(
d->columns.at(
i)->x() + dx, 0);
212 QAbstractItemView::scrollContentsBy(dx, dy);
222 if (!
index.isValid() ||
d->columns.isEmpty())
225#if QT_CONFIG(animation)
229 d->currentAnimation.stop();
233 d->closeColumns(
index,
true);
237 int currentColumn = 0;
239 while (currentColumn < d->columns.size()) {
240 if (indexParent ==
d->columns.at(currentColumn)->rootIndex())
242 leftEdge +=
d->columns.at(currentColumn)->width();
247 if (currentColumn ==
d->columns.size())
250 int indexColumn = currentColumn;
252 int visibleWidth =
d->columns.at(currentColumn)->width();
254 if (currentColumn + 1 <
d->columns.size()) {
256 visibleWidth +=
d->columns.at(currentColumn)->width();
259 int rightEdge = leftEdge + visibleWidth;
261 leftEdge =
viewport()->width() - leftEdge;
262 rightEdge = leftEdge - visibleWidth;
263 qSwap(rightEdge, leftEdge);
269 d->columns.at(indexColumn)->scrollTo(
index);
270 d->_q_changeCurrentColumn();
274 int newScrollbarValue = 0;
278 newScrollbarValue =
viewport()->size().width() - leftEdge;
286 newScrollbarValue = rightEdge -
viewport()->size().width();
289 newScrollbarValue = leftEdge;
293#if QT_CONFIG(animation)
295 d->currentAnimation.setDuration(animationDuration);
296 d->currentAnimation.setEndValue(newScrollbarValue);
297 d->currentAnimation.start();
301 horizontalScrollBar()->setValue(newScrollbarValue);
325 switch (cursorAction) {
328 return (current.
parent());
333 if (
model()->hasChildren(current))
352 d->updateScrollbars();
354 int diff =
event->oldSize().width() -
event->size().width();
355 if (diff < 0 && horizontalScrollBar()->
isVisible()
356 && horizontalScrollBar()->
value() == horizontalScrollBar()->
maximum()) {
357 horizontalScrollBar()->setMaximum(horizontalScrollBar()->
maximum() + diff);
369#if QT_CONFIG(animation)
375 int horizontalLength = 0;
378 if (horizontalLength <= 0)
383 if (horizontalLength < viewportSize.
width() && hbar->value() == 0) {
384 hbar->setRange(0, 0);
386 int visibleLength =
qMin(horizontalLength +
q->horizontalOffset(), viewportSize.
width());
387 int hiddenLength = horizontalLength - visibleLength;
388 if (hiddenLength != hbar->maximum())
389 hbar->setRange(0, hiddenLength);
392 int pageStepSize =
columns.
at(0)->width();
393 if (pageStepSize != hbar->pageStep())
394 hbar->setPageStep(pageStepSize);
396 bool visible = (hbar->maximum() > 0);
397 if (visible != hbar->isVisible())
398 hbar->setVisible(visible);
432 for (
int i = 0;
i < ranges; ++
i) {
440 if (firstIdx == lastIdx)
445 return firstRegion.
united(lastRegion);
463 for (
int i = 0;
i <
d->columns.size(); ++
i) {
465 d->columns.at(
i)->setSelectionModel(newSelectionModel);
479 for (
int i = 0;
i <
d->columns.size(); ++
i) {
496 if (
q->isRightToLeft())
501 if (!found &&
columns.
at(
i)->cornerWidget() == grip) {
504 if (
q->isRightToLeft())
530 bool clearAll = !
parent.isValid();
531 bool passThroughRoot =
false;
536 int currentColumn = -1;
538 while (currentColumn == -1 && parentIndex.
isValid()) {
541 parentIndex = parentIndex.
parent();
542 if (
root == parentIndex)
543 passThroughRoot =
true;
552 if (currentColumn == -1)
553 dirsToAppend.
append(parentIndex);
558 if (!clearAll && !passThroughRoot && currentColumn == -1)
561 if (currentColumn == -1 &&
parent.isValid())
565 bool alreadyExists =
false;
570 if (viewingParent || viewingChild) {
572 alreadyExists =
true;
580 notShownAnymore->setVisible(
false);
582 notShownAnymore->deleteLater();
591 while (!dirsToAppend.
isEmpty()) {
597 if (build && !alreadyExists)
612 if (
q->selectionModel() && columnClicked) {
616 q->selectionModel()->setCurrentIndex(
index,
flags);
663 view->setCornerWidget(grip);
671 if (
q->isRightToLeft())
736 column->setMinimumWidth(100);
739#if QT_CONFIG(draganddrop)
740 column->setDragDropMode(dragDropMode());
741 column->setDragDropOverwriteMode(dragDropOverwriteMode());
742 column->setDropIndicatorShown(showDropIndicator());
758 for (
auto i =
d->rowDelegates.cbegin(),
end =
d->rowDelegates.cend();
i !=
end; ++
i)
759 column->setItemDelegateForRow(
i.key(),
i.value());
763 column->setItemDelegate(
d->itemDelegate);
775 return d->previewWidget;
830 const int count =
qMin(listCount,
d->columns.size());
832 d->columns.at(
i)->resize(
list.
at(
i),
d->columns.at(
i)->height());
836 d->columnSizes.reserve(listCount);
837 for (;
i < listCount; ++
i)
850 const int columnCount =
d->columns.size();
852 for (
int i = 0;
i < columnCount; ++
i)
863 d_func()->checkColumnCreation(
parent);
879 if (currentParent == previous.
parent()
880 &&
model()->hasChildren(current) &&
model()->hasChildren(previous)) {
881 for (
int i = 0;
i <
d->columns.size(); ++
i) {
882 if (currentParent ==
d->columns.at(
i)->rootIndex()) {
883 if (
d->columns.size() >
i + 1) {
894 if (currentParent == previous) {
895 for (
int i = 0;
i <
d->columns.size(); ++
i) {
896 if (currentParent ==
d->columns.at(
i)->rootIndex()) {
898 if (
d->columns.size() <
i + 2) {
899 d->createColumn(current,
false);
906 d->closeColumns(current,
true);
908 if (!
model()->hasChildren(current))
936 q->setFocusProxy(parentColumn);
945 replacementSelectionModel->
select(
948 view->setSelectionModel(replacementSelectionModel);
953 view->setCurrentIndex(newRootIndex);
962 if (currentColumn > 0) {
963 parentColumn =
columns.
at(currentColumn - 1);
987 if (indexList.
size() >= 1)
989 if (indexList.
size() == 1) {
1010,showResizeGrips(true)
1066 int viewportHeight =
viewport->height();
1069 if (
q->isRightToLeft()) {
1070 x =
viewport->width() +
q->horizontalOffset();
1083 x += currentColumnWidth;
1096 const QStyleOptionViewItem &
option,
1109 opt.showDecorationSelected =
true;
1131#include "moc_qcolumnview.cpp"
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
QPersistentModelIndex root
QAbstractItemModel * model
virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end)
The QAbstractItemView class provides the basic functionality for item view classes.
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.
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
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
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.
virtual void rowsInserted(const QModelIndex &parent, int start, int end)
This slot is called when rows are inserted.
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 _q_gripMoved(int offset)
QAbstractItemView * createColumn(const QModelIndex &index, bool show)
void setPreviewWidget(QWidget *widget)
void _q_changeCurrentColumn()
QAbstractItemView * previewColumn
void _q_clicked(const QModelIndex &index)
QList< QAbstractItemView * > columns
void closeColumns(const QModelIndex &parent=QModelIndex(), bool build=false)
void checkColumnCreation(const QModelIndex &parent)
void _q_columnsInserted(const QModelIndex &parent, int start, int end) override
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.
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 setResizeGripsVisible(bool visible)
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
Q_INVOKABLE bool isSelected(const QModelIndex &index) const
Returns true if the given model item index is selected.
QModelIndexList selectedIndexes
virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
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 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.
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.
The QRegion class specifies a clip region for a painter.
QRegion united(const QRegion &r) const
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
Combined button and popup list for selecting options.
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept
QVector3D maximum(const QVector3D &v1, const QVector3D &v2) Q_DECL_NOTHROW
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)
QSqlQueryModel * model
[16]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
view viewport() -> scroll(dx, dy, deviceRect)
QItemSelection * selection
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent