1 | /* |
2 | * Copyright (C) 2003 Waldo Bastian <bastian@kde.org> |
3 | * |
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. |
8 | * |
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. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * |
18 | */ |
19 | |
20 | #ifndef menuinfo_h |
21 | #define menuinfo_h |
22 | |
23 | |
24 | #include <QList> |
25 | |
26 | #include <KShortcut> |
27 | #include <KService> |
28 | |
29 | class ; |
30 | class MenuEntryInfo; |
31 | |
32 | class |
33 | { |
34 | public: |
35 | () {} |
36 | virtual () {} |
37 | }; |
38 | |
39 | class : public MenuInfo |
40 | { |
41 | public: |
42 | () {} |
43 | }; |
44 | |
45 | class : public MenuInfo |
46 | { |
47 | public: |
48 | () : dirty(false), hidden(false) { } |
49 | () { qDeleteAll(subFolders); subFolders.clear(); } |
50 | // Add separator |
51 | void (MenuSeparatorInfo *, bool initial=false); |
52 | |
53 | // Add sub menu |
54 | void (MenuFolderInfo *, bool initial=false); |
55 | |
56 | // Remove sub menu (without deleting it) |
57 | void (MenuFolderInfo *); |
58 | |
59 | // Remove sub menu (without deleting it) |
60 | // @return true if found |
61 | bool (MenuFolderInfo *info); |
62 | |
63 | // Add entry |
64 | void (MenuEntryInfo *, bool initial = false); |
65 | |
66 | // Remove entry (without deleting it) |
67 | void (MenuEntryInfo *); |
68 | |
69 | // Return a unique sub-menu caption inspired by @p caption |
70 | QString (const QString &caption); |
71 | |
72 | // Return a unique item caption inspired by @p caption but different |
73 | // from @p exclude |
74 | QString (const QString &caption, const QString &exclude = QString()); |
75 | |
76 | // Update full id's for this item and all submenus |
77 | void (const QString &parentId); |
78 | |
79 | // Return a list of existing submenu ids |
80 | QStringList (); |
81 | |
82 | void (const QString &_caption) |
83 | { |
84 | if (_caption == caption) return; |
85 | caption = _caption; |
86 | setDirty(); |
87 | } |
88 | |
89 | void (const QString &_icon) |
90 | { |
91 | if (_icon == icon) return; |
92 | icon = _icon; |
93 | setDirty(); |
94 | } |
95 | |
96 | void (const QString &_description) |
97 | { |
98 | if (_description == genericname) return; |
99 | genericname = _description; |
100 | setDirty(); |
101 | } |
102 | |
103 | void (const QString &) |
104 | { |
105 | if (_comment == comment) return; |
106 | comment = _comment; |
107 | setDirty(); |
108 | } |
109 | |
110 | // Mark menu as dirty |
111 | void (); |
112 | |
113 | // Return whether this menu or any entry or submenu contained in it is dirty. |
114 | bool (); |
115 | |
116 | // Return whether this menu should be explicitly added to its parent menu |
117 | bool (); |
118 | |
119 | // Save menu and all its entries and submenus |
120 | void (MenuFile *); |
121 | |
122 | // Search service by shortcut |
123 | KService::Ptr (const KShortcut&); |
124 | |
125 | // Set whether the entry is in active use (as opposed to in the clipboard/deleted) |
126 | void (bool inUse); |
127 | |
128 | public: |
129 | QString ; // Relative to parent |
130 | QString ; // Name in tree |
131 | QString ; // Visible name |
132 | QString ; // Generic description |
133 | QString ; // Comment |
134 | QString ; // File describing this folder. |
135 | QString ; // Icon |
136 | QList<MenuFolderInfo *> ; // Sub menus in this folder |
137 | QList<MenuEntryInfo *> ; // Menu entries in this folder |
138 | QList<MenuInfo *> ; // Layout of menu entries according to sycoca |
139 | bool ; |
140 | bool ; |
141 | }; |
142 | |
143 | class : public MenuInfo |
144 | { |
145 | public: |
146 | explicit (const KService::Ptr &_service, KDesktopFile *_df = 0) |
147 | : service(_service), m_desktopFile(_df), |
148 | shortcutLoaded(false), shortcutDirty(false), dirty(_df != 0), hidden(false) |
149 | { |
150 | caption = service->name(); |
151 | description = service->genericName(); |
152 | icon = service->icon(); |
153 | } |
154 | (); |
155 | |
156 | void (const QString &_caption); |
157 | void (const QString &_description); |
158 | void (const QString &_icon); |
159 | |
160 | QString () const { return service->menuId(); } |
161 | |
162 | QString () const { return service->entryPath(); } |
163 | |
164 | KShortcut (); |
165 | void (const KShortcut &_shortcut); |
166 | bool (const KShortcut &_shortcut); |
167 | |
168 | void (); |
169 | |
170 | // Set whether the entry is in active use (as opposed to in the clipboard/deleted) |
171 | void (bool inUse); |
172 | |
173 | // Return whether this menu should be explicitly added to its parent menu |
174 | bool (); |
175 | |
176 | void (); |
177 | |
178 | KDesktopFile *(); |
179 | |
180 | public: |
181 | QString ; |
182 | QString ; |
183 | QString ; |
184 | KService::Ptr ; |
185 | KDesktopFile *; |
186 | KShortcut ; |
187 | bool ; |
188 | bool ; |
189 | bool ; |
190 | bool ; |
191 | }; |
192 | |
193 | #endif |
194 | |