| 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 Qt3Support 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 Q3DRAGOBJECT_H
|
|---|
| 43 | #define Q3DRAGOBJECT_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qobject.h>
|
|---|
| 46 | #include <QtGui/qcolor.h>
|
|---|
| 47 | #include <QtGui/qmime.h>
|
|---|
| 48 | #include <QtGui/qimage.h>
|
|---|
| 49 | #include <Qt3Support/q3strlist.h>
|
|---|
| 50 | #include <QtCore/qlist.h>
|
|---|
| 51 |
|
|---|
| 52 | QT_BEGIN_HEADER
|
|---|
| 53 |
|
|---|
| 54 | QT_BEGIN_NAMESPACE
|
|---|
| 55 |
|
|---|
| 56 | QT_MODULE(Qt3SupportLight)
|
|---|
| 57 |
|
|---|
| 58 | class QWidget;
|
|---|
| 59 | class Q3TextDragPrivate;
|
|---|
| 60 | class Q3DragObjectPrivate;
|
|---|
| 61 | class Q3StoredDragPrivate;
|
|---|
| 62 | class Q3ImageDragPrivate;
|
|---|
| 63 | class Q3ImageDrag;
|
|---|
| 64 | class Q3TextDrag;
|
|---|
| 65 | class Q3StrList;
|
|---|
| 66 | class QImage;
|
|---|
| 67 | class QPixmap;
|
|---|
| 68 |
|
|---|
| 69 | class Q_COMPAT_EXPORT Q3DragObject : public QObject, public QMimeSource {
|
|---|
| 70 | Q_OBJECT
|
|---|
| 71 | Q_DECLARE_PRIVATE(Q3DragObject)
|
|---|
| 72 | public:
|
|---|
| 73 | Q3DragObject(QWidget * dragSource = 0, const char *name = 0);
|
|---|
| 74 | virtual ~Q3DragObject();
|
|---|
| 75 |
|
|---|
| 76 | bool drag();
|
|---|
| 77 | bool dragMove();
|
|---|
| 78 | void dragCopy();
|
|---|
| 79 | void dragLink();
|
|---|
| 80 |
|
|---|
| 81 | virtual void setPixmap(QPixmap);
|
|---|
| 82 | virtual void setPixmap(QPixmap, const QPoint& hotspot);
|
|---|
| 83 | QPixmap pixmap() const;
|
|---|
| 84 | QPoint pixmapHotSpot() const;
|
|---|
| 85 |
|
|---|
| 86 | QWidget * source();
|
|---|
| 87 | static QWidget * target();
|
|---|
| 88 |
|
|---|
| 89 | enum DragMode { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove };
|
|---|
| 90 |
|
|---|
| 91 | protected:
|
|---|
| 92 | Q3DragObject(Q3DragObjectPrivate &, QWidget *dragSource = 0);
|
|---|
| 93 | virtual bool drag(DragMode);
|
|---|
| 94 |
|
|---|
| 95 | private:
|
|---|
| 96 | friend class QDragMime;
|
|---|
| 97 | Q_DISABLE_COPY(Q3DragObject)
|
|---|
| 98 | };
|
|---|
| 99 |
|
|---|
| 100 | class Q_COMPAT_EXPORT Q3StoredDrag: public Q3DragObject {
|
|---|
| 101 | Q_OBJECT
|
|---|
| 102 | Q_DECLARE_PRIVATE(Q3StoredDrag)
|
|---|
| 103 | public:
|
|---|
| 104 | Q3StoredDrag(const char *mimeType, QWidget *dragSource = 0, const char *name = 0);
|
|---|
| 105 | ~Q3StoredDrag();
|
|---|
| 106 |
|
|---|
| 107 | virtual void setEncodedData(const QByteArray &);
|
|---|
| 108 |
|
|---|
| 109 | const char * format(int i) const;
|
|---|
| 110 | virtual QByteArray encodedData(const char*) const;
|
|---|
| 111 |
|
|---|
| 112 | protected:
|
|---|
| 113 | Q3StoredDrag(Q3StoredDragPrivate &, const char *mimeType, QWidget *dragSource = 0);
|
|---|
| 114 |
|
|---|
| 115 | private:
|
|---|
| 116 | Q_DISABLE_COPY(Q3StoredDrag)
|
|---|
| 117 | };
|
|---|
| 118 |
|
|---|
| 119 | class Q_COMPAT_EXPORT Q3TextDrag: public Q3DragObject {
|
|---|
| 120 | Q_OBJECT
|
|---|
| 121 | Q_DECLARE_PRIVATE(Q3TextDrag)
|
|---|
| 122 | public:
|
|---|
| 123 | Q3TextDrag(const QString &, QWidget *dragSource = 0, const char *name = 0);
|
|---|
| 124 | Q3TextDrag(QWidget * dragSource = 0, const char * name = 0);
|
|---|
| 125 | ~Q3TextDrag();
|
|---|
| 126 |
|
|---|
| 127 | virtual void setText(const QString &);
|
|---|
| 128 | virtual void setSubtype(const QString &);
|
|---|
| 129 |
|
|---|
| 130 | const char * format(int i) const;
|
|---|
| 131 | virtual QByteArray encodedData(const char*) const;
|
|---|
| 132 |
|
|---|
| 133 | static bool canDecode(const QMimeSource* e);
|
|---|
| 134 | static bool decode(const QMimeSource* e, QString& s);
|
|---|
| 135 | static bool decode(const QMimeSource* e, QString& s, QString& subtype);
|
|---|
| 136 |
|
|---|
| 137 | protected:
|
|---|
| 138 | Q3TextDrag(Q3TextDragPrivate &, QWidget * dragSource = 0);
|
|---|
| 139 |
|
|---|
| 140 | private:
|
|---|
| 141 | Q_DISABLE_COPY(Q3TextDrag)
|
|---|
| 142 | };
|
|---|
| 143 |
|
|---|
| 144 | class Q_COMPAT_EXPORT Q3ImageDrag: public Q3DragObject {
|
|---|
| 145 | Q_OBJECT
|
|---|
| 146 | Q_DECLARE_PRIVATE(Q3ImageDrag)
|
|---|
| 147 | public:
|
|---|
| 148 | Q3ImageDrag(QImage image, QWidget * dragSource = 0, const char * name = 0);
|
|---|
| 149 | Q3ImageDrag(QWidget * dragSource = 0, const char * name = 0);
|
|---|
| 150 | ~Q3ImageDrag();
|
|---|
| 151 |
|
|---|
| 152 | virtual void setImage(QImage image);
|
|---|
| 153 |
|
|---|
| 154 | const char * format(int i) const;
|
|---|
| 155 | virtual QByteArray encodedData(const char*) const;
|
|---|
| 156 |
|
|---|
| 157 | static bool canDecode(const QMimeSource* e);
|
|---|
| 158 | static bool decode(const QMimeSource* e, QImage& i);
|
|---|
| 159 | static bool decode(const QMimeSource* e, QPixmap& i);
|
|---|
| 160 |
|
|---|
| 161 | protected:
|
|---|
| 162 | Q3ImageDrag(Q3ImageDragPrivate &, QWidget * dragSource = 0);
|
|---|
| 163 |
|
|---|
| 164 | private:
|
|---|
| 165 | Q_DISABLE_COPY(Q3ImageDrag)
|
|---|
| 166 | };
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 | class Q_COMPAT_EXPORT Q3UriDrag: public Q3StoredDrag {
|
|---|
| 170 | Q_OBJECT
|
|---|
| 171 |
|
|---|
| 172 | public:
|
|---|
| 173 | Q3UriDrag(const Q3StrList &uris, QWidget * dragSource = 0, const char * name = 0);
|
|---|
| 174 | Q3UriDrag(QWidget * dragSource = 0, const char * name = 0);
|
|---|
| 175 | ~Q3UriDrag();
|
|---|
| 176 |
|
|---|
| 177 | void setFileNames(const QStringList & fnames);
|
|---|
| 178 | inline void setFileNames(const QString & fname) { setFileNames(QStringList(fname)); }
|
|---|
| 179 | void setFilenames(const QStringList & fnames) { setFileNames(fnames); }
|
|---|
| 180 | inline void setFilenames(const QString & fname) { setFileNames(QStringList(fname)); }
|
|---|
| 181 | void setUnicodeUris(const QStringList & uuris);
|
|---|
| 182 | virtual void setUris(const QList<QByteArray> &uris);
|
|---|
| 183 |
|
|---|
| 184 | static QString uriToLocalFile(const char*);
|
|---|
| 185 | static QByteArray localFileToUri(const QString&);
|
|---|
| 186 | static QString uriToUnicodeUri(const char*);
|
|---|
| 187 | static QByteArray unicodeUriToUri(const QString&);
|
|---|
| 188 | static bool canDecode(const QMimeSource* e);
|
|---|
| 189 | static bool decode(const QMimeSource* e, Q3StrList& i);
|
|---|
| 190 | static bool decodeToUnicodeUris(const QMimeSource* e, QStringList& i);
|
|---|
| 191 | static bool decodeLocalFiles(const QMimeSource* e, QStringList& i);
|
|---|
| 192 |
|
|---|
| 193 | private:
|
|---|
| 194 | Q_DISABLE_COPY(Q3UriDrag)
|
|---|
| 195 | };
|
|---|
| 196 |
|
|---|
| 197 | class Q_COMPAT_EXPORT Q3ColorDrag : public Q3StoredDrag
|
|---|
| 198 | {
|
|---|
| 199 | Q_OBJECT
|
|---|
| 200 | QColor color;
|
|---|
| 201 |
|
|---|
| 202 | public:
|
|---|
| 203 | Q3ColorDrag(const QColor &col, QWidget *dragsource = 0, const char *name = 0);
|
|---|
| 204 | Q3ColorDrag(QWidget * dragSource = 0, const char * name = 0);
|
|---|
| 205 | void setColor(const QColor &col);
|
|---|
| 206 |
|
|---|
| 207 | static bool canDecode(QMimeSource *);
|
|---|
| 208 | static bool decode(QMimeSource *, QColor &col);
|
|---|
| 209 |
|
|---|
| 210 | private:
|
|---|
| 211 | Q_DISABLE_COPY(Q3ColorDrag)
|
|---|
| 212 | };
|
|---|
| 213 |
|
|---|
| 214 | QT_END_NAMESPACE
|
|---|
| 215 |
|
|---|
| 216 | QT_END_HEADER
|
|---|
| 217 |
|
|---|
| 218 | #endif // Q3DRAGOBJECT_H
|
|---|