]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinviewactionhandler.cpp
Port Dolphin to Baloo
[dolphin.git] / src / views / dolphinviewactionhandler.cpp
index 9a9718c3336869693105866c5622200ad0c508b4..48ec95c70e04439c5dbe8667d96edc421e26bb9f 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "dolphinviewactionhandler.h"
 
-#include <config-nepomuk.h>
+#include <config-baloo.h>
 
 #include "settings/viewpropertiesdialog.h"
 #include "views/dolphinview.h"
 #include <KPropertiesDialog>
 #include <KIcon>
 
-#ifdef HAVE_NEPOMUK
-    #include <Nepomuk2/ResourceManager>
-#endif
-
 #include <KDebug>
 
+#ifdef HAVE_BALOO
+    #include <baloo/indexerconfig.h>
+#endif
+
 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) :
     QObject(parent),
     m_actionCollection(collection),
@@ -84,6 +84,8 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
             this, SLOT(slotSortRoleChanged(QByteArray)));
     connect(view, SIGNAL(zoomLevelChanged(int,int)),
             this, SLOT(slotZoomLevelChanged(int,int)));
+    connect(view, SIGNAL(writeStateChanged(bool)),
+            this, SLOT(slotWriteStateChanged(bool)));
 }
 
 DolphinView* DolphinViewActionHandler::currentView()
@@ -99,6 +101,7 @@ void DolphinViewActionHandler::createActions()
     newDirAction->setText(i18nc("@action", "Create Folder..."));
     newDirAction->setShortcut(Qt::Key_F10);
     newDirAction->setIcon(KIcon("folder-new"));
+    newDirAction->setEnabled(false);    // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable
     connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory()));
 
     // File menu
@@ -234,14 +237,10 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
     KActionMenu* groupMenu = 0;
     QActionGroup* groupMenuGroup = 0;
 
-    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
 
     const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
@@ -281,8 +280,8 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
         action->setText(info.translation);
         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);
 
@@ -482,6 +481,11 @@ void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown)
     showHiddenFilesAction->setChecked(shown);
 }
 
+void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable)
+{
+    m_actionCollection->action("create_dir")->setEnabled(isFolderWritable);
+}
+
 KToggleAction* DolphinViewActionHandler::iconsModeAction()
 {
     KToggleAction* iconsView = m_actionCollection->add<KToggleAction>("icons");