Commit 8a79e6b8 authored by Michal Humpula's avatar Michal Humpula

migrate from KUrl to QUrl

REVIEW: 114485
parent aa7fdeb3
......@@ -327,12 +327,12 @@ KateSessionManager *KateApp::sessionManager ()
return m_sessionManager;
}
bool KateApp::openUrl (const KUrl &url, const QString &encoding, bool isTempFile)
bool KateApp::openUrl (const QUrl &url, const QString &encoding, bool isTempFile)
{
return openDocUrl(url,encoding,isTempFile);
}
KTextEditor::Document* KateApp::openDocUrl (const KUrl &url, const QString &encoding, bool isTempFile)
KTextEditor::Document* KateApp::openDocUrl (const QUrl &url, const QString &encoding, bool isTempFile)
{
KateMainWindow *mainWindow = activeMainWindow ();
......@@ -382,7 +382,7 @@ bool KateApp::setCursor (int line, int column)
bool KateApp::openInput (const QString &text)
{
activeMainWindow()->viewManager()->openUrl( KUrl(), "", true );
activeMainWindow()->viewManager()->openUrl( QUrl(), "", true );
if (!activeMainWindow()->viewManager()->activeView ())
return false;
......
......@@ -201,9 +201,9 @@ class KATEINTERFACES_EXPORT KateApp : public QObject
* @param encoding encoding name
* @return success
*/
bool openUrl (const KUrl &url, const QString &encoding, bool isTempFile);
bool openUrl (const QUrl &url, const QString &encoding, bool isTempFile);
KTextEditor::Document* openDocUrl (const KUrl &url, const QString &encoding, bool isTempFile);
KTextEditor::Document* openDocUrl (const QUrl &url, const QString &encoding, bool isTempFile);
void emitDocumentClosed(const QString& token);
......
......@@ -152,13 +152,13 @@ bool KateAppCommands::exec(KTextEditor::View *view, const QString &cmd, QString
if (argument.isEmpty() || argument == "!") {
view->document()->documentReload();
} else {
KUrl base = mainWin->activeDocumentUrl();
KUrl url;
KUrl arg2path(argument);
QUrl base = mainWin->activeDocumentUrl();
QUrl url;
QUrl arg2path(argument);
if (base.isValid()) { // first try to use the same path as the current open document has
url = KUrl(base.resolved(arg2path)); //resolved handles the case where the args is a relative path, and is the same as using KUrl(args) elsewise
url = QUrl(base.resolved(arg2path)); //resolved handles the case where the args is a relative path, and is the same as using QUrl(args) elsewise
} else { // else use the cwd
url = KUrl(KUrl(QDir::currentPath() + "/").resolved(arg2path)); // + "/" is needed because of http://lists.qt.nokia.com/public/qt-interest/2011-May/033913.html
url = QUrl(QUrl(QDir::currentPath() + "/").resolved(arg2path)); // + "/" is needed because of http://lists.qt.nokia.com/public/qt-interest/2011-May/033913.html
}
QFileInfo file( url.toLocalFile() );
KTextEditor::Document *doc = KateDocManager::self()->findDocument( url );
......@@ -167,7 +167,7 @@ bool KateAppCommands::exec(KTextEditor::View *view, const QString &cmd, QString
} else if (file.exists()) {
mainWin->viewManager()->openUrl( url, QString(), true );
} else {
mainWin->viewManager()->openUrl( KUrl(), QString(), true )->saveAs ( url );
mainWin->viewManager()->openUrl( QUrl(), QString(), true )->saveAs ( url );
}
}
}
......
......@@ -200,10 +200,9 @@ uint KateDocManager::documents ()
return m_docList.count ();
}
KTextEditor::Document *KateDocManager::findDocument (const KUrl &url) const
KTextEditor::Document *KateDocManager::findDocument (const QUrl &url) const
{
KUrl u(url);
u.cleanPath();
QUrl u( url.adjusted(QUrl::NormalizePathSegments) );
foreach (KTextEditor::Document* it, m_docList)
{
......@@ -214,16 +213,16 @@ KTextEditor::Document *KateDocManager::findDocument (const KUrl &url) const
return 0;
}
bool KateDocManager::isOpen(KUrl url)
bool KateDocManager::isOpen(QUrl url)
{
// return just if we found some document with this url
return findDocument (url) != 0;
}
KTextEditor::Document *KateDocManager::openUrl (const KUrl& url, const QString &encoding, bool isTempFile, const KateDocumentInfo& docInfo)
KTextEditor::Document *KateDocManager::openUrl (const QUrl& url, const QString &encoding, bool isTempFile, const KateDocumentInfo& docInfo)
{
KUrl u(url);
u.cleanPath();
QUrl u( url.adjusted(QUrl::NormalizePathSegments) );
// special handling if still only the first initial doc is there
if (!documentList().isEmpty() && (documentList().count() == 1) && (!documentList().at(0)->isModified() && documentList().at(0)->url().isEmpty()))
{
......@@ -249,7 +248,7 @@ KTextEditor::Document *KateDocManager::openUrl (const KUrl& url, const QString &
if ( fi.exists() )
{
m_tempFiles[ doc] = qMakePair(u, fi.lastModified());
kDebug(13001) << "temporary file will be deleted after use unless modified: " << u.pathOrUrl();
kDebug(13001) << "temporary file will be deleted after use unless modified: " << u.url();
}
}
}
......@@ -308,7 +307,7 @@ bool KateDocManager::closeDocuments(const QList<KTextEditor::Document *> &docume
if ( fi.lastModified() <= m_tempFiles[ doc ].second ||
KMessageBox::questionYesNo( KateApp::self()->activeMainWindow(),
i18n("The supposedly temporary file %1 has been modified. "
"Do you want to delete it anyway?", m_tempFiles[ doc ].first.pathOrUrl()),
"Do you want to delete it anyway?", m_tempFiles[ doc ].first.url(QUrl::PreferLocalFile)),
i18n("Delete File?") ) == KMessageBox::Yes )
{
KIO::del( m_tempFiles[ doc ].first, KIO::HideProgressInfo );
......@@ -318,7 +317,7 @@ bool KateDocManager::closeDocuments(const QList<KTextEditor::Document *> &docume
else
{
m_tempFiles.remove(doc);
kDebug(13001) << "The supposedly temporary file " << m_tempFiles[ doc ].first.pathOrUrl() << " have been modified since loaded, and has not been deleted.";
kDebug(13001) << "The supposedly temporary file " << m_tempFiles[ doc ].first.url() << " have been modified since loaded, and has not been deleted.";
}
}
......@@ -462,7 +461,7 @@ bool KateDocManager::queryCloseDocuments(KateMainWindow *w)
if (!r.URLs.isEmpty())
{
KUrl tmp = r.URLs.first();
QUrl tmp = r.URLs.first();
if ( !doc->saveAs( tmp ) )
return false;
......@@ -609,12 +608,12 @@ void KateDocManager::slotModifiedOnDisc (KTextEditor::Document *doc, bool b, KTe
/**
* Load file and file's meta-information if the MD5 didn't change since last time.
*/
bool KateDocManager::loadMetaInfos(KTextEditor::Document *doc, const KUrl &url)
bool KateDocManager::loadMetaInfos(KTextEditor::Document *doc, const QUrl &url)
{
if (!m_saveMetaInfos)
return false;
if (!m_metaInfos->hasGroup(url.prettyUrl()))
if (!m_metaInfos->hasGroup(url.toDisplayString()))
return false;
QByteArray md5;
......@@ -622,7 +621,7 @@ bool KateDocManager::loadMetaInfos(KTextEditor::Document *doc, const KUrl &url)
if (computeUrlMD5(url, md5))
{
KConfigGroup urlGroup( m_metaInfos, url.prettyUrl() );
KConfigGroup urlGroup( m_metaInfos, url.toDisplayString() );
const QString old_md5 = urlGroup.readEntry("MD5");
if (QString (md5) == old_md5)
......@@ -684,7 +683,7 @@ void KateDocManager::saveMetaInfos(const QList<KTextEditor::Document *> &documen
// TODO: KDE 5: KateDocument computes the md5 digest when loading a file, and
// when saving a file. Maybe add "QString KTextEditor::Document::md5sum()" const?
bool KateDocManager::computeUrlMD5(const KUrl &url, QByteArray &result)
bool KateDocManager::computeUrlMD5(const QUrl &url, QByteArray &result)
{
QFile f(url.toLocalFile());
......
......@@ -98,9 +98,9 @@ class KateDocManager : public QObject
int findDocument (KTextEditor::Document *doc);
/** Returns the documentNumber of the doc with url URL or -1 if no such doc is found */
KTextEditor::Document *findDocument (const KUrl &url) const;
KTextEditor::Document *findDocument (const QUrl &url) const;
bool isOpen(KUrl url);
bool isOpen(QUrl url);
uint documents ();
......@@ -109,7 +109,7 @@ class KateDocManager : public QObject
return m_docList;
}
KTextEditor::Document *openUrl(const KUrl&,
KTextEditor::Document *openUrl(const QUrl&,
const QString &encoding = QString(),
bool isTempFile = false,
const KateDocumentInfo& docInfo = KateDocumentInfo());
......@@ -192,9 +192,9 @@ class KateDocManager : public QObject
void showRestoreErrors ();
private:
bool loadMetaInfos(KTextEditor::Document *doc, const KUrl &url);
bool loadMetaInfos(KTextEditor::Document *doc, const QUrl &url);
void saveMetaInfos(const QList<KTextEditor::Document *> &docs);
bool computeUrlMD5(const KUrl &url, QByteArray &result);
bool computeUrlMD5(const QUrl &url, QByteArray &result);
Kate::DocumentManager *m_documentManager;
QList<KTextEditor::Document*> m_docList;
......@@ -208,7 +208,7 @@ class KateDocManager : public QObject
//KParts::Factory *m_factory;
KTextEditor::Editor *m_editor;
typedef QPair<KUrl, QDateTime> TPair;
typedef QPair<QUrl, QDateTime> TPair;
QMap<KTextEditor::Document *, TPair> m_tempFiles;
QString m_openingErrors;
int m_documentStillToRestore;
......
......@@ -267,7 +267,7 @@ void KateMainWindow::setupActions()
actionCollection()->addAction( KStandardAction::Open, "file_open", m_viewManager, SLOT(slotDocumentOpen()) )
->setWhatsThis(i18n("Open an existing document for editing"));
fileOpenRecent = KStandardAction::openRecent (m_viewManager, SLOT(openUrl(KUrl)), this);
fileOpenRecent = KStandardAction::openRecent (m_viewManager, SLOT(openUrl(QUrl)), this);
actionCollection()->addAction(fileOpenRecent->objectName(), fileOpenRecent);
fileOpenRecent->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));
......@@ -522,7 +522,7 @@ void KateMainWindow::slotFileClose()
m_viewManager->slotDocumentClose();
}
void KateMainWindow::slotOpenDocument(KUrl url)
void KateMainWindow::slotOpenDocument(QUrl url)
{
m_viewManager->openUrl(url,
QString(),
......@@ -594,8 +594,7 @@ void KateMainWindow::slotUpdateOpenWith()
void KateMainWindow::dragEnterEvent( QDragEnterEvent *event )
{
if (!event->mimeData()) return;
const bool accept = KUrl::List::canDecode(event->mimeData()) // files
|| event->mimeData()->hasText(); // text
const bool accept = event->mimeData()->hasUrls() || event->mimeData()->hasText();
event->setAccepted(accept);
}
......@@ -611,8 +610,10 @@ void KateMainWindow::slotDropEvent( QDropEvent * event )
//
// are we dropping files?
//
if (KUrl::List::canDecode(event->mimeData())) {
KUrl::List textlist = KUrl::List::fromMimeData(event->mimeData());
if ( event->mimeData()->hasUrls() )
{
QList<QUrl> textlist = event->mimeData()->urls();
// Try to get the KTextEditor::View that sent this, and activate it, so that the file opens in the
// view where it was dropped
......@@ -625,17 +626,17 @@ void KateMainWindow::slotDropEvent( QDropEvent * event )
}
}
for (KUrl::List::Iterator i = textlist.begin(); i != textlist.end(); ++i)
foreach ( const QUrl &url, textlist )
{
// if url has no file component, try and recursively scan dir
KFileItem kitem( KFileItem::Unknown, KFileItem::Unknown, *i, true );
KFileItem kitem( KFileItem::Unknown, KFileItem::Unknown, url, true );
if( kitem.isDir() ) {
KIO::ListJob *list_job = KIO::listRecursive(*i, KIO::DefaultFlags, false);
KIO::ListJob *list_job = KIO::listRecursive(url, KIO::DefaultFlags, false);
connect(list_job, SIGNAL(entries(KIO::Job*,KIO::UDSEntryList)),
this, SLOT(slotListRecursiveEntries(KIO::Job*,KIO::UDSEntryList)));
}
else {
m_viewManager->openUrl (*i);
m_viewManager->openUrl (url);
}
}
}
......@@ -652,11 +653,11 @@ void KateMainWindow::slotDropEvent( QDropEvent * event )
void KateMainWindow::slotListRecursiveEntries(KIO::Job *job, const KIO::UDSEntryList &list)
{
const KUrl dir = static_cast<KIO::SimpleJob*>( job )->url();
const QUrl dir = static_cast<KIO::SimpleJob*>( job )->url();
foreach( const KIO::UDSEntry &entry, list )
{
KUrl currentUrl = dir;
currentUrl.addPath( entry.stringValue( KIO::UDSEntry::UDS_NAME ) );
QUrl currentUrl = dir.resolved( entry.stringValue( KIO::UDSEntry::UDS_NAME ) );
if( !entry.isDir() )
{
m_viewManager->openUrl(currentUrl);
......@@ -697,7 +698,7 @@ void KateMainWindow::editKeys()
void KateMainWindow::openUrl (const QString &name)
{
m_viewManager->openUrl (KUrl(name));
m_viewManager->openUrl (QUrl(name));
}
void KateMainWindow::slotConfigure()
......@@ -723,14 +724,14 @@ void KateMainWindow::showPluginConfigPage(Kate::PluginConfigPageInterface *confi
// could have done on it, specially for plugins.
}
KUrl KateMainWindow::activeDocumentUrl()
QUrl KateMainWindow::activeDocumentUrl()
{
// anders: i make this one safe, as it may be called during
// startup (by the file selector)
KTextEditor::View *v = m_viewManager->activeView();
if ( v )
return v->document()->url();
return KUrl();
return QUrl();
}
void KateMainWindow::mSlotFixOpenWithMenu()
......@@ -767,7 +768,7 @@ void KateMainWindow::mSlotFixOpenWithMenu()
void KateMainWindow::slotOpenWithMenuAction(QAction* a)
{
KUrl::List list;
QList<QUrl> list;
list.append( m_viewManager->activeView()->document()->url() );
const QString openWith = a->data().toString();
......
......@@ -39,6 +39,7 @@
#include <QHash>
#include <QStackedWidget>
#include <QStackedLayout>
#include <QUrl>
class QMenu;
......@@ -119,7 +120,7 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
public:
/** Returns the URL of the current document.
* anders: I add this for use from the file selector. */
KUrl activeDocumentUrl();
QUrl activeDocumentUrl();
uint mainWindowNumber () const
{
......@@ -196,7 +197,7 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa
void slotEditToolbars();
void slotNewToolbarConfig();
void slotUpdateOpenWith();
void slotOpenDocument(KUrl);
void slotOpenDocument(QUrl);
void slotDropEvent(QDropEvent *);
void editKeys();
......
......@@ -299,7 +299,7 @@ void KateMwModOnHdDialog::slotPDone()
}
m_diffFile->setAutoRemove(false);
KUrl url = KUrl::fromPath(m_diffFile->fileName());
QUrl url = QUrl::fromLocalFile(m_diffFile->fileName());
delete m_diffFile;
m_diffFile = 0;
......
......@@ -238,7 +238,7 @@ void KateQuickOpen::update ()
QFileInfo fi (file);
QStandardItem *itemName = new QStandardItem(fi.fileName());
itemName->setData(qVariantFromValue(KUrl::fromPath (file)), UrlRole);
itemName->setData(qVariantFromValue(QUrl::fromLocalFile(file)), UrlRole);
itemName->setData(QString("%1: %2").arg(fi.fileName()).arg(file), SortFilterRole);
itemName->setEditable(false);
QFont font = itemName->font();
......@@ -281,7 +281,7 @@ void KateQuickOpen::slotReturnPressed ()
if (doc) {
m_mainWindow->mainWindow()->activateView (doc);
} else {
KUrl url = m_listView->currentIndex().data (UrlRole).value<KUrl>();
QUrl url = m_listView->currentIndex().data (UrlRole).value<QUrl>();
if (!url.isEmpty())
m_mainWindow->mainWindow()->openUrl (url);
}
......
......@@ -27,7 +27,6 @@
#include <KGuiItem>
#include <KStandardGuiItem>
#include <KVBox>
#include <kurl.h>
#include <KIconLoader>
#include <KMessageBox>
#include <kdebug.h>
......@@ -94,7 +93,7 @@ class KateSaveModifiedDocumentCheckListItem: public AbstractKateSaveModifiedDial
if (!r.URLs.isEmpty())
{
KUrl tmp = r.URLs.first();
QUrl tmp = r.URLs.first();
// check for overwriting a file
if( tmp.isLocalFile() )
......
......@@ -153,10 +153,10 @@ bool KateSession::rename (const QString &name)
m_sessionFileRel = oldRel;
return false;
}
KUrl srcUrl(QString("file://"));
srcUrl.addPath(oldSessionFile);
KUrl destUrl(QString("file://"));
destUrl.addPath(sessionFile());
QUrl srcUrl = QUrl::fromLocalFile( oldSessionFile );
QUrl destUrl = QUrl::fromLocalFile( sessionFile() );
KIO::CopyJob *job = KIO::move(srcUrl, destUrl, KIO::HideProgressInfo);
if ( ! KIO::NetAccess::synchronousRun(job, 0) )
{
......
......@@ -259,7 +259,7 @@ void KateViewManager::slotDocumentOpen ()
QString fileList;
foreach ( const KUrl &url, r.URLs )
foreach ( const QUrl &url, r.URLs )
{
qint64 size = QFile( url.toLocalFile() ).size();
......@@ -279,7 +279,7 @@ void KateViewManager::slotDocumentOpen ()
}
KTextEditor::Document *lastID = 0;
foreach ( const KUrl &url, r.URLs )
foreach ( const QUrl &url, r.URLs )
lastID = openUrl( url, r.encoding, false, false, docInfo);
if (lastID)
......@@ -314,7 +314,7 @@ void KateViewManager::slotDocumentClose ()
}
KTextEditor::Document *KateViewManager::openUrl (const KUrl &url,
KTextEditor::Document *KateViewManager::openUrl (const QUrl &url,
const QString& encoding,
bool activate,
bool isTempFile,
......@@ -331,7 +331,7 @@ KTextEditor::Document *KateViewManager::openUrl (const KUrl &url,
return doc;
}
KTextEditor::View *KateViewManager::openUrlWithView (const KUrl &url, const QString& encoding)
KTextEditor::View *KateViewManager::openUrlWithView (const QUrl &url, const QString& encoding)
{
KTextEditor::Document *doc = KateDocManager::self()->openUrl (url, encoding);
......@@ -346,7 +346,7 @@ KTextEditor::View *KateViewManager::openUrlWithView (const KUrl &url, const QStr
return activeView ();
}
void KateViewManager::openUrl (const KUrl &url)
void KateViewManager::openUrl (const QUrl &url)
{
openUrl (url, QString());
}
......
......@@ -74,16 +74,16 @@ class KateViewManager : public QSplitter
/* restore it */
void restoreViewConfiguration (const KConfigGroup& group);
KTextEditor::Document *openUrl (const KUrl &url,
KTextEditor::Document *openUrl (const QUrl &url,
const QString& encoding,
bool activate = true,
bool isTempFile = false,
const KateDocumentInfo& docInfo = KateDocumentInfo());
KTextEditor::View *openUrlWithView (const KUrl &url, const QString& encoding);
KTextEditor::View *openUrlWithView (const QUrl &url, const QString& encoding);
public Q_SLOTS:
void openUrl (const KUrl &url);
void openUrl (const QUrl &url);
public:
......
......@@ -247,7 +247,7 @@ void KateViewSpace::restoreConfig ( KateViewManager *viewMan, const KConfigBase*
if ( !fn.isEmpty() )
{
KTextEditor::Document *doc = KateDocManager::self()->findDocument (KUrl(fn));
KTextEditor::Document *doc = KateDocManager::self()->findDocument (QUrl(fn));
if (doc)
{
......
......@@ -249,7 +249,7 @@ void KateFileTree::slotFixOpenWithMenu()
void KateFileTree::slotOpenWithMenuAction(QAction* a)
{
KUrl::List list;
QList<QUrl> list;
KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
if (!doc) return;
......
......@@ -20,7 +20,8 @@
#define KATE_FILETREE_H
#include <QTreeView>
#include <KUrl>
#include <QUrl>
#include <KIcon>
namespace KTextEditor {
......@@ -70,7 +71,7 @@ class KateFileTree: public QTreeView
void closeDocument(KTextEditor::Document*);
void activateDocument(KTextEditor::Document*);
void openDocument(KUrl);
void openDocument(QUrl);
void viewModeChanged(bool treeMode);
void sortRoleChanged(int);
......
......@@ -1269,7 +1269,7 @@ void KateFileTreeModel::setupIcon(ProxyItem *item)
icon_name = "document-save";
}
else {
KUrl url = item->path();
QUrl url = item->path();
icon_name = QMimeDatabase().mimeTypeForFile(url.path(), QMimeDatabase::MatchExtension).iconName();
}
......
......@@ -23,8 +23,6 @@
#include <QtCore/QObject>
#include <kurl.h>
namespace KTextEditor
{
class Editor;
......
......@@ -57,12 +57,12 @@ namespace Kate
return d->docMan->documentList ();
}
KTextEditor::Document *DocumentManager::findUrl (const KUrl &url) const
KTextEditor::Document *DocumentManager::findUrl (const QUrl &url) const
{
return d->docMan->findDocument (url);
}
KTextEditor::Document *DocumentManager::openUrl(const KUrl&url, const QString &encoding)
KTextEditor::Document *DocumentManager::openUrl(const QUrl&url, const QString &encoding)
{
return d->docMan->openUrl (url, encoding);
}
......
......@@ -22,7 +22,7 @@
#include <kate_export.h>
#include <QtCore/QObject>
#include <kurl.h>
#include <QtCore/QUrl>
namespace KTextEditor
{
......@@ -89,7 +89,7 @@ namespace Kate
* \return the document with the given \p url or NULL, if no such document
* is in the document manager's internal list.
*/
KTextEditor::Document *findUrl (const KUrl &url) const;
KTextEditor::Document *findUrl (const QUrl &url) const;
/**
* Open the document \p url with the given \p encoding.
......@@ -99,7 +99,7 @@ namespace Kate
* encoding will be guessed or the default encoding will be used.
* \return a pointer to the created document
*/
KTextEditor::Document *openUrl (const KUrl &url, const QString &encoding = QString());
KTextEditor::Document *openUrl (const QUrl &url, const QString &encoding = QString());
/**
* Close the given \p document.
......
......@@ -85,7 +85,7 @@ namespace Kate
return d->win->viewManager()->activateView( doc );
}
KTextEditor::View *MainWindow::openUrl (const KUrl &url, const QString &encoding)
KTextEditor::View *MainWindow::openUrl (const QUrl &url, const QString &encoding)
{
return d->win->viewManager()->openUrlWithView (url, encoding);
}
......
......@@ -25,7 +25,6 @@
#include <QtGui/QPixmap>
#include <kxmlguifactory.h>
#include <kurl.h>
class QWidget;
......@@ -143,7 +142,7 @@ namespace Kate
* \return a pointer to the created view for the new document, if a document
* with this url is already existing, its view will be activated
*/
KTextEditor::View *openUrl (const KUrl &url, const QString &encoding = QString());
KTextEditor::View *openUrl (const QUrl &url, const QString &encoding = QString());
//
// SIGNALS !!!
......
......@@ -26,7 +26,6 @@
#include <QtGui/QPixmap>
#include <kicontheme.h>
#include <kurl.h>
#include <kxmlguiclient.h>
#include <KComponentData>
......
......@@ -23,7 +23,6 @@
#include <kate_export.h>
#include <QtCore/QObject>
#include <kurl.h>
namespace Kate
{
......
......@@ -38,10 +38,10 @@
#include <kdebug.h>
#include <klocalizedstring.h>
#include <klocale.h>
#include <kurl.h>
#include <kshellcompletion.h>
#include <QDir>
#include <QUrl>
#include <QtCore/QRegExp>
//BEGIN CoreCommands
......@@ -839,8 +839,12 @@ bool KateCommands::AppCommands::exec(KTextEditor::View *view,
if (file.isEmpty()) {
view->document()->documentSave();
} else {
KUrl base = view->document()->url();
KUrl url( base.isValid() ? base : KUrl( QDir::homePath() ), file );
QUrl base = view->document()->url();
if ( !base.isValid() )
base = QUrl( QDir::homePath() );
QUrl url = base.resolved( QUrl(file) );
view->document()->saveAs( url );
}
msg = i18n("Document written to disk");
......
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