1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** Copyright (C) 2009 netlabs.org. OS/2 parts.
|
---|
7 | **
|
---|
8 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
9 | **
|
---|
10 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
11 | ** Commercial Usage
|
---|
12 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
13 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
14 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
15 | ** a written agreement between you and Nokia.
|
---|
16 | **
|
---|
17 | ** GNU Lesser General Public License Usage
|
---|
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
19 | ** General Public License version 2.1 as published by the Free Software
|
---|
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
21 | ** packaging of this file. Please review the following information to
|
---|
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
24 | **
|
---|
25 | ** In addition, as a special exception, Nokia gives you certain
|
---|
26 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
27 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
28 | ** package.
|
---|
29 | **
|
---|
30 | ** GNU General Public License Usage
|
---|
31 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
32 | ** General Public License version 3.0 as published by the Free Software
|
---|
33 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
34 | ** packaging of this file. Please review the following information to
|
---|
35 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
36 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
37 | **
|
---|
38 | ** If you are unsure which license is appropriate for your use, please
|
---|
39 | ** contact the sales department at [email protected].
|
---|
40 | ** $QT_END_LICENSE$
|
---|
41 | **
|
---|
42 | ****************************************************************************/
|
---|
43 |
|
---|
44 | #include "qclipboard.h"
|
---|
45 |
|
---|
46 | #ifndef QT_NO_CLIPBOARD
|
---|
47 |
|
---|
48 | #include "qapplication.h"
|
---|
49 | #include "qapplication_p.h"
|
---|
50 | #include "qeventloop.h"
|
---|
51 | #include "qwidget.h"
|
---|
52 | #include "qevent.h"
|
---|
53 | #include "qmime.h"
|
---|
54 | #include "qt_os2.h"
|
---|
55 | #include "qdnd_p.h"
|
---|
56 |
|
---|
57 | QT_BEGIN_NAMESPACE
|
---|
58 |
|
---|
59 | ////////////////////////////////////////////////////////////////////////////////
|
---|
60 |
|
---|
61 | class QClipboardWatcher : public QInternalMimeData
|
---|
62 | {
|
---|
63 | public:
|
---|
64 | QClipboardWatcher() {}
|
---|
65 |
|
---|
66 | bool hasFormat_sys(const QString &mimetype) const;
|
---|
67 | QStringList formats_sys() const;
|
---|
68 | QVariant retrieveData_sys(const QString &mimetype, QVariant::Type preferredType) const;
|
---|
69 | };
|
---|
70 |
|
---|
71 | bool QClipboardWatcher::hasFormat_sys(const QString &mime) const
|
---|
72 | {
|
---|
73 | bool ok = false;
|
---|
74 | if (WinOpenClipbrd(NULLHANDLE)) {
|
---|
75 | ULONG cf = 0;
|
---|
76 | while ((cf = WinEnumClipbrdFmts(NULLHANDLE, cf))) {
|
---|
77 | if (QPMMime::converterToMime(mime, cf)) {
|
---|
78 | ok = true;
|
---|
79 | break;
|
---|
80 | }
|
---|
81 | }
|
---|
82 | WinCloseClipbrd(NULLHANDLE);
|
---|
83 | }
|
---|
84 | #ifndef QT_NO_DEBUG
|
---|
85 | else
|
---|
86 | qWarning("QClipboardWatcher: WinOpenClipbrd failed with %lX",
|
---|
87 | WinGetLastError(NULLHANDLE));
|
---|
88 | #endif
|
---|
89 | return ok;
|
---|
90 | }
|
---|
91 |
|
---|
92 | QStringList QClipboardWatcher::formats_sys() const
|
---|
93 | {
|
---|
94 | QStringList fmts;
|
---|
95 | if (WinOpenClipbrd(NULLHANDLE)) {
|
---|
96 | fmts = QPMMime::allMimesForFormats();
|
---|
97 | WinCloseClipbrd(NULLHANDLE);
|
---|
98 | }
|
---|
99 | #ifndef QT_NO_DEBUG
|
---|
100 | else
|
---|
101 | qWarning("QClipboardWatcher: WinOpenClipbrd failed with %lX",
|
---|
102 | WinGetLastError(NULLHANDLE));
|
---|
103 | #endif
|
---|
104 | return fmts;
|
---|
105 | }
|
---|
106 |
|
---|
107 | QVariant QClipboardWatcher::retrieveData_sys(const QString &mime,
|
---|
108 | QVariant::Type type) const
|
---|
109 | {
|
---|
110 | QStringList fmts;
|
---|
111 | if (WinOpenClipbrd(NULLHANDLE)) {
|
---|
112 | // @todo enumerate all formats and select the best converter
|
---|
113 | QPMMime *converter = QPMMime::converterToMime(mime, cf);
|
---|
114 | if (converter)
|
---|
115 | result = converter->convertToMime(mime, cf, type);
|
---|
116 | WinCloseClipbrd(NULLHANDLE);
|
---|
117 | }
|
---|
118 | #ifndef QT_NO_DEBUG
|
---|
119 | else
|
---|
120 | qWarning("QClipboardWatcher: WinOpenClipbrd failed with %lX",
|
---|
121 | WinGetLastError(NULLHANDLE));
|
---|
122 | #endif
|
---|
123 | return fmts;
|
---|
124 | }
|
---|
125 |
|
---|
126 | ////////////////////////////////////////////////////////////////////////////////
|
---|
127 |
|
---|
128 | class QClipboardData
|
---|
129 | {
|
---|
130 | public:
|
---|
131 | QClipboardData();
|
---|
132 | ~QClipboardData();
|
---|
133 |
|
---|
134 | // @todo ...
|
---|
135 |
|
---|
136 | private:
|
---|
137 | };
|
---|
138 |
|
---|
139 | QClipboardData::QClipboardData()
|
---|
140 | {
|
---|
141 | }
|
---|
142 |
|
---|
143 | QClipboardData::~QClipboardData()
|
---|
144 | {
|
---|
145 | }
|
---|
146 |
|
---|
147 | static QClipboardData *ptrClipboardData = 0;
|
---|
148 |
|
---|
149 | static QClipboardData *clipboardData()
|
---|
150 | {
|
---|
151 | if (ptrClipboardData == 0) {
|
---|
152 | ptrClipboardData = new QClipboardData;
|
---|
153 | // @todo ...
|
---|
154 | }
|
---|
155 | return ptrClipboardData;
|
---|
156 | }
|
---|
157 |
|
---|
158 | static void cleanupClipboardData()
|
---|
159 | {
|
---|
160 | delete ptrClipboardData;
|
---|
161 | ptrClipboardData = 0;
|
---|
162 | }
|
---|
163 |
|
---|
164 | ////////////////////////////////////////////////////////////////////////////////
|
---|
165 |
|
---|
166 | QClipboard::~QClipboard()
|
---|
167 | {
|
---|
168 | cleanupClipboardData();
|
---|
169 | }
|
---|
170 |
|
---|
171 | void QClipboard::setMimeData(QMimeData *src, Mode mode)
|
---|
172 | {
|
---|
173 | // @todo implement
|
---|
174 | }
|
---|
175 |
|
---|
176 | void QClipboard::clear(Mode mode)
|
---|
177 | {
|
---|
178 | // @todo implement
|
---|
179 | }
|
---|
180 |
|
---|
181 | bool QClipboard::event(QEvent *e)
|
---|
182 | {
|
---|
183 | // @todo implement
|
---|
184 | return false;
|
---|
185 | }
|
---|
186 |
|
---|
187 | void QClipboard::connectNotify(const char *signal)
|
---|
188 | {
|
---|
189 | // @todo implement
|
---|
190 | }
|
---|
191 |
|
---|
192 | const QMimeData *QClipboard::mimeData(Mode mode) const
|
---|
193 | {
|
---|
194 | // @todo implement
|
---|
195 | return 0;
|
---|
196 | }
|
---|
197 |
|
---|
198 | bool QClipboard::supportsMode(Mode mode) const
|
---|
199 | {
|
---|
200 | return (mode == Clipboard);
|
---|
201 | }
|
---|
202 |
|
---|
203 | bool QClipboard::ownsMode(Mode mode) const
|
---|
204 | {
|
---|
205 | // @todo implement
|
---|
206 | return false;
|
---|
207 | }
|
---|
208 |
|
---|
209 | void QClipboard::ownerDestroyed()
|
---|
210 | {
|
---|
211 | }
|
---|
212 |
|
---|
213 | QT_END_NAMESPACE
|
---|
214 |
|
---|
215 | #endif // QT_NO_CLIPBOARD
|
---|