![]() |
Qt 6.x
The Qt SDK
|
#include <qquickselectionrectangle_p_p.h>
Inheritance diagram for QQuickSelectionRectanglePrivate:
Collaboration diagram for QQuickSelectionRectanglePrivate:Definition at line 31 of file qquickselectionrectangle_p_p.h.
| QT_BEGIN_NAMESPACE QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate | ( | ) |
Used to select table cells inside a TableView.
\qmltype SelectionRectangle \inherits Control
! \instantiates QQuickSelectionRectangle \inqmlmodule QtQuick.Controls
SelectionRectangle is used for selecting table cells in a TableView. It lets the user start a selection by doing a pointer drag inside the viewport, or by doing a long press on top of a cell.
For a SelectionRectangle to be able to select cells, TableView must have an ItemSelectionModel assigned. The ItemSelectionModel will store any selections done on the model, and can be used for querying which cells that the user has selected.
The following example shows how you can make a SelectionRectangle target a TableView:
\qmlproperty Item QtQuick.Controls::SelectionRectangle::target
This property holds the TableView on which the SelectionRectangle should act.
\qmlproperty bool QtQuick.Controls::SelectionRectangle::active \readonly
This property is true while the user is performing a selection. The selection will be active from the time the the user starts to select, and until the selection is removed again, for example from tapping inside the viewport.
\qmlproperty bool QtQuick.Controls::SelectionRectangle::dragging \readonly
This property is true whenever the user is doing a pointer drag or a handle drag to adjust the selection rectangle.
\qmlproperty Component QtQuick.Controls::SelectionRectangle::topLeftHandle
This property holds the delegate that will be shown on the center of the top-left corner of the selection rectangle. When a handle is provided, the user can drag it to adjust the selection.
The handle is not hidden by default when a selection is removed. Instead, this is the responsibility of the delegate, to open up for custom fade-out animations. The easiest way to ensure that the handle ends up hidden, is to simply bind \l {Item::}{visible} to the \l active state of the SelectionRectangle:
\qml SelectionRectangle { topLeftHandle: Rectangle { width: 20 height: 20 visible: SelectionRectangle.control.active } } \endqml
Set this property to null if you don't want a selection handle on the top-left.
\qmlproperty Component QtQuick.Controls::SelectionRectangle::bottomRightHandle
This property holds the delegate that will be shown on the center of the top-left corner of the selection rectangle. When a handle is provided, the user can drag it to adjust the selection.
The handle is not hidden by default when a selection is removed. Instead, this is the responsibility of the delegate, to open up for custom fade-out animations. The easiest way to ensure that the handle ends up hidden, is to simply bind \l {Item::}{visible} to the \l active state of the SelectionRectangle:
\qml SelectionRectangle { bottomRightHandle: Rectangle { width: 20 height: 20 visible: SelectionRectangle.control.active } } \endqml
Set this property to null if you don't want a selection handle on the bottom-right.
\qmlproperty enumeration QtQuick.Controls::SelectionRectangle::selectionMode
This property holds when a selection should start.
\value SelectionRectangle.Drag A selection will start by doing a pointer drag inside the viewport \value SelectionRectangle.PressAndHold A selection will start by doing a press and hold on top a cell \value SelectionRectangle.Auto SelectionRectangle will choose which mode to use based on the target and the platform. This normally means PressAndHold on touch based platforms, and Drag on desktop. However, Drag will only be used if it doesn't conflict with flicking. This means that TableView will need to be configured with interactive set to false, or placed inside a ScrollView (where flicking, by default, is off for mouse events), for Drag to be chosen.
The default value is Auto.
\qmlattachedproperty SelectionRectangle QtQuick.Controls::SelectionRectangle::control
This attached property holds the SelectionRectangle that manages the delegate instance. It is attached to each handle instance.
\qmlattachedproperty bool QtQuick.Controls::SelectionRectangle::dragging
This attached property will be true if the user is dragging on the handle. It is attached to each handle instance.
Definition at line 160 of file qquickselectionrectangle.cpp.
References QQuickPointerHandler::active, QQuickPointerHandler::activeChanged(), QQuickMultiPointHandler::centroid, QQuickMultiPointHandler::centroidChanged(), QQuickSelectable::clearSelection(), QObject::connect(), Qt::ControlModifier, QScopedPointer< T, Cleanup >::data(), dist(), QQuickSelectionRectangle::Drag, handleUnderPos(), QSizeF::height(), QQuickTapHandler::isPressed(), QQuickTapHandler::longPressed(), m_active, m_draggedHandle, m_dragging, m_dragHandler, m_effectiveSelectionMode, m_scrollSpeed, m_scrollTimer, m_scrollToPoint, m_selectable, m_tapHandler, m_topLeftHandle, QQuickHandlerPoint::modifiers, Qt::NoModifier, QQuickSelectable::normalizeSelection(), QQuickSinglePointHandler::point, pos, QQuickHandlerPoint::position, position(), QQuickSelectionRectangle::PressAndHold, QQuickTapHandler::pressedChanged(), QQuickHandlerPoint::pressPosition, Q_ASSERT, qAbs(), QPointF::rx(), QPointF::ry(), scrollTowardsPos(), QQuickSelectable::scrollTowardsSelectionPoint(), QQuickSelectable::setSelectionEndPos(), QQuickSelectable::setSelectionStartPos(), QQuickPointerHandler::setTarget(), Qt::ShiftModifier, QQuickSelectable::startSelection(), QTimer::stop(), QQuickTapHandler::tapped(), QTimer::timeout(), updateActiveState(), updateDraggingState(), updateHandles(), and QSizeF::width().
Here is the call graph for this function:| void QQuickSelectionRectanglePrivate::connectToTarget | ( | ) |
Definition at line 470 of file qquickselectionrectangle.cpp.
References QObjectPrivate::connect(), QQuickFlickable::interactiveChanged(), m_target, and updateSelectionMode().
Here is the call graph for this function:| QQuickItem * QQuickSelectionRectanglePrivate::createHandle | ( | QQmlComponent * | delegate, |
| Qt::Corner | corner | ||
| ) |
Definition at line 368 of file qquickselectionrectangle.cpp.
References QQuickPointerHandler::active, QQuickPointerHandler::activeChanged(), QQmlComponent::beginCreate(), QQuickPointerHandler::CanTakeOverFromAnything, QQuickMultiPointHandler::centroid, QQuickMultiPointHandler::centroidChanged(), QQmlComponent::completeCreate(), QObject::connect(), QQmlEngine::contextForObject(), QQuickTapHandler::DragWithinBounds, getAttachedObject(), m_dragging, m_selectable, QQuickItem::mapToItem(), QQuickItem::parentItem(), pos, position(), qobject_cast< QQuickItem * >(), scrollTowardsPos(), QQuickSelectable::selectionPointerHandlerTarget(), QQuickHoverHandler::setBlocking(), QQuickTapHandler::setGesturePolicy(), QQuickPointerHandler::setGrabPermissions(), QQuickPointerHandler::setParentItem(), QQuickItem::setParentItem(), QQuickSelectable::setSelectionEndPos(), QQuickSelectable::setSelectionStartPos(), QQuickPointerHandler::setTarget(), QQuickItem::setZ(), Qt::SizeFDiagCursor, Qt::TopLeftCorner, updateHandles(), and QQuickItem::z.
Referenced by updateHandles().
Here is the call graph for this function:
Here is the caller graph for this function:| QQuickSelectionRectangleAttached * QQuickSelectionRectanglePrivate::getAttachedObject | ( | const QObject * | object | ) | const |
Definition at line 515 of file qquickselectionrectangle.cpp.
References attachedObject().
Referenced by createHandle(), and updateDraggingState().
Here is the call graph for this function:
Here is the caller graph for this function:| QQuickItem * QQuickSelectionRectanglePrivate::handleUnderPos | ( | const QPointF & | pos | ) |
Definition at line 320 of file qquickselectionrectangle.cpp.
References QQuickItem::contains(), QScopedPointer< T, Cleanup >::data(), m_bottomRightHandle, m_selectable, m_topLeftHandle, QQuickItem::mapFromItem(), pos, and QQuickSelectable::selectionPointerHandlerTarget().
Referenced by QQuickSelectionRectanglePrivate().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 309 of file qquickselectionrectangle.cpp.
References dist(), QTimer::isActive(), m_scrollSpeed, m_scrollTimer, m_scrollToPoint, m_selectable, pos, QQuickSelectable::scrollTowardsSelectionPoint(), and QTimer::start().
Referenced by QQuickSelectionRectanglePrivate(), and createHandle().
Here is the call graph for this function:
Here is the caller graph for this function:| void QQuickSelectionRectanglePrivate::updateActiveState | ( | bool | isActive | ) |
Definition at line 349 of file qquickselectionrectangle.cpp.
References QObjectPrivate::connect(), disconnect(), emit, m_active, m_target, and updateHandles().
Referenced by QQuickSelectionRectanglePrivate().
Here is the call graph for this function:
Here is the caller graph for this function:| void QQuickSelectionRectanglePrivate::updateDraggingState | ( | bool | isDragging | ) |
Definition at line 338 of file qquickselectionrectangle.cpp.
References emit, getAttachedObject(), m_draggedHandle, and m_dragging.
Referenced by QQuickSelectionRectanglePrivate().
Here is the call graph for this function:
Here is the caller graph for this function:| void QQuickSelectionRectanglePrivate::updateHandles | ( | ) |
Definition at line 449 of file qquickselectionrectangle.cpp.
References Qt::BottomRightCorner, createHandle(), QQuickItem::height, m_bottomRightHandle, m_bottomRightHandleDelegate, m_selectable, m_topLeftHandle, m_topLeftHandleDelegate, QRectF::normalized(), rect, QScopedPointer< T, Cleanup >::reset(), QQuickSelectable::selectionRectangle(), QQuickItem::setX(), QQuickItem::setY(), Qt::TopLeftCorner, and QQuickItem::width.
Referenced by QQuickSelectionRectanglePrivate(), createHandle(), and updateActiveState().
Here is the call graph for this function:
Here is the caller graph for this function:| void QQuickSelectionRectanglePrivate::updateSelectionMode | ( | ) |
Definition at line 478 of file qquickselectionrectangle.cpp.
References QInputDevice::AllDevices, QQuickSelectionRectangle::Auto, QQuickSelectionRectangle::Drag, m_dragHandler, m_effectiveSelectionMode, m_selectionMode, m_tapHandler, m_target, QInputDevice::Mouse, QQuickItem::parentItem(), QQuickSelectionRectangle::PressAndHold, QQuickPointerDeviceHandler::setAcceptedDevices(), and QQuickPointerHandler::setEnabled().
Referenced by connectToTarget().
Here is the call graph for this function:
Here is the caller graph for this function:| bool QQuickSelectionRectanglePrivate::m_active = false |
Definition at line 72 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and updateActiveState().
| QScopedPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_bottomRightHandle |
Definition at line 56 of file qquickselectionrectangle_p_p.h.
Referenced by handleUnderPos(), and updateHandles().
| QQmlComponent* QQuickSelectionRectanglePrivate::m_bottomRightHandleDelegate = nullptr |
Definition at line 54 of file qquickselectionrectangle_p_p.h.
Referenced by updateHandles().
| QPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_draggedHandle |
Definition at line 57 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and updateDraggingState().
| bool QQuickSelectionRectanglePrivate::m_dragging = false |
Definition at line 73 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), createHandle(), and updateDraggingState().
| QQuickDragHandler* QQuickSelectionRectanglePrivate::m_dragHandler = nullptr |
Definition at line 62 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and updateSelectionMode().
| QQuickSelectionRectangle::SelectionMode QQuickSelectionRectanglePrivate::m_effectiveSelectionMode = QQuickSelectionRectangle::Drag |
Definition at line 69 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and updateSelectionMode().
| bool QQuickSelectionRectanglePrivate::m_enabled = true |
Definition at line 71 of file qquickselectionrectangle_p_p.h.
Definition at line 66 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and scrollTowardsPos().
| QTimer QQuickSelectionRectanglePrivate::m_scrollTimer |
Definition at line 64 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and scrollTowardsPos().
| QPointF QQuickSelectionRectanglePrivate::m_scrollToPoint |
Definition at line 65 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and scrollTowardsPos().
| QQuickSelectable* QQuickSelectionRectanglePrivate::m_selectable = nullptr |
Definition at line 59 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), createHandle(), handleUnderPos(), scrollTowardsPos(), and updateHandles().
| QQuickSelectionRectangle::SelectionMode QQuickSelectionRectanglePrivate::m_selectionMode = QQuickSelectionRectangle::Auto |
Definition at line 68 of file qquickselectionrectangle_p_p.h.
Referenced by updateSelectionMode().
| QQuickTapHandler* QQuickSelectionRectanglePrivate::m_tapHandler = nullptr |
Definition at line 61 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), and updateSelectionMode().
| QPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_target |
Definition at line 51 of file qquickselectionrectangle_p_p.h.
Referenced by connectToTarget(), updateActiveState(), and updateSelectionMode().
| QScopedPointer<QQuickItem> QQuickSelectionRectanglePrivate::m_topLeftHandle |
Definition at line 55 of file qquickselectionrectangle_p_p.h.
Referenced by QQuickSelectionRectanglePrivate(), handleUnderPos(), and updateHandles().
| QQmlComponent* QQuickSelectionRectanglePrivate::m_topLeftHandleDelegate = nullptr |
Definition at line 53 of file qquickselectionrectangle_p_p.h.
Referenced by updateHandles().