Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qclipboard.cpp

    r95 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5151#include "qbuffer.h"
    5252#include "qimage.h"
     53#include "qtextcodec.h"
    5354
    5455QT_BEGIN_NAMESPACE
     
    5758    \class QClipboard
    5859    \brief The QClipboard class provides access to the window system clipboard.
    59 
    60     \ingroup io
    61     \ingroup environment
    62     \mainclass
    6360
    6461    The clipboard offers a simple mechanism to copy and paste data
     
    277274QString QClipboard::text(QString &subtype, Mode mode) const
    278275{
    279     const QMimeData *data = mimeData(mode);
     276    const QMimeData *const data = mimeData(mode);
    280277    if (!data)
    281278        return QString();
     279
     280    const QStringList formats = data->formats();
    282281    if (subtype.isEmpty()) {
    283         QStringList formats = data->formats();
    284282        if (formats.contains(QLatin1String("text/plain")))
    285283            subtype = QLatin1String("plain");
     
    290288                    break;
    291289                }
     290            if (subtype.isEmpty())
     291                return QString();
    292292        }
     293    } else if (!formats.contains(QLatin1String("text/") + subtype)) {
     294        return QString();
    293295    }
    294     if (subtype.isEmpty())
    295         return QString();
    296     if (subtype == QLatin1String("plain"))
    297         return data->text();
    298     return QString::fromUtf8(data->data(QLatin1String("text/") + subtype));
     296
     297    const QByteArray rawData = data->data(QLatin1String("text/") + subtype);
     298
     299#ifndef QT_NO_TEXTCODEC
     300    QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default
     301    if (subtype == QLatin1String("html"))
     302        codec = QTextCodec::codecForHtml(rawData, codec);
     303    else
     304        codec = QTextCodec::codecForUtfText(rawData, codec);
     305    return codec->toUnicode(rawData);
     306#else //QT_NO_TEXTCODEC
     307    return rawData;
     308#endif //QT_NO_TEXTCODEC
    299309}
    300310
     
    467477    The \a mode argument is used to control which part of the system
    468478    clipboard is used.  If \a mode is QClipboard::Clipboard, this
    469     function clears the the global clipboard contents.  If \a mode is
     479    function clears the global clipboard contents.  If \a mode is
    470480    QClipboard::Selection, this function clears the global mouse
    471481    selection contents. If \a mode is QClipboard::FindBuffer, this
Note: See TracChangeset for help on using the changeset viewer.