Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
9#include "private/qcore_mac_p.h"
10
12
13using namespace Qt::StringLiterals;
14
16
20
21// implemented in qutimimeconverter.mm
23
24void registerDraggedTypes(const QStringList &types)
25{
26 (*globalDraggedTypesList()) += types;
27}
28
30{
31 return (*globalDraggedTypesList());
32}
33
34/*****************************************************************************
35 QDnD debug facilities
36 *****************************************************************************/
37//#define DEBUG_MIME_MAPS
38
39/*!
40 \class QMacMimeRegistry
41 \internal
42 \ingroup draganddrop
43*/
44
45/*!
46 \internal
47
48 This is an internal function.
49*/
51{
52 if (globalMimeList()->isEmpty())
53 registerBuiltInTypes();
54}
55
56/*!
57 \internal
58*/
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*/
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]",
77#endif
78 if (relevantScope) {
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.
93}
94
100
101
102/*
103 Returns a list of all currently defined QUtiMimeConverter objects for scope \a scope.
104*/
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
118QT_END_NAMESPACE
QList< QUtiMimeConverter * > MimeList
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)