From 9f27bfb31acfba49a74a342d9249f24633a7ade2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 13 Apr 2018 09:01:43 +0200 Subject: Make sure we can build with -no-feature-draganddrop We move QInternalMimeData to a separate file, because this class is used, even if draganddrop is disabled. From now on, include qinternalmimedata_p.h instead of qdnd_p.h for QInternalMimeData. Change-Id: I594e08e2e90d574dc445119091686b4b69e4731b Reviewed-by: Gatis Paeglis --- src/widgets/widgets/qabstractscrollarea.cpp | 6 +++--- src/widgets/widgets/qabstractscrollarea.h | 2 +- src/widgets/widgets/qlineedit.cpp | 16 +++++++++------- src/widgets/widgets/qlineedit.h | 2 +- src/widgets/widgets/qlineedit_p.cpp | 7 ++++--- src/widgets/widgets/qlineedit_p.h | 2 +- src/widgets/widgets/qplaintextedit.cpp | 6 ++++-- src/widgets/widgets/qplaintextedit.h | 2 +- src/widgets/widgets/qtabbar.cpp | 2 +- src/widgets/widgets/qtextedit.cpp | 6 ++++-- src/widgets/widgets/qtextedit.h | 2 +- src/widgets/widgets/qwidgettextcontrol.cpp | 16 +++++++++------- 12 files changed, 39 insertions(+), 30 deletions(-) (limited to 'src/widgets/widgets') diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 917cddce6f..598d173144 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1065,7 +1065,7 @@ bool QAbstractScrollArea::event(QEvent *e) case QEvent::MouseButtonDblClick: case QEvent::MouseMove: case QEvent::Wheel: -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::Drop: case QEvent::DragEnter: case QEvent::DragMove: @@ -1206,7 +1206,7 @@ bool QAbstractScrollArea::viewportEvent(QEvent *e) #if QT_CONFIG(wheelevent) case QEvent::Wheel: #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::Drop: case QEvent::DragEnter: case QEvent::DragMove: @@ -1409,7 +1409,7 @@ void QAbstractScrollArea::keyPressEvent(QKeyEvent * e) } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \fn void QAbstractScrollArea::dragEnterEvent(QDragEnterEvent *event) diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h index 8a17036fb2..6d0d8fa6e6 100644 --- a/src/widgets/widgets/qabstractscrollarea.h +++ b/src/widgets/widgets/qabstractscrollarea.h @@ -122,7 +122,7 @@ protected: #ifndef QT_NO_CONTEXTMENU void contextMenuEvent(QContextMenuEvent *) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *) override; void dragMoveEvent(QDragMoveEvent *) override; void dragLeaveEvent(QDragLeaveEvent *) override; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index bdeef7cdf7..ca6aacc16c 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -43,7 +43,9 @@ #include "qaction.h" #include "qapplication.h" #include "qclipboard.h" -#include "qdrag.h" +#if QT_CONFIG(draganddrop) +#include +#endif #include "qdrawutil.h" #include "qevent.h" #include "qfontmetrics.h" @@ -1427,7 +1429,7 @@ bool QLineEdit::event(QEvent * e) // ### Qt6: move to timerEvent, is here for binary compatibility int timerId = ((QTimerEvent*)e)->timerId(); if (false) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) } else if (timerId == d->dndTimer.timerId()) { d->drag(); #endif @@ -1515,7 +1517,7 @@ void QLineEdit::mousePressEvent(QMouseEvent* e) mark = mark && (d->imHints & Qt::ImhNoPredictiveText); #endif // Q_OS_ANDROID int cursor = d->xToPos(e->pos().x()); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (!mark && d->dragEnabled && d->control->echoMode() == Normal && e->button() == Qt::LeftButton && d->inSelection(e->pos().x())) { if (!d->dndTimer.isActive()) @@ -1534,7 +1536,7 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e) Q_D(QLineEdit); if (e->buttons() & Qt::LeftButton) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (d->dndTimer.isActive()) { if ((d->mousePressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) d->drag(); @@ -1581,7 +1583,7 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e) Q_D(QLineEdit); if (d->sendMouseEventToInputContext(e)) return; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (e->button() == Qt::LeftButton) { if (d->dndTimer.isActive()) { d->dndTimer.stop(); @@ -2031,7 +2033,7 @@ void QLineEdit::paintEvent(QPaintEvent *) } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*!\reimp */ void QLineEdit::dragMoveEvent(QDragMoveEvent *e) @@ -2096,7 +2098,7 @@ void QLineEdit::dropEvent(QDropEvent* e) } } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) #ifndef QT_NO_CONTEXTMENU /*! diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h index 099bf4bb18..6c70a8f44a 100644 --- a/src/widgets/widgets/qlineedit.h +++ b/src/widgets/widgets/qlineedit.h @@ -217,7 +217,7 @@ protected: void focusInEvent(QFocusEvent *) override; void focusOutEvent(QFocusEvent *) override; void paintEvent(QPaintEvent *) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void dragEnterEvent(QDragEnterEvent *) override; void dragMoveEvent(QDragMoveEvent *e) override; void dragLeaveEvent(QDragLeaveEvent *e) override; diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 6a8af53c97..0eeff196a8 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -44,7 +44,9 @@ #if QT_CONFIG(itemviews) #include "qabstractitemview.h" #endif +#if QT_CONFIG(draganddrop) #include "qdrag.h" +#endif #include "qwidgetaction.h" #include "qclipboard.h" #ifndef QT_NO_ACCESSIBILITY @@ -310,7 +312,7 @@ bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e ) return false; } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) void QLineEditPrivate::drag() { Q_Q(QLineEdit); @@ -323,8 +325,7 @@ void QLineEditPrivate::drag() if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q) control->removeSelection(); } - -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) #if QT_CONFIG(toolbutton) diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 39f670b0b0..71a67e3d10 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -211,7 +211,7 @@ public: void _q_completionHighlighted(const QString &); #endif QPoint mousePressPos; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) QBasicTimer dndTimer; void drag(); #endif diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index e66b702ffd..903a9349ec 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -44,7 +44,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #if QT_CONFIG(menu) #include @@ -2139,7 +2141,7 @@ void QPlainTextEdit::contextMenuEvent(QContextMenuEvent *e) } #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QPlainTextEdit::dragEnterEvent(QDragEnterEvent *e) @@ -2180,7 +2182,7 @@ void QPlainTextEdit::dropEvent(QDropEvent *e) d->sendControlEvent(e); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \reimp */ diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h index 34ec96715e..e5ac4c82b8 100644 --- a/src/widgets/widgets/qplaintextedit.h +++ b/src/widgets/widgets/qplaintextedit.h @@ -247,7 +247,7 @@ protected: #ifndef QT_NO_CONTEXTMENU virtual void contextMenuEvent(QContextMenuEvent *e) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void dragEnterEvent(QDragEnterEvent *e) override; virtual void dragLeaveEvent(QDragLeaveEvent *e) override; virtual void dragMoveEvent(QDragMoveEvent *e) override; diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 2f2d1bceee..8af70d0f9c 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -1668,7 +1668,7 @@ bool QTabBar::event(QEvent *event) d->updateMacBorderMetrics(); return QWidget::event(event); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) } else if (event->type() == QEvent::DragEnter) { if (d->changeCurrentOnDrag) event->accept(); diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 95c85dc4fe..8a9a0eaf96 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -49,7 +49,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #if QT_CONFIG(menu) #include @@ -1648,7 +1650,7 @@ void QTextEdit::contextMenuEvent(QContextMenuEvent *e) } #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) /*! \reimp */ void QTextEdit::dragEnterEvent(QDragEnterEvent *e) @@ -1689,7 +1691,7 @@ void QTextEdit::dropEvent(QDropEvent *e) d->sendControlEvent(e); } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop) /*! \reimp */ diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 9e0913160d..51d6c2ccba 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -284,7 +284,7 @@ protected: #ifndef QT_NO_CONTEXTMENU virtual void contextMenuEvent(QContextMenuEvent *e) override; #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) virtual void dragEnterEvent(QDragEnterEvent *e) override; virtual void dragLeaveEvent(QDragLeaveEvent *e) override; virtual void dragMoveEvent(QDragMoveEvent *e) override; diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 43c1c3e365..e179ea3b40 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -46,7 +46,9 @@ #include #include #include +#if QT_CONFIG(draganddrop) #include +#endif #include #if QT_CONFIG(menu) #include @@ -129,7 +131,7 @@ QWidgetTextControlPrivate::QWidgetTextControlPrivate() interactionFlags(Qt::TextEditable | Qt::TextSelectableByKeyboard), #endif dragEnabled(true), -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mousePressed(false), mightStartDrag(false), #endif lastSelectionPosition(0), lastSelectionAnchor(0), @@ -514,7 +516,7 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString void QWidgetTextControlPrivate::startDrag() { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) Q_Q(QWidgetTextControl); mousePressed = false; if (!contextWidget) @@ -1066,7 +1068,7 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget } #endif // QT_NO_TOOLTIP -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) case QEvent::DragEnter: { QDragEnterEvent *ev = static_cast(e); if (d->dragEnterEvent(e, ev->mimeData())) @@ -1545,7 +1547,7 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto mousePressPos = pos.toPoint(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mightStartDrag = false; #endif @@ -1615,7 +1617,7 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto && cursorPos >= cursor.selectionStart() && cursorPos <= cursor.selectionEnd() && q->hitTest(pos, Qt::ExactHit) != -1) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mightStartDrag = true; #endif return; @@ -1744,7 +1746,7 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but const int oldCursorPos = cursor.position(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) if (mightStartDrag && (button & Qt::LeftButton)) { mousePressed = false; setCursorPosition(pos); @@ -1807,7 +1809,7 @@ void QWidgetTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton if (button == Qt::LeftButton && (interactionFlags & Qt::TextSelectableByMouse)) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop) mightStartDrag = false; #endif commitPreedit(); -- cgit v1.2.3