Rename QMacInternalPasteboardMime to QMacMime
We want to make it public, and there is no need for "pasteboard" since it also coveres drag'n'drop. Add a default constructor that defaults to supporting both clipboard and drag'n'drop, and clean up the code by using that constructor where applicable. Historical note: the converter interface was called QMacMime up to Qt 4.2, when due to macOS changes it had to be replaced by QMacPasteboardMime. Task-number: QTBUG-93632 Change-Id: Id9712300039375aa6394598b104827e6f5d6c948 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
fe1075332c
commit
76fcd436c1
@ -282,7 +282,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType ty
|
||||
On Windows, the MIME format does not always map directly to the
|
||||
clipboard formats. Qt provides QWinMime to map clipboard
|
||||
formats to open-standard MIME formats. Similarly, the
|
||||
QMacPasteboardMime maps MIME to Mac flavors.
|
||||
QMacMime maps MIME to Mac flavors.
|
||||
|
||||
\sa QClipboard, QDragEnterEvent, QDragMoveEvent, QDropEvent, QDrag,
|
||||
{Drag and Drop}
|
||||
|
@ -380,6 +380,6 @@
|
||||
|
||||
Custom classes for translating proprietary clipboard formats can be
|
||||
registered by reimplementing QWinMime on Windows or
|
||||
QMacPasteboardMime on \macos.
|
||||
QMacMime on \macos.
|
||||
|
||||
*/
|
||||
|
@ -34,9 +34,9 @@ using namespace Qt::StringLiterals;
|
||||
//#define DEBUG_MIME_MAPS
|
||||
|
||||
/*!
|
||||
\class QMacInternalPasteboardMime
|
||||
\class QMacMime
|
||||
\internal
|
||||
\brief The QMacPasteboardMime class converts between a MIME type and a
|
||||
\brief The QMacMime class converts between a MIME type and a
|
||||
\l{http://developer.apple.com/macosx/uniformtypeidentifiers.html}{Uniform
|
||||
Type Identifier (UTI)} format.
|
||||
\since 4.2
|
||||
@ -49,11 +49,11 @@ using namespace Qt::StringLiterals;
|
||||
Mac, although some applications use MIME to describe clipboard
|
||||
contents, it is more common to use Apple's UTI format.
|
||||
|
||||
QMacPasteboardMime's role is to bridge the gap between MIME and UTI;
|
||||
QMacMime's role is to bridge the gap between MIME and UTI;
|
||||
By subclasses this class, one can extend Qt's drag and drop
|
||||
and clipboard handling to convert to and from unsupported, or proprietary, UTI formats.
|
||||
|
||||
A subclass of QMacPasteboardMime will automatically be registered, and active, upon instantiation.
|
||||
A subclass of QMacMime will automatically be registered, and active, upon instantiation.
|
||||
|
||||
Qt has predefined support for the following UTIs:
|
||||
\list
|
||||
@ -69,7 +69,7 @@ using namespace Qt::StringLiterals;
|
||||
\li com.apple.pict - converts to "application/x-qt-image"
|
||||
\endlist
|
||||
|
||||
When working with MIME data, Qt will iterate through all instances of QMacPasteboardMime to
|
||||
When working with MIME data, Qt will iterate through all instances of QMacMime to
|
||||
find an instance that can convert to, or from, a specific MIME type. It will do this by calling
|
||||
canConvert() on each instance, starting with (and choosing) the last created instance first.
|
||||
The actual conversions will be done by using convertToMime() and convertFromMime().
|
||||
@ -79,7 +79,7 @@ using namespace Qt::StringLiterals;
|
||||
*/
|
||||
|
||||
/*
|
||||
\enum QMacPasteboardMime::QMacPasteboardMimeType
|
||||
\enum QMacMime::QMacMimeType
|
||||
\internal
|
||||
*/
|
||||
|
||||
@ -87,17 +87,25 @@ using namespace Qt::StringLiterals;
|
||||
Constructs a new conversion object of type \a t, adding it to the
|
||||
globally accessed list of available converters.
|
||||
*/
|
||||
QMacInternalPasteboardMime::QMacInternalPasteboardMime(QMacPasteboardMimeType t)
|
||||
QMacMime::QMacMime(QMacPasteboardMimeType t)
|
||||
: m_type(t)
|
||||
{
|
||||
QMacMimeRegistry::registerMimeConverter(this);
|
||||
}
|
||||
|
||||
/*
|
||||
Constructs a new conversion object and adds it to the
|
||||
globally accessed list of available converters.
|
||||
*/
|
||||
QMacMime::QMacMime()
|
||||
: QMacMime(MIME_ALL)
|
||||
{}
|
||||
|
||||
/*
|
||||
Destroys a conversion object, removing it from the global
|
||||
list of available converters.
|
||||
*/
|
||||
QMacInternalPasteboardMime::~QMacInternalPasteboardMime()
|
||||
QMacMime::~QMacMime()
|
||||
{
|
||||
QMacMimeRegistry::unregisterMimeConverter(this);
|
||||
}
|
||||
@ -105,15 +113,16 @@ QMacInternalPasteboardMime::~QMacInternalPasteboardMime()
|
||||
/*
|
||||
Returns the item count for the given \a mimeData
|
||||
*/
|
||||
int QMacInternalPasteboardMime::count(const QMimeData *mimeData) const
|
||||
int QMacMime::count(const QMimeData *mimeData) const
|
||||
{
|
||||
Q_UNUSED(mimeData);
|
||||
return 1;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeAny : public QMacInternalPasteboardMime {
|
||||
class QMacMimeAny : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeAny() : QMacInternalPasteboardMime(MIME_ALL_COMPATIBLE) {}
|
||||
QMacMimeAny() : QMacMime(MIME_ALL_COMPATIBLE) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
@ -122,7 +131,7 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeAny::flavorFor(const QString &mime) const
|
||||
QString QMacMimeAny::flavorFor(const QString &mime) const
|
||||
{
|
||||
// do not handle the mime type name in the drag pasteboard
|
||||
if (mime == "application/x-qt-mime-type-name"_L1)
|
||||
@ -131,7 +140,7 @@ QString QMacPasteboardMimeAny::flavorFor(const QString &mime) const
|
||||
return ret.replace(u'/', "--"_L1);
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeAny::mimeFor(const QString &flav) const
|
||||
QString QMacMimeAny::mimeFor(const QString &flav) const
|
||||
{
|
||||
const QString any_prefix = "com.trolltech.anymime."_L1;
|
||||
if (flav.size() > any_prefix.length() && flav.startsWith(any_prefix))
|
||||
@ -139,15 +148,15 @@ QString QMacPasteboardMimeAny::mimeFor(const QString &flav) const
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeAny::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeAny::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return mimeFor(flav) == mime;
|
||||
}
|
||||
|
||||
QVariant QMacPasteboardMimeAny::convertToMime(const QString &mime, const QList<QByteArray> &data, const QString &) const
|
||||
QVariant QMacMimeAny::convertToMime(const QString &mime, const QList<QByteArray> &data, const QString &) const
|
||||
{
|
||||
if (data.count() > 1)
|
||||
qWarning("QMacPasteboardMimeAny: Cannot handle multiple member data");
|
||||
qWarning("QMacMimeAny: Cannot handle multiple member data");
|
||||
QVariant ret;
|
||||
if (mime == "text/plain"_L1)
|
||||
ret = QString::fromUtf8(data.first());
|
||||
@ -156,7 +165,7 @@ QVariant QMacPasteboardMimeAny::convertToMime(const QString &mime, const QList<Q
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<QByteArray> QMacPasteboardMimeAny::convertFromMime(const QString &mime, const QVariant &data, const QString &) const
|
||||
QList<QByteArray> QMacMimeAny::convertFromMime(const QString &mime, const QVariant &data, const QString &) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
if (mime == "text/plain"_L1)
|
||||
@ -166,11 +175,10 @@ QList<QByteArray> QMacPasteboardMimeAny::convertFromMime(const QString &mime, co
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeTypeName : public QMacInternalPasteboardMime {
|
||||
private:
|
||||
|
||||
class QMacMimeTypeName : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeTypeName(): QMacInternalPasteboardMime(MIME_ALL_COMPATIBLE) {}
|
||||
QMacMimeTypeName(): QMacMime(MIME_ALL_COMPATIBLE) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
@ -179,40 +187,38 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeTypeName::flavorFor(const QString &mime) const
|
||||
QString QMacMimeTypeName::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime == "application/x-qt-mime-type-name"_L1)
|
||||
return u"com.trolltech.qt.MimeTypeName"_s;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeTypeName::mimeFor(const QString &) const
|
||||
QString QMacMimeTypeName::mimeFor(const QString &) const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeTypeName::canConvert(const QString &, const QString &) const
|
||||
bool QMacMimeTypeName::canConvert(const QString &, const QString &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant QMacPasteboardMimeTypeName::convertToMime(const QString &, const QList<QByteArray> &, const QString &) const
|
||||
QVariant QMacMimeTypeName::convertToMime(const QString &, const QList<QByteArray> &, const QString &) const
|
||||
{
|
||||
QVariant ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<QByteArray> QMacPasteboardMimeTypeName::convertFromMime(const QString &, const QVariant &, const QString &) const
|
||||
QList<QByteArray> QMacMimeTypeName::convertFromMime(const QString &, const QVariant &, const QString &) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
ret.append(QString("x-qt-mime-type-name"_L1).toUtf8());
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimePlainTextFallback : public QMacInternalPasteboardMime {
|
||||
class QMacMimePlainTextFallback : public QMacMime {
|
||||
public:
|
||||
QMacPasteboardMimePlainTextFallback() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -220,31 +226,31 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimePlainTextFallback::flavorFor(const QString &mime) const
|
||||
QString QMacMimePlainTextFallback::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime == "text/plain"_L1)
|
||||
return "public.text"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimePlainTextFallback::mimeFor(const QString &flav) const
|
||||
QString QMacMimePlainTextFallback::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.text"_L1)
|
||||
return "text/plain"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimePlainTextFallback::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimePlainTextFallback::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return mime == mimeFor(flav);
|
||||
}
|
||||
|
||||
QVariant
|
||||
QMacPasteboardMimePlainTextFallback::convertToMime(const QString &mimetype,
|
||||
QMacMimePlainTextFallback::convertToMime(const QString &mimetype,
|
||||
const QList<QByteArray> &data, const QString &flavor) const
|
||||
{
|
||||
if (data.count() > 1)
|
||||
qWarning("QMacPasteboardMimePlainTextFallback: Cannot handle multiple member data");
|
||||
qWarning("QMacMimePlainTextFallback: Cannot handle multiple member data");
|
||||
|
||||
if (flavor == "public.text"_L1) {
|
||||
// Note that public.text is documented by Apple to have an undefined encoding. From
|
||||
@ -260,7 +266,7 @@ QMacPasteboardMimePlainTextFallback::convertToMime(const QString &mimetype,
|
||||
}
|
||||
|
||||
QList<QByteArray>
|
||||
QMacPasteboardMimePlainTextFallback::convertFromMime(const QString &, const QVariant &data,
|
||||
QMacMimePlainTextFallback::convertFromMime(const QString &, const QVariant &data,
|
||||
const QString &flavor) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
@ -270,10 +276,9 @@ QMacPasteboardMimePlainTextFallback::convertFromMime(const QString &, const QVar
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeUnicodeText : public QMacInternalPasteboardMime {
|
||||
class QMacMimeUnicodeText : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeUnicodeText() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -281,7 +286,7 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeUnicodeText::flavorFor(const QString &mime) const
|
||||
QString QMacMimeUnicodeText::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime == "text/plain"_L1)
|
||||
return "public.utf16-plain-text"_L1;
|
||||
@ -299,25 +304,25 @@ QString QMacPasteboardMimeUnicodeText::flavorFor(const QString &mime) const
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeUnicodeText::mimeFor(const QString &flav) const
|
||||
QString QMacMimeUnicodeText::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.utf16-plain-text"_L1 || flav == "public.utf8-plain-text"_L1)
|
||||
return "text/plain"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeUnicodeText::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeUnicodeText::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return (mime == "text/plain"_L1
|
||||
&& (flav == "public.utf8-plain-text"_L1 || (flav == "public.utf16-plain-text"_L1)));
|
||||
}
|
||||
|
||||
QVariant
|
||||
QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype,
|
||||
QMacMimeUnicodeText::convertToMime(const QString &mimetype,
|
||||
const QList<QByteArray> &data, const QString &flavor) const
|
||||
{
|
||||
if (data.count() > 1)
|
||||
qWarning("QMacPasteboardMimeUnicodeText: Cannot handle multiple member data");
|
||||
qWarning("QMacMimeUnicodeText: Cannot handle multiple member data");
|
||||
const QByteArray &firstData = data.first();
|
||||
// I can only handle two types (system and unicode) so deal with them that way
|
||||
QVariant ret;
|
||||
@ -333,7 +338,7 @@ QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype,
|
||||
}
|
||||
|
||||
QList<QByteArray>
|
||||
QMacPasteboardMimeUnicodeText::convertFromMime(const QString &, const QVariant &data, const QString &flavor) const
|
||||
QMacMimeUnicodeText::convertFromMime(const QString &, const QVariant &data, const QString &flavor) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
QString string = data.toString();
|
||||
@ -359,10 +364,9 @@ QMacPasteboardMimeUnicodeText::convertFromMime(const QString &, const QVariant &
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeHTMLText : public QMacInternalPasteboardMime {
|
||||
class QMacMimeHTMLText : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeHTMLText() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -370,38 +374,38 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeHTMLText::flavorFor(const QString &mime) const
|
||||
QString QMacMimeHTMLText::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime == "text/html"_L1)
|
||||
return "public.html"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeHTMLText::mimeFor(const QString &flav) const
|
||||
QString QMacMimeHTMLText::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.html"_L1)
|
||||
return "text/html"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeHTMLText::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeHTMLText::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return flavorFor(mime) == flav;
|
||||
}
|
||||
|
||||
QVariant
|
||||
QMacPasteboardMimeHTMLText::convertToMime(const QString &mimeType,
|
||||
QMacMimeHTMLText::convertToMime(const QString &mimeType,
|
||||
const QList<QByteArray> &data, const QString &flavor) const
|
||||
{
|
||||
if (!canConvert(mimeType, flavor))
|
||||
return QVariant();
|
||||
if (data.count() > 1)
|
||||
qWarning("QMacPasteboardMimeHTMLText: Cannot handle multiple member data");
|
||||
qWarning("QMacMimeHTMLText: Cannot handle multiple member data");
|
||||
return data.first();
|
||||
}
|
||||
|
||||
QList<QByteArray>
|
||||
QMacPasteboardMimeHTMLText::convertFromMime(const QString &mime,
|
||||
QMacMimeHTMLText::convertFromMime(const QString &mime,
|
||||
const QVariant &data, const QString &flavor) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
@ -411,10 +415,9 @@ QMacPasteboardMimeHTMLText::convertFromMime(const QString &mime,
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeRtfText : public QMacInternalPasteboardMime {
|
||||
class QMacMimeRtfText : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeRtfText() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -422,33 +425,33 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeRtfText::flavorFor(const QString &mime) const
|
||||
QString QMacMimeRtfText::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime == "text/html"_L1)
|
||||
return "public.rtf"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeRtfText::mimeFor(const QString &flav) const
|
||||
QString QMacMimeRtfText::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.rtf"_L1)
|
||||
return "text/html"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeRtfText::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeRtfText::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return mime == mimeFor(flav);
|
||||
}
|
||||
|
||||
QVariant
|
||||
QMacPasteboardMimeRtfText::convertToMime(const QString &mimeType,
|
||||
QMacMimeRtfText::convertToMime(const QString &mimeType,
|
||||
const QList<QByteArray> &data, const QString &flavor) const
|
||||
{
|
||||
if (!canConvert(mimeType, flavor))
|
||||
return QVariant();
|
||||
if (data.count() > 1)
|
||||
qWarning("QMacPasteboardMimeHTMLText: Cannot handle multiple member data");
|
||||
qWarning("QMacMimeHTMLText: Cannot handle multiple member data");
|
||||
|
||||
// Read RTF into to NSAttributedString, then convert the string to HTML
|
||||
NSAttributedString *string = [[NSAttributedString alloc] initWithData:data.at(0).toNSData()
|
||||
@ -464,7 +467,7 @@ QMacPasteboardMimeRtfText::convertToMime(const QString &mimeType,
|
||||
}
|
||||
|
||||
QList<QByteArray>
|
||||
QMacPasteboardMimeRtfText::convertFromMime(const QString &mime,
|
||||
QMacMimeRtfText::convertFromMime(const QString &mime,
|
||||
const QVariant &data, const QString &flavor) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
@ -484,10 +487,9 @@ QMacPasteboardMimeRtfText::convertFromMime(const QString &mime,
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeFileUri : public QMacInternalPasteboardMime {
|
||||
class QMacMimeFileUri : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeFileUri() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -496,27 +498,27 @@ public:
|
||||
int count(const QMimeData *mimeData) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeFileUri::flavorFor(const QString &mime) const
|
||||
QString QMacMimeFileUri::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime == "text/uri-list"_L1)
|
||||
return "public.file-url"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeFileUri::mimeFor(const QString &flav) const
|
||||
QString QMacMimeFileUri::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.file-url"_L1)
|
||||
return "text/uri-list"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeFileUri::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeFileUri::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return mime == "text/uri-list"_L1 && flav == "public.file-url"_L1;
|
||||
}
|
||||
|
||||
QVariant
|
||||
QMacPasteboardMimeFileUri::convertToMime(const QString &mime,
|
||||
QMacMimeFileUri::convertToMime(const QString &mime,
|
||||
const QList<QByteArray> &data, const QString &flav) const
|
||||
{
|
||||
if (!canConvert(mime, flav))
|
||||
@ -545,7 +547,7 @@ QMacPasteboardMimeFileUri::convertToMime(const QString &mime,
|
||||
}
|
||||
|
||||
QList<QByteArray>
|
||||
QMacPasteboardMimeFileUri::convertFromMime(const QString &mime,
|
||||
QMacMimeFileUri::convertFromMime(const QString &mime,
|
||||
const QVariant &data, const QString &flav) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
@ -567,15 +569,14 @@ QMacPasteboardMimeFileUri::convertFromMime(const QString &mime,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int QMacPasteboardMimeFileUri::count(const QMimeData *mimeData) const
|
||||
int QMacMimeFileUri::count(const QMimeData *mimeData) const
|
||||
{
|
||||
return mimeData->urls().count();
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeUrl : public QMacInternalPasteboardMime {
|
||||
class QMacMimeUrl : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeUrl() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -583,27 +584,27 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeUrl::flavorFor(const QString &mime) const
|
||||
QString QMacMimeUrl::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime.startsWith("text/uri-list"_L1))
|
||||
return "public.url"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeUrl::mimeFor(const QString &flav) const
|
||||
QString QMacMimeUrl::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.url"_L1)
|
||||
return "text/uri-list"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeUrl::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeUrl::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return flav == "public.url"_L1
|
||||
&& mime == "text/uri-list"_L1;
|
||||
}
|
||||
|
||||
QVariant QMacPasteboardMimeUrl::convertToMime(const QString &mime,
|
||||
QVariant QMacMimeUrl::convertToMime(const QString &mime,
|
||||
const QList<QByteArray> &data, const QString &flav) const
|
||||
{
|
||||
if (!canConvert(mime, flav))
|
||||
@ -620,7 +621,7 @@ QVariant QMacPasteboardMimeUrl::convertToMime(const QString &mime,
|
||||
return QVariant(ret);
|
||||
}
|
||||
|
||||
QList<QByteArray> QMacPasteboardMimeUrl::convertFromMime(const QString &mime,
|
||||
QList<QByteArray> QMacMimeUrl::convertFromMime(const QString &mime,
|
||||
const QVariant &data, const QString &flav) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
@ -642,11 +643,9 @@ QList<QByteArray> QMacPasteboardMimeUrl::convertFromMime(const QString &mime,
|
||||
return ret;
|
||||
}
|
||||
|
||||
class QMacPasteboardMimeVCard : public QMacInternalPasteboardMime
|
||||
class QMacMimeVCard : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeVCard() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -654,26 +653,26 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
bool QMacPasteboardMimeVCard::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeVCard::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return mimeFor(flav) == mime;
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeVCard::flavorFor(const QString &mime) const
|
||||
QString QMacMimeVCard::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime.startsWith("text/vcard"_L1))
|
||||
return "public.vcard"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeVCard::mimeFor(const QString &flav) const
|
||||
QString QMacMimeVCard::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.vcard"_L1)
|
||||
return "text/vcard"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QVariant QMacPasteboardMimeVCard::convertToMime(const QString &mime,
|
||||
QVariant QMacMimeVCard::convertToMime(const QString &mime,
|
||||
const QList<QByteArray> &data, const QString &) const
|
||||
{
|
||||
QByteArray cards;
|
||||
@ -684,7 +683,7 @@ QVariant QMacPasteboardMimeVCard::convertToMime(const QString &mime,
|
||||
return QVariant(cards);
|
||||
}
|
||||
|
||||
QList<QByteArray> QMacPasteboardMimeVCard::convertFromMime(const QString &mime,
|
||||
QList<QByteArray> QMacMimeVCard::convertFromMime(const QString &mime,
|
||||
const QVariant &data, const QString &) const
|
||||
{
|
||||
QList<QByteArray> ret;
|
||||
@ -696,10 +695,9 @@ QList<QByteArray> QMacPasteboardMimeVCard::convertFromMime(const QString &mime,
|
||||
extern QImage qt_mac_toQImage(CGImageRef image);
|
||||
extern CGImageRef qt_mac_toCGImage(const QImage &qImage);
|
||||
|
||||
class QMacPasteboardMimeTiff : public QMacInternalPasteboardMime {
|
||||
class QMacMimeTiff : public QMacMime
|
||||
{
|
||||
public:
|
||||
QMacPasteboardMimeTiff() : QMacInternalPasteboardMime(MIME_ALL) {}
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -707,30 +705,30 @@ public:
|
||||
QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeTiff::flavorFor(const QString &mime) const
|
||||
QString QMacMimeTiff::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime.startsWith("application/x-qt-image"_L1))
|
||||
return "public.tiff"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeTiff::mimeFor(const QString &flav) const
|
||||
QString QMacMimeTiff::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "public.tiff"_L1)
|
||||
return "application/x-qt-image"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeTiff::canConvert(const QString &mime, const QString &flav) const
|
||||
bool QMacMimeTiff::canConvert(const QString &mime, const QString &flav) const
|
||||
{
|
||||
return flav == "public.tiff"_L1 && mime == "application/x-qt-image"_L1;
|
||||
}
|
||||
|
||||
QVariant QMacPasteboardMimeTiff::convertToMime(const QString &mime,
|
||||
QVariant QMacMimeTiff::convertToMime(const QString &mime,
|
||||
const QList<QByteArray> &data, const QString &flav) const
|
||||
{
|
||||
if (data.count() > 1)
|
||||
qWarning("QMacPasteboardMimeTiff: Cannot handle multiple member data");
|
||||
qWarning("QMacMimeTiff: Cannot handle multiple member data");
|
||||
|
||||
if (!canConvert(mime, flav))
|
||||
return QVariant();
|
||||
@ -744,7 +742,7 @@ QVariant QMacPasteboardMimeTiff::convertToMime(const QString &mime,
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QList<QByteArray> QMacPasteboardMimeTiff::convertFromMime(const QString &mime,
|
||||
QList<QByteArray> QMacMimeTiff::convertFromMime(const QString &mime,
|
||||
const QVariant &variant, const QString &flav) const
|
||||
{
|
||||
if (!canConvert(mime, flav))
|
||||
@ -772,26 +770,26 @@ namespace QMacMimeRegistry {
|
||||
|
||||
void registerBuiltInTypes()
|
||||
{
|
||||
// Create QMacPasteboardMimeAny first to put it at the end of globalMimeList
|
||||
// Create QMacMimeAny first to put it at the end of globalMimeList
|
||||
// with lowest priority. (the constructor prepends to the list)
|
||||
new QMacPasteboardMimeAny;
|
||||
new QMacMimeAny;
|
||||
|
||||
//standard types that we wrap
|
||||
new QMacPasteboardMimeTiff;
|
||||
new QMacPasteboardMimePlainTextFallback;
|
||||
new QMacPasteboardMimeUnicodeText;
|
||||
new QMacPasteboardMimeRtfText;
|
||||
new QMacPasteboardMimeHTMLText;
|
||||
new QMacPasteboardMimeFileUri;
|
||||
new QMacPasteboardMimeUrl;
|
||||
new QMacPasteboardMimeTypeName;
|
||||
new QMacPasteboardMimeVCard;
|
||||
new QMacMimeTiff;
|
||||
new QMacMimePlainTextFallback;
|
||||
new QMacMimeUnicodeText;
|
||||
new QMacMimeRtfText;
|
||||
new QMacMimeHTMLText;
|
||||
new QMacMimeFileUri;
|
||||
new QMacMimeUrl;
|
||||
new QMacMimeTypeName;
|
||||
new QMacMimeVCard;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
\fn bool QMacPasteboardMime::canConvert(const QString &mime, QString flav)
|
||||
\fn bool QMacMime::canConvert(const QString &mime, QString flav)
|
||||
|
||||
Returns \c true if the converter can convert (both ways) between
|
||||
\a mime and \a flav; otherwise returns \c false.
|
||||
@ -800,7 +798,7 @@ void registerBuiltInTypes()
|
||||
*/
|
||||
|
||||
/*
|
||||
\fn QString QMacPasteboardMime::mimeFor(QString flav)
|
||||
\fn QString QMacMime::mimeFor(QString flav)
|
||||
|
||||
Returns the MIME UTI used for Mac flavor \a flav, or 0 if this
|
||||
converter does not support \a flav.
|
||||
@ -809,7 +807,7 @@ void registerBuiltInTypes()
|
||||
*/
|
||||
|
||||
/*
|
||||
\fn QString QMacPasteboardMime::flavorFor(const QString &mime)
|
||||
\fn QString QMacMime::flavorFor(const QString &mime)
|
||||
|
||||
Returns the Mac UTI used for MIME type \a mime, or 0 if this
|
||||
converter does not support \a mime.
|
||||
@ -818,7 +816,7 @@ void registerBuiltInTypes()
|
||||
*/
|
||||
|
||||
/*
|
||||
\fn QVariant QMacPasteboardMime::convertToMime(const QString &mime, QList<QByteArray> data, QString flav)
|
||||
\fn QVariant QMacMime::convertToMime(const QString &mime, QList<QByteArray> data, QString flav)
|
||||
|
||||
Returns \a data converted from Mac UTI \a flav to MIME type \a
|
||||
mime.
|
||||
@ -830,7 +828,7 @@ void registerBuiltInTypes()
|
||||
*/
|
||||
|
||||
/*
|
||||
\fn QList<QByteArray> QMacPasteboardMime::convertFromMime(const QString &mime, const QVariant &data, const QString & flav)
|
||||
\fn QList<QByteArray> QMacMime::convertFromMime(const QString &mime, const QVariant &data, const QString & flav)
|
||||
|
||||
Returns \a data converted from MIME type \a mime
|
||||
to Mac UTI \a flav.
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_GUI_EXPORT QMacInternalPasteboardMime
|
||||
class Q_GUI_EXPORT QMacMime
|
||||
{
|
||||
public:
|
||||
enum QMacPasteboardMimeType
|
||||
@ -35,8 +35,9 @@ public:
|
||||
MIME_ALL_COMPATIBLE = MIME_ALL|MIME_QT_CONVERTOR
|
||||
};
|
||||
|
||||
explicit QMacInternalPasteboardMime(QMacPasteboardMimeType);
|
||||
virtual ~QMacInternalPasteboardMime();
|
||||
QMacMime();
|
||||
explicit QMacMime(QMacPasteboardMimeType type); // internal
|
||||
virtual ~QMacMime();
|
||||
|
||||
char type() const { return m_type; }
|
||||
|
||||
|
@ -14,7 +14,7 @@ using namespace Qt::StringLiterals;
|
||||
|
||||
namespace QMacMimeRegistry {
|
||||
|
||||
typedef QList<QMacInternalPasteboardMime*> MimeList;
|
||||
typedef QList<QMacMime*> MimeList;
|
||||
Q_GLOBAL_STATIC(MimeList, globalMimeList)
|
||||
Q_GLOBAL_STATIC(QStringList, globalDraggedTypesList)
|
||||
|
||||
@ -23,16 +23,16 @@ void registerBuiltInTypes();
|
||||
|
||||
/*!
|
||||
\fn void qRegisterDraggedTypes(const QStringList &types)
|
||||
\relates QMacPasteboardMime
|
||||
\relates QMacMime
|
||||
|
||||
Registers the given \a types as custom pasteboard types.
|
||||
|
||||
This function should be called to enable the Drag and Drop events
|
||||
for custom pasteboard types on Cocoa implementations. This is required
|
||||
in addition to a QMacPasteboardMime subclass implementation. By default
|
||||
in addition to a QMacMime subclass implementation. By default
|
||||
drag and drop is enabled for all standard pasteboard types.
|
||||
|
||||
\sa QMacPasteboardMime
|
||||
\sa QMacMime
|
||||
*/
|
||||
|
||||
void registerDraggedTypes(const QStringList &types)
|
||||
@ -97,7 +97,7 @@ QString flavorToMime(uchar t, QString flav)
|
||||
return QString();
|
||||
}
|
||||
|
||||
void registerMimeConverter(QMacInternalPasteboardMime *macMime)
|
||||
void registerMimeConverter(QMacMime *macMime)
|
||||
{
|
||||
// globalMimeList is in decreasing priority order. Recently added
|
||||
// converters take prioity over previously added converters: prepend
|
||||
@ -105,7 +105,7 @@ void registerMimeConverter(QMacInternalPasteboardMime *macMime)
|
||||
globalMimeList()->prepend(macMime);
|
||||
}
|
||||
|
||||
void unregisterMimeConverter(QMacInternalPasteboardMime *macMime)
|
||||
void unregisterMimeConverter(QMacMime *macMime)
|
||||
{
|
||||
if (!QGuiApplication::closingDown())
|
||||
globalMimeList()->removeAll(macMime);
|
||||
@ -113,9 +113,9 @@ void unregisterMimeConverter(QMacInternalPasteboardMime *macMime)
|
||||
|
||||
|
||||
/*
|
||||
Returns a list of all currently defined QMacPasteboardMime objects of type \a t.
|
||||
Returns a list of all currently defined QMacMime objects of type \a t.
|
||||
*/
|
||||
QList<QMacInternalPasteboardMime *> all(uchar t)
|
||||
QList<QMacMime *> all(uchar t)
|
||||
{
|
||||
MimeList ret;
|
||||
MimeList *mimes = globalMimeList();
|
||||
|
@ -22,16 +22,16 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMacInternalPasteboardMime;
|
||||
class QMacMime;
|
||||
|
||||
namespace QMacMimeRegistry {
|
||||
Q_GUI_EXPORT void initializeMimeTypes();
|
||||
Q_GUI_EXPORT void destroyMimeTypes();
|
||||
|
||||
Q_GUI_EXPORT void registerMimeConverter(QMacInternalPasteboardMime *);
|
||||
Q_GUI_EXPORT void unregisterMimeConverter(QMacInternalPasteboardMime *);
|
||||
Q_GUI_EXPORT void registerMimeConverter(QMacMime *);
|
||||
Q_GUI_EXPORT void unregisterMimeConverter(QMacMime *);
|
||||
|
||||
Q_GUI_EXPORT QList<QMacInternalPasteboardMime *> all(uchar);
|
||||
Q_GUI_EXPORT QList<QMacMime *> all(uchar);
|
||||
Q_GUI_EXPORT QString flavorToMime(uchar, QString flav);
|
||||
|
||||
Q_GUI_EXPORT void registerDraggedTypes(const QStringList &types);
|
||||
|
@ -10,8 +10,8 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QCocoaClipboard::QCocoaClipboard()
|
||||
:m_clipboard(new QMacPasteboard(kPasteboardClipboard, QMacInternalPasteboardMime::MIME_CLIP))
|
||||
,m_find(new QMacPasteboard(kPasteboardFind, QMacInternalPasteboardMime::MIME_CLIP))
|
||||
:m_clipboard(new QMacPasteboard(kPasteboardClipboard, QMacMime::MIME_CLIP))
|
||||
,m_find(new QMacPasteboard(kPasteboardFind, QMacMime::MIME_CLIP))
|
||||
{
|
||||
connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QCocoaClipboard::handleApplicationStateChanged);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
|
||||
m_drag = o;
|
||||
m_executed_drop_action = Qt::IgnoreAction;
|
||||
|
||||
QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND);
|
||||
QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacMime::MIME_DND);
|
||||
m_drag->mimeData()->setData("application/x-qt-mime-type-name"_L1, QByteArray("dummy"));
|
||||
dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
|
||||
|
||||
@ -305,7 +305,7 @@ QStringList QCocoaDropData::formats_sys() const
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return formats;
|
||||
}
|
||||
formats = QMacPasteboard(board, QMacInternalPasteboardMime::MIME_DND).formats();
|
||||
formats = QMacPasteboard(board, QMacMime::MIME_DND).formats();
|
||||
return formats;
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ QVariant QCocoaDropData::retrieveData_sys(const QString &mimeType, QMetaType typ
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return data;
|
||||
}
|
||||
data = QMacPasteboard(board, QMacInternalPasteboardMime::MIME_DND).retrieveData(mimeType, type);
|
||||
data = QMacPasteboard(board, QMacMime::MIME_DND).retrieveData(mimeType, type);
|
||||
CFRelease(board);
|
||||
return data;
|
||||
}
|
||||
@ -330,7 +330,7 @@ bool QCocoaDropData::hasFormat_sys(const QString &mimeType) const
|
||||
qDebug("DnD: Cannot get PasteBoard!");
|
||||
return has;
|
||||
}
|
||||
has = QMacPasteboard(board, QMacInternalPasteboardMime::MIME_DND).hasFormat(mimeType);
|
||||
has = QMacPasteboard(board, QMacMime::MIME_DND).hasFormat(mimeType);
|
||||
CFRelease(board);
|
||||
return has;
|
||||
}
|
||||
|
@ -12,10 +12,8 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
class QMacPasteboardMimeTraditionalMacPlainText : public QMacInternalPasteboardMime {
|
||||
class QMacMimeTraditionalMacPlainText : public QMacMime {
|
||||
public:
|
||||
QMacPasteboardMimeTraditionalMacPlainText() : QMacInternalPasteboardMime(MIME_ALL) { }
|
||||
|
||||
QString flavorFor(const QString &mime) const override;
|
||||
QString mimeFor(const QString &flav) const override;
|
||||
bool canConvert(const QString &mime, const QString &flav) const override;
|
||||
@ -25,33 +23,33 @@ public:
|
||||
const QString &flav) const override;
|
||||
};
|
||||
|
||||
QString QMacPasteboardMimeTraditionalMacPlainText::flavorFor(const QString &mime) const
|
||||
QString QMacMimeTraditionalMacPlainText::flavorFor(const QString &mime) const
|
||||
{
|
||||
if (mime == "text/plain"_L1)
|
||||
return "com.apple.traditional-mac-plain-text"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QMacPasteboardMimeTraditionalMacPlainText::mimeFor(const QString &flav) const
|
||||
QString QMacMimeTraditionalMacPlainText::mimeFor(const QString &flav) const
|
||||
{
|
||||
if (flav == "com.apple.traditional-mac-plain-text"_L1)
|
||||
return "text/plain"_L1;
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QMacPasteboardMimeTraditionalMacPlainText::canConvert(const QString &mime,
|
||||
bool QMacMimeTraditionalMacPlainText::canConvert(const QString &mime,
|
||||
const QString &flav) const
|
||||
{
|
||||
return flavorFor(mime) == flav;
|
||||
}
|
||||
|
||||
QVariant
|
||||
QMacPasteboardMimeTraditionalMacPlainText::convertToMime(const QString &mimetype,
|
||||
QMacMimeTraditionalMacPlainText::convertToMime(const QString &mimetype,
|
||||
const QList<QByteArray> &data,
|
||||
const QString &flavor) const
|
||||
{
|
||||
if (data.count() > 1)
|
||||
qWarning("QMacPasteboardMimeTraditionalMacPlainText: Cannot handle multiple member data");
|
||||
qWarning("QMacMimeTraditionalMacPlainText: Cannot handle multiple member data");
|
||||
const QByteArray &firstData = data.first();
|
||||
QVariant ret;
|
||||
if (flavor == "com.apple.traditional-mac-plain-text"_L1) {
|
||||
@ -65,7 +63,7 @@ QMacPasteboardMimeTraditionalMacPlainText::convertToMime(const QString &mimetype
|
||||
}
|
||||
|
||||
QList<QByteArray>
|
||||
QMacPasteboardMimeTraditionalMacPlainText::convertFromMime(const QString &,
|
||||
QMacMimeTraditionalMacPlainText::convertFromMime(const QString &,
|
||||
const QVariant &data,
|
||||
const QString &flavor) const
|
||||
{
|
||||
@ -78,7 +76,7 @@ QMacPasteboardMimeTraditionalMacPlainText::convertFromMime(const QString &,
|
||||
|
||||
void QCocoaMimeTypes::initializeMimeTypes()
|
||||
{
|
||||
new QMacPasteboardMimeTraditionalMacPlainText;
|
||||
new QMacMimeTraditionalMacPlainText;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -11,7 +11,7 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMacMimeData;
|
||||
class QMacInternalPasteboardMime;
|
||||
class QMacMime;
|
||||
|
||||
class QMacPasteboard
|
||||
{
|
||||
@ -21,12 +21,12 @@ private:
|
||||
struct Promise {
|
||||
Promise() : itemId(0), converter(nullptr) { }
|
||||
|
||||
static Promise eagerPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0);
|
||||
static Promise lazyPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0);
|
||||
Promise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *md, int o, DataRequestType drt);
|
||||
static Promise eagerPromise(int itemId, QMacMime *c, QString m, QMacMimeData *d, int o = 0);
|
||||
static Promise lazyPromise(int itemId, QMacMime *c, QString m, QMacMimeData *d, int o = 0);
|
||||
Promise(int itemId, QMacMime *c, QString m, QMacMimeData *md, int o, DataRequestType drt);
|
||||
|
||||
int itemId, offset;
|
||||
QMacInternalPasteboardMime *converter;
|
||||
QMacMime *converter;
|
||||
QString mime;
|
||||
QPointer<QMacMimeData> mimeData;
|
||||
QVariant variantData;
|
||||
|
@ -54,7 +54,7 @@ private:
|
||||
QMacMimeData();
|
||||
};
|
||||
|
||||
QMacPasteboard::Promise::Promise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *md, int o, DataRequestType drt)
|
||||
QMacPasteboard::Promise::Promise(int itemId, QMacMime *c, QString m, QMacMimeData *md, int o, DataRequestType drt)
|
||||
: itemId(itemId), offset(o), converter(c), mime(m), dataRequestType(drt)
|
||||
{
|
||||
// Request the data from the application immediately for eager requests.
|
||||
@ -72,7 +72,7 @@ QMacPasteboard::Promise::Promise(int itemId, QMacInternalPasteboardMime *c, QStr
|
||||
QMacPasteboard::QMacPasteboard(PasteboardRef p, uchar mt)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL);
|
||||
mime_type = mt ? mt : uchar(QMacMime::MIME_ALL);
|
||||
paste = p;
|
||||
CFRetain(paste);
|
||||
resolvingBeforeDestruction = false;
|
||||
@ -81,7 +81,7 @@ QMacPasteboard::QMacPasteboard(PasteboardRef p, uchar mt)
|
||||
QMacPasteboard::QMacPasteboard(uchar mt)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL);
|
||||
mime_type = mt ? mt : uchar(QMacMime::MIME_ALL);
|
||||
paste = nullptr;
|
||||
OSStatus err = PasteboardCreate(nullptr, &paste);
|
||||
if (err == noErr) {
|
||||
@ -95,7 +95,7 @@ QMacPasteboard::QMacPasteboard(uchar mt)
|
||||
QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt)
|
||||
{
|
||||
mac_mime_source = false;
|
||||
mime_type = mt ? mt : uchar(QMacInternalPasteboardMime::MIME_ALL);
|
||||
mime_type = mt ? mt : uchar(QMacMime::MIME_ALL);
|
||||
paste = nullptr;
|
||||
OSStatus err = PasteboardCreate(name, &paste);
|
||||
if (err == noErr) {
|
||||
@ -112,7 +112,7 @@ QMacPasteboard::~QMacPasteboard()
|
||||
Commit all promises for paste when shutting down,
|
||||
unless we are the stack-allocated clipboard used by QCocoaDrag.
|
||||
*/
|
||||
if (mime_type == QMacInternalPasteboardMime::MIME_DND)
|
||||
if (mime_type == QMacMime::MIME_DND)
|
||||
resolvingBeforeDestruction = true;
|
||||
PasteboardResolvePromises(paste);
|
||||
if (paste)
|
||||
@ -131,17 +131,17 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id,
|
||||
const long promise_id = (long)id;
|
||||
|
||||
// Find the kept promise
|
||||
QList<QMacInternalPasteboardMime*> availableConverters
|
||||
= QMacMimeRegistry::all(QMacInternalPasteboardMime::MIME_ALL);
|
||||
QList<QMacMime*> availableConverters
|
||||
= QMacMimeRegistry::all(QMacMime::MIME_ALL);
|
||||
const QString flavorAsQString = QString::fromCFString(flavor);
|
||||
QMacPasteboard::Promise promise;
|
||||
for (int i = 0; i < qpaste->promises.size(); i++){
|
||||
QMacPasteboard::Promise tmp = qpaste->promises[i];
|
||||
if (!availableConverters.contains(tmp.converter)) {
|
||||
// promise.converter is a pointer initialized by the value found
|
||||
// in QMacInternalPasteboardMime's global list of QMacInternalPasteboardMimes.
|
||||
// We add pointers to this list in QMacInternalPasteboardMime's ctor;
|
||||
// we remove these pointers in QMacInternalPasteboardMime's dtor.
|
||||
// in QMacMime's global list of QMacMimes.
|
||||
// We add pointers to this list in QMacMime's ctor;
|
||||
// we remove these pointers in QMacMime's dtor.
|
||||
// If tmp.converter was not found in this list, we probably have a
|
||||
// dangling pointer so let's skip it.
|
||||
continue;
|
||||
@ -299,7 +299,7 @@ QMacPasteboard::setMimeData(QMimeData *mime_src, DataRequestType dataRequestType
|
||||
delete mime;
|
||||
mime = mime_src;
|
||||
|
||||
const QList<QMacInternalPasteboardMime*> availableConverters = QMacMimeRegistry::all(mime_type);
|
||||
const QList<QMacMime*> availableConverters = QMacMimeRegistry::all(mime_type);
|
||||
if (mime != nullptr) {
|
||||
clear_helper();
|
||||
QStringList formats = mime_src->formats();
|
||||
@ -433,7 +433,7 @@ QMacPasteboard::retrieveData(const QString &format, QMetaType) const
|
||||
return QByteArray();
|
||||
|
||||
qCDebug(lcQpaClipboard, "Pasteboard: retrieveData [%s]", qPrintable(format));
|
||||
const QList<QMacInternalPasteboardMime *> availableConverters = QMacMimeRegistry::all(mime_type);
|
||||
const QList<QMacMime *> availableConverters = QMacMimeRegistry::all(mime_type);
|
||||
for (const auto *c : availableConverters) {
|
||||
QString c_flavor = c->flavorFor(format);
|
||||
if (!c_flavor.isEmpty()) {
|
||||
|
@ -116,8 +116,8 @@ QStringList QIOSMimeData::formats() const
|
||||
NSArray<NSString *> *pasteboardTypes = [pb pasteboardTypes];
|
||||
|
||||
for (NSUInteger i = 0; i < [pasteboardTypes count]; ++i) {
|
||||
QString uti = QString::fromNSString([pasteboardTypes objectAtIndex:i]);
|
||||
QString mimeType = QMacMimeRegistry::flavorToMime(QMacInternalPasteboardMime::MIME_ALL, uti);
|
||||
const QString uti = QString::fromNSString([pasteboardTypes objectAtIndex:i]);
|
||||
const QString mimeType = QMacMimeRegistry::flavorToMime(QMacMime::MIME_ALL, uti);
|
||||
if (!mimeType.isEmpty() && !foundMimeTypes.contains(mimeType))
|
||||
foundMimeTypes << mimeType;
|
||||
}
|
||||
@ -130,8 +130,7 @@ QVariant QIOSMimeData::retrieveData(const QString &mimeType, QMetaType) const
|
||||
UIPasteboard *pb = [UIPasteboard pasteboardWithQClipboardMode:m_mode];
|
||||
NSArray<NSString *> *pasteboardTypes = [pb pasteboardTypes];
|
||||
|
||||
foreach (QMacInternalPasteboardMime *converter,
|
||||
QMacMimeRegistry::all(QMacInternalPasteboardMime::MIME_ALL)) {
|
||||
foreach (QMacMime *converter, QMacMimeRegistry::all(QMacMime::MIME_ALL)) {
|
||||
if (!converter->canConvert(mimeType, converter->flavorFor(mimeType)))
|
||||
continue;
|
||||
|
||||
@ -185,8 +184,7 @@ void QIOSClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
|
||||
NSMutableDictionary<NSString *, id> *pbItem = [NSMutableDictionary<NSString *, id> dictionaryWithCapacity:mimeData->formats().size()];
|
||||
|
||||
foreach (const QString &mimeType, mimeData->formats()) {
|
||||
foreach (QMacInternalPasteboardMime *converter,
|
||||
QMacMimeRegistry::all(QMacInternalPasteboardMime::MIME_ALL)) {
|
||||
foreach (QMacMime *converter, QMacMimeRegistry::all(QMacMime::MIME_ALL)) {
|
||||
QString uti = converter->flavorFor(mimeType);
|
||||
if (uti.isEmpty() || !converter->canConvert(mimeType, uti))
|
||||
continue;
|
||||
|
@ -106,6 +106,7 @@ QIOSIntegration::~QIOSIntegration()
|
||||
delete m_clipboard;
|
||||
m_clipboard = 0;
|
||||
#endif
|
||||
|
||||
QMacMimeRegistry::destroyMimeTypes();
|
||||
|
||||
delete m_inputContext;
|
||||
|
Loading…
Reference in New Issue
Block a user