2
* Copyright (C) 2003 Waldo Bastian <bastian@kde.org>
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 Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36
virtual ~MenuInfo() {}
39
class MenuSeparatorInfo : public MenuInfo
42
MenuSeparatorInfo() {}
45
class MenuFolderInfo : public MenuInfo
48
MenuFolderInfo() : dirty(false), hidden(false) { }
49
~MenuFolderInfo() { qDeleteAll(subFolders); subFolders.clear(); }
51
void add(MenuSeparatorInfo *, bool initial=false);
54
void add(MenuFolderInfo *, bool initial=false);
56
// Remove sub menu (without deleting it)
57
void take(MenuFolderInfo *);
59
// Remove sub menu (without deleting it)
60
// @return true if found
61
bool takeRecursive(MenuFolderInfo *info);
64
void add(MenuEntryInfo *, bool initial = false);
66
// Remove entry (without deleting it)
67
void take(MenuEntryInfo *);
69
// Return a unique sub-menu caption inspired by @p caption
70
QString uniqueMenuCaption(const QString &caption);
72
// Return a unique item caption inspired by @p caption but different
74
QString uniqueItemCaption(const QString &caption, const QString &exclude = QString());
76
// Update full id's for this item and all submenus
77
void updateFullId(const QString &parentId);
79
// Return a list of existing submenu ids
80
QStringList existingMenuIds();
82
void setCaption(const QString &_caption)
84
if (_caption == caption) return;
89
void setIcon(const QString &_icon)
91
if (_icon == icon) return;
96
void setGenericName(const QString &_description)
98
if (_description == genericname) return;
99
genericname = _description;
103
void setComment(const QString &_comment)
105
if (_comment == comment) return;
110
// Mark menu as dirty
113
// Return whether this menu or any entry or submenu contained in it is dirty.
116
// Return whether this menu should be explicitly added to its parent menu
117
bool needInsertion();
119
// Save menu and all its entries and submenus
120
void save(MenuFile *);
122
// Search service by shortcut
123
KService::Ptr findServiceShortcut(const KShortcut&);
125
// Set whether the entry is in active use (as opposed to in the clipboard/deleted)
126
void setInUse(bool inUse);
129
QString id; // Relative to parent
130
QString fullId; // Name in tree
131
QString caption; // Visible name
132
QString genericname; // Generic description
133
QString comment; // Comment
134
QString directoryFile; // File describing this folder.
135
QString icon; // Icon
136
QList<MenuFolderInfo *> subFolders; // Sub menus in this folder
137
QList<MenuEntryInfo *> entries; // Menu entries in this folder
138
QList<MenuInfo *> initialLayout; // Layout of menu entries according to sycoca
143
class MenuEntryInfo : public MenuInfo
146
explicit MenuEntryInfo(const KService::Ptr &_service, KDesktopFile *_df = 0)
147
: service(_service), m_desktopFile(_df),
148
shortcutLoaded(false), shortcutDirty(false), dirty(_df != 0), hidden(false)
150
caption = service->name();
151
description = service->genericName();
152
icon = service->icon();
156
void setCaption(const QString &_caption);
157
void setDescription(const QString &_description);
158
void setIcon(const QString &_icon);
160
QString menuId() const { return service->menuId(); }
162
QString file() const { return service->entryPath(); }
164
KShortcut shortcut();
165
void setShortcut(const KShortcut &_shortcut);
166
bool isShortcutAvailable(const KShortcut &_shortcut);
170
// Set whether the entry is in active use (as opposed to in the clipboard/deleted)
171
void setInUse(bool inUse);
173
// Return whether this menu should be explicitly added to its parent menu
174
bool needInsertion();
178
KDesktopFile *desktopFile();
184
KService::Ptr service;
185
KDesktopFile *m_desktopFile;