Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qutimimeconverter.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 <ImageIO/ImageIO.h>
5#include <CoreFoundation/CoreFoundation.h>
6
7#include <QtCore/qsystemdetection.h>
8#include <QtCore/qurl.h>
9#include <QtGui/qimage.h>
10#include <QtCore/qmimedata.h>
11#include <QtCore/qstringconverter.h>
12
13#if defined(Q_OS_MACOS)
14#import <AppKit/AppKit.h>
15#else
16#include <MobileCoreServices/MobileCoreServices.h>
17#endif
18
19#if defined(QT_PLATFORM_UIKIT)
20#import <UIKit/UIKit.h>
21#endif
22
23#include "qutimimeconverter.h"
24#include "qmacmimeregistry_p.h"
25#include "qguiapplication.h"
26#include "private/qcore_mac_p.h"
27
29
30using namespace Qt::StringLiterals;
31
32/*****************************************************************************
33 QDnD debug facilities
34 *****************************************************************************/
35//#define DEBUG_MIME_MAPS
36
89 : m_scope(scope)
90{
92}
93
100{
101}
102
108{
110}
111
116{
118 return 1;
119}
120
172public:
174
175 QString utiForMime(const QString &mime) const override;
176 QString mimeForUti(const QString &uti) const override;
178 const QString &uti) const override;
180 const QString &uti) const override;
181};
182
184{
185 // do not handle the mime type name in the drag pasteboard
186 if (mime == "application/x-qt-mime-type-name"_L1)
187 return QString();
188 QString ret = "com.trolltech.anymime."_L1 + mime;
189 return ret.replace(u'/', "--"_L1);
190}
191
193{
194 const QString any_prefix = "com.trolltech.anymime."_L1;
195 if (uti.size() > any_prefix.length() && uti.startsWith(any_prefix))
196 return uti.mid(any_prefix.length()).replace("--"_L1, "/"_L1);
197 return QString();
198}
199
201 const QString &) const
202{
203 if (data.count() > 1)
204 qWarning("QMacMimeAny: Cannot handle multiple member data");
206 if (mime == "text/plain"_L1)
207 ret = QString::fromUtf8(data.first());
208 else
209 ret = data.first();
210 return ret;
211}
212
214 const QString &) const
215{
217 if (mime == "text/plain"_L1)
218 ret.append(data.toString().toUtf8());
219 else
220 ret.append(data.toByteArray());
221 return ret;
222}
223
225private:
226
227public:
229
230 QString utiForMime(const QString &mime) const override;
231 QString mimeForUti(const QString &uti) const override;
232 QVariant convertToMime(const QString &mime, const QList<QByteArray> &data, const QString &uti) const override;
233 QList<QByteArray> convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override;
234};
235
237{
238 if (mime == "application/x-qt-mime-type-name"_L1)
239 return u"com.trolltech.qt.MimeTypeName"_s;
240 return QString();
241}
242
244{
245 return QString();
246}
247
249{
251 return ret;
252}
253
255{
257 ret.append(QString("x-qt-mime-type-name"_L1).toUtf8());
258 return ret;
259}
260
262{
263public:
264 QString utiForMime(const QString &mime) const override;
265 QString mimeForUti(const QString &uti) const override;
267 const QString &uti) const override;
269 const QString &uti) const override;
270};
271
273{
274 if (mime == "text/plain"_L1)
275 return "public.text"_L1;
276 return QString();
277}
278
280{
281 if (uti == "public.text"_L1)
282 return "text/plain"_L1;
283 return QString();
284}
285
288 const QList<QByteArray> &data, const QString &uti) const
289{
290 if (data.count() > 1)
291 qWarning("QMacMimePlainTextFallback: Cannot handle multiple member data");
292
293 if (uti == "public.text"_L1) {
294 // Note that public.text is documented by Apple to have an undefined encoding. From
295 // testing it seems that utf8 is normally used, at least by Safari on iOS.
296 const QByteArray &firstData = data.first();
297 return QString(QCFString(CFStringCreateWithBytes(kCFAllocatorDefault,
298 reinterpret_cast<const UInt8 *>(firstData.constData()),
299 firstData.size(), kCFStringEncodingUTF8, false)));
300 } else {
301 qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
302 }
303 return QVariant();
304}
305
308 const QString &uti) const
309{
311 QString string = data.toString();
312 if (uti == "public.text"_L1)
313 ret.append(string.toUtf8());
314 return ret;
315}
316
318{
319public:
320 QString utiForMime(const QString &mime) const override;
321 QString mimeForUti(const QString &uti) const override;
323 const QString &uti) const override;
325 const QString &uti) const override;
326};
327
329{
330 if (mime == "text/plain"_L1)
331 return "public.utf16-plain-text"_L1;
332 if (qsizetype i = mime.indexOf("charset="_L1); i >= 0) {
333 QString cs(mime.mid(i + 8).toLower());
334 i = cs.indexOf(u';');
335 if (i >= 0)
336 cs = cs.left(i);
337 if (cs == "system"_L1)
338 return "public.utf8-plain-text"_L1;
339 else if (cs == "iso-10646-ucs-2"_L1 || cs == "utf16"_L1)
340 return "public.utf16-plain-text"_L1;
341 }
342 return QString();
343}
344
346{
347 if (uti == "public.utf16-plain-text"_L1 || uti == "public.utf8-plain-text"_L1)
348 return "text/plain"_L1;
349 return QString();
350}
351
354 const QList<QByteArray> &data, const QString &uti) const
355{
356 if (data.count() > 1)
357 qWarning("QMacMimeUnicodeText: Cannot handle multiple member data");
358 const QByteArray &firstData = data.first();
359 // I can only handle two types (system and unicode) so deal with them that way
361 if (uti == "public.utf8-plain-text"_L1) {
362 ret = QString::fromUtf8(firstData);
363 } else if (uti == "public.utf16-plain-text"_L1) {
365 ret = str;
366 } else {
367 qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
368 }
369 return ret;
370}
371
374 const QString &uti) const
375{
377 QString string = data.toString();
378 if (uti == "public.utf8-plain-text"_L1)
379 ret.append(string.toUtf8());
380 else if (uti == "public.utf16-plain-text"_L1) {
381 QStringEncoder::Flags f;
382#if defined(Q_OS_MACOS)
383 // Some applications such as Microsoft Excel, don't deal well with
384 // a BOM present, so we follow the traditional approach of Qt on
385 // macOS to not generate public.utf16-plain-text with a BOM.
387#else
388 // Whereas iOS applications will fail to paste if we do _not_
389 // include a BOM in the public.utf16-plain-text content, most
390 // likely due to converting the data using NSUTF16StringEncoding
391 // which assumes big-endian byte order if there is no BOM.
393#endif
395 ret.append(encoder(string));
396 }
397 return ret;
398}
399
401{
402public:
403 QString utiForMime(const QString &mime) const override;
404 QString mimeForUti(const QString &uti) const override;
406 const QString &uti) const override;
408 const QString &uti) const override;
409};
410
412{
413 if (mime == "text/html"_L1)
414 return "public.html"_L1;
415 return QString();
416}
417
419{
420 if (uti == "public.html"_L1)
421 return "text/html"_L1;
422 return QString();
423}
424
427 const QList<QByteArray> &data, const QString &uti) const
428{
429 if (!canConvert(mimeType, uti))
430 return QVariant();
431 if (data.count() > 1)
432 qWarning("QMacMimeHTMLText: Cannot handle multiple member data");
433 return data.first();
434}
435
438 const QVariant &data, const QString &uti) const
439{
441 if (!canConvert(mime, uti))
442 return ret;
443 ret.append(data.toByteArray());
444 return ret;
445}
446
448{
449public:
450 QString utiForMime(const QString &mime) const override;
451 QString mimeForUti(const QString &uti) const override;
453 const QString &uti) const override;
455 const QString &uti) const override;
456};
457
459{
460 if (mime == "text/html"_L1)
461 return "public.rtf"_L1;
462 return QString();
463}
464
466{
467 if (uti == "public.rtf"_L1)
468 return "text/html"_L1;
469 return QString();
470}
471
474 const QList<QByteArray> &data, const QString &uti) const
475{
476 if (!canConvert(mimeType, uti))
477 return QVariant();
478 if (data.count() > 1)
479 qWarning("QMacMimeHTMLText: Cannot handle multiple member data");
480
481 // Read RTF into to NSAttributedString, then convert the string to HTML
482 NSAttributedString *string = [[NSAttributedString alloc] initWithData:data.at(0).toNSData()
483 options:@{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType}
484 documentAttributes:nil
485 error:nil];
486
487 NSError *error;
488 NSRange range = NSMakeRange(0, [string length]);
489 NSDictionary *dict = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
490 NSData *htmlData = [string dataFromRange:range documentAttributes:dict error:&error];
491 return QByteArray::fromNSData(htmlData);
492}
493
496 const QVariant &data, const QString &uti) const
497{
499 if (!canConvert(mime, uti))
500 return ret;
501
502 NSAttributedString *string = [[NSAttributedString alloc] initWithData:data.toByteArray().toNSData()
503 options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}
504 documentAttributes:nil
505 error:nil];
506
507 NSError *error;
508 NSRange range = NSMakeRange(0, [string length]);
509 NSDictionary *dict = @{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType};
510 NSData *rtfData = [string dataFromRange:range documentAttributes:dict error:&error];
511 ret << QByteArray::fromNSData(rtfData);
512 return ret;
513}
514
516{
517public:
518 QString utiForMime(const QString &mime) const override;
519 QString mimeForUti(const QString &uti) const override;
521 const QString &uti) const override;
523 const QString &uti) const override;
524 int count(const QMimeData *mimeData) const override;
525};
526
528{
529 if (mime == "text/uri-list"_L1)
530 return "public.file-url"_L1;
531 return QString();
532}
533
535{
536 if (uti == "public.file-url"_L1)
537 return "text/uri-list"_L1;
538 return QString();
539}
540
543 const QList<QByteArray> &data, const QString &uti) const
544{
545 if (!canConvert(mime, uti))
546 return QVariant();
548 for (int i = 0; i < data.size(); ++i) {
549 const QByteArray &a = data.at(i);
550 NSString *urlString = [[[NSString alloc] initWithBytesNoCopy:(void *)a.data() length:a.size()
551 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease];
552 NSURL *nsurl = [NSURL URLWithString:urlString];
553 QUrl url;
554 // OS X 10.10 sends file references instead of file paths
555 if ([nsurl isFileReferenceURL]) {
556 url = QUrl::fromNSURL([nsurl filePathURL]);
557 } else {
558 url = QUrl::fromNSURL(nsurl);
559 }
560
561 if (url.host().toLower() == "localhost"_L1)
563
565 ret.append(url);
566 }
567 return QVariant(ret);
568}
569
572 const QVariant &data, const QString &uti) const
573{
575 if (!canConvert(mime, uti))
576 return ret;
577 QList<QVariant> urls = data.toList();
578 for (int i = 0; i < urls.size(); ++i) {
579 QUrl url = urls.at(i).toUrl();
580 if (url.scheme().isEmpty())
581 url.setScheme("file"_L1);
582 if (url.scheme() == "file"_L1) {
583 if (url.host().isEmpty())
584 url.setHost("localhost"_L1);
586 }
587 if (url.isLocalFile())
588 ret.append(url.toEncoded());
589 }
590 return ret;
591}
592
594{
595 return mimeData->urls().count();
596}
597
599{
600public:
601 QString utiForMime(const QString &mime) const override;
602 QString mimeForUti(const QString &uti) const override;
604 const QString &uti) const override;
606 const QString &uti) const override;
607};
608
610{
611 if (mime.startsWith("text/uri-list"_L1))
612 return "public.url"_L1;
613 return QString();
614}
615
617{
618 if (uti == "public.url"_L1)
619 return "text/uri-list"_L1;
620 return QString();
621}
622
624 const QList<QByteArray> &data, const QString &uti) const
625{
626 if (!canConvert(mime, uti))
627 return QVariant();
628
630 for (int i=0; i<data.size(); ++i) {
632 if (url.host().toLower() == "localhost"_L1)
635 ret.append(url);
636 }
637 return QVariant(ret);
638}
639
641 const QVariant &data, const QString &uti) const
642{
644 if (!canConvert(mime, uti))
645 return ret;
646
647 QList<QVariant> urls = data.toList();
648 for (int i=0; i<urls.size(); ++i) {
649 QUrl url = urls.at(i).toUrl();
650 if (url.scheme().isEmpty())
651 url.setScheme("file"_L1);
652 if (url.scheme() == "file"_L1) {
653 if (url.host().isEmpty())
654 url.setHost("localhost"_L1);
656 }
657 ret.append(url.toEncoded());
658 }
659 return ret;
660}
661
663{
664public:
665 QString utiForMime(const QString &mime) const override;
666 QString mimeForUti(const QString &uti) const override;
668 const QString &uti) const override;
670 const QString &uti) const override;
671};
672
674{
675 if (mime.startsWith("text/vcard"_L1))
676 return "public.vcard"_L1;
677 return QString();
678}
679
681{
682 if (uti == "public.vcard"_L1)
683 return "text/vcard"_L1;
684 return QString();
685}
686
688 const QList<QByteArray> &data, const QString &uti) const
689{
690 if (!canConvert(mime, uti))
691 return QVariant();
692 QByteArray cards;
693 if (uti == "public.vcard"_L1) {
694 for (int i=0; i<data.size(); ++i)
695 cards += data[i];
696 }
697 return QVariant(cards);
698}
699
701 const QVariant &data, const QString &uti) const
702{
704 if (!canConvert(mime, uti))
705 return ret;
706
707 if (mime == "text/vcard"_L1)
708 ret.append(data.toString().toUtf8());
709 return ret;
710}
711
712extern QImage qt_mac_toQImage(CGImageRef image);
713extern CGImageRef qt_mac_toCGImage(const QImage &qImage);
714
716{
717public:
718 QString utiForMime(const QString &mime) const override;
719 QString mimeForUti(const QString &uti) const override;
721 const QString &uti) const override;
723 const QString &uti) const override;
724};
725
727{
728 if (mime.startsWith("application/x-qt-image"_L1))
729 return "public.tiff"_L1;
730 return QString();
731}
732
734{
735 if (uti == "public.tiff"_L1)
736 return "application/x-qt-image"_L1;
737 return QString();
738}
739
741 const QList<QByteArray> &data, const QString &uti) const
742{
743 if (data.count() > 1)
744 qWarning("QMacMimeTiff: Cannot handle multiple member data");
745
746 if (!canConvert(mime, uti))
747 return QVariant();
748
749 QCFType<CFDataRef> tiffData = data.first().toRawCFData();
750 QCFType<CGImageSourceRef> imageSource = CGImageSourceCreateWithData(tiffData, 0);
751
752 if (QCFType<CGImageRef> image = CGImageSourceCreateImageAtIndex(imageSource, 0, 0))
754
755 return QVariant();
756}
757
759 const QVariant &variant, const QString &uti) const
760{
761 if (!canConvert(mime, uti))
762 return QList<QByteArray>();
763
764 QCFType<CFMutableDataRef> data = CFDataCreateMutable(0, 0);
765 QCFType<CGImageDestinationRef> imageDestination = CGImageDestinationCreateWithData(data,
766 kUTTypeTIFF, 1, 0);
767
768 if (!imageDestination)
769 return QList<QByteArray>();
770
771 QImage img = qvariant_cast<QImage>(variant);
772 NSDictionary *props = @{
773 static_cast<NSString *>(kCGImagePropertyPixelWidth): @(img.width()),
774 static_cast<NSString *>(kCGImagePropertyPixelHeight): @(img.height())
775 };
776
777 CGImageDestinationAddImage(imageDestination, qt_mac_toCGImage(img),
778 static_cast<CFDictionaryRef>(props));
779 CGImageDestinationFinalize(imageDestination);
780
781 return QList<QByteArray>() << QByteArray::fromCFData(data);
782}
783
784namespace QMacMimeRegistry {
785
787{
788 // Create QMacMimeAny first to put it at the end of globalMimeList
789 // with lowest priority. (the constructor prepends to the list)
790 new QMacMimeAny;
791
792 //standard types that we wrap
793 new QMacMimeTiff;
796 new QMacMimeRtfText;
798 new QMacMimeFileUri;
799 new QMacMimeUrl;
801 new QMacMimeVCard;
802}
803
804}
805
\inmodule QtCore
Definition qbytearray.h:57
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
Definition qbytearray.h:474
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:122
char at(qsizetype i) const
Returns the byte at index position i in the byte array.
Definition qbytearray.h:523
QByteArray first(qsizetype n) const
Definition qbytearray.h:159
\inmodule QtGui
Definition qimage.h:37
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
QList< T > toList() const noexcept
Definition qlist.h:716
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
qsizetype count() const noexcept
Definition qlist.h:387
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
int count(const QMimeData *mimeData) const override
Returns the item count for the given mimeData.
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QVariant convertToMime(const QString &mime, const QList< QByteArray > &data, const QString &uti) const override
Returns data converted from Mac UTI uti to MIME type mime.
QString utiForMime(const QString &mime) const override
Returns the Mac UTI used for MIME type mime, or an empty string if this converter does not support co...
QString mimeForUti(const QString &uti) const override
Returns the MIME type used for Mac UTI uti, or an empty string if this converter does not support con...
QList< QByteArray > convertFromMime(const QString &mime, const QVariant &data, const QString &uti) const override
Returns data converted from MIME type mime to Mac UTI uti.
\inmodule QtCore
Definition qmimedata.h:16
QList< QUrl > urls() const
Returns a list of URLs contained within the MIME data object.
\inmodule QtCore
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition qstring.cpp:5299
QString & replace(qsizetype i, qsizetype len, QChar after)
Definition qstring.cpp:3794
qsizetype size() const
Returns the number of characters in this string.
Definition qstring.h:182
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
Definition qstring.cpp:5204
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
QString toLower() const &
Definition qstring.h:368
QString left(qsizetype n) const
Returns a substring that contains the n leftmost characters of the string.
Definition qstring.cpp:5161
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4420
@ NormalizationForm_C
Definition qstring.h:548
@ NormalizationForm_D
Definition qstring.h:547
qsizetype length() const
Returns the number of characters in this string.
Definition qstring.h:187
QString normalized(NormalizationForm mode, QChar::UnicodeVersion version=QChar::Unicode_Unassigned) const
Returns the string in the given Unicode normalization mode, according to the given version of the Uni...
Definition qstring.cpp:8212
\inmodule QtCore
Definition qurl.h:94
bool isLocalFile() const
Definition qurl.cpp:3431
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
Definition qurl.cpp:2337
QByteArray toEncoded(FormattingOptions options=FullyEncoded) const
Returns the encoded representation of the URL if it's valid; otherwise an empty QByteArray is returne...
Definition qurl.cpp:2964
QString scheme() const
Returns the scheme of the URL.
Definition qurl.cpp:1983
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
Definition qurl.cpp:1959
void setHost(const QString &host, ParsingMode mode=DecodedMode)
Sets the host of the URL to host.
Definition qurl.cpp:2286
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
Definition qurl.cpp:2411
static QUrl fromEncoded(QByteArrayView input, ParsingMode mode=TolerantMode)
Parses input and returns the corresponding QUrl.
Definition qurl.cpp:2985
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
Definition qurl.cpp:2465
The QUtiMimeConverter class converts between a MIME type and a \l{https://developer....
bool canConvert(const QString &mime, const QString &uti) const
Returns true if the converter can convert (both ways) between mime and uti; otherwise returns false.
virtual ~QUtiMimeConverter()
Destroys a conversion object, removing it from the global list of available converters.
QUtiMimeConverter()
Constructs a new conversion object and adds it to the globally accessed list of available converters.
virtual int count(const QMimeData *mimeData) const
Returns the item count for the given mimeData.
\inmodule QtCore
Definition qvariant.h:64
QString str
[2]
void unregisterMimeConverter(QUtiMimeConverter *macMime)
void registerMimeConverter(QUtiMimeConverter *macMime)
Combined button and popup list for selecting options.
Definition image.cpp:4
DBusConnection const char DBusError * error
const char * mimeType
#define qWarning
Definition qlogging.h:162
return ret
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei count
GLfloat GLfloat f
GLsizei range
GLenum GLuint GLsizei const GLenum * props
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint void * img
Definition qopenglext.h:233
#define qPrintable(string)
Definition qstring.h:1391
#define Q_UNUSED(x)
ptrdiff_t qsizetype
Definition qtypes.h:70
QImage qt_mac_toQImage(CGImageRef image)
CGImageRef qt_mac_toCGImage(const QImage &qImage)
QUrl url("example.com")
[constructor-url-reference]
application x qt windows mime
[2]
QMimeData * mimeData
QVariant variant
[1]