src/qt3support/other/q3dragobject.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt3Support module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    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