1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef DOLPHINCONTEXTMENU_H
21 #define DOLPHINCONTEXTMENU_H
23 #include <kdesktopfileactions.h>
24 #include <kfileitem.h>
27 #include <konq_copytomenu.h>
28 #include <kmodifierkeyinfo.h>
30 #include <QtCore/QObject>
32 #include <QtCore/QVector>
34 #include <QScopedPointer>
39 class DolphinMainWindow
;
40 class KFileItemActions
;
41 class KFileItemListProperties
;
44 * @brief Represents the context menu which appears when doing a right
45 * click on an item or the viewport of the file manager.
47 * Beside static menu entries (e. g. 'Paste' or 'Properties') two
48 * dynamic sub menus are shown when opening a context menu above
50 * - 'Open With': Contains all applications which are registered to
51 * open items of the given MIME type.
52 * - 'Actions': Contains all actions which can be applied to the
55 class DolphinContextMenu
: public QObject
61 * @parent Pointer to the main window the context menu
63 * @fileInfo Pointer to the file item the context menu
64 * is applied. If 0 is passed, the context menu
65 * is above the viewport.
66 * @baseUrl Base URL of the viewport where the context menu
69 DolphinContextMenu(DolphinMainWindow
* parent
,
70 const KFileItem
& fileInfo
,
73 virtual ~DolphinContextMenu();
75 void setCustomActions(const QList
<QAction
*>& actions
);
77 /** Opens the context menu model. */
81 void deleteOrTrashMenuEntry(Qt::Key key
, bool pressed
);
84 void openTrashContextMenu();
85 void openTrashItemContextMenu();
86 void openItemContextMenu();
87 void openViewportContextMenu();
89 void insertDefaultItemActions();
92 * Adds the "Show menubar" action to the menu if the
95 void addShowMenubarAction();
98 * Returns a name for adding the URL \a url to the Places panel.
100 QString
placesName(const KUrl
& url
) const;
102 bool placeExists(const KUrl
& url
) const;
104 QAction
* createPasteAction();
106 KFileItemListProperties
& capabilities();
107 void addServiceActions(KFileItemActions
& fileItemActions
);
108 void addVersionControlActions();
109 void addCustomActions();
116 QString filePath
; // empty for separator
117 QString templatePath
; // same as filePath for template
129 DolphinMainWindow
* m_mainWindow
;
130 KFileItemListProperties
* m_capabilities
;
131 KFileItem m_fileInfo
;
133 KFileItemList m_selectedItems
;
134 KUrl::List m_selectedUrls
;
136 KonqCopyToMenu m_copyToMenu
;
137 QList
<QAction
*> m_customActions
;
138 QScopedPointer
<KMenu
> m_popup
;
139 bool m_showDeleteCommand
;
142 KModifierKeyInfo m_keyInfo
;