]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Allow compiling Dolphin with KF5
[dolphin.git] / src / views / dolphinview.cpp
index 1416bb6df4de107e3b3fd03971285f5b3637de4b..02a844c2bb8e23c7baabe39bf546a1ae61308a0f 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "dolphinview.h"
 
-#include <config-nepomuk.h>
+#include <config-baloo.h>
 
 #include <QAbstractItemView>
 #include <QApplication>
@@ -32,6 +32,8 @@
 #include <QItemSelection>
 #include <QTimer>
 #include <QScrollBar>
+#include <QPointer>
+#include <QMenu>
 
 #include <KDesktopFile>
 #include <KProtocolManager>
@@ -55,7 +57,9 @@
 #include <KIO/PreviewJob>
 #include <KJob>
 #include <KMenu>
+#include <KGlobal>
 #include <KMessageBox>
+#include <KJobWidgets>
 #include <konq_fileitemcapabilities.h>
 #include <konq_operations.h>
 #include <konqmimedata.h>
@@ -74,8 +78,8 @@
 #include "views/tooltips/tooltipmanager.h"
 #include "zoomlevelinfo.h"
 
-#ifdef HAVE_NEPOMUK
-    #include <Nepomuk2/ResourceManager>
+#ifdef HAVE_BALOO
+    #include <baloo/indexerconfig.h>
 #endif
 
 namespace {
@@ -295,7 +299,7 @@ void DolphinView::setHiddenFilesShown(bool show)
 
     const KFileItemList itemList = selectedItems();
     m_selectedUrls.clear();
-    m_selectedUrls = itemList.urlList();
+    m_selectedUrls = KUrl::List(itemList.urlList());
 
     ViewProperties props(viewPropertiesUrl());
     props.setHiddenFilesShown(show);
@@ -472,7 +476,7 @@ void DolphinView::reload()
 
     const KFileItemList itemList = selectedItems();
     m_selectedUrls.clear();
-    m_selectedUrls = itemList.urlList();
+    m_selectedUrls = KUrl::List(itemList.urlList());
 
     setUrl(url());
     loadDirectory(url(), true);
@@ -649,6 +653,8 @@ void DolphinView::renameSelectedItems()
         const int index = m_model->index(items.first());
         m_view->editRole(index, "text");
 
+        hideToolTip();
+
         connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
                 this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
     } else {
@@ -682,7 +688,7 @@ void DolphinView::deleteSelectedItems()
     if (del) {
         KIO::Job* job = KIO::del(list);
         if (job->ui()) {
-            job->ui()->setWindow(this);
+            KJobWidgets::setWindow(job, this);
         }
         connect(job, SIGNAL(result(KJob*)),
                 this, SLOT(slotDeleteFileFinished(KJob*)));
@@ -868,14 +874,10 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
     KItemListView* view = m_container->controller()->view();
     const QSet<QByteArray> visibleRolesSet = view->visibleRoles().toSet();
 
-    bool nepomukRunning = false;
     bool indexingEnabled = false;
-#ifdef HAVE_NEPOMUK
-    nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized());
-    if (nepomukRunning) {
-        KConfig config("nepomukserverrc");
-        indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
-    }
+#ifdef HAVE_BALOO
+    Baloo::IndexerConfig config;
+    indexingEnabled = config.fileIndexingEnabled();
 #endif
 
     QString groupName;
@@ -906,8 +908,8 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
         action->setChecked(visibleRolesSet.contains(info.role));
         action->setData(info.role);
 
-        const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) ||
-                            (info.requiresNepomuk && nepomukRunning) ||
+        const bool enable = (!info.requiresBaloo && !info.requiresIndexer) ||
+                            (info.requiresBaloo) ||
                             (info.requiresIndexer && indexingEnabled);
         action->setEnabled(enable);
     }
@@ -1093,7 +1095,7 @@ void DolphinView::slotAboutToCreate(const KUrl::List& urls)
             markUrlAsCurrent(urls.first());
             m_markFirstNewlySelectedItemAsCurrent = false;
         }
-        m_selectedUrls << KDirModel::simplifiedUrlList(urls);
+        m_selectedUrls << KUrl::List(KDirModel::simplifiedUrlList(urls));
     }
 }
 
@@ -1664,11 +1666,16 @@ void DolphinView::updateWritableState()
     const bool wasFolderWritable = m_isFolderWritable;
     m_isFolderWritable = false;
 
-    const KFileItem item = m_model->rootItem();
-    if (!item.isNull()) {
-        KFileItemListProperties capabilities(KFileItemList() << item);
-        m_isFolderWritable = capabilities.supportsWriting();
+    KFileItem item = m_model->rootItem();
+    if (item.isNull()) {
+        // Try to find out if the URL is writable even if the "root item" is
+        // null, see https://bugs.kde.org/show_bug.cgi?id=330001
+        item = KFileItem(KFileItem::Unknown, KFileItem::Unknown, url(), true);
     }
+
+    KFileItemListProperties capabilities(KFileItemList() << item);
+    m_isFolderWritable = capabilities.supportsWriting();
+
     if (m_isFolderWritable != wasFolderWritable) {
         emit writeStateChanged(m_isFolderWritable);
     }