1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QDND_P_H
|
---|
43 | #define QDND_P_H
|
---|
44 |
|
---|
45 | //
|
---|
46 | // W A R N I N G
|
---|
47 | // -------------
|
---|
48 | //
|
---|
49 | // This file is not part of the Qt API. It exists for the convenience
|
---|
50 | // of other Qt classes. This header file may change from version to
|
---|
51 | // version without notice, or even be removed.
|
---|
52 | //
|
---|
53 | // We mean it.
|
---|
54 | //
|
---|
55 |
|
---|
56 | #include "QtCore/qobject.h"
|
---|
57 | #include "QtCore/qmap.h"
|
---|
58 | #include "QtGui/qmime.h"
|
---|
59 | #include "QtGui/qdrag.h"
|
---|
60 | #include "QtGui/qpixmap.h"
|
---|
61 | #include "QtCore/qpoint.h"
|
---|
62 | #include "private/qobject_p.h"
|
---|
63 | #ifdef Q_WS_MAC
|
---|
64 | # include "private/qt_mac_p.h"
|
---|
65 | #endif
|
---|
66 |
|
---|
67 | #if defined(Q_WS_WIN)
|
---|
68 | # include <windows.h>
|
---|
69 | # include <objidl.h>
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | QT_BEGIN_NAMESPACE
|
---|
73 |
|
---|
74 | class QEventLoop;
|
---|
75 |
|
---|
76 | #if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
|
---|
77 |
|
---|
78 | class QInternalMimeData : public QMimeData
|
---|
79 | {
|
---|
80 | Q_OBJECT
|
---|
81 | public:
|
---|
82 | QInternalMimeData();
|
---|
83 | ~QInternalMimeData();
|
---|
84 |
|
---|
85 | bool hasFormat(const QString &mimeType) const;
|
---|
86 | QStringList formats() const;
|
---|
87 | static bool canReadData(const QString &mimeType);
|
---|
88 |
|
---|
89 |
|
---|
90 | static QStringList formatsHelper(const QMimeData *data);
|
---|
91 | static bool hasFormatHelper(const QString &mimeType, const QMimeData *data);
|
---|
92 | static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data);
|
---|
93 |
|
---|
94 | protected:
|
---|
95 | QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
|
---|
96 |
|
---|
97 | virtual bool hasFormat_sys(const QString &mimeType) const = 0;
|
---|
98 | virtual QStringList formats_sys() const = 0;
|
---|
99 | virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
|
---|
100 | };
|
---|
101 |
|
---|
102 | #ifdef Q_WS_WIN
|
---|
103 | class QOleDataObject : public IDataObject
|
---|
104 | {
|
---|
105 | public:
|
---|
106 | explicit QOleDataObject(QMimeData *mimeData);
|
---|
107 | virtual ~QOleDataObject();
|
---|
108 |
|
---|
109 | void releaseQt();
|
---|
110 | const QMimeData *mimeData() const;
|
---|
111 | DWORD reportedPerformedEffect() const;
|
---|
112 |
|
---|
113 | // IUnknown methods
|
---|
114 | STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
|
---|
115 | STDMETHOD_(ULONG,AddRef)(void);
|
---|
116 | STDMETHOD_(ULONG,Release)(void);
|
---|
117 |
|
---|
118 | // IDataObject methods
|
---|
119 | STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
|
---|
120 | STDMETHOD(GetDataHere)(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium);
|
---|
121 | STDMETHOD(QueryGetData)(LPFORMATETC pformatetc);
|
---|
122 | STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pformatetc, LPFORMATETC pformatetcOut);
|
---|
123 | STDMETHOD(SetData)(LPFORMATETC pformatetc, STGMEDIUM FAR * pmedium,
|
---|
124 | BOOL fRelease);
|
---|
125 | STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC FAR* ppenumFormatEtc);
|
---|
126 | STDMETHOD(DAdvise)(FORMATETC FAR* pFormatetc, DWORD advf,
|
---|
127 | LPADVISESINK pAdvSink, DWORD FAR* pdwConnection);
|
---|
128 | STDMETHOD(DUnadvise)(DWORD dwConnection);
|
---|
129 | STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR* ppenumAdvise);
|
---|
130 |
|
---|
131 | private:
|
---|
132 | ULONG m_refs;
|
---|
133 | QPointer<QMimeData> data;
|
---|
134 | int CF_PERFORMEDDROPEFFECT;
|
---|
135 | DWORD performedEffect;
|
---|
136 | };
|
---|
137 |
|
---|
138 | class QOleEnumFmtEtc : public IEnumFORMATETC
|
---|
139 | {
|
---|
140 | public:
|
---|
141 | explicit QOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs);
|
---|
142 | explicit QOleEnumFmtEtc(const QVector<LPFORMATETC> &lpfmtetcs);
|
---|
143 | virtual ~QOleEnumFmtEtc();
|
---|
144 |
|
---|
145 | bool isNull() const;
|
---|
146 |
|
---|
147 | // IUnknown methods
|
---|
148 | STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
|
---|
149 | STDMETHOD_(ULONG,AddRef)(void);
|
---|
150 | STDMETHOD_(ULONG,Release)(void);
|
---|
151 |
|
---|
152 | // IEnumFORMATETC methods
|
---|
153 | STDMETHOD(Next)(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetched);
|
---|
154 | STDMETHOD(Skip)(ULONG celt);
|
---|
155 | STDMETHOD(Reset)(void);
|
---|
156 | STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum);
|
---|
157 |
|
---|
158 | private:
|
---|
159 | bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const;
|
---|
160 |
|
---|
161 | ULONG m_dwRefs;
|
---|
162 | ULONG m_nIndex;
|
---|
163 | QVector<LPFORMATETC> m_lpfmtetcs;
|
---|
164 | bool m_isNull;
|
---|
165 | };
|
---|
166 |
|
---|
167 | #endif
|
---|
168 |
|
---|
169 | #endif //QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
|
---|
170 |
|
---|
171 | #ifndef QT_NO_DRAGANDDROP
|
---|
172 |
|
---|
173 | class QDragPrivate : public QObjectPrivate
|
---|
174 | {
|
---|
175 | public:
|
---|
176 | QWidget *source;
|
---|
177 | QWidget *target;
|
---|
178 | QMimeData *data;
|
---|
179 | QPixmap pixmap;
|
---|
180 | QPoint hotspot;
|
---|
181 | Qt::DropActions possible_actions;
|
---|
182 | Qt::DropAction executed_action;
|
---|
183 | QMap<Qt::DropAction, QPixmap> customCursors;
|
---|
184 | Qt::DropAction defaultDropAction;
|
---|
185 | };
|
---|
186 |
|
---|
187 | class QDropData : public QInternalMimeData
|
---|
188 | {
|
---|
189 | Q_OBJECT
|
---|
190 | public:
|
---|
191 | QDropData();
|
---|
192 | ~QDropData();
|
---|
193 |
|
---|
194 | protected:
|
---|
195 | bool hasFormat_sys(const QString &mimeType) const;
|
---|
196 | QStringList formats_sys() const;
|
---|
197 | QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
|
---|
198 |
|
---|
199 | #if defined(Q_WS_WIN)
|
---|
200 | public:
|
---|
201 | LPDATAOBJECT currentDataObject;
|
---|
202 | #endif
|
---|
203 | };
|
---|
204 |
|
---|
205 | class Q_GUI_EXPORT QDragManager: public QObject {
|
---|
206 | Q_OBJECT
|
---|
207 |
|
---|
208 | QDragManager();
|
---|
209 | ~QDragManager();
|
---|
210 | // only friend classes can use QDragManager.
|
---|
211 | friend class QDrag;
|
---|
212 | friend class QDragMoveEvent;
|
---|
213 | friend class QDropEvent;
|
---|
214 | friend class QApplication;
|
---|
215 | #ifdef Q_WS_MAC
|
---|
216 | friend class QWidgetPrivate; //dnd is implemented here
|
---|
217 | #endif
|
---|
218 |
|
---|
219 | bool eventFilter(QObject *, QEvent *);
|
---|
220 | void timerEvent(QTimerEvent*);
|
---|
221 |
|
---|
222 | public:
|
---|
223 | Qt::DropAction drag(QDrag *);
|
---|
224 |
|
---|
225 | void cancel(bool deleteSource = true);
|
---|
226 | void move(const QPoint &);
|
---|
227 | void drop();
|
---|
228 | void updatePixmap();
|
---|
229 | QWidget *source() const { return object ? object->d_func()->source : 0; }
|
---|
230 | QDragPrivate *dragPrivate() const { return object ? object->d_func() : 0; }
|
---|
231 | static QDragPrivate *dragPrivate(QDrag *drag) { return drag ? drag->d_func() : 0; }
|
---|
232 |
|
---|
|
---|