]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Merge remote-tracking branch 'origin/KDE/4.13'
[dolphin.git] / src / views / dolphinview.cpp
index d0a85b3e26ef125112bcca4a3f903fa07d684769..c1f585da9448cf8955355db9120921b6130b8e29 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "dolphinview.h"
 
-#include <config-nepomuk.h>
+#include <config-baloo.h>
 
 #include <QAbstractItemView>
 #include <QApplication>
@@ -74,8 +74,8 @@
 #include "views/tooltips/tooltipmanager.h"
 #include "zoomlevelinfo.h"
 
-#ifdef HAVE_NEPOMUK
-    #include <Nepomuk2/ResourceManager>
+#ifdef HAVE_BALOO
+    #include <baloo/indexerconfig.h>
 #endif
 
 namespace {
@@ -649,6 +649,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 {
@@ -868,14 +870,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 +904,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);
     }
@@ -1048,6 +1046,7 @@ void DolphinView::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
     if (op && destUrl == url()) {
         // Mark the dropped urls as selected.
         m_clearSelectionBeforeSelectingNewItems = true;
+        m_markFirstNewlySelectedItemAsCurrent = true;
         connect(op, SIGNAL(aboutToCreate(KUrl::List)), this, SLOT(slotAboutToCreate(KUrl::List)));
     }
 
@@ -1072,17 +1071,15 @@ void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* prev
 
 void DolphinView::slotMouseButtonPressed(int itemIndex, Qt::MouseButtons buttons)
 {
+    Q_UNUSED(itemIndex);
+
     hideToolTip();
 
-    if (itemIndex < 0) {
-        // Trigger the history navigation only when clicking on the viewport:
-        // Above an item the XButtons provide a simple way to select items in
-        // the singleClick mode.
-        if (buttons & Qt::XButton1) {
-            emit goBackRequested();
-        } else if (buttons & Qt::XButton2) {
-            emit goForwardRequested();
-        }
+    // TODO: Qt5: Replace Qt::XButton1 by Qt::BackButton and Qt::XButton2 by Qt::ForwardButton
+    if (buttons & Qt::XButton1) {
+        emit goBackRequested();
+    } else if (buttons & Qt::XButton2) {
+        emit goForwardRequested();
     }
 }
 
@@ -1356,16 +1353,6 @@ void DolphinView::calculateItemCount(int& fileCount,
     }
 }
 
-void DolphinView::showHoverInformation(const KFileItem& item)
-{
-    emit requestItemInfo(item);
-}
-
-void DolphinView::clearHoverInformation()
-{
-    emit requestItemInfo(KFileItem());
-}
-
 void DolphinView::slotDeleteFileFinished(KJob* job)
 {
     if (job->error() == 0) {
@@ -1486,7 +1473,9 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, con
             }
 
             KonqOperations* op = KonqOperations::renameV2(this, oldUrl, newName);
-            if (op) {
+            if (op && !newNameExistsAlready) {
+                // Only connect the renamingFailed signal if there is no item with the new name
+                // in the model yet, see bug 328262.
                 connect(op, SIGNAL(renamingFailed(KUrl,KUrl)), SLOT(slotRenamingFailed(KUrl,KUrl)));
             }
         }
@@ -1662,11 +1651,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);
     }