Changeset 324 for trunk/src/gui/kernel
- Timestamp:
- Nov 18, 2009, 1:49:31 AM (16 years ago)
- Location:
- trunk/src/gui/kernel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/kernel/qclipboard_pm.cpp
r323 r324 52 52 #include "qevent.h" 53 53 #include "qmime.h" 54 55 54 56 #include "qt_os2.h" 55 #include " qdnd_p.h"57 #include "_p.h" 56 58 57 59 #define QCLIPBOARD_DEBUG 58 60 61 62 63 64 59 65 QT_BEGIN_NAMESPACE 60 66 … … 64 70 { 65 71 public: 66 QClipboardWatcher() {}72 QClipboardWatcher() {} 67 73 68 74 bool hasFormat_sys(const QString &mimetype) const; 69 75 QStringList formats_sys() const; 70 76 QVariant retrieveData_sys(const QString &mimetype, QVariant::Type preferredType) const; 77 78 79 80 81 82 83 84 71 85 }; 72 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 73 111 bool QClipboardWatcher::hasFormat_sys(const QString &mime) const 74 112 { 75 bool ok = false; 76 if (WinOpenClipbrd(NULLHANDLE)) { 77 ULONG cf = 0; 78 while ((cf = WinEnumClipbrdFmts(NULLHANDLE, cf))) { 79 if (QPMMime::converterToMime(mime, cf)) { 80 ok = true; 81 break; 82 } 83 } 84 WinCloseClipbrd(NULLHANDLE); 85 } 86 #ifndef QT_NO_DEBUG 87 else 88 qWarning("QClipboardWatcher: WinOpenClipbrd failed with %lX", 89 WinGetLastError(NULLHANDLE)); 90 #endif 91 return ok; 113 peekData(); 114 if (isDirty) 115 return false; // peekData() failed 116 117 foreach (QPMMime::Match match, matches) 118 if (match.mime == mime) 119 return true; 120 121 return false; 92 122 } 93 123 … … 95 125 { 96 126 QStringList fmts; 97 if (WinOpenClipbrd(NULLHANDLE)) { 98 QVector<ULONG> cfs; 99 ULONG cf = 0; 100 while ((cf = WinEnumClipbrdFmts(NULLHANDLE, cf))) 101 cfs << cf; 102 fmts = QPMMime::allMimesForFormats(cfs); 103 WinCloseClipbrd(NULLHANDLE); 104 } 105 #ifndef QT_NO_DEBUG 106 else 107 qWarning("QClipboardWatcher: WinOpenClipbrd failed with %lX", 108 WinGetLastError(NULLHANDLE)); 109 #endif 127 128 peekData(); 129 if (isDirty) 130 return fmts; // peekData() failed 131 132 foreach (QPMMime::Match match, matches) 133 fmts << match.mime; 134 110 135 return fmts; 111 136 } … … 116 141 QVariant result; 117 142 118 if (WinOpenClipbrd(NULLHANDLE)) { 119 ULONG cf = 0; 120 while ((cf = WinEnumClipbrdFmts(NULLHANDLE, cf))) { 121 QPMMime *converter = QPMMime::converterToMime(mime, cf); 122 if (converter) { 123 ULONG flags; 124 if (WinQueryClipbrdFmtInfo(NULLHANDLE, cf, &flags)) { 125 ULONG data = WinQueryClipbrdData(NULLHANDLE, cf); 126 if (data) { 127 result = converter->convertToMime(mime, type, cf, flags, data); 128 } 129 } 130 break; 143 peekData(); 144 if (isDirty) 145 return result; // peekData() failed 146 147 foreach (QPMMime::Match match, matches) { 148 if (match.mime == mime) { 149 ULONG flags; 150 if (WinQueryClipbrdFmtInfo(NULLHANDLE, match.format, &flags)) { 151 ULONG data = WinQueryClipbrdData(NULLHANDLE, match.format); 152 result = match.converter->convertFromFormat(match.format, flags, 153 data, match.mime, type); 131 154 } 155 132 156 } 133 WinCloseClipbrd(NULLHANDLE); 134 } 135 #ifndef QT_NO_DEBUG 136 else 137 qWarning("QClipboardWatcher: WinOpenClipbrd failed with %lX", 138 WinGetLastError(NULLHANDLE)); 139 #endif 157 } 158 140 159 return result; 141 160 } … … 143 162 //////////////////////////////////////////////////////////////////////////////// 144 163 145 class QClipboardData 164 class QClipboardData 146 165 { 147 166 public: … … 149 168 ~QClipboardData(); 150 169 151 // @todo ... 170 void setSource(QMimeData *s) 171 { 172 if (s == src) 173 return; 174 delete src; 175 src = s; 176 } 177 178 QMimeData *source() 179 { 180 return src; 181 } 182 183 bool setClipboard(QPMMime *converter, ULONG format, bool isDelayed); 184 185 MRESULT message(ULONG msg, MPARAM mp1, MPARAM mp2); 152 186 153 187 private: 188 154 189 }; 155 190 156 QClipboardData::QClipboardData() 191 QClipboardData::QClipboardData() 157 192 { 158 193 }