Commit 1da1b23f authored by Simon Persson's avatar Simon Persson
Browse files

Port remaining parts from KUrl to QUrl

Mostly straight forward porting, using porting script and also manual labour. Either way, it follows the guidelines (doc comments) in kurl.h from KF5.
Mostly the difficult thing is the change in constructor that takes a QString. Needed to decide for each case if KUrl(QString) construction needed to be replaces with QUrl::fromUserInput or the simpler one, QUrl::fromLocalFile. If there are any regressions that would be likely candidate.
Also some additional changes that now made sense to do:
- KChooseDir dialogs: code could be simplified quite a lot, KUrlRequester does everything we needed already.
- Krusader class, constructor: making sure relative paths are resolved is now done by QUrl anyway, could remove code for that.
parent dcacb034
......@@ -34,7 +34,6 @@
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <kde_file.h>
#include <KDE/KUrl>
#include <KDE/KDebug>
#include <KDE/KComponentData>
#include <KDE/KMimeType>
......@@ -211,12 +210,12 @@ void kio_isoProtocol::createUDSEntry(const KArchiveEntry * isoEntry, UDSEntry &
entry.insert(UDSEntry::UDS_LINK_DEST, isoEntry->symLinkTarget());
}
void kio_isoProtocol::listDir(const KUrl & url)
void kio_isoProtocol::listDir(const QUrl &url)
{
kDebug() << "kio_isoProtocol::listDir " << url.url() << endl;
QString path;
if (!checkNewFile(getPath(url), path, url.hasRef() ? url.htmlRef().toInt() : -1)) {
if (!checkNewFile(getPath(url), path, url.hasFragment() ? url.fragment(QUrl::FullyDecoded).toInt() : -1)) {
QByteArray _path(QFile::encodeName(getPath(url)));
kDebug() << "Checking (stat) on " << _path << endl;
KDE_struct_stat buff;
......@@ -225,9 +224,9 @@ void kio_isoProtocol::listDir(const KUrl & url)
return;
}
// It's a real dir -> redirect
KUrl redir;
QUrl redir;
redir.setPath(getPath(url));
if (url.hasRef()) redir.setRef(url.htmlRef());
if (url.hasFragment()) redir.setFragment(url.fragment(QUrl::FullyDecoded));
kDebug() << "Ok, redirection to " << redir.url() << endl;
redirection(redir);
finished();
......@@ -238,9 +237,9 @@ void kio_isoProtocol::listDir(const KUrl & url)
}
if (path.isEmpty()) {
KUrl redir(QString::fromLatin1("iso:/"));
QUrl redir(QStringLiteral("iso:/"));
kDebug() << "url.path()==" << getPath(url) << endl;
if (url.hasRef()) redir.setRef(url.htmlRef());
if (url.hasFragment()) redir.setFragment(url.fragment(QUrl::FullyDecoded));
redir.setPath(getPath(url) + QString::fromLatin1(DIR_SEPARATOR));
kDebug() << "kio_isoProtocol::listDir: redirection " << redir.url() << endl;
redirection(redir);
......@@ -288,13 +287,13 @@ void kio_isoProtocol::listDir(const KUrl & url)
kDebug() << "kio_isoProtocol::listDir done" << endl;
}
void kio_isoProtocol::stat(const KUrl & url)
void kio_isoProtocol::stat(const QUrl &url)
{
QString path;
UDSEntry entry;
kDebug() << "kio_isoProtocol::stat " << url.url() << endl;
if (!checkNewFile(getPath(url), path, url.hasRef() ? url.htmlRef().toInt() : -1)) {
if (!checkNewFile(getPath(url), path, url.hasFragment() ? url.fragment(QUrl::FullyDecoded).toInt() : -1)) {
// We may be looking at a real directory - this happens
// when pressing up after being in the root of an archive
QByteArray _path(QFile::encodeName(getPath(url)));
......@@ -464,12 +463,12 @@ void kio_isoProtocol::getFile(const KIsoFile *isoFileEntry, const QString &path)
}
void kio_isoProtocol::get(const KUrl & url)
void kio_isoProtocol::get(const QUrl &url)
{
kDebug() << "kio_isoProtocol::get" << url.url() << endl;
QString path;
if (!checkNewFile(getPath(url), path, url.hasRef() ? url.htmlRef().toInt() : -1)) {
if (!checkNewFile(getPath(url), path, url.hasFragment() ? url.fragment(QUrl::FullyDecoded).toInt() : -1)) {
error(KIO::ERR_DOES_NOT_EXIST, getPath(url));
return;
}
......@@ -489,7 +488,7 @@ void kio_isoProtocol::get(const KUrl & url)
const KIsoFile* isoFileEntry = static_cast<const KIsoFile *>(isoEntry);
if (!isoEntry->symLinkTarget().isEmpty()) {
kDebug() << "Redirection to " << isoEntry->symLinkTarget() << endl;
KUrl realURL(url, isoEntry->symLinkTarget());
QUrl realURL = QUrl(url).resolved(QUrl(isoEntry->symLinkTarget()));
kDebug() << "realURL= " << realURL.url() << endl;
redirection(realURL);
finished();
......@@ -499,7 +498,7 @@ void kio_isoProtocol::get(const KUrl & url)
if (m_isoFile->device()->isOpen()) m_isoFile->device()->close();
}
QString kio_isoProtocol::getPath(const KUrl & url)
QString kio_isoProtocol::getPath(const QUrl &url)
{
QString path = url.path();
REPLACE_DIR_SEP2(path);
......
......@@ -25,9 +25,7 @@
#include <sys/types.h>
#include <QtCore/QByteArray>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KUrl>
#include <QtCore/QUrl>
#include <KIO/SlaveBase>
......@@ -41,15 +39,15 @@ public:
kio_isoProtocol(const QByteArray &pool, const QByteArray &app);
virtual ~kio_isoProtocol();
virtual void listDir(const KUrl & url);
virtual void stat(const KUrl & url);
virtual void get(const KUrl & url);
virtual void listDir(const QUrl &url);
virtual void stat(const QUrl &url);
virtual void get(const QUrl &url);
protected:
void getFile(const KIsoFile *isoFileEntry, const QString &path);
void createUDSEntry(const KArchiveEntry * isoEntry, KIO::UDSEntry & entry);
bool checkNewFile(QString fullPath, QString & path, int startsec);
QString getPath(const KUrl & url);
QString getPath(const QUrl &url);
KIso * m_isoFile;
time_t m_mtime;
......
......@@ -37,7 +37,6 @@
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <kde_file.h>
#include <KDE/KDebug>
#include <KDE/KUrl>
#include <KDE/KMimeType>
#include <KConfigCore/KConfig>
......
......@@ -34,7 +34,6 @@
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KDebug>
#include <KDE/KUrl>
#include <KDE/KComponentData>
#include <KDE/KLocale>
#include <KDE/KTemporaryFile>
......@@ -212,7 +211,7 @@ void kio_krarcProtocol::receivedData(KProcess *, QByteArray &d)
decompressedLen += d.length();
}
void kio_krarcProtocol::mkdir(const KUrl& url, int permissions)
void kio_krarcProtocol::mkdir(const QUrl &url, int permissions)
{
KRDEBUG(getPath(url));
......@@ -286,7 +285,7 @@ void kio_krarcProtocol::mkdir(const KUrl& url, int permissions)
finished();
}
void kio_krarcProtocol::put(const KUrl& url, int permissions, KIO::JobFlags flags)
void kio_krarcProtocol::put(const QUrl &url, int permissions, KIO::JobFlags flags)
{
KRDEBUG(getPath(url));
......@@ -383,12 +382,12 @@ void kio_krarcProtocol::put(const KUrl& url, int permissions, KIO::JobFlags flag
finished();
}
void kio_krarcProtocol::get(const KUrl& url)
void kio_krarcProtocol::get(const QUrl &url)
{
get(url, TRIES_WITH_PASSWORDS);
}
void kio_krarcProtocol::get(const KUrl& url, int tries)
void kio_krarcProtocol::get(const QUrl &url, int tries)
{
bool decompressToFile = false;
KRDEBUG(getPath(url));
......@@ -420,7 +419,7 @@ void kio_krarcProtocol::get(const KUrl& url, int tries)
// for RPM files extract the cpio file first
if (!extArcReady && arcType == "rpm") {
KrLinecountingProcess cpio;
cpio << "rpm2cpio" << getPath(arcFile->url(), KUrl::RemoveTrailingSlash);
cpio << "rpm2cpio" << getPath(arcFile->url(), QUrl::StripTrailingSlash);
cpio.setStandardOutputFile(arcTempDir + "contents.cpio");
cpio.start();
......@@ -435,7 +434,7 @@ void kio_krarcProtocol::get(const KUrl& url, int tries)
// for DEB files extract the tar file first
if (!extArcReady && arcType == "deb") {
KrLinecountingProcess dpkg;
dpkg << cmd << "--fsys-tarfile" << getPath(arcFile->url(), KUrl::RemoveTrailingSlash);
dpkg << cmd << "--fsys-tarfile" << getPath(arcFile->url(), QUrl::StripTrailingSlash);
dpkg.setStandardOutputFile(arcTempDir + "contents.cpio");
dpkg.start();
......@@ -454,7 +453,7 @@ void kio_krarcProtocol::get(const KUrl& url, int tries)
if (extArcReady) {
proc << getCmd << arcTempDir + "contents.cpio" << '*' + localeEncodedString(file);
} else if (arcType == "arj" || arcType == "ace" || arcType == "7z") {
proc << getCmd << getPath(arcFile->url(), KUrl::RemoveTrailingSlash) << localeEncodedString(file);
proc << getCmd << getPath(arcFile->url(), QUrl::StripTrailingSlash) << localeEncodedString(file);
if (arcType == "ace" && QFile("/dev/ptmx").exists()) // Don't remove, unace crashes if missing!!!
proc.setStandardInputFile("/dev/ptmx");
file = url.fileName();
......@@ -590,7 +589,7 @@ void kio_krarcProtocol::get(const KUrl& url, int tries)
finished();
}
void kio_krarcProtocol::del(KUrl const & url, bool isFile)
void kio_krarcProtocol::del(QUrl const & url, bool isFile)
{
KRDEBUG(getPath(url));
......@@ -640,7 +639,7 @@ void kio_krarcProtocol::del(KUrl const & url, bool isFile)
finished();
}
void kio_krarcProtocol::stat(const KUrl & url)
void kio_krarcProtocol::stat(const QUrl &url)
{
KRDEBUG(getPath(url));
if (!setArcFile(url)) {
......@@ -657,11 +656,11 @@ void kio_krarcProtocol::stat(const KUrl & url)
i18n("Accessing files is not supported with %1 archives", arcType));
return;
}
QString path = getPath(url, KUrl::RemoveTrailingSlash);
KUrl newUrl = url;
QString path = getPath(url, QUrl::StripTrailingSlash);
QUrl newUrl = url;
// but treat the archive itself as the archive root
if (path == getPath(arcFile->url(), KUrl::RemoveTrailingSlash)) {
if (path == getPath(arcFile->url(), QUrl::StripTrailingSlash)) {
newUrl.setPath(path + DIR_SEPARATOR);
path = getPath(newUrl);
}
......@@ -684,7 +683,7 @@ void kio_krarcProtocol::stat(const KUrl & url)
} else error(KIO::ERR_DOES_NOT_EXIST, path);
}
void kio_krarcProtocol::copy(const KUrl &url, const KUrl &dest, int, KIO::JobFlags flags)
void kio_krarcProtocol::copy(const QUrl &url, const QUrl &dest, int, KIO::JobFlags flags)
{
kDebug() << "url:" << url << "dest:" << dest;
......@@ -724,7 +723,7 @@ void kio_krarcProtocol::copy(const KUrl &url, const KUrl &dest, int, KIO::JobFla
QString file = getPath(url).mid(getPath(arcFile->url()).length() + 1);
QString destDir = getPath(dest, KUrl::RemoveTrailingSlash);
QString destDir = getPath(dest, QUrl::StripTrailingSlash);
if (!QDir(destDir).exists()) {
int ndx = destDir.lastIndexOf(DIR_SEPARATOR_CHAR);
if (ndx != -1)
......@@ -738,7 +737,7 @@ void kio_krarcProtocol::copy(const KUrl &url, const KUrl &dest, int, KIO::JobFla
escapedFilename.replace("[", "[[]");
KrLinecountingProcess proc;
proc << copyCmd << getPath(arcFile->url(), KUrl::RemoveTrailingSlash) << escapedFilename;
proc << copyCmd << getPath(arcFile->url(), QUrl::StripTrailingSlash) << escapedFilename;
if (arcType == "ace" && QFile("/dev/ptmx").exists()) // Don't remove, unace crashes if missing!!!
proc.setStandardInputFile("/dev/ptmx");
proc.setOutputChannelMode(KProcess::SeparateChannels); // without this output redirection has no effect
......@@ -747,11 +746,11 @@ void kio_krarcProtocol::copy(const KUrl &url, const KUrl &dest, int, KIO::JobFla
proc.start();
proc.waitForFinished();
if (proc.exitStatus() != QProcess::NormalExit || !checkStatus(proc.exitCode())) {
error(KIO::ERR_COULD_NOT_WRITE, getPath(dest, KUrl::RemoveTrailingSlash) + "\n\n" + proc.getErrorMsg());
error(KIO::ERR_COULD_NOT_WRITE, getPath(dest, QUrl::StripTrailingSlash) + "\n\n" + proc.getErrorMsg());
return;
}
if (!QFileInfo(getPath(dest, KUrl::RemoveTrailingSlash)).exists()) {
error(KIO::ERR_COULD_NOT_WRITE, getPath(dest, KUrl::RemoveTrailingSlash));
if (!QFileInfo(getPath(dest, QUrl::StripTrailingSlash)).exists()) {
error(KIO::ERR_COULD_NOT_WRITE, getPath(dest, QUrl::StripTrailingSlash));
return;
}
......@@ -770,7 +769,7 @@ void kio_krarcProtocol::copy(const KUrl &url, const KUrl &dest, int, KIO::JobFla
//error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_COPY));
}
void kio_krarcProtocol::listDir(const KUrl& url)
void kio_krarcProtocol::listDir(const QUrl &url)
{
KRDEBUG(getPath(url));
if (!setArcFile(url)) {
......@@ -788,7 +787,7 @@ void kio_krarcProtocol::listDir(const KUrl& url)
// it might be a real dir !
if (QFileInfo(path).exists()) {
if (QFileInfo(path).isDir()) {
KUrl redir;
QUrl redir;
redir.setPath(getPath(url));
redirection(redir);
finished();
......@@ -815,7 +814,7 @@ void kio_krarcProtocol::listDir(const KUrl& url)
finished();
}
bool kio_krarcProtocol::setArcFile(const KUrl& url)
bool kio_krarcProtocol::setArcFile(const QUrl &url)
{
kDebug() << url;
......@@ -824,7 +823,7 @@ bool kio_krarcProtocol::setArcFile(const KUrl& url)
archiveChanged = true;
newArchiveURL = true;
// is the file already set ?
if (arcFile && getPath(arcFile->url(), KUrl::RemoveTrailingSlash) == path.left(getPath(arcFile->url(), KUrl::RemoveTrailingSlash).length())) {
if (arcFile && getPath(arcFile->url(), QUrl::StripTrailingSlash) == path.left(getPath(arcFile->url(), QUrl::StripTrailingSlash).length())) {
newArchiveURL = false;
// Has it changed ?
KFileItem* newArcFile = new KFileItem(arcFile->url(), QString(), arcFile->mode());
......@@ -859,7 +858,7 @@ bool kio_krarcProtocol::setArcFile(const KUrl& url)
if (qfi.exists() && !qfi.isDir()) {
KDE_struct_stat stat_p;
KDE_lstat(newPath.left(pos).toLocal8Bit(), &stat_p);
arcFile = new KFileItem(KUrl(newPath.left(pos)), QString(), stat_p.st_mode);
arcFile = new KFileItem(QUrl::fromLocalFile(newPath.left(pos)), QString(), stat_p.st_mode);
break;
}
}
......@@ -886,7 +885,7 @@ bool kio_krarcProtocol::setArcFile(const KUrl& url)
archiveChanged = true;
archiveChanging = (currTime == (time_t)arcFile->time(KFileItem::ModificationTime).toTime_t());
arcPath = getPath(arcFile->url(), KUrl::RemoveTrailingSlash);
arcPath = getPath(arcFile->url(), QUrl::StripTrailingSlash);
arcType = detectArchive(encrypted, arcPath);
if (arcType == "tbz")
......@@ -909,7 +908,7 @@ bool kio_krarcProtocol::setArcFile(const KUrl& url)
return initArcParameters();
}
bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced)
bool kio_krarcProtocol::initDirDict(const QUrl &url, bool forced)
{
KRDEBUG(getPath(url));
// set the archive location
......@@ -941,7 +940,7 @@ bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced)
proc << listCmd << arcPath;
proc.setStandardOutputFile(temp.fileName());
} else {
proc << listCmd << getPath(arcFile->url(), KUrl::RemoveTrailingSlash);
proc << listCmd << getPath(arcFile->url(), QUrl::StripTrailingSlash);
proc.setStandardOutputFile(temp.fileName());
}
if (arcType == "ace" && QFile("/dev/ptmx").exists()) // Don't remove, unace crashes if missing!!!
......@@ -1038,7 +1037,7 @@ bool kio_krarcProtocol::initDirDict(const KUrl&url, bool forced)
return true;
}
QString kio_krarcProtocol::findArcDirectory(const KUrl& url)
QString kio_krarcProtocol::findArcDirectory(const QUrl &url)
{
kDebug() << url;
......@@ -1055,7 +1054,7 @@ QString kio_krarcProtocol::findArcDirectory(const KUrl& url)
return arcDir;
}
UDSEntry* kio_krarcProtocol::findFileEntry(const KUrl& url)
UDSEntry* kio_krarcProtocol::findFileEntry(const QUrl &url)
{
QString arcDir = findArcDirectory(url);
if (arcDir.isEmpty()) return 0;
......@@ -1066,7 +1065,7 @@ UDSEntry* kio_krarcProtocol::findFileEntry(const KUrl& url)
UDSEntryList* dirList = itef.value();
QString name = getPath(url);
if (getPath(arcFile->url(), KUrl::RemoveTrailingSlash) == getPath(url, KUrl::RemoveTrailingSlash)) name = '.'; // the '/' case
if (getPath(arcFile->url(), QUrl::StripTrailingSlash) == getPath(url, QUrl::StripTrailingSlash)) name = '.'; // the '/' case
else {
if (name.right(1) == DIR_SEPARATOR) name.truncate(name.length() - 1);
name = name.mid(name.lastIndexOf(DIR_SEPARATOR) + 1);
......@@ -1851,7 +1850,7 @@ void kio_krarcProtocol::checkOutputForPassword(KProcess * proc, QByteArray & buf
void kio_krarcProtocol::invalidatePassword()
{
KRDEBUG(getPath(arcFile->url(), KUrl::RemoveTrailingSlash) + DIR_SEPARATOR);
KRDEBUG(getPath(arcFile->url(), QUrl::StripTrailingSlash) + DIR_SEPARATOR);
if (!encrypted)
return;
......@@ -1862,8 +1861,8 @@ void kio_krarcProtocol::invalidatePassword()
authInfo.readOnly = true;
authInfo.keepPassword = true;
authInfo.verifyPath = true;
QString fileName = getPath(arcFile->url(), KUrl::RemoveTrailingSlash);
authInfo.url = KUrl(ROOT_DIR);
QString fileName = getPath(arcFile->url(), QUrl::StripTrailingSlash);
authInfo.url = QUrl::fromLocalFile(ROOT_DIR);
authInfo.url.setHost(fileName /*.replace('/','_')*/);
authInfo.url.setScheme("krarc");
......@@ -1887,8 +1886,8 @@ QString kio_krarcProtocol::getPassword()
authInfo.readOnly = true;
authInfo.keepPassword = true;
authInfo.verifyPath = true;
QString fileName = getPath(arcFile->url(), KUrl::RemoveTrailingSlash);
authInfo.url = KUrl(ROOT_DIR);
QString fileName = getPath(arcFile->url(), QUrl::StripTrailingSlash);
authInfo.url = QUrl::fromLocalFile(ROOT_DIR);
authInfo.url.setHost(fileName /*.replace('/','_')*/);
authInfo.url.setScheme("krarc");
......@@ -1967,9 +1966,9 @@ QString kio_krarcProtocol::decodeString(char * buf)
return codec->toUnicode(buf);
}
QString kio_krarcProtocol::getPath(const KUrl & url, KUrl::AdjustPathOption trailing)
QString kio_krarcProtocol::getPath(const QUrl &url, QUrl::FormattingOptions options)
{
QString path = url.path(trailing);
QString path = url.adjusted(options).path();
REPLACE_DIR_SEP2(path);
#ifdef Q_WS_WIN
......
......@@ -22,9 +22,7 @@
#include <QtCore/QString>
#include <QtCore/QHash>
#include <QtCore/QFile>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KUrl>
#include <QtCore/QUrl>
#include <KIO/Global>
#include <KIO/SlaveBase>
......@@ -41,27 +39,27 @@ class kio_krarcProtocol : public QObject, public KIO::SlaveBase
public:
kio_krarcProtocol(const QByteArray &pool_socket, const QByteArray &app_socket);
virtual ~kio_krarcProtocol();
virtual void stat(const KUrl & url);
virtual void get(const KUrl& url);
virtual void put(const KUrl& url, int permissions, KIO::JobFlags flags);
virtual void mkdir(const KUrl& url, int permissions);
virtual void listDir(const KUrl& url);
virtual void del(KUrl const & url, bool isFile);
virtual void copy(const KUrl &src, const KUrl &dest, int permissions, KIO::JobFlags flags);
virtual void stat(const QUrl &url);
virtual void get(const QUrl &url);
virtual void put(const QUrl &url, int permissions, KIO::JobFlags flags);
virtual void mkdir(const QUrl &url, int permissions);
virtual void listDir(const QUrl &url);
virtual void del(QUrl const & url, bool isFile);
virtual void copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags);
public slots:
void receivedData(KProcess *, QByteArray &);
void checkOutputForPassword(KProcess *, QByteArray &);
protected:
virtual bool initDirDict(const KUrl& url, bool forced = false);
virtual bool initDirDict(const QUrl &url, bool forced = false);
virtual bool initArcParameters();
QString detectArchive(bool &encrypted, QString fileName);
virtual void parseLine(int lineNo, QString line);
virtual bool setArcFile(const KUrl& url);
virtual bool setArcFile(const QUrl &url);
virtual QString getPassword();
virtual void invalidatePassword();
QString getPath(const KUrl & url, KUrl::AdjustPathOption trailing = KUrl::LeaveTrailingSlash);
QString getPath(const QUrl &url, QUrl::FormattingOptions options = 0);
QString localeEncodedString(QString str);
QByteArray encodeString(QString);
......@@ -76,7 +74,7 @@ protected:
QStringList copyCmd; ///< copy to file command.
private:
void get(const KUrl& url, int tries);
void get(const QUrl &url, int tries);
/** checks if the exit code is OK. */
bool checkStatus(int exitCode);
/** service function for parseLine. */
......@@ -84,9 +82,9 @@ private:
/** translate permittion string to mode_t. */
mode_t parsePermString(QString perm);
/** return the name of the directory inside the archive. */
QString findArcDirectory(const KUrl& url);
QString findArcDirectory(const QUrl &url);
/** find the UDSEntry of a file in a directory. */
KIO::UDSEntry* findFileEntry(const KUrl& url);
KIO::UDSEntry* findFileEntry(const QUrl &url);
/** add a new directory (file list container). */
KIO::UDSEntryList* addNewDir(QString path);
QString fullPathName(QString name);
......
......@@ -33,7 +33,7 @@
#include <KIconThemes/KIconLoader>
KrAddBookmarkDlg::KrAddBookmarkDlg(QWidget *parent, KUrl url):
KrAddBookmarkDlg::KrAddBookmarkDlg(QWidget *parent, QUrl url):
KDialog(parent)
{
setButtons(KDialog::User1 | KDialog::Ok | KDialog::Cancel);
......@@ -57,7 +57,7 @@ KrAddBookmarkDlg::KrAddBookmarkDlg(QWidget *parent, KUrl url):
// name and url
QLabel *lb1 = new QLabel(i18n("Name:"), page);
_name = new KLineEdit(page);
_name->setText(url.prettyUrl()); // default name is the url
_name->setText(url.toDisplayString()); // default name is the url
_name->selectAll(); // make the text selected
layout->addWidget(lb1, 0, 0);
layout->addWidget(_name, 0, 1);
......@@ -66,7 +66,7 @@ KrAddBookmarkDlg::KrAddBookmarkDlg(QWidget *parent, KUrl url):
_url = new KLineEdit(page);
layout->addWidget(lb2, 1, 0);
layout->addWidget(_url, 1, 1);
_url->setText(url.prettyUrl()); // set the url in the field
_url->setText(url.toDisplayString()); // set the url in the field
// create in linedit and button
QLabel *lb3 = new QLabel(i18n("Create in:"), page);
......
......@@ -24,12 +24,12 @@
#include "../VFS/vfs.h"
#include "../GUI/krtreewidget.h"
#include <QtWidgets/QToolButton>
#include <QtCore/QMap>
#include <QtCore/QUrl>
#include <QtWidgets/QToolButton>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KDialog>
#include <KDE/KUrl>
#include <KCompletion/KLineEdit>
......@@ -37,9 +37,9 @@ class KrAddBookmarkDlg: public KDialog
{
Q_OBJECT
public:
KrAddBookmarkDlg(QWidget *parent, KUrl url = KUrl());
KUrl url() const {
return KUrl(_url->text());
KrAddBookmarkDlg(QWidget *parent, QUrl url = QUrl());
QUrl url() const {
return QUrl::fromUserInput(_url->text(), QString(), QUrl::AssumeLocalFile);
}
QString name() const {
return _name->text();
......
......@@ -36,7 +36,7 @@ static const char* NAME_TRASH = I18N_NOOP("Trash bin");
static const char* NAME_VIRTUAL = I18N_NOOP("Virtual Filesystem");
static const char* NAME_LAN = I18N_NOOP("Local Network");
KrBookmark::KrBookmark(QString name, KUrl url, KActionCollection *parent, QString icon, QString actionName) :
KrBookmark::KrBookmark(QString name, QUrl url, KActionCollection *parent, QString icon, QString actionName) :
QAction(parent), _url(url), _icon(icon), _folder(false), _separator(false), _autoDelete(true)
{
QString actName = actionName.isNull() ? BM_NAME(name) : BM_NAME(actionName);
......@@ -84,7 +84,7 @@ KrBookmark* KrBookmark::trash(KActionCollection *collection)
{
KrBookmark *bm = getExistingBookmark(i18n(NAME_TRASH), collection);
if (!bm)
bm = new KrBookmark(i18n(NAME_TRASH), KUrl("trash:/"), collection);
bm = new KrBookmark(i18n(NAME_TRASH), QUrl("trash:/"), collection);
bm->setIcon(krLoader->loadIcon(KrTrashHandler::trashIcon(), KIconLoader::Small));
return bm;
......@@ -94,7 +94,7 @@ KrBookmark* KrBookmark::virt(KActionCollection *collection)
{
KrBookmark *bm = getExistingBookmark(i18n(NAME_VIRTUAL), collection);
if (!bm) {
bm = new KrBookmark(i18n(NAME_VIRTUAL), KUrl("virt:/"), collection);
bm = new KrBookmark(i18n(NAME_VIRTUAL), QUrl("virt:/"), collection);
bm->setIcon(krLoader->loadIcon("inode-fifo", KIconLoader::Small));
}
return bm;
......@@ -104,7 +104,7 @@ KrBookmark* KrBookmark::lan(KActionCollection *collection)
{
KrBookmark *bm = getExistingBookmark(i18n(NAME_LAN), collection);
if (!bm) {
bm = new KrBookmark(i18n(NAME_LAN), KUrl("remote:/"), collection);
bm = new KrBookmark(i18n(NAME_LAN), QUrl("remote:/"), collection);
bm->setIcon(krLoader->loadIcon("network-wired", KIconLoader::Small));
}
return bm;
......
......@@ -21,10 +21,9 @@
#define KRBOOKMARK_H
#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtWidgets/QAction>
// TODO KF5 - these headers are from deprecated KDE4LibsSupport : remove them
#include <KDE/KUrl>
class KActionCollection;
......@@ -32,7 +31,7 @@ class KrBookmark: public QAction
{
Q_OBJECT
public:
KrBookmark(QString name, KUrl url, KActionCollection *parent, QString icon = "", QString actionName = QString());