]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.h
Backport for #156375: don't add a place having an empty name
[dolphin.git] / src / dolphincontextmenu.h
index 2a678d9a2b08c61fa2755e8cb934b9b4c1270e0f..a7cd9c01da420fe70c37ee2b6be6a90d8311af27 100644 (file)
 #ifndef DOLPHINCONTEXTMENU_H
 #define DOLPHINCONTEXTMENU_H
 
-#include <kdedesktopmimetype.h>
+#include <kdesktopfileactions.h>
 #include <kfileitem.h>
 #include <kservice.h>
 #include <kurl.h>
 
-#include <QObject>
-#include <QString>
-#include <QVector>
+#include <QtCore/QObject>
+
+#include <QtCore/QVector>
 
 class KMenu;
 class KFileItem;
@@ -51,12 +51,6 @@ class DolphinContextMenu : public QObject
     Q_OBJECT
 
 public:
-    enum ViewType
-    {
-        ItemsView,
-        SidebarView
-    };
-
     /**
      * @parent        Pointer to the main window the context menu
      *                belongs to.
@@ -65,40 +59,16 @@ public:
      *                is above the viewport.
      * @baseUrl       Base URL of the viewport where the context menu
      *                should be opened.
-     * @viewType      On which view type is the context menu shown.
      */
     DolphinContextMenu(DolphinMainWindow* parent,
-                       KFileItem* fileInfo,
-                       const KUrl& baseUrl,
-                       ViewType viewType = ItemsView);
+                       const KFileItem& fileInfo,
+                       const KUrl& baseUrl);
 
     virtual ~DolphinContextMenu();
 
-    /** Opens the context menu modal. */
+    /** Opens the context menu model. */
     void open();
 
-private slots:
-    /** Cuts the item m_fileInfo. */
-    void cut();
-
-    /** Copies the item m_fileInfo. */
-    void copy();
-
-    /** Paste the clipboard to m_fileInfo. */
-    void paste();
-
-    /** Renames the item m_fileInfo. */
-    void rename();
-
-    /** Moves the item m_fileInfo to the trash. */
-    void moveToTrash();
-
-    /** Deletes the item m_fileInfo. */
-    void deleteItem();
-
-    /** Shows the properties of the item m_fileInfo. */
-    void showProperties();
-
 private:
     void openTrashContextMenu();
     void openTrashItemContextMenu();
@@ -120,16 +90,6 @@ private:
     QList<QAction*> insertOpenWithItems(KMenu* popup,
                                         QVector<KService::Ptr>& openWithVector);
 
-    /**
-     * Inserts the 'Actions...' submenu to \a popup.
-     * @param popup          Menu where the 'Actions...' sub menu should
-     *                       be added.
-     * @param openWithVector Output parameter which contains all 'Actions...'
-     *                       services.
-     */
-    QList<QAction*> insertActionItems(KMenu* popup,
-                                      QVector<KDEDesktopMimeType::Service>& actionsVector);
-
     /**
      * Returns true, if 'menu' contains already
      * an entry with the name 'entryName'.
@@ -137,8 +97,20 @@ private:
     bool containsEntry(const KMenu* menu,
                        const QString& entryName) const;
 
+    /**
+     * Adds the "Show menubar" action to the menu if the
+     * menubar is hidden.
+     */
+    void addShowMenubarAction(KMenu* menu);
+
+    /**
+     * Returns a name for adding the URL \a url to the Places panel.
+     */
+    QString placesName(const KUrl& url) const;
+
 private:
-    struct Entry {
+    struct Entry
+    {
         int type;
         QString name;
         QString filePath;     // empty for separator
@@ -147,18 +119,18 @@ private:
         QString comment;
     };
 
-    enum ContextType {
+    enum ContextType
+    {
         NoContext = 0,
         ItemContext = 1,
         TrashContext = 2
     };
 
     DolphinMainWindow* m_mainWindow;
-    KFileItem* m_fileInfo;
+    KFileItem m_fileInfo;
     KUrl m_baseUrl;
     KFileItemList m_selectedItems;
     KUrl::List m_selectedUrls;
-    ViewType m_viewType;
     int m_context;
 };