[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdelibs/frameworks] /: Port KCmdLineArgs from KUrl to QUrl
From: Matt Williams <matt () milliams ! com>
Date: 2012-02-18 16:58:42
Message-ID: 20120218165842.9D727A60A6 () git ! kde ! org
[Download RAW message or body]
Git commit 65935ecfa67d4c4190892372ee5f9601d9657219 by Matt Williams.
Committed on 18/02/2012 at 17:59.
Pushed by milliams into branch 'frameworks'.
Port KCmdLineArgs from KUrl to QUrl
QUrl has no cleanPath method so leave comment reminding to port to
QUrlInfo or similar with Qt5
M +4 -4 kdecore/tests/kcmdlineargstest.cpp
M +10 -8 staging/kcoreaddons/src/kernel/kcmdlineargs.cpp
M +3 -3 staging/kcoreaddons/src/kernel/kcmdlineargs.h
http://commits.kde.org/kdelibs/65935ecfa67d4c4190892372ee5f9601d9657219
diff --git a/kdecore/tests/kcmdlineargstest.cpp b/kdecore/tests/kcmdlineargstest.cpp
index 4369c32..9363176 100644
--- a/kdecore/tests/kcmdlineargstest.cpp
+++ b/kdecore/tests/kcmdlineargstest.cpp
@@ -1,6 +1,6 @@
#include <kcmdlineargs.h>
#include <QtCore/QCoreApplication>
-#include <kurl.h>
+#include <QtCore/QUrl>
#include <stdio.h>
#include <assert.h>
@@ -62,15 +62,15 @@ main(int argc, char *argv[])
for(int i = 0; i < args->count(); i++)
{
printf("%d: %s\n", i, args->arg(i).toLocal8Bit().data());
- printf("%d: %s\n", i, args->url(i).url().toLocal8Bit().data());
+ printf("%d: %s\n", i, args->url(i).toEncoded().data());
}
// Check how KCmdLineArgs::url() works
- KUrl u = KCmdLineArgs::makeURL("/tmp");
+ QUrl u = KCmdLineArgs::makeURL("/tmp");
kDebug() << u;
assert(u.toLocalFile() == "/tmp");
u = KCmdLineArgs::makeURL("foo");
- kDebug() << u << " expected: " << KUrl(QDir::currentPath()+"/foo");
+ kDebug() << u << " expected: " << QUrl(QDir::currentPath()+"/foo");
assert(u.toLocalFile() == QDir::currentPath()+"/foo");
u = KCmdLineArgs::makeURL("http://www.kde.org");
kDebug() << u;
diff --git a/staging/kcoreaddons/src/kernel/kcmdlineargs.cpp \
b/staging/kcoreaddons/src/kernel/kcmdlineargs.cpp index 1829b8b..641c669 100644
--- a/staging/kcoreaddons/src/kernel/kcmdlineargs.cpp
+++ b/staging/kcoreaddons/src/kernel/kcmdlineargs.cpp
@@ -38,11 +38,11 @@
#include <QtCore/QFile>
#include <QtCore/QHash>
#include <QtCore/QTextCodec>
+#include <QtCore/QUrl>
#include "kaboutdata.h"
#include "kdeversion.h"
#include "kglobal.h"
-#include "kurl.h"
// PORTING HACK (KDE5 TODO: clean up)
#define i18nc(a,b) QObject::tr(b, a)
@@ -1576,30 +1576,32 @@ KCmdLineArgs::arg(int n) const
return QString::fromLocal8Bit(d->parsedArgList->at(n).data());
}
-KUrl
+QUrl
KCmdLineArgs::url(int n) const
{
return makeURL( arg(n).toUtf8() );
}
-KUrl KCmdLineArgs::makeURL(const QByteArray &_urlArg)
+QUrl KCmdLineArgs::makeURL(const QByteArray &_urlArg)
{
const QString urlArg = QString::fromUtf8(_urlArg.data());
QFileInfo fileInfo(urlArg);
if (!fileInfo.isRelative()) { // i.e. starts with '/', on unix
- KUrl result;
+ QUrl result;
result.setPath(QDir::fromNativeSeparators(urlArg));
return result; // Absolute path.
}
- if ( KUrl::isRelativeUrl(urlArg) || fileInfo.exists() ) {
- KUrl result;
+ if ( fileInfo.isRelative() || fileInfo.exists() ) {
+ QUrl result;
result.setPath(cwd()+QLatin1Char('/')+urlArg);
- result.cleanPath();
+#if 0 //Qt5 TODO: QUrlInfo::cleanPath
+ result.cleanPath(); //This did use KUrl::cleanPath()
+#endif
return result; // Relative path
}
- return KUrl(urlArg); // Argument is a URL
+ return QUrl(urlArg); // Argument is a URL
}
void
diff --git a/staging/kcoreaddons/src/kernel/kcmdlineargs.h \
b/staging/kcoreaddons/src/kernel/kcmdlineargs.h index 899a7f6..fbaf1ad 100644
--- a/staging/kcoreaddons/src/kernel/kcmdlineargs.h
+++ b/staging/kcoreaddons/src/kernel/kcmdlineargs.h
@@ -29,7 +29,7 @@ class QString;
class QStringList;
class QByteArray;
class QDataStream;
-class KUrl;
+class QUrl;
class KCmdLineArgs;
class KCmdLineArgsPrivate;
@@ -563,7 +563,7 @@ public:
*
* @return a URL representing the n'th argument.
*/
- KUrl url(int n) const;
+ QUrl url(int n) const;
/**
* Used by url().
@@ -571,7 +571,7 @@ public:
* @param urlArg the argument
* @return the url.
*/
- static KUrl makeURL( const QByteArray &urlArg );
+ static QUrl makeURL( const QByteArray &urlArg );
/**
* Made public for apps that don't use KCmdLineArgs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic