[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kde-baseapps/frameworks] lib/konq/src: port newDir away from deprecated classes and methods
From: David Faure <faure () kde ! org>
Date: 2014-10-18 9:50:43
Message-ID: E1XfQep-0007Pi-Qr () scm ! kde ! org
[Download RAW message or body]
Git commit 8f66214752d88a504e9f4f8d1fa57e647983a7b7 by David Faure.
Committed on 18/10/2014 at 09:50.
Pushed by dfaure into branch 'frameworks'.
port newDir away from deprecated classes and methods
M +13 -19 lib/konq/src/konq_operations.cpp
M +3 -13 lib/konq/src/konq_operations.h
http://commits.kde.org/kde-baseapps/8f66214752d88a504e9f4f8d1fa57e647983a7b7
diff --git a/lib/konq/src/konq_operations.cpp b/lib/konq/src/konq_operations.cpp
index 71af7c9..fad013c 100644
--- a/lib/konq/src/konq_operations.cpp
+++ b/lib/konq/src/konq_operations.cpp
@@ -27,7 +27,7 @@
#include <ktoolinvocation.h>
#include <kautomount.h>
#include <kmountpoint.h>
-#include <kinputdialog.h>
+#include <QInputDialog>
#include <kmessagebox.h>
#include <knotification.h>
#include <krun.h>
@@ -590,7 +590,7 @@ void KonqOperations::slotResult(KJob *job)
deleteLater();
}
-// Duplicated in libkfile's KDirOperator
+// Duplicated in KNewFileMenuPrivate::confirmCreatingHiddenDir (and this version \
isn't kdelibs4support free, so use the other one) static bool \
confirmCreatingHiddenDir(const QString& name, QWidget* parent) {
KGuiItem continueGuiItem(KStandardGuiItem::cont());
@@ -606,28 +606,23 @@ static bool confirmCreatingHiddenDir(const QString& name, \
QWidget* parent) "confirm_create_hidden_dir") == KMessageBox::Continue;
}
-KIO::Job* KonqOperations::newDir(QWidget * parent, const KUrl & baseUrl)
+KIO::Job *KonqOperations::newDir(QWidget * parent, const QUrl &baseUrl, NewDirFlags \
flags) {
- return newDir(parent, baseUrl, NewDirFlags());
-}
-
-KIO::Job* KonqOperations::newDir(QWidget * parent, const KUrl & baseUrl, NewDirFlags \
flags)
-{
- // Notice that kfile's KDirOperator::mkdir() is somewhat similar
bool ok;
QString name = i18nc( "@label Default name when creating a folder", "New Folder" \
);
- if ( baseUrl.isLocalFile() && QFileInfo( baseUrl.toLocalFile( \
KUrl::AddTrailingSlash ) + name ).exists() )
- name = KIO::RenameDialog::suggestName(baseUrl, name);
+ if ( baseUrl.isLocalFile() && QFileInfo(baseUrl.toLocalFile() + QLatin1Char('/') \
+ name).exists() ) { + name = KIO::suggestName(baseUrl, name);
+ }
bool askAgain;
do {
askAgain = false;
- name = KInputDialog::getText ( i18nc( "@title:window", "New Folder" ),
- i18nc( "@label:textbox", "Enter folder name:" \
), name, &ok, parent ); + name = QInputDialog::getText(parent, i18nc( \
"@title:window", "New Folder" ), + i18nc( \
"@label:textbox", "Enter folder name:" ), QLineEdit::Normal, name, &ok); if ( ok && \
!name.isEmpty() ) {
- KUrl url;
- if ((name[0] == '/') || (name[0] == '~')) {
- url.setPath(KShell::tildeExpand(name));
+ QUrl url;
+ if (QDir::isAbsolutePath(name) || (name[0] == '~')) {
+ url = QUrl::fromLocalFile(KShell::tildeExpand(name));
} else {
const bool viewShowsHiddenFiles = (flags & ViewShowsHiddenFile);
if (!viewShowsHiddenFiles && name.startsWith('.')) {
@@ -636,11 +631,10 @@ KIO::Job* KonqOperations::newDir(QWidget * parent, const KUrl & \
baseUrl, NewDirF continue;
}
}
- name = KIO::encodeFileName( name );
url = baseUrl;
- url.addPath( name );
+ url.setPath(baseUrl.path() + QLatin1Char('/') + name);
}
- KIO::Job *job = KIO::mkpath(url);
+ KIO::Job *job = KIO::mkpath(url, baseUrl);
KJobWidgets::setWindow(job, parent);
job->ui()->setAutoErrorHandlingEnabled(true);
KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Mkpath, \
QList<QUrl>(), url, job);
diff --git a/lib/konq/src/konq_operations.h b/lib/konq/src/konq_operations.h
index 783979e..44f6e03 100644
--- a/lib/konq/src/konq_operations.h
+++ b/lib/konq/src/konq_operations.h
@@ -116,27 +116,17 @@ public:
*/
static QPair<bool, QString> pasteInfo(const KUrl& targetUrl);
- /**
- * Ask for the name of a new directory and create it.
- * Calls KonqOperations::mkdir.
- *
- * @param parent the parent widget
- * @param baseUrl the directory to create the new directory in
- * @return the job used to create the directory or 0 if the creation was \
cancelled by the user
- */
- static KIO::Job* newDir( QWidget * parent, const KUrl & baseUrl );
enum NewDirFlag { ViewShowsHiddenFile = 1 };
Q_DECLARE_FLAGS(NewDirFlags, NewDirFlag)
/**
- * Ask for the name of a new directory and create it.
- * Calls KonqOperations::mkdir.
+ * Ask for the name of a new directory and create it (using KIO::mkpath).
*
* @param parent the parent widget
* @param baseUrl the directory to create the new directory in
* @param flags see NewDirFlags
- * @return the job used to create the directory or 0 if the creation was \
cancelled by the user + * @return the mkpath job used to create the directory or \
0 if the creation was cancelled by the user
*/
- static KIO::Job* newDir( QWidget * parent, const KUrl & baseUrl, NewDirFlags \
flags ); + static KIO::Job* newDir(QWidget *parent, const QUrl &baseUrl, \
NewDirFlags flags = NewDirFlags());
/**
* Returns the list of dropped URL's.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic