Clean up QMacMimeRegistry: remove convertor
It's not called anywhere, we always get all convertors and iterate over them to find the best match for the relevant context. Change those loops to use ranged for. Task-number: QTBUG-93632 Change-Id: Icb450ca56310a0acab881899234ac647792ce0c9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>bb10
parent
3d6a89c5cc
commit
8f3e24c17d
|
|
@ -77,24 +77,6 @@ void destroyMimeTypes()
|
|||
delete mimes->takeFirst();
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the most-recently created QMacPasteboardMime of type \a t that can convert
|
||||
between the \a mime and \a flav formats. Returns 0 if no such convertor
|
||||
exists.
|
||||
*/
|
||||
QMacInternalPasteboardMime *convertor(uchar t, const QString &mime, QString flav)
|
||||
{
|
||||
MimeList *mimes = globalMimeList();
|
||||
for (MimeList::const_iterator it = mimes->constBegin(); it != mimes->constEnd(); ++it) {
|
||||
#ifdef DEBUG_MIME_MAPS
|
||||
qDebug("QMacMimeRegistry::convertor: seeing if converter(%d) can convert %s to %s [%d]",
|
||||
(*it)->type() & t, qPrintable(mime), qPrintable(flav), (*it)->canConvert(mime,flav));
|
||||
#endif
|
||||
if (((*it)->type() & t) && (*it)->canConvert(mime, flav))
|
||||
return (*it);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
Returns a MIME type of type \a t for \a flav, or 0 if none exists.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ namespace QMacMimeRegistry {
|
|||
Q_GUI_EXPORT void unregisterMimeConverter(QMacInternalPasteboardMime *);
|
||||
|
||||
Q_GUI_EXPORT QList<QMacInternalPasteboardMime *> all(uchar);
|
||||
Q_GUI_EXPORT QMacInternalPasteboardMime *convertor(uchar, const QString &mime, QString flav);
|
||||
Q_GUI_EXPORT QString flavorToMime(uchar, QString flav);
|
||||
|
||||
Q_GUI_EXPORT void registerDraggedTypes(const QStringList &types);
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ QMacPasteboard::setMimeData(QMimeData *mime_src, DataRequestType dataRequestType
|
|||
delete mime;
|
||||
mime = mime_src;
|
||||
|
||||
QList<QMacInternalPasteboardMime*> availableConverters = QMacMimeRegistry::all(mime_type);
|
||||
const QList<QMacInternalPasteboardMime*> availableConverters = QMacMimeRegistry::all(mime_type);
|
||||
if (mime != nullptr) {
|
||||
clear_helper();
|
||||
QStringList formats = mime_src->formats();
|
||||
|
|
@ -316,8 +316,7 @@ QMacPasteboard::setMimeData(QMimeData *mime_src, DataRequestType dataRequestType
|
|||
}
|
||||
for (int f = 0; f < formats.size(); ++f) {
|
||||
QString mimeType = formats.at(f);
|
||||
for (QList<QMacInternalPasteboardMime *>::Iterator it = availableConverters.begin(); it != availableConverters.end(); ++it) {
|
||||
QMacInternalPasteboardMime *c = (*it);
|
||||
for (auto *c : availableConverters) {
|
||||
// Hack: The Rtf handler converts incoming Rtf to Html. We do
|
||||
// not want to convert outgoing Html to Rtf but instead keep
|
||||
// posting it as Html. Skip the Rtf handler here.
|
||||
|
|
@ -434,9 +433,8 @@ QMacPasteboard::retrieveData(const QString &format, QMetaType) const
|
|||
return QByteArray();
|
||||
|
||||
qCDebug(lcQpaClipboard, "Pasteboard: retrieveData [%s]", qPrintable(format));
|
||||
const QList<QMacInternalPasteboardMime *> mimes = QMacMimeRegistry::all(mime_type);
|
||||
for (int mime = 0; mime < mimes.size(); ++mime) {
|
||||
QMacInternalPasteboardMime *c = mimes.at(mime);
|
||||
const QList<QMacInternalPasteboardMime *> availableConverters = QMacMimeRegistry::all(mime_type);
|
||||
for (const auto *c : availableConverters) {
|
||||
QString c_flavor = c->flavorFor(format);
|
||||
if (!c_flavor.isEmpty()) {
|
||||
// Converting via PasteboardCopyItemFlavorData below will for some UITs result
|
||||
|
|
|
|||
Loading…
Reference in New Issue