Commit b6304bcc authored by Kurt Hindenburg's avatar Kurt Hindenburg

Port KUrl to QUrl

Thanks to Michal Humpula michal humpula hudrydum cz

REVIEW: 120430
parent f2723204
......@@ -33,7 +33,6 @@
#include <KBookmarkOwner>
#include <KStandardDirs>
#include <KLocalizedString>
#include <KMenu>
// Konsole
#include "ViewProperties.h"
......@@ -107,7 +106,7 @@ QString BookmarkHandler::currentTitle() const
QString BookmarkHandler::titleForView(ViewProperties* view) const
{
const KUrl& url = view ? view->url() : KUrl();
const QUrl& url = view ? view->url() : QUrl();
if (url.isLocalFile()) {
QString path = url.path();
......@@ -115,14 +114,14 @@ QString BookmarkHandler::titleForView(ViewProperties* view) const
path = QFileInfo(path).baseName();
return path;
} else if (url.hasHost()) {
if (url.hasUser())
return i18nc("@item:inmenu The user's name and host they are connected to via ssh", "%1 on %2", url.user(), url.host());
} else if (!url.host().isEmpty()) {
if (!url.userName().isEmpty())
return i18nc("@item:inmenu The user's name and host they are connected to via ssh", "%1 on %2", url.userName(), url.host());
else
return i18nc("@item:inmenu The host the user is connected to via ssh", "%1", url.host());
}
return url.prettyUrl();
return url.toDisplayString();
}
QString BookmarkHandler::currentIcon() const
......
......@@ -26,7 +26,8 @@
// KDE
#include <KBookmarkManager>
#include <KUrl>
#include <QtCore/QUrl>
// Konsole
#include "konsole_export.h"
......@@ -99,7 +100,7 @@ signals:
*
* @param url The url of the bookmark which was selected by the user.
*/
void openUrl(const KUrl& url);
void openUrl(const QUrl& url);
/**
* Emitted when the user selects 'Open Folder in Tabs'
......
......@@ -25,6 +25,7 @@
#include <QtCore/QFileInfo>
#include <QCompleter>
#include <QFileSystemModel>
#include <QtCore/QUrl>
// KDE
#include <KColorDialog>
......@@ -32,7 +33,6 @@
#include <KFileDialog>
#include <KUrlCompletion>
#include <KIcon>
#include <KUrl>
#include <KLocalizedString>
// Konsole
......@@ -165,7 +165,7 @@ void ColorSchemeEditor::editColorItem(QTableWidgetItem* item)
}
void ColorSchemeEditor::selectWallpaper()
{
const KUrl url = KFileDialog::getImageOpenUrl(KUrl(_ui->wallpaperPath->text()),
const QUrl url = KFileDialog::getImageOpenUrl(QUrl::fromUserInput(_ui->wallpaperPath->text()),
this,
i18nc("@action:button", "Select wallpaper image file"));
......
......@@ -33,6 +33,7 @@
#include <QtCore/QTimer>
#include <QCompleter>
#include <QFileSystemModel>
#include <QtCore/QUrl>
// KDE
#include <kdeversion.h>
......@@ -50,7 +51,6 @@
#include <KWindowSystem>
#include <KTextEdit>
#include <KMessageBox>
#include <KUrl>
#include <KLocalizedString>
// Konsole
......@@ -428,7 +428,7 @@ void EditProfileDialog::commandChanged(const QString& command)
}
void EditProfileDialog::selectInitialDir()
{
const KUrl url = KFileDialog::getExistingDirectoryUrl(KUrl(_ui->initialDirEdit->text()),
const QUrl url = KFileDialog::getExistingDirectoryUrl(QUrl::fromUserInput(_ui->initialDirEdit->text()),
this,
i18n("Select Initial Directory"));
......
......@@ -26,11 +26,11 @@
#include <QtGui/QClipboard>
#include <QtCore/QString>
#include <QtCore/QTextStream>
#include <QtCore/QUrl>
// KDE
#include <KLocalizedString>
#include <KRun>
#include <KUrl>
// Konsole
#include "TerminalCharacterDecoder.h"
......@@ -420,7 +420,7 @@ void UrlFilter::HotSpot::activate(QObject* object)
url.prepend("mailto:");
}
new KRun(KUrl(url), QApplication::activeWindow());
new KRun(QUrl(url), QApplication::activeWindow());
}
}
......
......@@ -442,11 +442,11 @@ void MainWindow::openUrls(const QList<QUrl>& urls)
{
Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile();
foreach(const KUrl& url, urls) {
Q_FOREACH (auto url, urls) {
if (url.isLocalFile())
createSession(defaultProfile, url.path());
else if (url.protocol() == "ssh")
else if (url.scheme() == "ssh")
createSSHSession(defaultProfile, url);
}
}
......@@ -493,7 +493,7 @@ Session* MainWindow::createSession(Profile::Ptr profile, const QString& director
return session;
}
Session* MainWindow::createSSHSession(Profile::Ptr profile, const KUrl& url)
Session* MainWindow::createSSHSession(Profile::Ptr profile, const QUrl& url)
{
if (!profile)
profile = ProfileManager::instance()->defaultProfile();
......@@ -504,10 +504,10 @@ Session* MainWindow::createSSHSession(Profile::Ptr profile, const KUrl& url)
if (url.port() > -1) {
sshCommand += QString("-p %1 ").arg(url.port());
}
if (url.hasUser()) {
sshCommand += (url.user() + '@');
if (!url.userName().isEmpty()) {
sshCommand += (url.userName() + '@');
}
if (url.hasHost()) {
if (!url.host().isEmpty()) {
sshCommand += url.host();
}
......@@ -742,7 +742,7 @@ void MainWindow::setNavigationBehavior(int behavior)
_viewManager->setNavigationBehavior(behavior);
}
void MainWindow::setNavigationStyleSheetFromFile(const KUrl& styleSheetFile)
void MainWindow::setNavigationStyleSheetFromFile(const QUrl& styleSheetFile)
{
// Let's only deal w/ local files for now
if (!styleSheetFile.isLocalFile()) {
......
......@@ -22,10 +22,10 @@
// Qt
#include <QtCore/QPointer>
#include <QtCore/QUrl>
// KDE
#include <KXmlGuiWindow>
#include <KUrl>
// Konsole
#include "Profile.h"
......@@ -86,7 +86,7 @@ public:
* @param profile The profile to use to create the new session.
* @param url the URL representing the new SSH connection
*/
Session* createSSHSession(Profile::Ptr profile, const KUrl& url);
Session* createSSHSession(Profile::Ptr profile, const QUrl& url);
/**
* create view for the specified session
......@@ -106,7 +106,7 @@ public:
void setNavigationVisibility(int visibility);
void setNavigationPosition(int position);
void setNavigationStyleSheet(const QString& stylesheet);
void setNavigationStyleSheetFromFile(const KUrl& stylesheetfile);
void setNavigationStyleSheetFromFile(const QUrl& stylesheetfile);
void setNavigationBehavior(int behavior);
void setShowQuickButtons(bool show);
......
......@@ -24,13 +24,13 @@
#include <QtCore/QStringList>
#include <QtCore/QDir>
#include <QtGui/QKeyEvent>
#include <QtCore/QUrl>
// KDE
#include <KAction>
#include <KActionCollection>
#include <KLocale>
#include <KPluginFactory>
#include <KUrl>
#include <KGlobal>
#include <KLocalizedString>
#include <kde_file.h>
......@@ -322,7 +322,7 @@ void Part::changeSessionSettings(const QString& text)
// Konqueror integration
bool Part::openUrl(const QUrl& aQUrl)
{
KUrl aUrl = aQUrl;
QUrl aUrl = aQUrl;
if (url() == aUrl) {
emit completed();
......@@ -330,14 +330,14 @@ bool Part::openUrl(const QUrl& aQUrl)
}
setUrl(aUrl);
emit setWindowCaption(aUrl.pathOrUrl());
emit setWindowCaption(aUrl.toDisplayString(QUrl::PreferLocalFile));
//kdDebug() << "Set Window Caption to " << url.pathOrUrl();
emit started(0);
if (aUrl.isLocalFile() /*&& b_openUrls*/) {
KDE_struct_stat buff;
if (KDE::stat(QFile::encodeName(aUrl.path()), &buff) == 0) {
QString text = (S_ISDIR(buff.st_mode) ? aUrl.path() : aUrl.directory());
QString text = (S_ISDIR(buff.st_mode) ? aUrl.path() : aUrl.adjusted(QUrl::StripTrailingSlash).path());
showShellInDir(text);
} else {
showShellInDir(QDir::homePath());
......
......@@ -33,7 +33,6 @@
class QAction;
class QStringList;
class QKeyEvent;
class KUrl;
namespace Konsole
{
......
......@@ -1000,7 +1000,7 @@ QString Session::getDynamicTitle()
return title;
}
KUrl Session::getUrl()
QUrl Session::getUrl()
{
QString path;
......@@ -1033,7 +1033,7 @@ KUrl Session::getUrl()
}
}
return KUrl(path);
return QUrl(path);
}
void Session::setIconName(const QString& iconName)
......
......@@ -32,9 +32,7 @@
#include <QtCore/QSize>
#include <QtCore/QProcess>
#include <QWidget>
// KDE
#include <KUrl>
#include <QtCore/QUrl>
// Konsole
#include "konsole_export.h"
......@@ -263,7 +261,7 @@ public:
QString iconName() const;
/** Return URL for the session. */
KUrl getUrl();
QUrl getUrl();
/** Sets the text of the icon associated with this session. */
void setIconText(const QString& iconText);
......
......@@ -29,6 +29,7 @@
#include <QPrintDialog>
#include <QPainter>
#include <QStandardPaths>
#include <QtCore/QUrl>
// KDE
#include <KAction>
......@@ -44,7 +45,6 @@
#include <KStandardDirs>
#include <KToggleAction>
#include <KSelectAction>
#include <KUrl>
#include <KXmlGuiWindow>
#include <KXMLGUIFactory>
#include <KXMLGUIBuilder>
......@@ -292,7 +292,7 @@ QString SessionController::currentDir() const
return _session->currentWorkingDirectory();
}
KUrl SessionController::url() const
QUrl SessionController::url() const
{
return _session->getUrl();
}
......@@ -302,7 +302,7 @@ void SessionController::rename()
renameSession();
}
void SessionController::openUrl(const KUrl& url)
void SessionController::openUrl(const QUrl& url)
{
// Clear shell's command line
if (!_session->isForegroundProcessActive()
......@@ -315,34 +315,34 @@ void SessionController::openUrl(const KUrl& url)
if (url.isLocalFile()) {
QString path = url.toLocalFile();
_session->emulation()->sendText("cd " + KShell::quoteArg(path) + '\r');
} else if (url.protocol().isEmpty()) {
// KUrl couldn't parse what the user entered into the URL field
} else if (url.scheme().isEmpty()) {
// QUrl couldn't parse what the user entered into the URL field
// so just dump it to the shell
QString command = url.prettyUrl();
QString command = url.toDisplayString();
if (!command.isEmpty())
_session->emulation()->sendText(command + '\r');
} else if (url.protocol() == "ssh") {
} else if (url.scheme() == "ssh") {
QString sshCommand = "ssh ";
if (url.port() > -1) {
sshCommand += QString("-p %1 ").arg(url.port());
}
if (url.hasUser()) {
sshCommand += (url.user() + '@');
if (!url.userName().isEmpty()) {
sshCommand += (url.userName() + '@');
}
if (url.hasHost()) {
if (!url.host().isEmpty()) {
sshCommand += url.host();
}
_session->sendText(sshCommand + '\r');
} else if (url.protocol() == "telnet") {
} else if (url.scheme() == "telnet") {
QString telnetCommand = "telnet ";
if (url.hasUser()) {
telnetCommand += QString("-l %1 ").arg(url.user());
if (!url.userName().isEmpty()) {
telnetCommand += QString("-l %1 ").arg(url.userName());
}
if (url.hasHost()) {
if (!url.host().isEmpty()) {
telnetCommand += (url.host() + ' ');
}
if (url.port() > -1) {
......@@ -356,10 +356,10 @@ void SessionController::openUrl(const KUrl& url)
KMessageBox::sorry(_view->window(),
i18n("Konsole does not know how to open the bookmark: ") +
url.prettyUrl());
url.toDisplayString());
kWarning() << "Unable to open bookmark at url" << url << ", I do not know"
<< " how to handle the protocol " << url.protocol();
<< " how to handle the protocol " << url.scheme();
}
}
......@@ -446,7 +446,7 @@ void SessionController::handleWebShortcutAction()
KUriFilterData filterData(action->data().toString());
if (KUriFilter::self()->filterUri(filterData, QStringList() << "kurisearchfilter")) {
const KUrl& url = filterData.uri();
const QUrl& url = filterData.uri();
new KRun(url, QApplication::activeWindow());
}
}
......@@ -932,7 +932,7 @@ void SessionController::closeSession()
// 2) transform url to get the desired result (ssh -> sftp, etc)
void SessionController::openBrowser()
{
KUrl currentUrl = url();
const QUrl currentUrl = url();
if (currentUrl.isLocalFile()) {
new KRun(currentUrl, QApplication::activeWindow(), true);
......@@ -1603,7 +1603,7 @@ void SessionController::zmodemDownload()
}
if (!zmodem.isEmpty()) {
const QString path = KFileDialog::getExistingDirectory(
KUrl(), _view,
QUrl(), _view,
i18n("Save ZModem Download to..."));
if (!path.isEmpty()) {
......@@ -1638,7 +1638,7 @@ void SessionController::zmodemUpload()
return;
}
QStringList files = KFileDialog::getOpenFileNames(KUrl(), QString(), _view,
QStringList files = KFileDialog::getOpenFileNames(QUrl(), QString(), _view,
i18n("Select Files for ZModem Upload"));
if (!files.isEmpty()) {
_session->startZModem(zmodem, QString(), files);
......@@ -1692,7 +1692,7 @@ void SaveHistoryTask::execute()
// TODO - show a warning ( preferably passive ) if saving the history output fails
//
KFileDialog* dialog = new KFileDialog(KUrl(QString(":konsole")) /* check this */,
KFileDialog* dialog = new KFileDialog(QUrl(QString(":konsole")) /* check this */,
QString(), QApplication::activeWindow());
dialog->setOperationMode(KFileDialog::Saving);
dialog->setConfirmOverwrite(true);
......@@ -1713,7 +1713,7 @@ void SaveHistoryTask::execute()
if (result != QDialog::Accepted)
continue;
KUrl url = dialog->selectedUrl();
QUrl url = dialog->selectedUrl();
if (!url.isValid()) {
// UI: Can we make this friendlier?
......
......@@ -45,9 +45,9 @@ class QAction;
class QTextCodec;
class QKeyEvent;
class QTimer;
class QUrl;
class KCodecAction;
class KUrl;
class KJob;
class KAction;
class KActionMenu;
......@@ -155,7 +155,7 @@ public:
EditProfileDialog* profileDialogPointer();
// reimplemented
virtual KUrl url() const;
virtual QUrl url() const;
virtual QString currentDir() const;
virtual void rename();
virtual bool confirmClose() const;
......@@ -195,7 +195,7 @@ public slots:
* openUrl() currently supports urls for local paths and those
* using the 'ssh' protocol ( eg. "ssh://joebloggs@hostname" )
*/
void openUrl(const KUrl& url);
void openUrl(const QUrl& url);
/**
* update actions which are meaningful only when primary screen is in use.
......
......@@ -3127,12 +3127,12 @@ void TerminalDisplay::dragEnterEvent(QDragEnterEvent* event)
void TerminalDisplay::dropEvent(QDropEvent* event)
{
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
auto urls = event->mimeData()->urls();
QString dropText;
if (!urls.isEmpty()) {
for (int i = 0 ; i < urls.count() ; i++) {
KUrl url = KIO::NetAccess::mostLocalUrl(urls[i] , 0);
QUrl url = KIO::NetAccess::mostLocalUrl(urls[i] , 0);
QString urlText;
if (url.isLocalFile())
......@@ -3165,7 +3165,7 @@ void TerminalDisplay::dropEvent(QDropEvent* event)
additionalActions.append(pasteAction);
if (urls.count() == 1) {
const KUrl url = KIO::NetAccess::mostLocalUrl(urls[0] , 0);
const QUrl url = KIO::NetAccess::mostLocalUrl(urls[0] , 0);
if (url.isLocalFile()) {
const QFileInfo fileInfo(url.path());
......@@ -3180,7 +3180,7 @@ void TerminalDisplay::dropEvent(QDropEvent* event)
}
}
KUrl target(_sessionController->currentDir());
QUrl target = QUrl::fromLocalFile(_sessionController->currentDir());
KonqOperations::doDrop(KFileItem(), target, event, this, additionalActions);
......
......@@ -39,9 +39,9 @@ ViewProperties* ViewProperties::propertiesById(int id)
{
return _viewProperties[id];
}
KUrl ViewProperties::url() const
QUrl ViewProperties::url() const
{
return KUrl();
return QUrl();
}
QString ViewProperties::currentDir() const
{
......
......@@ -25,9 +25,7 @@
#include <QtCore/QObject>
#include <QtCore/QHash>
#include <QtCore/QMimeData>
// KDE
#include <KUrl>
#include <QtCore/QUrl>
// Konsole
#include "konsole_export.h"
......@@ -58,7 +56,7 @@ public:
* Returns the URL current associated with a view.
* The default implementation returns an empty URL.
*/
virtual KUrl url() const;
virtual QUrl url() const;
/**
* Returns the current directory associated with a view.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment