File indexing completed on 2025-02-09 05:31:50
0001 /* This file is part of the KDE project 0002 Copyright (C) 2011 Harald Sitter <sitter@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 */ 0021 0022 #include "mrl.h" 0023 0024 #include <QFile> 0025 0026 namespace Phonon 0027 { 0028 0029 Mrl::Mrl() 0030 : QUrl() 0031 { 0032 } 0033 0034 Mrl::Mrl(const Mrl ©) 0035 : QUrl(copy) 0036 { 0037 } 0038 0039 Mrl::Mrl(const QUrl &url) 0040 : QUrl(url) 0041 { 0042 } 0043 0044 Mrl::Mrl(const QString &url) 0045 : QUrl(url) 0046 { 0047 } 0048 0049 Mrl &Mrl::operator =(const Mrl ©) 0050 { 0051 QUrl::operator =(copy); 0052 return *this; 0053 } 0054 0055 #ifndef QT_NO_URL_CAST_FROM_STRING 0056 Mrl &Mrl::operator =(const QString &url) 0057 { 0058 QUrl::operator =(url); 0059 return *this; 0060 } 0061 #endif // QT_NO_URL_CAST_FROM_STRING 0062 0063 QByteArray Mrl::toEncoded(FormattingOptions options) const 0064 { 0065 QByteArray encodedMrl; 0066 0067 static QByteArray encodingExclude(":/\\?=&,@"); 0068 if (scheme() == QLatin1String("")) { 0069 encodedMrl = QFile::encodeName("file://" + toLocalFile()).toPercentEncoding(encodingExclude); 0070 } else if (scheme() == QLatin1String("file")) { 0071 encodedMrl = QFile::encodeName("file://" + toLocalFile()).toPercentEncoding(encodingExclude); 0072 } else { 0073 encodedMrl = QUrl::toEncoded(options); 0074 } 0075 0076 return encodedMrl; 0077 } 0078 0079 } // namespace Phonon