7#include <QtQml/qqmlinfo.h>
8#include <QtQuick/private/qquickdraghandler_p.h>
9#include <QtQuick/private/qquickhoverhandler_p.h>
11#include <QtQuick/private/qquicktableview_p_p.h>
340 emit q_func()->draggingChanged();
344 attached->setDragging(dragging);
354 if (
const auto tableview = qobject_cast<QQuickTableView *>(
m_target)) {
363 emit q_func()->activeChanged();
374 handleItem->setParentItem(handlerTarget);
376 attached->setControl(
q);
378 if (handleItem->z() == 0)
379 handleItem->setZ(100);
383 dragHandler->setTarget(
nullptr);
384 dragHandler->setParentItem(handleItem);
398 tapHandler->setTarget(
nullptr);
399 tapHandler->setParentItem(handleItem);
405 if (dragHandler->active()) {
406 const QPointF localPos = dragHandler->centroid().position();
407 const QPointF pos = handleItem->mapToItem(handleItem->parentItem(), localPos);
408 if (corner == Qt::TopLeftCorner)
409 m_selectable->setSelectionStartPos(pos);
411 m_selectable->setSelectionEndPos(pos);
413 m_draggedHandle = handleItem;
415 updateDraggingState(true);
417 QGuiApplication::setOverrideCursor(Qt::SizeFDiagCursor);
420 m_scrollTimer.stop();
421 m_selectable->normalizeSelection();
422 updateDraggingState(false);
424 QGuiApplication::restoreOverrideCursor();
434 const QPointF pos = handleItem->mapToItem(handleItem->parentItem(), localPos);
471 if (
const auto flickable = qobject_cast<QQuickFlickable *>(
m_target)) {
499 const bool enabled =
q->isEnabled();
509 }
else if (
const auto flickable = qobject_cast<QQuickFlickable *>(
m_target)) {
510 if (
enabled && !flickable->isInteractive()) {
544 d->m_tapHandler->setParent(
this);
545 d->m_dragHandler->setParent(
this);
548 d->m_scrollTimer.stop();
549 d->updateSelectionMode();
550 d->updateDraggingState(
false);
551 d->updateActiveState(
false);
557 return d_func()->m_target;
566 if (
d->m_selectable) {
567 d->m_scrollTimer.stop();
568 d->m_tapHandler->setParent(
this);
569 d->m_dragHandler->setParent(
this);
570 d->m_target->disconnect(
this);
571 d->m_selectable->setCallback(
nullptr);
575 d->m_selectable =
nullptr;
579 if (!
d->m_selectable)
580 qmlWarning(
this) <<
"the assigned target is not supported by the control";
583 if (
d->m_selectable) {
584 const auto handlerTarget =
d->m_selectable->selectionPointerHandlerTarget();
585 d->m_dragHandler->setParentItem(handlerTarget);
586 d->m_tapHandler->setParentItem(handlerTarget);
587 d->connectToTarget();
588 d->updateSelectionMode();
596 return d_func()->m_active;
601 return d_func()->m_dragging;
606 return d_func()->m_selectionMode;
618 d->updateSelectionMode();
625 return d_func()->m_topLeftHandleDelegate;
640 return d_func()->m_bottomRightHandleDelegate;
693#include "moc_qquickselectionrectangle_p.cpp"
static QObjectPrivate * get(QObject *o)
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
\inmodule QtCore\reentrant
constexpr qreal & ry() noexcept
Returns a reference to the y coordinate of this point.
constexpr qreal & rx() noexcept
Returns a reference to the x coordinate of this point.
\inmodule QtCore\reentrant
The QQmlComponent class encapsulates a QML component definition.
virtual QObject * beginCreate(QQmlContext *)
Create an object instance from this component, within the specified context.
virtual void completeCreate()
This method provides advanced control over component instance creation.
static QQmlContext * contextForObject(const QObject *)
Returns the QQmlContext for the object, or nullptr if no context has been set.
void interactiveChanged()
Qt::KeyboardModifiers modifiers
void setBlocking(bool blocking)
\qmlproperty bool QtQuick::HoverHandler::blocking
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Q_INVOKABLE QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in item's coordinate system to the equivalent point within this item's coordinat...
virtual Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
qreal width
This property holds the width of this item.
QQuickItem * parentItem() const
qreal height
This property holds the height of this item.
QQuickHandlerPoint centroid
void setAcceptedDevices(QInputDevice::DeviceTypes acceptedDevices)
\qmlproperty flags PointerDeviceHandler::acceptedDevices
void setParentItem(QQuickItem *p)
void setEnabled(bool enabled)
void setTarget(QQuickItem *target)
@ CanTakeOverFromAnything
virtual void normalizeSelection()=0
virtual QQuickItem * selectionPointerHandlerTarget() const =0
virtual void setSelectionEndPos(const QPointF &pos)=0
virtual void setCallback(std::function< void(CallBackFlag)> func)=0
virtual void clearSelection()=0
virtual QRectF selectionRectangle() const =0
@ SelectionRectangleChanged
virtual bool startSelection(const QPointF &pos, Qt::KeyboardModifiers modifiers)=0
virtual QSizeF scrollTowardsSelectionPoint(const QPointF &pos, const QSizeF &step)=0
virtual void setSelectionStartPos(const QPointF &pos)=0
void setControl(QQuickSelectionRectangle *control)
QQuickSelectionRectangle * control
QQuickSelectionRectangleAttached(QObject *parent)
void setDragging(bool dragging)
QQuickSelectionRectanglePrivate()
Used to select table cells inside a TableView.
QQuickSelectable * m_selectable
QQmlComponent * m_topLeftHandleDelegate
QQuickSelectionRectangle::SelectionMode m_selectionMode
void updateActiveState(bool isActive)
QQuickTapHandler * m_tapHandler
QQuickDragHandler * m_dragHandler
void updateSelectionMode()
QPointer< QQuickItem > m_draggedHandle
QQuickItem * createHandle(QQmlComponent *delegate, Qt::Corner corner)
void updateDraggingState(bool isDragging)
QPointer< QQuickItem > m_target
QScopedPointer< QQuickItem > m_topLeftHandle
QQmlComponent * m_bottomRightHandleDelegate
QScopedPointer< QQuickItem > m_bottomRightHandle
QQuickItem * handleUnderPos(const QPointF &pos)
void scrollTowardsPos(const QPointF &pos)
QQuickSelectionRectangleAttached * getAttachedObject(const QObject *object) const
QQuickSelectionRectangle::SelectionMode m_effectiveSelectionMode
void setBottomRightHandle(QQmlComponent *bottomRightHandle)
static QQuickSelectionRectangleAttached * qmlAttachedProperties(QObject *obj)
void setTarget(QQuickItem *target)
QQmlComponent * topLeftHandle
QQuickSelectionRectangle(QQuickItem *parent=nullptr)
void bottomRightHandleChanged()
void topLeftHandleChanged()
void setTopLeftHandle(QQmlComponent *topLeftHandle)
QQmlComponent * bottomRightHandle
void setSelectionMode(SelectionMode selectionMode)
SelectionMode selectionMode
void selectionModeChanged()
\inmodule QtCore\reentrant
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
constexpr qreal width() const noexcept
Returns the width.
constexpr qreal height() const noexcept
Returns the height.
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
void stop()
Stops the timer.
void timeout(QPrivateSignal)
This signal is emitted when the timer times out.
EGLImageKHR int int EGLuint64KHR * modifiers
Combined button and popup list for selecting options.
constexpr T qAbs(const T &t)
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLdouble GLdouble GLdouble GLdouble q
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QQuickAttachedPropertyPropagator * attachedObject(const QMetaObject *type, QObject *object, bool create=false)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
std::uniform_real_distribution dist(1, 2.5)
[2]
myObject disconnect()
[26]