]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Port QRegExp to QRegularExpression
[dolphin.git] / src / dolphinpart.cpp
index dc083f1a5563e90a1067af282b3cae901da8e450..12c361011dffd14330e62bae4ebf42c06997544a 100644 (file)
@@ -34,6 +34,7 @@
 #include <KActionCollection>
 #include <KAuthorized>
 #include <KConfigGroup>
+#include <KDialogJobUiDelegate>
 #include <KFileItemListProperties>
 #include <KIconLoader>
 #include <KJobWidgets>
@@ -42,7 +43,7 @@
 #include <KMimeTypeEditor>
 #include <KNS3/KMoreToolsMenuFactory>
 #include <KPluginFactory>
-#include <KRun>
+#include <KIO/CommandLauncherJob>
 #include <KSharedConfig>
 #include <KToolInvocation>
 
@@ -53,6 +54,7 @@
 #include <QInputDialog>
 #include <QKeyEvent>
 #include <QMenu>
+#include <QRegularExpression>
 #include <QStandardPaths>
 #include <QTextDocument>
 
@@ -506,7 +508,7 @@ void DolphinPart::openSelectionDialog(const QString& title, const QString& text,
     const QString pattern = QInputDialog::getText(m_view, title, text, QLineEdit::Normal, QStringLiteral("*"), &okClicked);
 
     if (okClicked && !pattern.isEmpty()) {
-        QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
+        const QRegularExpression patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern));
         m_view->selectItems(patternRegExp, selectItems);
     }
 }
@@ -533,23 +535,7 @@ void DolphinPart::setNameFilter(const QString& nameFilter)
 
 void DolphinPart::slotOpenTerminal()
 {
-    QString dir(QDir::homePath());
-
-    QUrl u(url());
-
-    // If the given directory is not local, it can still be the URL of an
-    // ioslave using UDS_LOCAL_PATH which to be converted first.
-    KIO::StatJob* statJob = KIO::mostLocalUrl(u);
-    KJobWidgets::setWindow(statJob, widget());
-    statJob->exec();
-    u = statJob->mostLocalUrl();
-
-    //If the URL is local after the above conversion, set the directory.
-    if (u.isLocalFile()) {
-        dir = u.toLocalFile();
-    }
-
-    KToolInvocation::invokeTerminal(QString(), dir);
+    KToolInvocation::invokeTerminal(QString(), KParts::ReadOnlyPart::localFilePath());
 }
 
 void DolphinPart::slotFindFile()
@@ -562,7 +548,10 @@ void DolphinPart::slotFindFile()
     if (!(actions.isEmpty())) {
         actions.first()->trigger();
     } else {
-        KRun::run(QStringLiteral("kfind"), {url()}, widget());
+        KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
+        job->setDesktopName(QStringLiteral("org.kde.kfind"));
+        job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, widget()));
+        job->start();
     }
 }
 
@@ -572,7 +561,7 @@ void DolphinPart::updateNewMenu()
     m_newFileMenu->checkUpToDate();
     m_newFileMenu->setViewShowsHiddenFiles(m_view->hiddenFilesShown());
     // And set the files that the menu apply on :
-    m_newFileMenu->setPopupFiles(url());
+    m_newFileMenu->setPopupFiles(QList<QUrl>() << url());
 }
 
 void DolphinPart::updateStatusBar()
@@ -589,7 +578,7 @@ void DolphinPart::updateProgress(int percent)
 void DolphinPart::createDirectory()
 {
     m_newFileMenu->setViewShowsHiddenFiles(m_view->hiddenFilesShown());
-    m_newFileMenu->setPopupFiles(url());
+    m_newFileMenu->setPopupFiles(QList<QUrl>() << url());
     m_newFileMenu->createDirectory();
 }