Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmacmimeregistry.mm
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtCore/qmimedata.h>
5
6#include "qutimimeconverter.h"
8#include "qguiapplication.h"
9#include "private/qcore_mac_p.h"
10
12
13using namespace Qt::StringLiterals;
14
16
17typedef QList<QUtiMimeConverter*> MimeList;
18Q_GLOBAL_STATIC(MimeList, globalMimeList)
19Q_GLOBAL_STATIC(QStringList, globalDraggedTypesList)
20
21// implemented in qutimimeconverter.mm
23
25{
26 (*globalDraggedTypesList()) += types;
27}
28
30{
31 return (*globalDraggedTypesList());
32}
33
34/*****************************************************************************
35 QDnD debug facilities
36 *****************************************************************************/
37//#define DEBUG_MIME_MAPS
38
51{
52 if (globalMimeList()->isEmpty())
54}
55
60{
61 MimeList *mimes = globalMimeList();
62 while (!mimes->isEmpty())
63 delete mimes->takeFirst();
64}
65
66/*
67 Returns a MIME type of for scope \a scope for \a uti, or \nullptr if none exists.
68*/
69QString flavorToMime(QUtiMimeConverter::HandlerScope scope, const QString &uti)
70{
71 const MimeList &mimes = *globalMimeList();
72 for (const auto &mime : mimes) {
73 const bool relevantScope = mime->scope() & scope;
74#ifdef DEBUG_MIME_MAPS
75 qDebug("QMacMimeRegistry::flavorToMime: attempting (%d) for uti %s [%s]",
76 relevantScope, qPrintable(uti), qPrintable((*it)->mimeForUti(uti)));
77#endif
78 if (relevantScope) {
79 const QString mimeType = mime->mimeForUti(uti);
80 if (!mimeType.isNull())
81 return mimeType;
82 }
83 }
84 return QString();
85}
86
88{
89 // globalMimeList is in decreasing priority order. Recently added
90 // converters take prioity over previously added converters: prepend
91 // to the list.
92 globalMimeList()->prepend(macMime);
93}
94
96{
98 globalMimeList()->removeAll(macMime);
99}
100
101
102/*
103 Returns a list of all currently defined QUtiMimeConverter objects for scope \a scope.
104*/
105QList<QUtiMimeConverter *> all(QUtiMimeConverter::HandlerScope scope)
106{
108 const MimeList &mimes = *globalMimeList();
109 for (const auto &mime : mimes) {
110 if (mime->scope() & scope)
111 ret.append(mime);
112 }
113 return ret;
114}
115
116} // namespace QMacMimeRegistry
117
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
QList< QUtiMimeConverter * > MimeList
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QUtiMimeConverter class converts between a MIME type and a \l{https://developer....
void unregisterMimeConverter(QUtiMimeConverter *macMime)
const QStringList & enabledDraggedTypes()
QList< QUtiMimeConverter * > all(QUtiMimeConverter::HandlerScope scope)
QString flavorToMime(QUtiMimeConverter::HandlerScope scope, const QString &uti)
void registerDraggedTypes(const QStringList &types)
void registerMimeConverter(QUtiMimeConverter *macMime)
Combined button and popup list for selecting options.
const char * mimeType
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qDebug
[1]
Definition qlogging.h:164
return ret
GLsizei GLenum GLenum * types
#define qPrintable(string)
Definition qstring.h:1531
application x qt windows mime
[2]