]> cloud.milkyroute.net Git - dolphin.git/commitdiff
also provide revision control actions for the viewport-context-menu
authorPeter Penz <peter.penz19@gmail.com>
Thu, 23 Jul 2009 06:10:01 +0000 (06:10 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 23 Jul 2009 06:10:01 +0000 (06:10 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1001385

src/dolphincontextmenu.cpp
src/dolphincontextmenu.h
src/revisioncontrolplugin.cpp
src/revisioncontrolplugin.h

index 69b551493c4077bce748fb4347892740579276a9..cd3195e9ae4bffc5ada6806674e1b43b554dbfc5 100644 (file)
@@ -65,7 +65,7 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
 {
     // The context menu either accesses the URLs of the selected items
     // or the items itself. To increase the performance both lists are cached.
-    DolphinView* view = m_mainWindow->activeViewContainer()->view();
+    const DolphinView* view = m_mainWindow->activeViewContainer()->view();
     m_selectedUrls = view->selectedUrls();
     m_selectedItems = view->selectedItems();
 }
@@ -224,14 +224,7 @@ void DolphinContextMenu::openItemContextMenu()
     }
 
     // insert revision control actions
-    DolphinView* view = m_mainWindow->activeViewContainer()->view();
-    const QList<QAction*> revControlActions = view->revisionControlActions(m_selectedItems);
-    if (revControlActions.count() > 0) {
-        foreach (QAction* action, revControlActions) {
-            popup->addAction(action);
-        }
-        popup->addSeparator();
-    }
+    addRevisionControlActions(popup);
 
     // insert 'Copy To' and 'Move To' sub menus
     if (DolphinSettings::instance().generalSettings()->showCopyMoveMenu()) {
@@ -290,6 +283,8 @@ void DolphinContextMenu::openViewportContextMenu()
 
     popup->addSeparator();
 
+    addRevisionControlActions(popup);
+
     QAction* addToPlacesAction = popup->addAction(KIcon("bookmark-new"),
                                                   i18nc("@action:inmenu Add current folder to places", "Add to Places"));
 
@@ -395,6 +390,18 @@ KFileItemListProperties& DolphinContextMenu::capabilities()
     return *m_capabilities;
 }
 
+void DolphinContextMenu::addRevisionControlActions(KMenu* menu)
+{
+    const DolphinView* view = m_mainWindow->activeViewContainer()->view();
+    const QList<QAction*> revControlActions = view->revisionControlActions(m_selectedItems);
+    if (revControlActions.count() > 0) {
+        foreach (QAction* action, revControlActions) {
+            menu->addAction(action);
+        }
+        menu->addSeparator();
+    }
+}
+
 void DolphinContextMenu::addCustomActions(KMenu* menu)
 {
     foreach (QAction* action, m_customActions) {
index 59da57146d073ea2351ebae40e269a20a52860ae..613e4a43419acce2edc04141793059295f394ea1 100644 (file)
@@ -96,6 +96,7 @@ private:
 
 private:
     KFileItemListProperties& capabilities();
+    void addRevisionControlActions(KMenu* menu);
     void addCustomActions(KMenu* menu);
 
 private:
index 295dbe1c0cb2cb3567a07eac22ab6e8fe9050adf..6a833f622407d5946c2d55e7935f31c12acf58fc 100644 (file)
@@ -133,13 +133,13 @@ RevisionControlPlugin::RevisionState SubversionPlugin::revisionState(const KFile
 
 QList<QAction*> SubversionPlugin::contextMenuActions(const KFileItemList& items) const
 {
-    Q_UNUSED(items);
-    // TODO...
     QList<QAction*> actions;
     actions.append(m_updateAction);
     actions.append(m_commitAction);
-    actions.append(m_addAction);
-    actions.append(m_removeAction);
+    if (!items.isEmpty()) {
+        actions.append(m_addAction);
+        actions.append(m_removeAction);
+    }
     return actions;
 }
 
index 055464b69ba200e5b82de3f3ad5edb0483025d4b..54bd10f032506a36c3a76527225e33af89320067 100644 (file)
@@ -93,10 +93,10 @@ public:
     
     /**
      * Returns the list of actions that should be shown in the context menu
-     * for the files \p items. If an action cannot be applied to the list
-     * of files, it is recommended to disable the action instead of removing it
-     * from the returned list. If an action triggers a change of the revisions,
-     * the signal RevisionControlPlugin::revisionStatesChanged() must be emitted.
+     * for the files \p items. If no files are provided by \p items, the context
+     * menu is valid for the current directory (see RevisionControlPlugin::beginRetrieval()).
+     * If an action triggers a change of the revisions, the signal
+     * RevisionControlPlugin::revisionStatesChanged() must be emitted.
      */
     virtual QList<QAction*> contextMenuActions(const KFileItemList& items) const = 0;