]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Correct value for autostart setting of Service-nepomukfileindexer, part2
[dolphin.git] / src / views / dolphinview.cpp
index 13db9896e66ae83f616ead6f46653e6dc9a6da01..ea64a04dc1c0e55d2ee04964625eac5a2c05dc15 100644 (file)
@@ -73,7 +73,7 @@
 #include "zoomlevelinfo.h"
 
 #ifdef HAVE_NEPOMUK
-    #include <Nepomuk/ResourceManager>
+    #include <Nepomuk2/ResourceManager>
 #endif
 
 namespace {
@@ -101,6 +101,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
     m_scrollToCurrentItem(false),
     m_restoredContentsPosition(),
     m_selectedUrls(),
+    m_clearSelectionBeforeSelectingNewItems(false),
     m_versionControlObserver(0)
 {
     m_topLayout = new QVBoxLayout(this);
@@ -154,6 +155,7 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
 
     connect(m_model, SIGNAL(directoryLoadingStarted()),       this, SLOT(slotDirectoryLoadingStarted()));
     connect(m_model, SIGNAL(directoryLoadingCompleted()),     this, SLOT(slotDirectoryLoadingCompleted()));
+    connect(m_model, SIGNAL(directoryLoadingCanceled()),      this, SIGNAL(directoryLoadingCanceled()));
     connect(m_model, SIGNAL(directoryLoadingProgress(int)),   this, SIGNAL(directoryLoadingProgress(int)));
     connect(m_model, SIGNAL(directorySortingProgress(int)),   this, SIGNAL(directorySortingProgress(int)));
     connect(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet<QByteArray>)),
@@ -637,25 +639,25 @@ void DolphinView::clearSelection()
 void DolphinView::renameSelectedItems()
 {
     const KFileItemList items = selectedItems();
-     if (items.isEmpty()) {
-         return;
-     }
-
-     if (items.count() == 1 && GeneralSettings::renameInline()) {
-         const int index = m_model->index(items.first());
-         m_view->editRole(index, "text");
-     } else {
-         RenameDialog* dialog = new RenameDialog(this, items);
-         dialog->setAttribute(Qt::WA_DeleteOnClose);
-         dialog->show();
-         dialog->raise();
-         dialog->activateWindow();
-     }
-
-     // Assure that the current index remains visible when KFileItemModel
-     // will notify the view about changed items (which might result in
-     // a changed sorting).
-     m_assureVisibleCurrentIndex = true;
+    if (items.isEmpty()) {
+        return;
+    }
+
+    if (items.count() == 1 && GeneralSettings::renameInline()) {
+        const int index = m_model->index(items.first());
+        m_view->editRole(index, "text");
+    } else {
+        RenameDialog* dialog = new RenameDialog(this, items);
+        dialog->setAttribute(Qt::WA_DeleteOnClose);
+        dialog->show();
+        dialog->raise();
+        dialog->activateWindow();
+    }
+
+    // Assure that the current index remains visible when KFileItemModel
+    // will notify the view about changed items (which might result in
+    // a changed sorting).
+    m_assureVisibleCurrentIndex = true;
 }
 
 void DolphinView::trashSelectedItems()
@@ -798,6 +800,14 @@ void DolphinView::slotItemsActivated(const QSet<int>& indexes)
         items.append(m_model->fileItem(index));
     }
 
+    if (items.count() > 5) {
+        QString question = QString("Are you sure you want to open %1 items?").arg(items.count());
+        const int answer = KMessageBox::warningYesNo(this, question);
+        if (answer != KMessageBox::Yes) {
+            return;
+        }
+    }
+
     foreach (const KFileItem& item, items) {
         if (item.isDir()) {
             emit tabRequested(item.url());
@@ -838,10 +848,10 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
     bool nepomukRunning = false;
     bool indexingEnabled = false;
 #ifdef HAVE_NEPOMUK
-    nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized());
+    nepomukRunning = (Nepomuk2::ResourceManager::instance()->initialized());
     if (nepomukRunning) {
         KConfig config("nepomukserverrc");
-        indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false);
+        indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", true);
     }
 #endif
 
@@ -1218,13 +1228,22 @@ void DolphinView::updateViewState()
 
     if (!m_selectedUrls.isEmpty()) {
         KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
+
+        if (m_clearSelectionBeforeSelectingNewItems) {
+            selectionManager->clearSelection();
+            m_clearSelectionBeforeSelectingNewItems = false;
+        }
+
         QSet<int> selectedItems = selectionManager->selectedItems();
 
-        for (QList<KUrl>::iterator it = m_selectedUrls.begin(); it != m_selectedUrls.end(); ++it) {
+        QList<KUrl>::iterator it = m_selectedUrls.begin();
+        while (it != m_selectedUrls.end()) {
             const int index = m_model->index(*it);
             if (index >= 0) {
                 selectedItems.insert(index);
-                m_selectedUrls.erase(it);
+                it = m_selectedUrls.erase(it);
+            } else {
+                 ++it;
             }
         }
 
@@ -1535,6 +1554,7 @@ void DolphinView::markPastedUrlsAsSelected(const QMimeData* mimeData)
         destUrls << destination;
     }
     markUrlsAsSelected(destUrls);
+    m_clearSelectionBeforeSelectingNewItems = true;
 }
 
 void DolphinView::updateWritableState()