]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Replace kDebug/kWarning by categorized logging (org.kde.dolphin)
[dolphin.git] / src / dolphinpart.cpp
index 28259aaee0dc869841e657e5a0d2387d6bf50ed5..3473218e56f45ff59b12f0f8c6edad8a1fbbc111 100644 (file)
 #include "dolphinremoveaction.h"
 
 #include <KFileItemListProperties>
-#include <konq_operations.h>
 
 #include <KAboutData>
 #include <KActionCollection>
-#include <KConfigGroup>
-#include <KDebug>
-#include <KGlobalSettings>
+#include "dolphindebug.h"
 #include <KIconLoader>
-#include <KLocale>
+#include <KLocalizedString>
 #include <KMessageBox>
 #include <KPluginFactory>
 #include <KRun>
-#include <KToggleAction>
-#include <KGlobal>
 #include <KIO/NetAccess>
 #include <KToolInvocation>
 #include <kauthorized.h>
-#include <KMenu>
-#include <KInputDialog>
-#include <KProtocolInfo>
+#include <QMenu>
 #include <kdeversion.h>
+#include <KSharedConfig>
+#include <KConfigGroup>
+#include <KMimeTypeEditor>
 
 #include "dolphinpart_ext.h"
-
 #include "dolphinnewfilemenu.h"
 #include "views/dolphinview.h"
 #include "views/dolphinviewactionhandler.h"
 #include "kitemviews/kfileitemmodel.h"
 #include "kitemviews/private/kfileitemmodeldirlister.h"
 
+#include <QStandardPaths>
 #include <QActionGroup>
+#include <QTextDocument>
 #include <QApplication>
 #include <QClipboard>
 #include <QDir>
-#include <QTextDocument>
+#include <QKeyEvent>
+#include <QInputDialog>
 
 K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
-K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
 
 DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
     : KParts::ReadOnlyPart(parent)
@@ -68,14 +65,13 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
       ,m_removeAction(0)
 {
     Q_UNUSED(args)
-#pragma message("TODO: port to KF5")
-    //setComponentData(DolphinPartFactory::componentData(), false);
+    setComponentData(*createAboutData(), false);
     m_extension = new DolphinPartBrowserExtension(this);
 
     // make sure that other apps using this part find Dolphin's view-file-columns icons
     KIconLoader::global()->addAppDir("dolphin");
 
-    m_view = new DolphinView(KUrl(), parentWidget);
+    m_view = new DolphinView(QUrl(), parentWidget);
     m_view->setTabsForFilesEnabled(true);
     setWidget(m_view);
 
@@ -142,7 +138,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
         connect(lister, &KDirLister::newItems, notifyExt, &DolphinPartListingNotificationExtension::slotNewItems);
         connect(lister, &KDirLister::itemsDeleted, notifyExt, &DolphinPartListingNotificationExtension::slotItemsDeleted);
     } else {
-        kWarning() << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
+        qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
     }
 
     createActions();
@@ -205,16 +201,16 @@ void DolphinPart::createActions()
             this, &DolphinPart::slotGoTriggered);
 
     createGoAction("go_applications", "start-here-kde",
-                   i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
+                   i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
                    goActionGroup);
     createGoAction("go_network_folders", "folder-remote",
-                   i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
+                   i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
                    goActionGroup);
     createGoAction("go_settings", "preferences-system",
-                   i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
+                   i18nc("@action:inmenu Go", "Sett&ings"), QStringLiteral("settings:/"),
                    goActionGroup);
     createGoAction("go_trash", "user-trash",
-                   i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
+                   i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
                    goActionGroup);
     createGoAction("go_autostart", "",
                    i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
@@ -250,7 +246,7 @@ void DolphinPart::createGoAction(const char* name, const char* iconName,
 void DolphinPart::slotGoTriggered(QAction* action)
 {
     const QString url = action->data().toString();
-    emit m_extension->openUrlRequest(KUrl(url));
+    emit m_extension->openUrlRequest(QUrl(url));
 }
 
 void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
@@ -313,11 +309,11 @@ bool DolphinPart::openUrl(const QUrl &url)
         return true;
     }
     setUrl(url); // remember it at the KParts level
-    KUrl visibleUrl(url);
+    QUrl visibleUrl(url);
     if (!m_nameFilter.isEmpty()) {
-        visibleUrl.addPath(m_nameFilter);
+        visibleUrl.setPath(visibleUrl.path() + '/' + m_nameFilter);
     }
-    QString prettyUrl = visibleUrl.pathOrUrl();
+    QString prettyUrl = visibleUrl.toDisplayString(QUrl::PreferLocalFile);
     emit setWindowCaption(prettyUrl);
     emit m_extension->setLocationBarUrl(prettyUrl);
     emit started(0); // get the wheel to spin
@@ -344,7 +340,7 @@ void DolphinPart::slotMessage(const QString& msg)
 
 void DolphinPart::slotErrorMessage(const QString& msg)
 {
-    kDebug() << msg;
+    qCDebug(DolphinDebug) << msg;
     emit canceled(msg);
     //KMessageBox::error(m_view, msg);
 }
@@ -383,7 +379,7 @@ void DolphinPart::slotItemsActivated(const KFileItemList& items)
     }
 }
 
-void DolphinPart::createNewWindow(const KUrl& url)
+void DolphinPart::createNewWindow(const QUrl& url)
 {
     // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
     // should be moved into DolphinPart::slotItemActivated()
@@ -392,7 +388,7 @@ void DolphinPart::createNewWindow(const KUrl& url)
 
 void DolphinPart::slotOpenContextMenu(const QPoint& pos,
                                       const KFileItem& _item,
-                                      const KUrl&,
+                                      const QUrl &,
                                       const QList<QAction*>& customActions)
 {
     KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
@@ -405,7 +401,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
         popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
         item = m_view->rootItem();
         if (item.isNull())
-            item = KFileItem( S_IFDIR, (mode_t)-1, url() );
+            item = KFileItem(url());
         else
             item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
     }
@@ -473,12 +469,12 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
                                 actionGroups);
 }
 
-void DolphinPart::slotDirectoryRedirection(const KUrl& oldUrl, const KUrl& newUrl)
+void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
 {
-    //kDebug() << oldUrl << newUrl << "currentUrl=" << url();
-    if (oldUrl.equals(url(), KUrl::CompareWithoutTrailingSlash /* #207572 */)) {
+    //qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url();
+    if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) {
         KParts::ReadOnlyPart::setUrl(newUrl);
-        const QString prettyUrl = newUrl.pathOrUrl();
+        const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile);
         emit m_extension->setLocationBarUrl(prettyUrl);
     }
 }
@@ -488,7 +484,7 @@ void DolphinPart::slotEditMimeType()
 {
     const KFileItemList items = m_view->selectedItems();
     if (!items.isEmpty()) {
-        KonqOperations::editMimeType(items.first().mimetype(), m_view);
+        KMimeTypeEditor::editMimeType(items.first().mimetype(), m_view);
     }
 }
 
@@ -509,7 +505,7 @@ void DolphinPart::slotUnselectItemsMatchingPattern()
 void DolphinPart::openSelectionDialog(const QString& title, const QString& text, bool selectItems)
 {
     bool okClicked;
-    QString pattern = KInputDialog::getText(title, text, "*", &okClicked, m_view);
+    const QString pattern = QInputDialog::getText(m_view, title, text, QLineEdit::Normal, "*", &okClicked);
 
     if (okClicked && !pattern.isEmpty()) {
         QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
@@ -541,7 +537,7 @@ void DolphinPart::slotOpenTerminal()
 {
     QString dir(QDir::homePath());
 
-    KUrl u(url());
+    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.
@@ -557,7 +553,7 @@ void DolphinPart::slotOpenTerminal()
 
 void DolphinPart::slotFindFile()
 {
-    KRun::run("kfind", QList<QUrl>() << url(), widget());
+    KRun::run("kfind", {url()}, widget());
 }
 
 void DolphinPart::updateNewMenu()
@@ -587,7 +583,7 @@ void DolphinPart::createDirectory()
     m_newFileMenu->createDirectory();
 }
 
-void DolphinPart::setFilesToSelect(const KUrl::List& files)
+void DolphinPart::setFilesToSelect(const QList<QUrl>& files)
 {
     if (files.isEmpty()) {
         return;