diff options
| author | Joerg Bornemann <[email protected]> | 2018-04-13 09:01:43 +0200 | 
|---|---|---|
| committer | Joerg Bornemann <[email protected]> | 2018-05-29 18:31:35 +0000 | 
| commit | 9f27bfb31acfba49a74a342d9249f24633a7ade2 (patch) | |
| tree | b156192def25d688ff924b60f1c8defadd86c351 | |
| parent | dd8e73504edbf71808d6585b7a08daddcdcbf18e (diff) | |
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 <[email protected]>
108 files changed, 651 insertions, 539 deletions
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp index f80c2c69750..660472c05c6 100644 --- a/examples/network/torrent/mainwindow.cpp +++ b/examples/network/torrent/mainwindow.cpp @@ -62,7 +62,7 @@ class TorrentView : public QTreeWidget  public:      TorrentView(QWidget *parent = 0); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  signals:      void fileDropped(const QString &fileName); @@ -702,12 +702,12 @@ void MainWindow::closeEvent(QCloseEvent *)  TorrentView::TorrentView(QWidget *parent)      : QTreeWidget(parent)  { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      setAcceptDrops(true);  #endif  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void TorrentView::dragMoveEvent(QDragMoveEvent *event)  {      // Accept file actions with a '.torrent' extension. diff --git a/examples/widgets/graphicsview/graphicsview.pro b/examples/widgets/graphicsview/graphicsview.pro index 5a054fe6b28..b9bef70a0e6 100644 --- a/examples/widgets/graphicsview/graphicsview.pro +++ b/examples/widgets/graphicsview/graphicsview.pro @@ -13,7 +13,7 @@ SUBDIRS       = \                simpleanchorlayout \                weatheranchorlayout -contains(DEFINES, QT_NO_CURSOR)|contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= dragdroprobot +contains(DEFINES, QT_NO_CURSOR)|!qtConfig(draganddrop): SUBDIRS -= dragdroprobot  qtHaveModule(opengl):!qtConfig(opengles.):!qtConfig(dynamicgl) {      SUBDIRS += boxes diff --git a/examples/widgets/itemviews/itemviews.pro b/examples/widgets/itemviews/itemviews.pro index 75307bd74e2..b4a002c1567 100644 --- a/examples/widgets/itemviews/itemviews.pro +++ b/examples/widgets/itemviews/itemviews.pro @@ -20,5 +20,5 @@ SUBDIRS       = addressbook \                  spreadsheet \                  stardelegate \                  storageview -contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= puzzle +!qtConfig(draganddrop): SUBDIRS -= puzzle  !qtHaveModule(xml): SUBDIRS -= simpledommodel diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro index cef4936d324..f9d863b69ef 100644 --- a/examples/widgets/widgets.pro +++ b/examples/widgets/widgets.pro @@ -26,5 +26,5 @@ qtHaveModule(gui):qtConfig(opengl): \      SUBDIRS += windowcontainer  contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows -contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= draganddrop +!qtConfig(draganddrop): SUBDIRS -= draganddrop  mac:SUBDIRS += mac diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index c340bddc51a..f55e90c1537 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -1414,7 +1414,7 @@ void QStandardItem::setTristate(bool tristate)  }  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!    Sets whether the item is drag enabled. If \a dragEnabled is true, the item @@ -1472,7 +1472,7 @@ void QStandardItem::setDropEnabled(bool dropEnabled)    \sa setDropEnabled(), isDragEnabled(), flags()  */ -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!    Returns the row where the item is located in its parent's child table, or diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index d1c04d6b513..827179b31dc 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -179,7 +179,7 @@ public:      QT_DEPRECATED void setTristate(bool tristate);  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      inline bool isDragEnabled() const {          return (flags() & Qt::ItemIsDragEnabled) != 0;      } @@ -189,7 +189,7 @@ public:          return (flags() & Qt::ItemIsDropEnabled) != 0;      }      void setDropEnabled(bool dropEnabled); -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)      QStandardItem *parent() const;      int row() const; diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 792ca9fbaf6..3b9afdfe8ba 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -13,7 +13,6 @@ HEADERS += \          kernel/qwindowsysteminterface.h \          kernel/qwindowsysteminterface_p.h \          kernel/qplatformintegration.h \ -        kernel/qplatformdrag.h \          kernel/qplatformscreen.h \          kernel/qplatformscreen_p.h \          kernel/qplatforminputcontext.h \ @@ -33,8 +32,6 @@ HEADERS += \          kernel/qplatformclipboard.h \          kernel/qplatformnativeinterface.h \          kernel/qplatformmenu.h \ -        kernel/qshapedpixmapdndwindow_p.h \ -        kernel/qsimpledrag_p.h \          kernel/qsurfaceformat.h \          kernel/qguiapplication.h \          kernel/qguiapplication_p.h \ @@ -46,12 +43,11 @@ HEADERS += \          kernel/qclipboard.h \          kernel/qcursor.h \          kernel/qcursor_p.h \ -        kernel/qdrag.h \ -        kernel/qdnd_p.h \          kernel/qevent.h \          kernel/qevent_p.h \          kernel/qinputmethod.h \          kernel/qinputmethod_p.h \ +        kernel/qinternalmimedata_p.h \          kernel/qkeysequence.h \          kernel/qkeysequence_p.h \          kernel/qkeymapper_p.h \ @@ -89,7 +85,6 @@ SOURCES += \          kernel/qplatforminputcontextplugin.cpp \          kernel/qplatforminputcontext.cpp \          kernel/qplatformintegration.cpp \ -        kernel/qplatformdrag.cpp \          kernel/qplatformscreen.cpp \          kernel/qplatformintegrationfactory.cpp \          kernel/qplatformintegrationplugin.cpp \ @@ -102,8 +97,6 @@ SOURCES += \          kernel/qplatformclipboard.cpp \          kernel/qplatformnativeinterface.cpp \          kernel/qsessionmanager.cpp \ -        kernel/qshapedpixmapdndwindow.cpp \ -        kernel/qsimpledrag.cpp \          kernel/qsurfaceformat.cpp \          kernel/qguiapplication.cpp \          kernel/qwindow.cpp \ @@ -112,10 +105,9 @@ SOURCES += \          kernel/qsurface.cpp \          kernel/qclipboard.cpp \          kernel/qcursor.cpp \ -        kernel/qdrag.cpp \ -        kernel/qdnd.cpp \          kernel/qevent.cpp \          kernel/qinputmethod.cpp \ +        kernel/qinternalmimedata.cpp \          kernel/qkeysequence.cpp \          kernel/qkeymapper.cpp \          kernel/qpalette.cpp \ @@ -138,6 +130,21 @@ SOURCES += \          kernel/qinputdevicemanager.cpp \          kernel/qhighdpiscaling.cpp +qtConfig(draganddrop) { +    HEADERS += \ +        kernel/qdnd_p.h \ +        kernel/qdrag.h \ +        kernel/qplatformdrag.h \ +        kernel/qshapedpixmapdndwindow_p.h \ +        kernel/qsimpledrag_p.h + +    SOURCES += \ +        kernel/qdnd.cpp \ +        kernel/qdrag.cpp \ +        kernel/qplatformdrag.cpp \ +        kernel/qshapedpixmapdndwindow.cpp \ +        kernel/qsimpledrag.cpp +}  qtConfig(opengl) {      HEADERS += \ diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp index 3af7f5c1816..5c5f1665548 100644 --- a/src/gui/kernel/qdnd.cpp +++ b/src/gui/kernel/qdnd.cpp @@ -37,39 +37,19 @@  **  ****************************************************************************/ -#include "qplatformdefs.h" +#include "qdnd_p.h" -#include "qbitmap.h" -#include "qdrag.h" -#include "qpixmap.h" -#include "qevent.h" -#include "qfile.h" -#include "qtextcodec.h"  #include "qguiapplication.h" -#include "qpoint.h" -#include "qbuffer.h" -#include "qimage.h" -#include "qpainter.h" -#include "qregexp.h" -#include "qdir.h" -#include "qdnd_p.h" -#include "qimagereader.h" -#include "qimagewriter.h" -#include "qdebug.h"  #include <ctype.h> -#include <qpa/qplatformintegration.h>  #include <qpa/qplatformdrag.h> - +#include <qpa/qplatformintegration.h>  #include <private/qguiapplication_p.h> -#ifndef QT_NO_DRAGANDDROP -  QT_BEGIN_NAMESPACE  // the universe's only drag manager  QDragManager *QDragManager::m_instance = 0; -  QDragManager::QDragManager()      : QObject(qApp), m_currentDropTarget(0),        m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()), @@ -78,7 +58,6 @@ QDragManager::QDragManager()      Q_ASSERT(!m_instance);  } -  QDragManager::~QDragManager()  {      m_instance = 0; @@ -142,196 +121,4 @@ Qt::DropAction QDragManager::drag(QDrag *o)      return result;  } -#endif // QT_NO_DRAGANDDROP - -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - -static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats) -{ -    QStringList formats; -    formats.reserve(imageFormats.size()); -    for (const auto &format : imageFormats) -        formats.append(QLatin1String("image/") + QLatin1String(format.toLower())); - -    //put png at the front because it is best -    int pngIndex = formats.indexOf(QLatin1String("image/png")); -    if (pngIndex != -1 && pngIndex != 0) -        formats.move(pngIndex, 0); - -    return formats; -} - -static inline QStringList imageReadMimeFormats() -{ -    return imageMimeFormats(QImageReader::supportedImageFormats()); -} - - -static inline QStringList imageWriteMimeFormats() -{ -    return imageMimeFormats(QImageWriter::supportedImageFormats()); -} - -QInternalMimeData::QInternalMimeData() -    : QMimeData() -{ -} - -QInternalMimeData::~QInternalMimeData() -{ -} - -bool QInternalMimeData::hasFormat(const QString &mimeType) const -{ -    bool foundFormat = hasFormat_sys(mimeType); -    if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) { -        QStringList imageFormats = imageReadMimeFormats(); -        for (int i = 0; i < imageFormats.size(); ++i) { -            if ((foundFormat = hasFormat_sys(imageFormats.at(i)))) -                break; -        } -    } -    return foundFormat; -} - -QStringList QInternalMimeData::formats() const -{ -    QStringList realFormats = formats_sys(); -    if (!realFormats.contains(QLatin1String("application/x-qt-image"))) { -        QStringList imageFormats = imageReadMimeFormats(); -        for (int i = 0; i < imageFormats.size(); ++i) { -            if (realFormats.contains(imageFormats.at(i))) { -                realFormats += QLatin1String("application/x-qt-image"); -                break; -            } -        } -    } -    return realFormats; -} - -QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const -{ -    QVariant data = retrieveData_sys(mimeType, type); -    if (mimeType == QLatin1String("application/x-qt-image")) { -        if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { -            // try to find an image -            QStringList imageFormats = imageReadMimeFormats(); -            for (int i = 0; i < imageFormats.size(); ++i) { -                data = retrieveData_sys(imageFormats.at(i), type); -                if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) -                    continue; -                break; -            } -        } -        // we wanted some image type, but all we got was a byte array. Convert it to an image. -        if (data.type() == QVariant::ByteArray -            && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) -            data = QImage::fromData(data.toByteArray()); - -    } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { -        QColor c; -        QByteArray ba = data.toByteArray(); -        if (ba.size() == 8) { -            ushort * colBuf = (ushort *)ba.data(); -            c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), -                      qreal(colBuf[1]) / qreal(0xFFFF), -                      qreal(colBuf[2]) / qreal(0xFFFF), -                      qreal(colBuf[3]) / qreal(0xFFFF)); -            data = c; -        } else { -            qWarning("Qt: Invalid color format"); -        } -    } else if (data.type() != type && data.type() == QVariant::ByteArray) { -        // try to use mime data's internal conversion stuf. -        QInternalMimeData *that = const_cast<QInternalMimeData *>(this); -        that->setData(mimeType, data.toByteArray()); -        data = QMimeData::retrieveData(mimeType, type); -        that->clear(); -    } -    return data; -} - -bool QInternalMimeData::canReadData(const QString &mimeType) -{ -    return imageReadMimeFormats().contains(mimeType); -} - -// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core. -QStringList QInternalMimeData::formatsHelper(const QMimeData *data) -{ -    QStringList realFormats = data->formats(); -    if (realFormats.contains(QLatin1String("application/x-qt-image"))) { -        // add all supported image formats -        QStringList imageFormats = imageWriteMimeFormats(); -        for (int i = 0; i < imageFormats.size(); ++i) { -            if (!realFormats.contains(imageFormats.at(i))) -                realFormats.append(imageFormats.at(i)); -        } -    } -    return realFormats; -} - -bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data) -{ - -    bool foundFormat = data->hasFormat(mimeType); -    if (!foundFormat) { -        if (mimeType == QLatin1String("application/x-qt-image")) { -            // check all supported image formats -            QStringList imageFormats = imageWriteMimeFormats(); -            for (int i = 0; i < imageFormats.size(); ++i) { -                if ((foundFormat = data->hasFormat(imageFormats.at(i)))) -                    break; -            } -        } else if (mimeType.startsWith(QLatin1String("image/"))) { -            return data->hasImage() && imageWriteMimeFormats().contains(mimeType); -        } -    } -    return foundFormat; -} - -QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data) -{ -    QByteArray ba; -    if (mimeType == QLatin1String("application/x-color")) { -        /* QMimeData can only provide colors as QColor or the name -           of a color as a QByteArray or a QString. So we need to do -           the conversion to application/x-color here. -           The application/x-color format is : -           type: application/x-color -           format: 16 -           data[0]: red -           data[1]: green -           data[2]: blue -           data[3]: opacity -        */ -        ba.resize(8); -        ushort * colBuf = (ushort *)ba.data(); -        QColor c = qvariant_cast<QColor>(data->colorData()); -        colBuf[0] = ushort(c.redF() * 0xFFFF); -        colBuf[1] = ushort(c.greenF() * 0xFFFF); -        colBuf[2] = ushort(c.blueF() * 0xFFFF); -        colBuf[3] = ushort(c.alphaF() * 0xFFFF); -    } else { -        ba = data->data(mimeType); -        if (ba.isEmpty()) { -            if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) { -                QImage image = qvariant_cast<QImage>(data->imageData()); -                QBuffer buf(&ba); -                buf.open(QBuffer::WriteOnly); -                // would there not be PNG ?? -                image.save(&buf, "PNG"); -            } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) { -                QImage image = qvariant_cast<QImage>(data->imageData()); -                QBuffer buf(&ba); -                buf.open(QBuffer::WriteOnly); -                image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); -            } -        } -    } -    return ba; -} - -#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD -  QT_END_NAMESPACE diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h index e7d83cbbafd..cc00bc1442c 100644 --- a/src/gui/kernel/qdnd_p.h +++ b/src/gui/kernel/qdnd_p.h @@ -62,41 +62,16 @@  #include "QtCore/qpoint.h"  #include "private/qobject_p.h"  #include "QtGui/qbackingstore.h" -QT_BEGIN_NAMESPACE - -class QEventLoop; -class QMouseEvent; -class QPlatformDrag; - -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - -class Q_GUI_EXPORT QInternalMimeData : public QMimeData -{ -    Q_OBJECT -public: -    QInternalMimeData(); -    ~QInternalMimeData(); - -    bool hasFormat(const QString &mimeType) const override; -    QStringList formats() const override; -    static bool canReadData(const QString &mimeType); +// ### Remove the following include, once everybody includes +//     qinternalmimedata_p.h for QInternalMimeData. +#include "qinternalmimedata_p.h" -    static QStringList formatsHelper(const QMimeData *data); -    static bool hasFormatHelper(const QString &mimeType, const QMimeData *data); -    static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data); +QT_REQUIRE_CONFIG(draganddrop); -protected: -    QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override; - -    virtual bool hasFormat_sys(const QString &mimeType) const = 0; -    virtual QStringList formats_sys() const = 0; -    virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0; -}; - -#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP +class QPlatformDrag;  class QDragPrivate : public QObjectPrivate  { @@ -142,10 +117,6 @@ private:      Q_DISABLE_COPY(QDragManager)  }; - -#endif // !QT_NO_DRAGANDDROP - -  QT_END_NAMESPACE  #endif // QDND_P_H diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 982c9e7659b..bb0e490aa02 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -45,8 +45,6 @@  #include <qpoint.h>  #include "qdnd_p.h" -#ifndef QT_NO_DRAGANDDROP -  QT_BEGIN_NAMESPACE  /*! @@ -420,5 +418,3 @@ void QDrag::cancel()  */  QT_END_NAMESPACE - -#endif // QT_NO_DRAGANDDROP diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h index a8288e1b53c..27b9c2c88f3 100644 --- a/src/gui/kernel/qdrag.h +++ b/src/gui/kernel/qdrag.h @@ -43,10 +43,10 @@  #include <QtGui/qtguiglobal.h>  #include <QtCore/qobject.h> -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); +QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP  class QMimeData;  class QDragPrivate;  class QPixmap; @@ -95,8 +95,6 @@ private:      Q_DISABLE_COPY(QDrag)  }; -#endif // QT_NO_DRAGANDDROP -  QT_END_NAMESPACE  #endif // QDRAG_H diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 50d9bbb2ccd..3c412903e12 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -42,16 +42,19 @@  #include "private/qguiapplication_p.h"  #include "private/qtouchdevice_p.h"  #include "qpa/qplatformintegration.h" -#include "qpa/qplatformdrag.h"  #include "private/qevent_p.h"  #include "qfile.h"  #include "qhashfunctions.h"  #include "qmetaobject.h"  #include "qmimedata.h" -#include "private/qdnd_p.h"  #include "qevent_p.h"  #include "qmath.h" +#if QT_CONFIG(draganddrop) +#include <qpa/qplatformdrag.h> +#include <private/qdnd_p.h> +#endif +  #include <private/qdebug_p.h>  QT_BEGIN_NAMESPACE @@ -2883,7 +2886,7 @@ const QTouchDevice *QNativeGestureEvent::device() const  */  #endif // QT_NO_GESTURES -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      Creates a QDragMoveEvent of the required \a type indicating      that the mouse is at position \a pos given within a widget. @@ -3227,7 +3230,7 @@ QDragLeaveEvent::QDragLeaveEvent()  QDragLeaveEvent::~QDragLeaveEvent()  {  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      \class QHelpEvent @@ -3902,7 +3905,7 @@ static const char *eventClassName(QEvent::Type t)      return "QEvent";  } -#  ifndef QT_NO_DRAGANDDROP +#  if QT_CONFIG(draganddrop)  static void formatDropEvent(QDebug d, const QDropEvent *e)  { @@ -3923,7 +3926,7 @@ static void formatDropEvent(QDebug d, const QDropEvent *e)      QtDebugUtils::formatQFlags(d, e->mouseButtons());  } -#  endif // !QT_NO_DRAGANDDROP +#  endif // QT_CONFIG(draganddrop)  #  if QT_CONFIG(tabletevent) @@ -4086,13 +4089,13 @@ QDebug operator<<(QDebug dbg, const QEvent *e)          dbg << ')';      }          break; -#  ifndef QT_NO_DRAGANDDROP +#  if QT_CONFIG(draganddrop)      case QEvent::DragEnter:      case QEvent::DragMove:      case QEvent::Drop:          formatDropEvent(dbg, static_cast<const QDropEvent *>(e));          break; -#  endif // !QT_NO_DRAGANDDROP +#  endif // QT_CONFIG(draganddrop)      case QEvent::InputMethod:          formatInputMethodEvent(dbg, static_cast<const QInputMethodEvent *>(e));          break; diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index d95da403681..033d24d6652 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -598,7 +598,7 @@ Q_DECLARE_TYPEINFO(QInputMethodQueryEvent::QueryPair, Q_MOVABLE_TYPE);  #endif // QT_NO_INPUTMETHOD -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  class QMimeData; @@ -671,7 +671,7 @@ public:      QDragLeaveEvent();      ~QDragLeaveEvent();  }; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  class Q_GUI_EXPORT QHelpEvent : public QEvent diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index caa8aaca4b5..c73dac42d68 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -50,7 +50,6 @@  #include <qpa/qplatformnativeinterface.h>  #include <qpa/qplatformtheme.h>  #include <qpa/qplatformintegration.h> -#include <qpa/qplatformdrag.h>  #include <QtCore/QAbstractEventDispatcher>  #include <QtCore/QStandardPaths> @@ -87,9 +86,13 @@  #include "private/qinputdevicemanager_p.h"  #include "private/qtouchdevice_p.h" -#include "private/qdnd_p.h"  #include <qpa/qplatformthemefactory_p.h> +#if QT_CONFIG(draganddrop) +#include <qpa/qplatformdrag.h> +#include <private/qdnd_p.h> +#endif +  #ifndef QT_NO_CURSOR  #include <qpa/qplatformcursor.h>  #endif @@ -3034,7 +3037,7 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E      QCoreApplication::sendSpontaneousEvent(window, &exposeEvent);  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  QPlatformDragQtResponse QGuiApplicationPrivate::processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions)  { @@ -3094,7 +3097,7 @@ QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QM      return response;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  #ifndef QT_NO_CLIPBOARD  /*! @@ -3910,7 +3913,7 @@ void QGuiApplicationPrivate::notifyThemeChanged()      }  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag)  {      Q_UNUSED(drag) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 75cbc7abde7..2fefaf0af6c 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -70,9 +70,9 @@ class QColorProfile;  class QPlatformIntegration;  class QPlatformTheme;  class QPlatformDragQtResponse; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  class QDrag; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  class QInputDeviceManager;  class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate @@ -162,7 +162,7 @@ public:      static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e);  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);      static QPlatformDropQtResponse processDrop(QWindow *w, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);  #endif @@ -309,9 +309,9 @@ public:  protected:      virtual void notifyThemeChanged();      bool tryCloseRemainingWindows(QWindowList processedWindows); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual void notifyDragStarted(const QDrag *); -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  private:      friend class QDragManager; diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp new file mode 100644 index 00000000000..8f4da1afb56 --- /dev/null +++ b/src/gui/kernel/qinternalmimedata.cpp @@ -0,0 +1,234 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qinternalmimedata_p.h" + +#include <QtCore/qbuffer.h> +#include <QtGui/qimage.h> +#include <QtGui/qimagereader.h> +#include <QtGui/qimagewriter.h> + +QT_BEGIN_NAMESPACE + +static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats) +{ +    QStringList formats; +    formats.reserve(imageFormats.size()); +    for (const auto &format : imageFormats) +        formats.append(QLatin1String("image/") + QLatin1String(format.toLower())); + +    //put png at the front because it is best +    int pngIndex = formats.indexOf(QLatin1String("image/png")); +    if (pngIndex != -1 && pngIndex != 0) +        formats.move(pngIndex, 0); + +    return formats; +} + +static inline QStringList imageReadMimeFormats() +{ +    return imageMimeFormats(QImageReader::supportedImageFormats()); +} + +static inline QStringList imageWriteMimeFormats() +{ +    return imageMimeFormats(QImageWriter::supportedImageFormats()); +} + +QInternalMimeData::QInternalMimeData() +    : QMimeData() +{ +} + +QInternalMimeData::~QInternalMimeData() +{ +} + +bool QInternalMimeData::hasFormat(const QString &mimeType) const +{ +    bool foundFormat = hasFormat_sys(mimeType); +    if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) { +        QStringList imageFormats = imageReadMimeFormats(); +        for (int i = 0; i < imageFormats.size(); ++i) { +            if ((foundFormat = hasFormat_sys(imageFormats.at(i)))) +                break; +        } +    } +    return foundFormat; +} + +QStringList QInternalMimeData::formats() const +{ +    QStringList realFormats = formats_sys(); +    if (!realFormats.contains(QLatin1String("application/x-qt-image"))) { +        QStringList imageFormats = imageReadMimeFormats(); +        for (int i = 0; i < imageFormats.size(); ++i) { +            if (realFormats.contains(imageFormats.at(i))) { +                realFormats += QLatin1String("application/x-qt-image"); +                break; +            } +        } +    } +    return realFormats; +} + +QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const +{ +    QVariant data = retrieveData_sys(mimeType, type); +    if (mimeType == QLatin1String("application/x-qt-image")) { +        if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { +            // try to find an image +            QStringList imageFormats = imageReadMimeFormats(); +            for (int i = 0; i < imageFormats.size(); ++i) { +                data = retrieveData_sys(imageFormats.at(i), type); +                if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) +                    continue; +                break; +            } +        } +        // we wanted some image type, but all we got was a byte array. Convert it to an image. +        if (data.type() == QVariant::ByteArray +            && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) +            data = QImage::fromData(data.toByteArray()); + +    } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { +        QColor c; +        QByteArray ba = data.toByteArray(); +        if (ba.size() == 8) { +            ushort * colBuf = (ushort *)ba.data(); +            c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF), +                      qreal(colBuf[1]) / qreal(0xFFFF), +                      qreal(colBuf[2]) / qreal(0xFFFF), +                      qreal(colBuf[3]) / qreal(0xFFFF)); +            data = c; +        } else { +            qWarning("Qt: Invalid color format"); +        } +    } else if (data.type() != type && data.type() == QVariant::ByteArray) { +        // try to use mime data's internal conversion stuf. +        QInternalMimeData *that = const_cast<QInternalMimeData *>(this); +        that->setData(mimeType, data.toByteArray()); +        data = QMimeData::retrieveData(mimeType, type); +        that->clear(); +    } +    return data; +} + +bool QInternalMimeData::canReadData(const QString &mimeType) +{ +    return imageReadMimeFormats().contains(mimeType); +} + +// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core. +QStringList QInternalMimeData::formatsHelper(const QMimeData *data) +{ +    QStringList realFormats = data->formats(); +    if (realFormats.contains(QLatin1String("application/x-qt-image"))) { +        // add all supported image formats +        QStringList imageFormats = imageWriteMimeFormats(); +        for (int i = 0; i < imageFormats.size(); ++i) { +            if (!realFormats.contains(imageFormats.at(i))) +                realFormats.append(imageFormats.at(i)); +        } +    } +    return realFormats; +} + +bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data) +{ + +    bool foundFormat = data->hasFormat(mimeType); +    if (!foundFormat) { +        if (mimeType == QLatin1String("application/x-qt-image")) { +            // check all supported image formats +            QStringList imageFormats = imageWriteMimeFormats(); +            for (int i = 0; i < imageFormats.size(); ++i) { +                if ((foundFormat = data->hasFormat(imageFormats.at(i)))) +                    break; +            } +        } else if (mimeType.startsWith(QLatin1String("image/"))) { +            return data->hasImage() && imageWriteMimeFormats().contains(mimeType); +        } +    } +    return foundFormat; +} + +QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data) +{ +    QByteArray ba; +    if (mimeType == QLatin1String("application/x-color")) { +        /* QMimeData can only provide colors as QColor or the name +           of a color as a QByteArray or a QString. So we need to do +           the conversion to application/x-color here. +           The application/x-color format is : +           type: application/x-color +           format: 16 +           data[0]: red +           data[1]: green +           data[2]: blue +           data[3]: opacity +        */ +        ba.resize(8); +        ushort * colBuf = (ushort *)ba.data(); +        QColor c = qvariant_cast<QColor>(data->colorData()); +        colBuf[0] = ushort(c.redF() * 0xFFFF); +        colBuf[1] = ushort(c.greenF() * 0xFFFF); +        colBuf[2] = ushort(c.blueF() * 0xFFFF); +        colBuf[3] = ushort(c.alphaF() * 0xFFFF); +    } else { +        ba = data->data(mimeType); +        if (ba.isEmpty()) { +            if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) { +                QImage image = qvariant_cast<QImage>(data->imageData()); +                QBuffer buf(&ba); +                buf.open(QBuffer::WriteOnly); +                // would there not be PNG ?? +                image.save(&buf, "PNG"); +            } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) { +                QImage image = qvariant_cast<QImage>(data->imageData()); +                QBuffer buf(&ba); +                buf.open(QBuffer::WriteOnly); +                image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper()); +            } +        } +    } +    return ba; +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qinternalmimedata_p.h b/src/gui/kernel/qinternalmimedata_p.h new file mode 100644 index 00000000000..aa5e896323f --- /dev/null +++ b/src/gui/kernel/qinternalmimedata_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QINTERNALMIMEDATA_P_H +#define QINTERNALMIMEDATA_P_H + +// +//  W A R N I N G +//  ------------- +// +// This file is not part of the Qt API.  It exists for the convenience +// of other Qt classes.  This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtCore/qbytearray.h> +#include <QtCore/qmimedata.h> +#include <QtCore/qstring.h> +#include <QtCore/qstringlist.h> +#include <QtCore/qvariant.h> +#include <QtGui/private/qtguiglobal_p.h> + +QT_BEGIN_NAMESPACE + +class QEventLoop; +class QMouseEvent; +class QPlatformDrag; + +class Q_GUI_EXPORT QInternalMimeData : public QMimeData +{ +    Q_OBJECT +public: +    QInternalMimeData(); +    ~QInternalMimeData(); + +    bool hasFormat(const QString &mimeType) const override; +    QStringList formats() const override; +    static bool canReadData(const QString &mimeType); + + +    static QStringList formatsHelper(const QMimeData *data); +    static bool hasFormatHelper(const QString &mimeType, const QMimeData *data); +    static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data); + +protected: +    QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override; + +    virtual bool hasFormat_sys(const QString &mimeType) const = 0; +    virtual QStringList formats_sys() const = 0; +    virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0; +}; + +QT_END_NAMESPACE + +#endif // QINTERNALMIMEDATA_P_H diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp index 3c23406a6b9..b40ddcbfb8a 100644 --- a/src/gui/kernel/qplatformdrag.cpp +++ b/src/gui/kernel/qplatformdrag.cpp @@ -46,7 +46,6 @@  QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP  #ifdef QDND_DEBUG  #  include <QtCore/QDebug>  #endif @@ -222,6 +221,4 @@ bool QPlatformDrag::ownsDragObject() const      return false;  } -#endif // QT_NO_DRAGANDDROP -  QT_END_NAMESPACE diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h index 54e6a667fea..9d4e352b4b9 100644 --- a/src/gui/kernel/qplatformdrag.h +++ b/src/gui/kernel/qplatformdrag.h @@ -52,9 +52,9 @@  #include <QtGui/qtguiglobal.h>  #include <QtGui/QPixmap> -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE  class QMimeData;  class QMouseEvent; @@ -112,8 +112,6 @@ private:      Q_DISABLE_COPY(QPlatformDrag)  }; -#endif // QT_NO_DRAGANDDROP -  QT_END_NAMESPACE  #endif diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 2aaa4c85104..dfb8f609150 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -45,8 +45,11 @@  #include <qpa/qplatformtheme.h>  #include <QtGui/private/qguiapplication_p.h>  #include <QtGui/private/qpixmap_raster_p.h> + +#if QT_CONFIG(draganddrop)  #include <private/qdnd_p.h>  #include <private/qsimpledrag_p.h> +#endif  #ifndef QT_NO_SESSIONMANAGER  # include <qpa/qplatformsessionmanager.h> @@ -92,7 +95,7 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      Accessor for the platform integration's drag object. @@ -107,7 +110,7 @@ QPlatformDrag *QPlatformIntegration::drag() const      }      return drag;  } -#endif +#endif // QT_CONFIG(draganddrop)  QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const  { diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index d88f8189209..efb1481f6da 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -130,7 +130,7 @@ public:  #ifndef QT_NO_CLIPBOARD      virtual QPlatformClipboard *clipboard() const;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual QPlatformDrag *drag() const;  #endif      virtual QPlatformInputContext *inputContext() const; diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h index 477938867ca..072e7c6aea5 100644 --- a/src/gui/kernel/qshapedpixmapdndwindow_p.h +++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h @@ -55,6 +55,8 @@  #include <QtGui/QRasterWindow>  #include <QtGui/QPixmap> +QT_REQUIRE_CONFIG(draganddrop); +  QT_BEGIN_NAMESPACE  class QShapedPixmapWindow : public QRasterWindow diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index c98b879a158..12e204a09f7 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -68,8 +68,6 @@  QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP -  Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd")  static QWindow* topLevelAt(const QPoint &pos) @@ -434,6 +432,4 @@ void QSimpleDrag::drop(const QPoint &nativeGlobalPos)      }  } -#endif // QT_NO_DRAGANDDROP -  QT_END_NAMESPACE diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h index e56c7bf3060..d980a3c49d8 100644 --- a/src/gui/kernel/qsimpledrag_p.h +++ b/src/gui/kernel/qsimpledrag_p.h @@ -56,9 +56,9 @@  #include <QtCore/QObject> -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE  class QMouseEvent;  class QWindow; @@ -136,8 +136,6 @@ protected:      virtual void drop(const QPoint &globalPos) override;  }; -#endif // QT_NO_DRAGANDDROP -  QT_END_NAMESPACE  #endif diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 2c7e061bcfb..9abe04810b3 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -55,7 +55,9 @@  #  include "qaccessible.h"  #endif  #include "qhighdpiscaling_p.h" +#if QT_CONFIG(draganddrop)  #include "qshapedpixmapdndwindow_p.h" +#endif // QT_CONFIG(draganddrop)  #include <private/qevent_p.h> @@ -382,7 +384,11 @@ void QWindowPrivate::setVisible(bool visible)              QGuiApplicationPrivate::hideModalWindow(q);      // QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block      // input to this window as it is performing a drag - QTBUG-63846 -    } else if (visible && QGuiApplication::modalWindow() && !qobject_cast<QShapedPixmapWindow *>(q)) { +    } else if (visible && QGuiApplication::modalWindow() +#if QT_CONFIG(draganddrop) +               && !qobject_cast<QShapedPixmapWindow *>(q) +#endif // QT_CONFIG(draganddrop) +              ) {          QGuiApplicationPrivate::updateBlockedStatus(q);      } diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index c310ab5213c..6edcdfc255f 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -43,12 +43,15 @@  #include "private/qevent_p.h"  #include "private/qtouchdevice_p.h"  #include <QAbstractEventDispatcher> -#include <qpa/qplatformdrag.h>  #include <qpa/qplatformintegration.h>  #include <qdebug.h>  #include "qhighdpiscaling_p.h"  #include <QtCore/qscopedvaluerollback.h> +#if QT_CONFIG(draganddrop) +#include <qpa/qplatformdrag.h> +#endif +  QT_BEGIN_NAMESPACE @@ -791,7 +794,7 @@ void QWindowSystemInterface::handleThemeChange(QWindow *window)      QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions)  {      return QGuiApplicationPrivate::processDrag(window, dropData, QHighDpi::fromNativeLocalPosition(p, window) ,supportedActions); @@ -801,7 +804,7 @@ QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, cons  {      return QGuiApplicationPrivate::processDrop(window, dropData, QHighDpi::fromNativeLocalPosition(p, window),supportedActions);  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      \fn static QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result) diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index a7cc30be4b6..bba0b05c5a3 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -214,7 +214,7 @@ public:      template<typename Delivery = QWindowSystemInterface::DefaultDelivery>      static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      // Drag and drop. These events are sent immediately.      static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions);      static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData, const QPoint &p, Qt::DropActions supportedActions); diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h index dc0cc17dfba..5a5b985c6e0 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.h +++ b/src/plugins/platforms/cocoa/qcocoadrag.h @@ -46,6 +46,7 @@  #include <private/qsimpledrag_p.h>  #include <QtGui/private/qdnd_p.h> +#include <QtGui/private/qinternalmimedata_p.h>  QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.h b/src/plugins/platforms/offscreen/qoffscreencommon.h index 541c07384c3..f4f0142911c 100644 --- a/src/plugins/platforms/offscreen/qoffscreencommon.h +++ b/src/plugins/platforms/offscreen/qoffscreencommon.h @@ -41,7 +41,9 @@  #define QOFFSCREENCOMMON_H  #include <qpa/qplatformbackingstore.h> +#if QT_CONFIG(draganddrop)  #include <qpa/qplatformdrag.h> +#endif  #include <qpa/qplatformintegration.h>  #include <qpa/qplatformscreen.h>  #include <qpa/qplatformwindow.h> @@ -71,7 +73,7 @@ public:      QScopedPointer<QPlatformCursor> m_cursor;  }; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  class QOffscreenDrag : public QPlatformDrag  {  public: diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index 75bb786b282..01cd2545014 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -109,7 +109,7 @@ QOffscreenIntegration::QOffscreenIntegration()      m_fontDatabase.reset(new QFreeTypeFontDatabase());  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      m_drag.reset(new QOffscreenDrag);  #endif      m_services.reset(new QPlatformServices); @@ -204,7 +204,7 @@ QPlatformFontDatabase *QOffscreenIntegration::fontDatabase() const      return m_fontDatabase.data();  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  QPlatformDrag *QOffscreenIntegration::drag() const  {      return m_drag.data(); diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.h b/src/plugins/platforms/offscreen/qoffscreenintegration.h index a1e3a9bde8b..fc988126bb0 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.h +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.h @@ -59,7 +59,7 @@ public:      QPlatformWindow *createPlatformWindow(QWindow *window) const override;      QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QPlatformDrag *drag() const override;  #endif @@ -76,7 +76,7 @@ public:  private:      QScopedPointer<QPlatformFontDatabase> m_fontDatabase; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QScopedPointer<QPlatformDrag> m_drag;  #endif      QScopedPointer<QPlatformInputContext> m_inputContext; diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index bffe7ee34bd..6085cd34c0f 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -139,7 +139,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList)      , m_clipboard(0)  #endif      , m_navigator(0) -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop)      , m_drag(new QSimpleDrag())  #endif  { @@ -212,7 +212,7 @@ QQnxIntegration::~QQnxIntegration()      qIntegrationDebug("platform plugin shutdown begin");      delete m_nativeInterface; -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop)      // Destroy the drag object      delete m_drag;  #endif @@ -419,7 +419,7 @@ QPlatformClipboard *QQnxIntegration::clipboard() const  }  #endif -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop)  QPlatformDrag *QQnxIntegration::drag() const  {      return m_drag; diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index d1ebb1d4bf6..f11afa17484 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -113,7 +113,7 @@ public:  #if !defined(QT_NO_CLIPBOARD)      QPlatformClipboard *clipboard() const override;  #endif -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop)      QPlatformDrag *drag() const override;  #endif      QVariant styleHint(StyleHint hint) const override; @@ -158,7 +158,7 @@ private:      mutable QQnxClipboard* m_clipboard;  #endif      QQnxAbstractNavigator *m_navigator; -#if !defined(QT_NO_DRAGANDDROP) +#if QT_CONFIG(draganddrop)      QSimpleDrag *m_drag;  #endif      static QQnxWindowMapper ms_windowMapper; diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 593ff3cef1e..e427ee162aa 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -56,6 +56,7 @@  #include <QtGui/QRasterWindow>  #include <QtGui/QGuiApplication>  #include <qpa/qwindowsysteminterface_p.h> +#include <QtGui/private/qdnd_p.h>  #include <QtGui/private/qguiapplication_p.h>  #include <QtGui/private/qhighdpiscaling_p.h> diff --git a/src/plugins/platforms/windows/qwindowsdrag.h b/src/plugins/platforms/windows/qwindowsdrag.h index 2b4ca2dce15..d934679488b 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.h +++ b/src/plugins/platforms/windows/qwindowsdrag.h @@ -44,6 +44,7 @@  #include "qwindowsinternalmimedata.h"  #include <qpa/qplatformdrag.h> +#include <QtGui/qdrag.h>  #include <QtGui/QPixmap>  struct IDropTargetHelper; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 287b65cd5d4..0a9e8b9d91d 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -552,7 +552,7 @@ QPlatformDrag *QWindowsIntegration::drag() const  {      return &d->m_drag;  } -#  endif // !QT_NO_DRAGANDDROP +#  endif // QT_CONFIG(draganddrop)  #endif // !QT_NO_CLIPBOARD  QPlatformInputContext * QWindowsIntegration::inputContext() const diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.h b/src/plugins/platforms/windows/qwindowsinternalmimedata.h index a7df1ee6e07..a44f5b509cf 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.h +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.h @@ -42,7 +42,7 @@  #include <QtCore/qt_windows.h> -#include <QtGui/private/qdnd_p.h> // QInternalMime +#include <QtGui/private/qinternalmimedata_p.h>  #include <QtCore/QVariant>  QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 34e60416875..0439797a7df 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -40,7 +40,7 @@  #include "qwindowsmime.h"  #include "qwindowscontext.h" -#include <QtGui/private/qdnd_p.h> +#include <QtGui/private/qinternalmimedata_p.h>  #include <QtCore/QByteArrayMatcher>  #include <QtCore/QTextCodec>  #include <QtCore/QMap> @@ -1255,7 +1255,7 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData          } else {  #if QT_CONFIG(draganddrop)              data = QInternalMimeData::renderDataHelper(outFormats.value(getCf(formatetc)), mimeData); -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)          }          return setData(data, pmedium);      } @@ -1363,7 +1363,7 @@ bool QLastResortMimes::canConvertFromMime(const FORMATETC &formatetc, const QMim      Q_UNUSED(formatetc);      return formatetc.tymed & TYMED_HGLOBAL          && formats.contains(formatetc.cfFormat); -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  }  bool QLastResortMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const @@ -1376,7 +1376,7 @@ bool QLastResortMimes::convertFromMime(const FORMATETC &formatetc, const QMimeDa      Q_UNUSED(formatetc);      Q_UNUSED(pmedium);      return false; -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  }  QVector<FORMATETC> QLastResortMimes::formatsForMime(const QString &mimeType, const QMimeData * /*mimeData*/) const @@ -1484,7 +1484,7 @@ QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const                      format = clipFormat;              }          } -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)      }      return format; @@ -1559,7 +1559,7 @@ QVector<FORMATETC> QWindowsMimeConverter::allFormatsForMime(const QMimeData *mim  {      ensureInitialized();      QVector<FORMATETC> formatics; -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop)      Q_UNUSED(mimeData);  #else      formatics.reserve(20); @@ -1568,7 +1568,7 @@ QVector<FORMATETC> QWindowsMimeConverter::allFormatsForMime(const QMimeData *mim          for (int i = m_mimes.size() - 1; i >= 0; --i)              formatics += m_mimes.at(i)->formatsForMime(formats.at(f), mimeData);      } -#endif //QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)      return formatics;  } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index f8d6ae222eb..a2883e2601d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1248,7 +1248,7 @@ void QWindowsWindow::setDropSiteEnabled(bool dropEnabled)          RevokeDragDrop(m_data.hwnd);          m_dropTarget = 0;      } -#endif // !QT_NO_CLIPBOARD && !QT_NO_DRAGANDDROP +#endif // QT_CONFIG(clipboard) && QT_CONFIG(draganddrop)  }  // Returns topmost QWindowsWindow ancestor even if there are embedded windows in the chain. diff --git a/src/plugins/platforms/winrt/qwinrtdrag.h b/src/plugins/platforms/winrt/qwinrtdrag.h index 2371201507c..3868c9f015e 100644 --- a/src/plugins/platforms/winrt/qwinrtdrag.h +++ b/src/plugins/platforms/winrt/qwinrtdrag.h @@ -41,7 +41,8 @@  #include <QtCore/QLoggingCategory>  #include <QtCore/QMimeData> -#include <QtGui/private/qdnd_p.h> // QInternalMime +#include <QtGui/private/qdnd_p.h> +#include <QtGui/private/qinternalmimedata_p.h>  #include <wrl.h> diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp index 7a30c8d98b8..c52207d23bb 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.cpp +++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp @@ -47,7 +47,7 @@  #include "qwinrteglcontext.h"  #include "qwinrttheme.h"  #include "qwinrtclipboard.h" -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  #include "qwinrtdrag.h"  #endif @@ -308,12 +308,12 @@ QPlatformClipboard *QWinRTIntegration::clipboard() const      return d->clipboard;  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  QPlatformDrag *QWinRTIntegration::drag() const  {      return QWinRTDrag::instance();  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  Qt::KeyboardModifiers QWinRTIntegration::queryKeyboardModifiers() const  { diff --git a/src/plugins/platforms/winrt/qwinrtintegration.h b/src/plugins/platforms/winrt/qwinrtintegration.h index e22532a266f..d1a9b7edbdd 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.h +++ b/src/plugins/platforms/winrt/qwinrtintegration.h @@ -97,7 +97,7 @@ public:      QPlatformInputContext *inputContext() const override;      QPlatformServices *services() const override;      QPlatformClipboard *clipboard() const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QPlatformDrag *drag() const override;  #endif diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index e37aeb0bc59..531e8438298 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -42,7 +42,7 @@  #include "qwinrtbackingstore.h"  #include "qwinrtinputcontext.h"  #include "qwinrtcursor.h" -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  #include "qwinrtdrag.h"  #endif  #include "qwinrtwindow.h" @@ -567,7 +567,7 @@ QWinRTScreen::QWinRTScreen()      ComPtr<Xaml::IUIElement> uiElement;      hr = canvas.As(&uiElement);      Q_ASSERT_SUCCEEDED(hr); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QWinRTDrag::instance()->setUiElement(uiElement);  #endif      hr = window->put_Content(uiElement.Get()); @@ -850,7 +850,7 @@ void QWinRTScreen::addWindow(QWindow *window)      handleExpose();      QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QWinRTDrag::instance()->setDropTarget(window);  #endif  } @@ -869,7 +869,7 @@ void QWinRTScreen::removeWindow(QWindow *window)          QWindowSystemInterface::handleWindowActivated(nullptr, Qt::OtherFocusReason);      handleExpose();      QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (wasTopWindow)          QWinRTDrag::instance()->setDropTarget(topWindow());  #endif diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 042b270cffa..46371b48805 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -15,7 +15,6 @@ SOURCES = \      qwinrtbackingstore.cpp \      qwinrtclipboard.cpp \      qwinrtcursor.cpp \ -    qwinrtdrag.cpp \      qwinrteglcontext.cpp \      qwinrteventdispatcher.cpp \      qwinrtfiledialoghelper.cpp \ @@ -33,7 +32,6 @@ HEADERS = \      qwinrtbackingstore.h \      qwinrtclipboard.h \      qwinrtcursor.h \ -    qwinrtdrag.h \      qwinrteglcontext.h \      qwinrteventdispatcher.h \      qwinrtfiledialoghelper.h \ @@ -53,9 +51,9 @@ WINRT_SDK_VERSION = $$member($$list($$split(WINRT_SDK_VERSION_STRING, .)), 2)  lessThan(WINRT_SDK_VERSION, 14322): DEFINES += QT_WINRT_LIMITED_DRAGANDDROP  greaterThan(WINRT_SDK_VERSION, 14393): DEFINES += QT_WINRT_DISABLE_PHONE_COLORS -contains(DEFINES, QT_NO_DRAGANDDROP) { -    SOURCES -= qwinrtdrag.cpp -    HEADERS -= qwinrtdrag.h +qtConfig(draganddrop) { +    SOURCES += qwinrtdrag.cpp +    HEADERS += qwinrtdrag.h  }  PLUGIN_TYPE = platforms diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 444e3a7669e..879d31f29a2 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -46,7 +46,9 @@  #include "qxcbscreen.h"  #include "qxcbwindow.h"  #include "qxcbclipboard.h" +#if QT_CONFIG(draganddrop)  #include "qxcbdrag.h" +#endif  #include "qxcbwmsupport.h"  #include "qxcbnativeinterface.h"  #include "qxcbintegration.h" @@ -604,7 +606,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra  #ifndef QT_NO_CLIPBOARD      m_clipboard = new QXcbClipboard(this);  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      m_drag = new QXcbDrag(this);  #endif @@ -648,7 +650,7 @@ QXcbConnection::~QXcbConnection()  #ifndef QT_NO_CLIPBOARD      delete m_clipboard;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      delete m_drag;  #endif      if (m_reader && m_reader->isRunning()) { @@ -1139,7 +1141,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)  #if QT_CONFIG(draganddrop) || QT_CONFIG(clipboard)              xcb_selection_request_event_t *sr = reinterpret_cast<xcb_selection_request_event_t *>(event);  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)              if (sr->selection == atom(QXcbAtom::XdndSelection))                  m_drag->handleSelectionRequest(sr);              else @@ -1802,7 +1804,7 @@ void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t *      if (event->format != 32)          return; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (event->type == atom(QXcbAtom::XdndStatus)) {          drag()->handleStatus(event);      } else if (event->type == atom(QXcbAtom::XdndFinished)) { diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index d9321d94d07..583659ea813 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -424,7 +424,7 @@ public:  #ifndef QT_NO_CLIPBOARD      QXcbClipboard *clipboard() const { return m_clipboard; }  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QXcbDrag *drag() const { return m_drag; }  #endif @@ -673,7 +673,7 @@ private:  #ifndef QT_NO_CLIPBOARD      QXcbClipboard *m_clipboard = nullptr;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QXcbDrag *m_drag = nullptr;  #endif      QScopedPointer<QXcbWMSupport> m_wmSupport; diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 8ea0ebf9660..c8ba33edf5b 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -63,8 +63,6 @@  QT_BEGIN_NAMESPACE -#ifndef QT_NO_DRAGANDDROP -  //#define DND_DEBUG  #ifdef DND_DEBUG  #define DEBUG qDebug @@ -1312,6 +1310,4 @@ QStringList QXcbDropData::formats_sys() const      return formats;  } -#endif // QT_NO_DRAGANDDROP -  QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index 31f1c47d835..60287b717bd 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -55,9 +55,9 @@  #include <QtCore/QDebug> -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(draganddrop); -#ifndef QT_NO_DRAGANDDROP +QT_BEGIN_NAMESPACE  class QWindow;  class QPlatformWindow; @@ -173,8 +173,6 @@ private:  };  Q_DECLARE_TYPEINFO(QXcbDrag::Transaction, Q_MOVABLE_TYPE); -#endif // QT_NO_DRAGANDDROP -  QT_END_NAMESPACE  #endif diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 471287eb44b..7b6fd844e04 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -46,7 +46,9 @@  #include "qxcbbackingstore.h"  #include "qxcbnativeinterface.h"  #include "qxcbclipboard.h" +#if QT_CONFIG(draganddrop)  #include "qxcbdrag.h" +#endif  #include "qxcbglintegration.h"  #ifndef QT_NO_SESSIONMANAGER @@ -376,7 +378,7 @@ QPlatformClipboard *QXcbIntegration::clipboard() const  }  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  QPlatformDrag *QXcbIntegration::drag() const  {      return m_connections.at(0)->drag(); diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index 186b6c5ddd0..69e49cb7f6e 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -84,7 +84,7 @@ public:  #ifndef QT_NO_CLIPBOARD      QPlatformClipboard *clipboard() const override;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QPlatformDrag *drag() const override;  #endif diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 58e2e8c0e67..7170d259fd2 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -46,8 +46,6 @@  QT_BEGIN_NAMESPACE -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) -  QXcbMime::QXcbMime()      : QInternalMimeData()  { } @@ -320,6 +318,4 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString      return 0;  } -#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) -  QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbmime.h b/src/plugins/platforms/xcb/qxcbmime.h index 561631a377b..f2136ec9f44 100644 --- a/src/plugins/platforms/xcb/qxcbmime.h +++ b/src/plugins/platforms/xcb/qxcbmime.h @@ -40,7 +40,7 @@  #ifndef QXCBMIME_H  #define QXCBMIME_H -#include <private/qdnd_p.h> +#include <QtGui/private/qinternalmimedata_p.h>  #include <QtGui/QClipboard> @@ -49,8 +49,6 @@  QT_BEGIN_NAMESPACE -#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) -  class QXcbMime : public QInternalMimeData {      Q_OBJECT  public: @@ -67,9 +65,6 @@ public:                                          const QVector<xcb_atom_t> &atoms, QByteArray *requestedEncoding);  }; -#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD)) - -  QT_END_NAMESPACE  #endif // QXCBMIME_H diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index f87da28ee04..731b00f8fd4 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -49,7 +49,9 @@  #include "qxcbintegration.h"  #include "qxcbconnection.h"  #include "qxcbscreen.h" +#if QT_CONFIG(draganddrop)  #include "qxcbdrag.h" +#endif  #include "qxcbkeyboard.h"  #include "qxcbimage.h"  #include "qxcbwmsupport.h" @@ -541,7 +543,7 @@ void QXcbWindow::create()      XSync(static_cast<Display*>(platformScreen->connection()->xlib_display()), false);  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      connection()->drag()->dndEnable(this, true);  #endif @@ -1983,7 +1985,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even              qCWarning(lcQpaXcb, "Unhandled WM_PROTOCOLS (%s)",                        connection()->atomName(protocolAtom).constData());          } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      } else if (event->type == atom(QXcbAtom::XdndEnter)) {          connection()->drag()->handleEnter(this, event);      } else if (event->type == atom(QXcbAtom::XdndPosition)) { diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index ffc8a29116b..9c4797ac265 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -19,7 +19,6 @@ SOURCES = \          qxcbintegration.cpp \          qxcbkeyboard.cpp \          qxcbmime.cpp \ -        qxcbdrag.cpp \          qxcbscreen.cpp \          qxcbwindow.cpp \          qxcbbackingstore.cpp \ @@ -35,7 +34,6 @@ HEADERS = \          qxcbconnection.h \          qxcbintegration.h \          qxcbkeyboard.h \ -        qxcbdrag.h \          qxcbmime.h \          qxcbobject.h \          qxcbscreen.h \ @@ -49,6 +47,11 @@ HEADERS = \          qxcbsystemtraytracker.h \          qxcbxkbcommon.h +qtConfig(draganddrop) { +    SOURCES += qxcbdrag.cpp +    HEADERS += qxcbdrag.h +} +  load(qt_build_paths)  DEFINES += QT_BUILD_XCB_PLUGIN diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index cf1119254b3..99946d341d7 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -45,7 +45,9 @@  #include "qdrawutil.h"  #include "qevent.h"  #include "qimage.h" -#include "qdrag.h" +#if QT_CONFIG(draganddrop) +#include <qdrag.h> +#endif  #include "qlabel.h"  #include "qlayout.h"  #include "qlineedit.h" @@ -592,7 +594,7 @@ protected:      void mousePressEvent(QMouseEvent *e) override;      void mouseMoveEvent(QMouseEvent *e) override;      void mouseReleaseEvent(QMouseEvent *e) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragEnterEvent(QDragEnterEvent *e) override;      void dragLeaveEvent(QDragLeaveEvent *e) override;      void dragMoveEvent(QDragMoveEvent *e) override; @@ -624,7 +626,7 @@ void QColorWell::mousePressEvent(QMouseEvent *e)  void QColorWell::mouseMoveEvent(QMouseEvent *e)  {      QWellArray::mouseMoveEvent(e); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (!mousePressed)          return;      if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { @@ -647,7 +649,7 @@ void QColorWell::mouseMoveEvent(QMouseEvent *e)  #endif  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QColorWell::dragEnterEvent(QDragEnterEvent *e)  {      if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) @@ -684,7 +686,7 @@ void QColorWell::dropEvent(QDropEvent *e)      }  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  void QColorWell::mouseReleaseEvent(QMouseEvent *e)  { @@ -1072,7 +1074,7 @@ protected:      void mousePressEvent(QMouseEvent *e) override;      void mouseMoveEvent(QMouseEvent *e) override;      void mouseReleaseEvent(QMouseEvent *e) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragEnterEvent(QDragEnterEvent *e) override;      void dragLeaveEvent(QDragLeaveEvent *e) override;      void dropEvent(QDropEvent *e) override; @@ -1110,7 +1112,7 @@ void QColorShowLabel::mousePressEvent(QMouseEvent *e)  void QColorShowLabel::mouseMoveEvent(QMouseEvent *e)  { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop)      Q_UNUSED(e);  #else      if (!mousePressed) @@ -1132,7 +1134,7 @@ void QColorShowLabel::mouseMoveEvent(QMouseEvent *e)  #endif  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QColorShowLabel::dragEnterEvent(QDragEnterEvent *e)  {      if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) @@ -1157,7 +1159,7 @@ void QColorShowLabel::dropEvent(QDropEvent *e)          e->ignore();      }  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  void QColorShowLabel::mouseReleaseEvent(QMouseEvent *)  { diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 3d91bdef347..5d8ca458c29 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -3945,7 +3945,7 @@ void QFileDialogListView::setFileDialogPrivate(QFileDialogPrivate *d_pointer)      setResizeMode(QListView::Adjust);      setEditTriggers(QAbstractItemView::EditKeyPressed);      setContextMenuPolicy(Qt::CustomContextMenu); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      setDragDropMode(QAbstractItemView::InternalMove);  #endif  } @@ -3986,7 +3986,7 @@ void QFileDialogTreeView::setFileDialogPrivate(QFileDialogPrivate *d_pointer)      setTextElideMode(Qt::ElideMiddle);      setEditTriggers(QAbstractItemView::EditKeyPressed);      setContextMenuPolicy(Qt::CustomContextMenu); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      setDragDropMode(QAbstractItemView::InternalMove);  #endif  } diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index f77b10ecbca..d52f18b4060 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -118,7 +118,7 @@ QMimeData *QUrlModel::mimeData(const QModelIndexList &indexes) const      return data;  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      Decide based upon the data if it should be accepted or not @@ -154,7 +154,7 @@ bool QUrlModel::dropMimeData(const QMimeData *data, Qt::DropAction action,      return true;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      \reimp @@ -391,7 +391,7 @@ void QSidebar::setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUr      connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),              this, SLOT(clicked(QModelIndex))); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      setDragDropMode(QAbstractItemView::DragDrop);  #endif      setContextMenuPolicy(Qt::CustomContextMenu); @@ -405,13 +405,13 @@ QSidebar::~QSidebar()  {  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QSidebar::dragEnterEvent(QDragEnterEvent *event)  {      if (urlModel->canDrop(event))          QListView::dragEnterEvent(event);  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  QSize QSidebar::sizeHint() const  { diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 07aaa5abd27..4a82f888788 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -86,7 +86,7 @@ public:      QStringList mimeTypes() const override;      QMimeData *mimeData(const QModelIndexList &indexes) const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      bool canDrop(QDragEnterEvent *event);      bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;  #endif @@ -142,7 +142,7 @@ public:  protected:      bool event(QEvent * e) override;      void focusInEvent(QFocusEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragEnterEvent(QDragEnterEvent *event) override;  #endif diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 442f08325d1..177dbc4871e 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -1050,13 +1050,13 @@ void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *even  }  #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      \reimp  */  void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event)  { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop)      Q_UNUSED(event);  #else      Q_D(QGraphicsProxyWidget); @@ -1077,7 +1077,7 @@ void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event)  void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)  {      Q_UNUSED(event); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      Q_D(QGraphicsProxyWidget);      if (!d->widget || !d->dragDropWidget)          return; @@ -1092,7 +1092,7 @@ void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)  */  void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)  { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop)      Q_UNUSED(event);  #else      Q_D(QGraphicsProxyWidget); @@ -1158,7 +1158,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)  */  void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event)  { -#ifdef QT_NO_DRAGANDDROP +#if !QT_CONFIG(draganddrop)      Q_UNUSED(event);  #else      Q_D(QGraphicsProxyWidget); diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h index 76fdf8aeba7..aa51500ecb7 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.h +++ b/src/widgets/graphicsview/qgraphicsproxywidget.h @@ -85,7 +85,7 @@ protected:      void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override;      void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override;      void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override; diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 0c847b899e3..f79ee41e102 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -850,7 +850,7 @@ void QGraphicsViewPrivate::storeDragDropEvent(const QGraphicsSceneDragDropEvent  void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,                                                        QDropEvent *source)  { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      Q_Q(QGraphicsView);      dest->setScenePos(q->mapToScene(source->pos()));      dest->setScreenPos(q->mapToGlobal(source->pos())); diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 117de8edf97..c9f321c3f63 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -63,9 +63,11 @@  #include <private/qabstractitemdelegate_p.h>  #include <qpa/qplatformintegration.h> +#if QT_CONFIG(draganddrop)  #include <qpa/qplatformdrag.h> -#include <private/qguiapplication_p.h>  #include <private/qdnd_p.h> +#endif +#include <private/qguiapplication_p.h>  QT_BEGIN_NAMESPACE @@ -515,7 +517,7 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev                      return false;                  w = w->parentWidget();              } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)              // The window may lose focus during an drag operation.              // i.e when dragging involves the taskbar on Windows.              QPlatformDrag *platformDrag = QGuiApplicationPrivate::instance()->platformIntegration()->drag(); diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index a07297863d6..02eae33a122 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -44,7 +44,9 @@  #include <qclipboard.h>  #include <qpainter.h>  #include <qstyle.h> +#if QT_CONFIG(draganddrop)  #include <qdrag.h> +#endif  #include <qevent.h>  #include <qscrollbar.h>  #include <qtooltip.h> @@ -90,7 +92,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate()          editTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed),          lastTrigger(QAbstractItemView::NoEditTriggers),          tabKeyNavigation(false), -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)          showDropIndicator(true),          dragEnabled(false),          dragDropMode(QAbstractItemView::NoDragDrop), @@ -1325,7 +1327,7 @@ void QAbstractItemView::resetHorizontalScrollMode()      d_func()->horizontalScrollModeSet = false;  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      \since 4.2      \property QAbstractItemView::dragDropOverwriteMode @@ -1432,7 +1434,7 @@ QSize QAbstractItemView::viewportSizeHint() const      return QAbstractScrollArea::viewportSizeHint();  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      \property QAbstractItemView::showDropIndicator      \brief whether the drop indicator is shown when dragging items and dropping. @@ -1551,7 +1553,7 @@ Qt::DropAction QAbstractItemView::defaultDropAction() const      return d->defaultDropAction;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      \property QAbstractItemView::alternatingRowColors @@ -1828,7 +1830,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)      if (state() == ExpandingState || state() == CollapsingState)          return; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (state() == DraggingState) {          topLeft = d->pressedPosition - d->offset();          if ((topLeft - bottomRight).manhattanLength() > QApplication::startDragDistance()) { @@ -1839,7 +1841,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)          }          return;      } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)      QPersistentModelIndex index = indexAt(bottomRight);      QModelIndex buddy = d->model->buddy(d->pressedIndex); @@ -1854,7 +1856,7 @@ void QAbstractItemView::mouseMoveEvent(QMouseEvent *event)      d->checkMouseMove(index); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (d->pressedIndex.isValid()          && d->dragEnabled          && (state() != DragSelectingState) @@ -1962,7 +1964,7 @@ void QAbstractItemView::mouseDoubleClickEvent(QMouseEvent *event)          emit activated(persistent);  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      This function is called with the given \a event when a drag and drop operation enters @@ -2216,7 +2218,7 @@ QAbstractItemViewPrivate::position(const QPoint &pos, const QRect &rect, const Q      return r;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      This function is called with the given \a event when the widget obtains the focus. @@ -2567,7 +2569,7 @@ void QAbstractItemView::inputMethodEvent(QInputMethodEvent *event)      }  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      \enum QAbstractItemView::DropIndicatorPosition @@ -3667,7 +3669,7 @@ void QAbstractItemView::currentChanged(const QModelIndex ¤t, const QModelI      setAttribute(Qt::WA_InputMethodEnabled, (current.isValid() && (current.flags() & Qt::ItemIsEditable)));  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      Starts a drag by calling drag->exec() using the given \a supportedActions.  */ @@ -3698,7 +3700,7 @@ void QAbstractItemView::startDrag(Qt::DropActions supportedActions)          d->dropIndicatorPosition = OnItem;      }  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      Returns a QStyleOptionViewItem structure populated with the view's @@ -3911,7 +3913,7 @@ void QAbstractItemView::doAutoScroll()      if (verticalUnchanged && horizontalUnchanged) {          stopAutoScroll();      } else { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)          d->dropIndicatorRect = QRect();          d->dropIndicatorPosition = QAbstractItemView::OnViewport;  #endif @@ -4286,7 +4288,7 @@ void QAbstractItemViewPrivate::updateEditorData(const QModelIndex &tl, const QMo  */  void QAbstractItemViewPrivate::clearOrRemove()  { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      const QItemSelection selection = selectionModel->selection();      QList<QItemSelectionRange>::const_iterator it = selection.constBegin(); diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index 8a138bdb674..981582c1666 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -65,7 +65,7 @@ class Q_WIDGETS_EXPORT QAbstractItemView : public QAbstractScrollArea      Q_PROPERTY(int autoScrollMargin READ autoScrollMargin WRITE setAutoScrollMargin)      Q_PROPERTY(EditTriggers editTriggers READ editTriggers WRITE setEditTriggers)      Q_PROPERTY(bool tabKeyNavigation READ tabKeyNavigation WRITE setTabKeyNavigation) -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      Q_PROPERTY(bool showDropIndicator READ showDropIndicator WRITE setDropIndicatorShown)      Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)      Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode) @@ -165,7 +165,7 @@ public:      void setTabKeyNavigation(bool enable);      bool tabKeyNavigation() const; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void setDropIndicatorShown(bool enable);      bool showDropIndicator() const; @@ -297,7 +297,7 @@ protected:      virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,                                                                   const QEvent *event = nullptr) const; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual void startDrag(Qt::DropActions supportedActions);  #endif @@ -334,7 +334,7 @@ protected:      void mouseMoveEvent(QMouseEvent *event) override;      void mouseReleaseEvent(QMouseEvent *event) override;      void mouseDoubleClickEvent(QMouseEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragEnterEvent(QDragEnterEvent *event) override;      void dragMoveEvent(QDragMoveEvent *event) override;      void dragLeaveEvent(QDragLeaveEvent *event) override; @@ -348,7 +348,7 @@ protected:      void inputMethodEvent(QInputMethodEvent *event) override;      bool eventFilter(QObject *object, QEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport };      DropIndicatorPosition dropIndicatorPosition() const;  #endif diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index d8af96af559..fe1c00248fd 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -130,7 +130,7 @@ public:      }      void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;} -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);  #endif      bool droppingOnItself(QDropEvent *event, const QModelIndex &index); @@ -162,7 +162,7 @@ public:          }      } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;      inline bool canDrop(QDropEvent *event) { @@ -400,7 +400,7 @@ public:      bool tabKeyNavigation; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      bool showDropIndicator;      QRect dropIndicatorRect;      bool dragEnabled; diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index d94f25de78b..5100d2a4275 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -772,7 +772,7 @@ void QColumnView::initializeColumn(QAbstractItemView *column) const      column->setMinimumWidth(100);      column->setAttribute(Qt::WA_MacShowFocusRect, false); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      column->setDragDropMode(dragDropMode());      column->setDragDropOverwriteMode(dragDropOverwriteMode());      column->setDropIndicatorShown(showDropIndicator()); diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 6777b090437..a7174a92e8b 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -44,7 +44,9 @@  #include <qapplication.h>  #include <qpainter.h>  #include <qbitmap.h> +#if QT_CONFIG(draganddrop)  #include <qdrag.h> +#endif  #include <qvector.h>  #include <qstyle.h>  #include <qevent.h> @@ -230,7 +232,7 @@ void QListView::setMovement(Movement movement)      d->modeProperties |= uint(QListViewPrivate::Movement);      d->movement = movement; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      bool movable = (movement != Static);      setDragEnabled(movable);      d->viewport->setAcceptDrops(movable); @@ -494,7 +496,7 @@ void QListView::setViewMode(ViewMode mode)              d->showElasticBand = true;      } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      bool movable = (d->movement != Static);      setDragEnabled(movable);      setAcceptDrops(movable); @@ -875,7 +877,7 @@ void QListView::resizeEvent(QResizeEvent *e)      }  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!    \reimp @@ -919,7 +921,7 @@ void QListView::startDrag(Qt::DropActions supportedActions)          QAbstractItemView::startDrag(supportedActions);  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!    \reimp @@ -1048,7 +1050,7 @@ void QListView::paintEvent(QPaintEvent *e)          d->delegateForIndex(*it)->paint(&painter, option, *it);      } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      d->commonListView->paintDragDrop(&painter);  #endif @@ -1829,7 +1831,7 @@ QItemSelection QListViewPrivate::selection(const QRect &rect) const      return selection;  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const  {      if (viewMode == QListView::ListMode && flow == QListView::LeftToRight) @@ -1871,7 +1873,7 @@ void QCommonListViewBase::removeHiddenRow(int row)      dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex()));  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QCommonListViewBase::paintDragDrop(QPainter *painter)  {      // FIXME: Until the we can provide a proper drop indicator @@ -2006,7 +2008,7 @@ QListModeViewBase::QListModeViewBase(QListView *q, QListViewPrivate *d)  #endif  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const  {      QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport; @@ -2165,7 +2167,7 @@ bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QM      return false;  } -#endif //QT_NO_DRAGANDDROP +#endif //QT_CONFIG(draganddrop)  void QListModeViewBase::updateVerticalScrollBar(const QSize &step)  { @@ -2740,7 +2742,7 @@ void QIconModeViewBase::removeHiddenRow(int row)          tree.insertLeaf(items.at(row).rect(), row);  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions)  {      // This function does the same thing as in QAbstractItemView::startDrag(), @@ -2862,7 +2864,7 @@ bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)          dd->startAutoScroll();      return true;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  void QIconModeViewBase::setRowCount(int rowCount)  { diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h index 2da510facfd..9fc40359995 100644 --- a/src/widgets/itemviews/qlistview.h +++ b/src/widgets/itemviews/qlistview.h @@ -158,12 +158,12 @@ protected:      void timerEvent(QTimerEvent *e) override;      void resizeEvent(QResizeEvent *e) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragMoveEvent(QDragMoveEvent *e) override;      void dragLeaveEvent(QDragLeaveEvent *e) override;      void dropEvent(QDropEvent *e) override;      void startDrag(Qt::DropActions supportedActions) override; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)      QStyleOptionViewItem viewOptions() const override;      void paintEvent(QPaintEvent *e) override; diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index 8d297679512..ca947292e3b 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -143,7 +143,7 @@ public:      virtual void removeHiddenRow(int row);      virtual void setPositionForIndex(const QPoint &, const QModelIndex &) { } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual void paintDragDrop(QPainter *painter);      virtual bool filterDragMoveEvent(QDragMoveEvent *) { return false; }      virtual bool filterDragLeaveEvent(QDragLeaveEvent *) { return false; } @@ -228,7 +228,7 @@ public:      void updateHorizontalScrollBar(const QSize &step) override;      void updateVerticalScrollBar(const QSize &step) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      // The next two methods are to be used on LefToRight flow only.      // WARNING: Plenty of duplicated code from QAbstractItemView{,Private}.      QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; @@ -274,7 +274,7 @@ public:      void removeHiddenRow(int row) override;      void setPositionForIndex(const QPoint &position, const QModelIndex &index) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      bool filterDragMoveEvent(QDragMoveEvent *) override;      bool filterDragLeaveEvent(QDragLeaveEvent *) override;      bool filterDropEvent(QDropEvent *e) override; @@ -358,7 +358,7 @@ public:      QItemSelection selection(const QRect &rect) const;      void selectAll(QItemSelectionModel::SelectionFlags command) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const override;      bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index) override;  #endif diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 1fedad80aa3..4f1c7fe80aa 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -444,7 +444,7 @@ QMimeData *QListModel::mimeData(const QModelIndexList &indexes) const      return mimeData;  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  bool QListModel::dropMimeData(const QMimeData *data, Qt::DropAction action,                                int row, int column, const QModelIndex &index)  { @@ -463,7 +463,7 @@ Qt::DropActions QListModel::supportedDropActions() const      const QListWidget *view = qobject_cast<const QListWidget*>(QObject::parent());      return view->supportedDropActions();  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      \class QListWidgetItem @@ -1859,7 +1859,7 @@ QMimeData *QListWidget::mimeData(const QList<QListWidgetItem*> items) const      return d->listModel()->internalMimeData();  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      Handles \a data supplied by an external drag and drop operation that ended      with the given \a action in the given \a index. Returns \c true if \a data and @@ -1934,7 +1934,7 @@ Qt::DropActions QListWidget::supportedDropActions() const      Q_D(const QListWidget);      return d->listModel()->QAbstractListModel::supportedDropActions() | Qt::MoveAction;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      Returns a list of pointers to the items contained in the \a data object. If diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h index 8a31411429d..947fdb1a2f0 100644 --- a/src/widgets/itemviews/qlistwidget.h +++ b/src/widgets/itemviews/qlistwidget.h @@ -286,7 +286,7 @@ protected:  #else      virtual QMimeData *mimeData(const QList<QListWidgetItem*> items) const;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);      virtual Qt::DropActions supportedDropActions() const;  #endif diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h index 30b5016db60..9cb3d5966b9 100644 --- a/src/widgets/itemviews/qlistwidget_p.h +++ b/src/widgets/itemviews/qlistwidget_p.h @@ -124,7 +124,7 @@ public:      // dnd      QStringList mimeTypes() const override;      QMimeData *mimeData(const QModelIndexList &indexes) const override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      bool dropMimeData(const QMimeData *data, Qt::DropAction action,                        int row, int column, const QModelIndex &parent) override;      Qt::DropActions supportedDropActions() const override; diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index ec25ccdb12f..1938fd8e92c 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1512,7 +1512,7 @@ void QTableView::paintEvent(QPaintEvent *event)          }      } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      // Paint the dropIndicator      d->paintDropIndicator(&painter);  #endif diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 1a0fef9017a..805787597c2 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -142,7 +142,7 @@ public:            visualCursor(QPoint())   {      wrapItemText = true; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      overwrite = true;  #endif   } diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 301d5dbe4d2..9d5a2aa1bde 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -2618,7 +2618,7 @@ QMimeData *QTableWidget::mimeData(const QList<QTableWidgetItem*> items) const  bool QTableWidget::dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action)  {      QModelIndex idx; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (dropIndicatorPosition() == QAbstractItemView::OnItem) {          // QAbstractTableModel::dropMimeData will overwrite on the index if row == -1 and column == -1          idx = model()->index(row, column); @@ -2701,7 +2701,7 @@ bool QTableWidget::event(QEvent *e)      return QTableView::event(e);  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*! \reimp */  void QTableWidget::dropEvent(QDropEvent *event) {      Q_D(QTableWidget); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index ebeefad682e..fbfbe56246c 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1287,7 +1287,7 @@ void QTreeView::timerEvent(QTimerEvent *event)  /*!    \reimp  */ -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QTreeView::dragMoveEvent(QDragMoveEvent *event)  {      Q_D(QTreeView); @@ -1342,7 +1342,7 @@ void QTreeView::paintEvent(QPaintEvent *event)  #endif //QT_NO_ANIMATION      {          drawTree(&painter, event->region()); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)          d->paintDropIndicator(&painter);  #endif      } diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h index e7ee55aa2a8..09ce0e3fffe 100644 --- a/src/widgets/itemviews/qtreeview.h +++ b/src/widgets/itemviews/qtreeview.h @@ -201,7 +201,7 @@ protected:      void mouseDoubleClickEvent(QMouseEvent *event) override;      void mouseMoveEvent(QMouseEvent *event) override;      void keyPressEvent(QKeyEvent *event) override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragMoveEvent(QDragMoveEvent *event) override;  #endif      bool viewportEvent(QEvent *event) override; diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index de7f7c0b77c..654c241079f 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -3394,7 +3394,7 @@ QTreeWidgetItem *QTreeWidget::itemFromIndex(const QModelIndex &index) const      return d->item(index);  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*! \reimp */  void QTreeWidget::dropEvent(QDropEvent *event) {      Q_D(QTreeWidget); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 404bebd40cf..ba315d4338e 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -63,7 +63,9 @@  #include "qtranslator.h"  #include "qvariant.h"  #include "qwidget.h" -#include "private/qdnd_p.h" +#if QT_CONFIG(draganddrop) +#include <private/qdnd_p.h> +#endif  #include "private/qguiapplication_p.h"  #include "qcolormap.h"  #include "qdebug.h" @@ -832,7 +834,7 @@ QApplication::~QApplication()      delete QApplicationPrivate::app_style;      QApplicationPrivate::app_style = 0; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (qt_is_gui_used)          delete QDragManager::self();  #endif @@ -3429,7 +3431,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)          break;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      case QEvent::DragEnter: {              QWidget* w = static_cast<QWidget *>(receiver);              QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e); @@ -4477,7 +4479,7 @@ void QApplicationPrivate::notifyThemeChanged()      qt_init_tooltip_palette();  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QApplicationPrivate::notifyDragStarted(const QDrag *drag)  {      QGuiApplicationPrivate::notifyDragStarted(drag); @@ -4488,7 +4490,7 @@ void QApplicationPrivate::notifyDragStarted(const QDrag *drag)      if (qt_button_down && !qt_button_down->inherits("QQuickWidget"))          qt_button_down = nullptr;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  #ifndef QT_NO_GESTURES  QGestureManager* QGestureManager::instance() diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 019fad3fc35..488ca6cbfd3 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -177,9 +177,9 @@ public:  protected:      void notifyThemeChanged() override; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void notifyDragStarted(const QDrag *) override; -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  public:      static QFont *sys_font; diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index a86834002c9..12dab9870ad 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1322,7 +1322,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)               << "Alien?" << !testAttribute(Qt::WA_NativeWindow);  #endif -#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ && !defined(QT_NO_DRAGANDDROP) +#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ && QT_CONFIG(draganddrop)      // Unregister the dropsite (if already registered) before we      // re-create the widget with a native window.      if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow) @@ -9094,7 +9094,7 @@ bool QWidget::event(QEvent *event)          break;  #endif // QT_NO_CONTEXTMENU -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      case QEvent::Drop:          dropEvent((QDropEvent*) event);          break; @@ -9976,7 +9976,7 @@ void QWidget::setInputMethodHints(Qt::InputMethodHints hints)  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /*!      \fn void QWidget::dragEnterEvent(QDragEnterEvent *event) @@ -10045,7 +10045,7 @@ void QWidget::dropEvent(QDropEvent *)  {  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  /*!      \fn void QWidget::showEvent(QShowEvent *event) @@ -11194,7 +11194,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)      switch (attribute) { -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      case Qt::WA_AcceptDrops:  {          if (on && !testAttribute(Qt::WA_DropSiteRegistered))              setAttribute(Qt::WA_DropSiteRegistered, true); diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 5087d330eef..9f9f1670023 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -636,7 +636,7 @@ protected:      virtual void actionEvent(QActionEvent *event);  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      virtual void dragEnterEvent(QDragEnterEvent *event);      virtual void dragMoveEvent(QDragMoveEvent *event);      virtual void dragLeaveEvent(QDragLeaveEvent *event); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index a9c73c6a265..e8b550b1cd3 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -268,7 +268,7 @@ struct QWExtra {      // *************************** Platform specific values (bit fields first) **********  #if 0 /* Used to be included in Qt4 for Q_WS_WIN */ // <----------------------------------------------------------- WIN -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QOleDropTarget *dropTarget; // drop target      QList<QPointer<QWidget> > oleDropWidgets;  #endif @@ -800,7 +800,7 @@ public:      bool shouldShowMaximizeButton();      void winUpdateIsOpaque();      void reparentChildren(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QOleDropTarget *registerOleDnd(QWidget *widget);      void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);  #endif diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 949076b2606..1f3057b008d 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -309,7 +309,7 @@ bool QWidgetWindow::event(QEvent *event)          return true;  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      case QEvent::DragEnter:      case QEvent::DragMove:          handleDragEnterMoveEvent(static_cast<QDragMoveEvent *>(event)); @@ -846,7 +846,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)  #endif // QT_CONFIG(wheelevent) -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event)  { @@ -922,7 +922,7 @@ void QWidgetWindow::handleDropEvent(QDropEvent *event)      m_dragTarget = 0;  } -#endif // QT_NO_DRAGANDDROP +#endif // QT_CONFIG(draganddrop)  void QWidgetWindow::handleExposeEvent(QExposeEvent *event)  { diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h index d0f1d55c2ad..ead099390e2 100644 --- a/src/widgets/kernel/qwidgetwindow_p.h +++ b/src/widgets/kernel/qwidgetwindow_p.h @@ -95,7 +95,7 @@ protected:  #if QT_CONFIG(wheelevent)      void handleWheelEvent(QWheelEvent *);  #endif -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void handleDragEnterMoveEvent(QDragMoveEvent *);      void handleDragLeaveEvent(QDragLeaveEvent *);      void handleDropEvent(QDropEvent *); @@ -132,7 +132,7 @@ private:      QPointer<QWidget> m_widget;      QPointer<QWidget> m_implicit_mouse_grabber; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QPointer<QWidget> m_dragTarget;  #endif  }; diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 097931913eb..81916bba90b 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -329,7 +329,7 @@ bool QWindowContainer::event(QEvent *e)              }          }          break; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      case QEvent::Drop:      case QEvent::DragMove:      case QEvent::DragLeave: diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index 130260704f7..42691d6b778 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -136,7 +136,7 @@ static QEvent *cloneEvent(QEvent *e)          return new QEvent(*e);      case QEvent::DeferredDelete:          return new QEvent(*e); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)     case QEvent::DragEnter:          return new QDragEnterEvent(*static_cast<QDragEnterEvent*>(e));      case QEvent::DragMove: diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index 917cddce6fb..598d1731447 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 8a17036fb27..6d0d8fa6e60 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 bdeef7cdf77..ca6aacc16ce 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 <qdrag.h> +#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 099bf4bb188..6c70a8f44a2 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 6a8af53c970..0eeff196a86 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 39f670b0b09..71a67e3d10d 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 e66b702ffde..903a9349ece 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -44,7 +44,9 @@  #include <qpainter.h>  #include <qevent.h>  #include <qdebug.h> +#if QT_CONFIG(draganddrop)  #include <qdrag.h> +#endif  #include <qclipboard.h>  #if QT_CONFIG(menu)  #include <qmenu.h> @@ -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 34ec96715e3..e5ac4c82b8e 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 2f2d1bceeed..8af70d0f9cf 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 95c85dc4fe5..8a9a0eaf96c 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -49,7 +49,9 @@  #include <qpainter.h>  #include <qevent.h>  #include <qdebug.h> +#if QT_CONFIG(draganddrop)  #include <qdrag.h> +#endif  #include <qclipboard.h>  #if QT_CONFIG(menu)  #include <qmenu.h> @@ -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 9e0913160d3..51d6c2ccba4 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 43c1c3e365f..e179ea3b400 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -46,7 +46,9 @@  #include <qpainter.h>  #include <qevent.h>  #include <qdebug.h> +#if QT_CONFIG(draganddrop)  #include <qdrag.h> +#endif  #include <qclipboard.h>  #if QT_CONFIG(menu)  #include <qmenu.h> @@ -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<QDragEnterEvent *>(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(); diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp index b7d57dea55f..a45539a041c 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -256,7 +256,7 @@ void tst_QStandardItem::getSetFlags()      item.setAutoTristate(true);      QVERIFY(item.isAutoTristate());      QVERIFY(item.flags() & Qt::ItemIsAutoTristate); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      item.setDragEnabled(true);      QVERIFY(item.isDragEnabled());      QVERIFY(item.flags() & Qt::ItemIsDragEnabled); @@ -287,7 +287,7 @@ void tst_QStandardItem::getSetFlags()      item.setAutoTristate(false);      QVERIFY(!item.isAutoTristate());      QVERIFY(!(item.flags() & Qt::ItemIsAutoTristate)); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QVERIFY(item.isDragEnabled());      item.setDragEnabled(false);      QVERIFY(!item.isDragEnabled()); diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index 1ecfdb5e476..9399ebce34b 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -1426,7 +1426,7 @@ void tst_QStandardItemModel::rootItemFlags()      QCOMPARE(model.invisibleRootItem()->flags() , f);      QCOMPARE(model.invisibleRootItem()->flags() , model.flags(QModelIndex())); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      model.invisibleRootItem()->setDropEnabled(false);  #endif      QCOMPARE(model.invisibleRootItem()->flags() , Qt::ItemIsEnabled); @@ -1560,7 +1560,7 @@ void tst_QStandardItemModel::treeDragAndDrop()      view.setModel(&model);      view.expandAll();      view.show(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      view.setDragDropMode(QAbstractItemView::InternalMove);  #endif      view.setSelectionMode(QAbstractItemView::ExtendedSelection); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index 0071c39f495..b256aab3e73 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -210,7 +210,7 @@ private slots:      void mouseEventPropagation_focus();      void mouseEventPropagation_doubleclick();      void mouseEventPropagation_mouseMove(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragAndDrop_simple();      void dragAndDrop_disabledOrInvisible();      void dragAndDrop_propagate(); @@ -2204,7 +2204,7 @@ private:      }  }; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void tst_QGraphicsScene::dragAndDrop_simple()  {      DndTester *item = new DndTester(QRectF(-10, -10, 20, 20)); diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index f52bbce53a6..fe5b320492b 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -206,7 +206,7 @@ private slots:      void resizeAnchor();      void viewportUpdateMode();      void viewportUpdateMode2(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void acceptDrops();  #endif      void optimizationFlags(); @@ -2561,7 +2561,7 @@ void tst_QGraphicsView::viewportUpdateMode2()  #endif  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void tst_QGraphicsView::acceptDrops()  {      QGraphicsView view; diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 231474c71c2..58a66f99b4f 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -238,7 +238,7 @@ void tst_QAbstractItemView::getSetCheck()      // bool QAbstractItemView::dragEnabled()      // void QAbstractItemView::setDragEnabled(bool) -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      obj1->setDragEnabled(false);      QCOMPARE(false, obj1->dragEnabled());      obj1->setDragEnabled(true); @@ -415,7 +415,7 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view)      view->setTabKeyNavigation(true);      QCOMPARE(view->tabKeyNavigation(), true); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      // setDropIndicatorShown      view->setDropIndicatorShown(false);      QCOMPARE(view->showDropIndicator(), false); @@ -527,7 +527,7 @@ void tst_QAbstractItemView::basic_tests(QAbstractItemView *view)      view->selectionCommand(QModelIndex(), 0); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      if (!view->model())          view->startDrag(Qt::CopyAction); diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp index f1239b2e7ca..afd6d84486e 100644 --- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp +++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp @@ -327,7 +327,7 @@ void tst_QItemView::nonDestructiveBasicTest()      QCOMPARE(view->tabKeyNavigation(), false);      view->setTabKeyNavigation(true);      QCOMPARE(view->tabKeyNavigation(), true); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      // setDropIndicatorShown      view->setDropIndicatorShown(false);      QCOMPARE(view->showDropIndicator(), false); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 4c637573d03..1ea1843abe1 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -37,7 +37,7 @@  using namespace QTestPrivate; -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  Q_DECLARE_METATYPE(QAbstractItemView::DragDropMode)  #endif  Q_DECLARE_METATYPE(QAbstractItemView::EditTriggers) @@ -76,7 +76,7 @@ private slots:      void alternatingRowColors();      void currentIndex_data();      void currentIndex(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void dragDropMode_data();      void dragDropMode();      void dragDropModeFromDragEnabledAndAcceptDrops_data(); @@ -440,7 +440,7 @@ void tst_QTreeView::construction()      // QAbstractItemView properties      QVERIFY(!view.alternatingRowColors());      QCOMPARE(view.currentIndex(), QModelIndex()); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QCOMPARE(view.dragDropMode(), QAbstractItemView::NoDragDrop);      QVERIFY(!view.dragDropOverwriteMode());      QVERIFY(!view.dragEnabled()); @@ -463,7 +463,7 @@ void tst_QTreeView::construction()      QCOMPARE(view.selectionBehavior(), QAbstractItemView::SelectRows);      QCOMPARE(view.selectionMode(), QAbstractItemView::SingleSelection);      QVERIFY(!view.selectionModel()); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      QVERIFY(view.showDropIndicator());  #endif      QCOMPARE(view.QAbstractItemView::sizeHintForColumn(-1), -1); // <- protected in QTreeView @@ -573,7 +573,7 @@ void tst_QTreeView::currentIndex()      // ### Test child and grandChild indexes.  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void tst_QTreeView::dragDropMode_data()  { diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 47ffee15017..6a049aedf1e 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -171,7 +171,7 @@ private slots:      void enabledPropagation();      void ignoreKeyEventsWhenDisabled_QTBUG27417();      void properTabHandlingWhenDisabled_QTBUG27417(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void acceptDropsPropagation();  #endif      void isEnabledTo(); @@ -1048,7 +1048,7 @@ void tst_QWidget::properTabHandlingWhenDisabled_QTBUG27417()  }  // Drag'n drop disabled in this build. -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  void tst_QWidget::acceptDropsPropagation()  {      QScopedPointer<QWidget> testWidget(new QWidget); diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 1d2bb00678a..b143555b0dd 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -81,7 +81,7 @@ private slots:      void tst_paintEventOnSecondShow();      void tst_paintEventOnResize_QTBUG50796(); -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)      void tst_dnd();  #endif @@ -393,7 +393,7 @@ void tst_QWidget_window::tst_paintEventOnResize_QTBUG50796()      QTRY_COMPARE(native->paintEventCount, 1); // Only one paint event must occur  } -#ifndef QT_NO_DRAGANDDROP +#if QT_CONFIG(draganddrop)  /* DnD test for QWidgetWindow (handleDrag*Event() functions).   * Simulates a drop onto a QWidgetWindow of a top level widget  | 
