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 <kdedesktopmimetype.h>
24 #include <kfileitem.h>
35 class DolphinMainWindow
;
38 * @brief Represents the context menu which appears when doing a right
39 * click on an item or the viewport of the file manager.
41 * Beside static menu entries (e. g. 'Paste' or 'Properties') two
42 * dynamic sub menus are shown when opening a context menu above
44 * - 'Open With': Contains all applications which are registered to
45 * open items of the given MIME type.
46 * - 'Actions': Contains all actions which can be applied to the
49 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
68 * @viewType On which view type is the context menu shown.
70 DolphinContextMenu(DolphinMainWindow
* parent
,
73 ViewType viewType
= ItemsView
);
75 virtual ~DolphinContextMenu();
77 /** Opens the context menu modal. */
81 /** Cuts the item m_fileInfo. */
84 /** Copies the item m_fileInfo. */
87 /** Paste the clipboard to m_fileInfo. */
90 /** Renames the item m_fileInfo. */
93 /** Moves the item m_fileInfo to the trash. */
96 /** Deletes the item m_fileInfo. */
99 /** Shows the properties of the item m_fileInfo. */
100 void showProperties();
103 void openTrashContextMenu();
104 void openTrashItemContextMenu();
105 void openItemContextMenu();
106 void openViewportContextMenu();
108 void insertDefaultItemActions(KMenu
* popup
);
111 * Inserts the 'Open With...' submenu to \a popup.
112 * @param popup Menu where the 'Open With...' sub menu should
114 * @param openWithVector Output parameter which contains all 'Open with...'
116 * @return Identifier of the first 'Open With...' entry.
117 * All succeeding identifiers have an increased value of 1
118 * to the predecessor.
120 QList
<QAction
*> insertOpenWithItems(KMenu
* popup
,
121 QVector
<KService::Ptr
>& openWithVector
);
124 * Inserts the 'Actions...' submenu to \a popup.
125 * @param popup Menu where the 'Actions...' sub menu should
127 * @param openWithVector Output parameter which contains all 'Actions...'
130 QList
<QAction
*> insertActionItems(KMenu
* popup
,
131 QVector
<KDEDesktopMimeType::Service
>& actionsVector
);
134 * Returns true, if 'menu' contains already
135 * an entry with the name 'entryName'.
137 bool containsEntry(const KMenu
* menu
,
138 const QString
& entryName
) const;
144 QString filePath
; // empty for separator
145 QString templatePath
; // same as filePath for template
156 DolphinMainWindow
* m_mainWindow
;
157 KFileItem
* m_fileInfo
;
159 KFileItemList m_selectedItems
;
160 KUrl::List m_selectedUrls
;