summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/io.pri1
-rw-r--r--src/corelib/io/qurl.cpp27
-rw-r--r--src/corelib/io/qurl.h12
-rw-r--r--src/corelib/io/qurl_mac.mm70
4 files changed, 110 insertions, 0 deletions
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index b7fc1bc600..eab3981f7a 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -130,6 +130,7 @@ win32 {
!nacl:mac: {
SOURCES += io/qsettings_mac.cpp
+ OBJECTIVE_SOURCES += io/qurl_mac.mm
}
mac {
macx {
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 1854ea9487..5535ae126a 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3319,6 +3319,33 @@ QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclu
return input.toUtf8().toPercentEncoding(exclude, include);
}
+/*! \fn QUrl QUrl::fromCFURL(CFURLRef url)
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the CFURL \a url.
+*/
+
+/*! \fn CFURLRef QUrl::toCFURL() const
+ \since 5.2
+
+ Creates a CFURL from a QUrl. The caller owns the CFURL and is
+ responsible for releasing it.
+*/
+
+/*!
+ \fn QUrl QUrl::fromNSURL(const NSURL *url)
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the NSURL \a url.
+*/
+
+/*!
+ \fn NSURL* QUrl::toNSURL() const
+ \since 5.2
+
+ Creates a NSURL from a QUrl. The NSURL is autoreleased.
+*/
+
/*!
\internal
\since 5.0
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index abb7df0056..e7edb4365e 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -50,6 +50,11 @@
#include <QtCore/qpair.h>
#include <QtCore/qglobal.h>
+#ifdef Q_OS_MAC
+Q_FORWARD_DECLARE_OBJC_CLASS(NSURL);
+Q_FORWARD_DECLARE_CF_TYPE(CFURL);
+#endif
+
QT_BEGIN_NAMESPACE
@@ -257,6 +262,13 @@ public:
static QByteArray toPercentEncoding(const QString &,
const QByteArray &exclude = QByteArray(),
const QByteArray &include = QByteArray());
+#if defined(Q_OS_MAC) || defined(Q_QDOC)
+ static QUrl fromCFURL(CFURLRef url);
+ CFURLRef toCFURL() const Q_DECL_CF_RETURNS_RETAINED;
+ static QUrl fromNSURL(const NSURL *url);
+ NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED;
+#endif
+
#if QT_DEPRECATED_SINCE(5,0)
QT_DEPRECATED static QString fromPunycode(const QByteArray &punycode)
{ return fromAce(punycode); }
diff --git a/src/corelib/io/qurl_mac.mm b/src/corelib/io/qurl_mac.mm
new file mode 100644
index 0000000000..c235365ad8
--- /dev/null
+++ b/src/corelib/io/qurl_mac.mm
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qurl.h"
+
+#ifdef Q_OS_MAC
+#include <Foundation/Foundation.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QUrl QUrl::fromCFURL(CFURLRef url)
+{
+ return QUrl(QString::fromCFString(CFURLGetString(url)));
+}
+
+CFURLRef QUrl::toCFURL() const
+{
+ return CFURLCreateWithString(0, toString(FullyEncoded).toCFString(), 0);
+}
+
+QUrl QUrl::fromNSURL(const NSURL *url)
+{
+ return QUrl(QString::fromNSString([url absoluteString]));
+}
+
+NSURL *QUrl::toNSURL() const
+{
+ return [NSURL URLWithString:toString(FullyEncoded).toNSString()];
+}
+
+QT_END_NAMESPACE