Ignore:
Timestamp:
Nov 14, 2009, 3:06:49 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui/kernel: Prototyped QPMMime and QClipboard helpers.

File:
1 edited

Legend:

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

    r95 r321  
    5757QT_BEGIN_NAMESPACE
    5858
     59////////////////////////////////////////////////////////////////////////////////
     60
     61class QClipboardWatcher : public QInternalMimeData
     62{
     63public:
     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
     71bool 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
     92QStringList 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
     107QVariant 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
     128class QClipboardData
     129{
     130public:
     131    QClipboardData();
     132    ~QClipboardData();
     133
     134    // @todo ...
     135
     136private:
     137};
     138
     139QClipboardData::QClipboardData()
     140{
     141}
     142
     143QClipboardData::~QClipboardData()
     144{
     145}
     146
     147static QClipboardData *ptrClipboardData = 0;
     148
     149static QClipboardData *clipboardData()
     150{
     151    if (ptrClipboardData == 0) {
     152        ptrClipboardData = new QClipboardData;
     153        // @todo ...
     154    }
     155    return ptrClipboardData;
     156}
     157
     158static void cleanupClipboardData()
     159{
     160    delete ptrClipboardData;
     161    ptrClipboardData = 0;
     162}
     163
     164////////////////////////////////////////////////////////////////////////////////
     165
    59166QClipboard::~QClipboard()
    60167{
    61     // @todo implement
     168    cleanupClipboardData();
    62169}
    63170
Note: See TracChangeset for help on using the changeset viewer.