Ignore:
Timestamp:
Nov 16, 2009, 1:06:34 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui/kernel: More QPMMime work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qclipboard_pm.cpp

    r322 r323  
    5555#include "qdnd_p.h"
    5656
     57#define QCLIPBOARD_DEBUG
     58
    5759QT_BEGIN_NAMESPACE
    5860
     
    7577        ULONG cf = 0;
    7678        while ((cf = WinEnumClipbrdFmts(NULLHANDLE, cf))) {
    77 //          if (QPMMime::converterToMime(mime, cf)) {
    78 //              ok = true;
    79 //              break;
    80 //          }
     79            if (QPMMime::converterToMime(mime, cf)) {
     80                ok = true;
     81                break;
     82            }
    8183        }
    8284        WinCloseClipbrd(NULLHANDLE);
     
    9496    QStringList fmts;
    9597    if (WinOpenClipbrd(NULLHANDLE)) {
    96 //      fmts = QPMMime::allMimesForFormats();
     98        QVector<ULONG> cfs;
     99        ULONG cf = 0;
     100        while ((cf = WinEnumClipbrdFmts(NULLHANDLE, cf)))
     101            cfs << cf;
     102        fmts = QPMMime::allMimesForFormats(cfs);
    97103        WinCloseClipbrd(NULLHANDLE);
    98104    }
     
    108114                                             QVariant::Type type) const
    109115{
    110     QStringList fmts;
     116    QVariant result;
     117
    111118    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);
     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;
     131            }
     132        }
    116133        WinCloseClipbrd(NULLHANDLE);
    117134    }
     
    121138                 WinGetLastError(NULLHANDLE));
    122139#endif
    123     return fmts;
     140    return result;
    124141}
    125142
     
    171188void QClipboard::setMimeData(QMimeData *src, Mode mode)
    172189{
    173     // @todo implement
     190    if (mode != Clipboard)
     191        return;
     192
     193    if (!WinOpenClipbrd(NULLHANDLE)) {
     194#ifndef QT_NO_DEBUG
     195        qWarning("QClipboard: WinOpenClipbrd failed with %lX",
     196                 WinGetLastError(NULLHANDLE));
     197#endif
     198        return;
     199    }
     200
     201    // @todo
     202//  QClipboardData *d = clipboardData();
     203//  d->setSource(src);
     204
     205    WinCloseClipbrd(NULLHANDLE);
    174206}
    175207
Note: See TracChangeset for help on using the changeset viewer.