diff options
Diffstat (limited to 'src/widgets/itemviews/qabstractitemview.cpp')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index cb99214d4e..d4c83cb82c 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -61,6 +61,7 @@ #include <qstyleditemdelegate.h> #include <private/qabstractitemview_p.h> #include <private/qabstractitemmodel_p.h> +#include <private/qapplication_p.h> #include <private/qguiapplication_p.h> #include <private/qscrollbar_p.h> #ifndef QT_NO_ACCESSIBILITY @@ -180,7 +181,7 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index QString statustip = model->data(index, Qt::StatusTipRole).toString(); if (parent && (shouldClearStatusTip || !statustip.isEmpty())) { QStatusTipEvent tip(statustip); - QApplication::sendEvent(parent, &tip); + QCoreApplication::sendEvent(parent, &tip); shouldClearStatusTip = !statustip.isEmpty(); } #endif @@ -189,7 +190,7 @@ void QAbstractItemViewPrivate::checkMouseMove(const QPersistentModelIndex &index if (parent && shouldClearStatusTip) { QString emptyString; QStatusTipEvent tip( emptyString ); - QApplication::sendEvent(parent, &tip); + QCoreApplication::sendEvent(parent, &tip); } #endif emit q->viewportEntered(); @@ -521,7 +522,7 @@ void QAbstractItemViewPrivate::_q_scrollerStateChanged() the mouse was pressed on is specified by \a index. The signal is only emitted when the index is valid. - Use the QApplication::mouseButtons() function to get the state + Use the QGuiApplication::mouseButtons() function to get the state of the mouse buttons. \sa activated(), clicked(), doubleClicked(), entered() @@ -1713,7 +1714,7 @@ bool QAbstractItemView::viewportEvent(QEvent *event) if (d->shouldClearStatusTip && d->parent) { QString empty; QStatusTipEvent tip(empty); - QApplication::sendEvent(d->parent, &tip); + QCoreApplication::sendEvent(d->parent, &tip); d->shouldClearStatusTip = false; } #endif @@ -2290,7 +2291,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) #ifdef QT_KEYPAD_NAVIGATION switch (event->key()) { case Qt::Key_Select: - if (QApplication::keypadNavigationEnabled()) { + if (QApplicationPrivate::keypadNavigationEnabled()) { if (!hasEditFocus()) { setEditFocus(true); return; @@ -2298,7 +2299,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) } break; case Qt::Key_Back: - if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { + if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()) { setEditFocus(false); } else { event->ignore(); @@ -2309,7 +2310,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) // Let's ignore vertical navigation events, only if there is no other widget // what can take the focus in vertical direction. This means widget can handle navigation events // even the widget don't have edit focus, and there is no other widget in requested direction. - if(QApplication::keypadNavigationEnabled() && !hasEditFocus() + if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) { event->ignore(); return; @@ -2318,14 +2319,14 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) case Qt::Key_Left: case Qt::Key_Right: // Similar logic as in up and down events - if(QApplication::keypadNavigationEnabled() && !hasEditFocus() + if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus() && (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this))) { event->ignore(); return; } break; default: - if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { + if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) { event->ignore(); return; } @@ -2338,7 +2339,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (d->model) variant = d->model->data(currentIndex(), Qt::DisplayRole); if (variant.type() == QVariant::String) - QApplication::clipboard()->setText(variant.toString()); + QGuiApplication::clipboard()->setText(variant.toString()); event->accept(); } #endif @@ -2413,7 +2414,8 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) case Qt::Key_Down: case Qt::Key_Up: #ifdef QT_KEYPAD_NAVIGATION - if (QApplication::keypadNavigationEnabled() && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) { + if (QApplicationPrivate::keypadNavigationEnabled() + && QWidgetPrivate::canKeypadNavigate(Qt::Vertical)) { event->accept(); // don't change focus break; } @@ -2845,7 +2847,7 @@ void QAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndE } QPointer<QWidget> ed = editor; - QApplication::sendPostedEvents(editor, 0); + QCoreApplication::sendPostedEvents(editor, 0); editor = ed; if (!isPersistent && editor) @@ -3957,7 +3959,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemView::selectionCommand(const QM keyModifiers = (static_cast<const QInputEvent*>(event))->modifiers(); break; default: - keyModifiers = QApplication::keyboardModifiers(); + keyModifiers = QGuiApplication::keyboardModifiers(); } } switch (d->selectionMode) { @@ -4015,7 +4017,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::multiSelectionComm QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionCommand( const QModelIndex &index, const QEvent *event) const { - Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers(); + Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers(); if (event) { switch (event->type()) { case QEvent::MouseMove: { @@ -4425,7 +4427,7 @@ bool QAbstractItemViewPrivate::openEditor(const QModelIndex &index, QEvent *even w->setFocus(); if (event) - QApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event); + QCoreApplication::sendEvent(w->focusProxy() ? w->focusProxy() : w, event); return true; } @@ -4461,15 +4463,8 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes, if (paintPairs.isEmpty()) return QPixmap(); - qreal scale = 1.0f; - - Q_Q(const QAbstractItemView); - QWidget *window = q->window(); - if (window) { - QWindow *windowHandle = window->windowHandle(); - if (windowHandle) - scale = windowHandle->devicePixelRatio(); - } + QWindow *window = windowHandle(WindowHandleMode::Closest); + const qreal scale = window ? window->devicePixelRatio() : qreal(1); QPixmap pixmap(r->size() * scale); pixmap.setDevicePixelRatio(scale); |