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// Qt-Security score:significant reason:default
4
5#include <QtCore/qmimedata.h>
6
10#include "private/qcore_mac_p.h"
11
13
14using namespace Qt::StringLiterals;
15
17
21
22// implemented in qutimimeconverter.mm
24
25void registerDraggedTypes(const QStringList &types)
26{
27 (*globalDraggedTypesList()) += types;
28}
29
31{
32 return (*globalDraggedTypesList());
33}
34
35/*****************************************************************************
36 QDnD debug facilities
37 *****************************************************************************/
38//#define DEBUG_MIME_MAPS
39
40/*!
41 \class QMacMimeRegistry
42 \internal
43 \ingroup draganddrop
44*/
45
46/*!
47 \internal
48
49 This is an internal function.
50*/
52{
53 if (globalMimeList()->isEmpty())
54 registerBuiltInTypes();
55}
56
57/*!
58 \internal
59*/
61{
62 MimeList *mimes = globalMimeList();
63 while (!mimes->isEmpty())
64 delete mimes->takeFirst();
65}
66
67/*
68 Returns a MIME type of for scope \a scope for \a uti, or \nullptr if none exists.
69*/
71{
72 const MimeList &mimes = *globalMimeList();
73 for (const auto &mime : mimes) {
74 const bool relevantScope = mime->scope() & scope;
75#ifdef DEBUG_MIME_MAPS
76 qDebug("QMacMimeRegistry::flavorToMime: attempting (%d) for uti %s [%s]",
78#endif
79 if (relevantScope) {
81 if (!mimeType.isNull())
82 return mimeType;
83 }
84 }
85 return QString();
86}
87
89{
90 // globalMimeList is in decreasing priority order. Recently added
91 // converters take prioity over previously added converters: prepend
92 // to the list.
94}
95
101
102
103/*
104 Returns a list of all currently defined QUtiMimeConverter objects for scope \a scope.
105*/
107{
109 const MimeList &mimes = *globalMimeList();
110 for (const auto &mime : mimes) {
111 if (mime->scope() & scope)
112 ret.append(mime);
113 }
114 return ret;
115}
116
117} // namespace QMacMimeRegistry
118
119QT_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)
Combined button and popup list for selecting options.