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.
20
#ifndef __menuinfo_h__
21
#define __menuinfo_h__
27
#include <kshortcut.h>
37
virtual ~MenuInfo() {}
40
class MenuSeparatorInfo : public MenuInfo
43
MenuSeparatorInfo() {}
46
class MenuFolderInfo : public MenuInfo
49
MenuFolderInfo() : dirty(false), hidden(false) { subFolders.setAutoDelete(true); }
52
void add(MenuSeparatorInfo *, bool initial=false);
55
void add(MenuFolderInfo *, bool initial=false);
57
// Remove sub menu (without deleting it)
58
void take(MenuFolderInfo *);
60
// Remove sub menu (without deleting it)
61
// @return true if found
62
bool takeRecursive(MenuFolderInfo *info);
65
void add(MenuEntryInfo *, bool initial = false);
67
// Remove entry (without deleting it)
68
void take(MenuEntryInfo *);
70
// Return a unique sub-menu caption inspired by @p caption
71
QString uniqueMenuCaption(const QString &caption);
73
// Return a unique item caption inspired by @p caption but different
75
QString uniqueItemCaption(const QString &caption, const QString &exclude = QString());
77
// Update full id's for this item and all submenus
78
void updateFullId(const QString &parentId);
80
// Return a list of existing submenu ids
81
QStringList existingMenuIds();
83
void setCaption(const QString &_caption)
85
if (_caption == caption) return;
90
void setIcon(const QString &_icon)
92
if (_icon == icon) return;
97
void setGenericName(const QString &_description)
99
if (_description == genericname) return;
100
genericname = _description;
104
void setComment(const QString &_comment)
106
if (_comment == comment) return;
111
// Mark menu as dirty
114
// Return whether this menu or any entry or submenu contained in it is dirty.
117
// Return whether this menu should be explicitly added to its parent menu
118
bool needInsertion();
120
// Save menu and all its entries and submenus
121
void save(MenuFile *);
123
// Search service by shortcut
124
KService::Ptr findServiceShortcut(const KShortcut&);
126
// Set whether the entry is in active use (as opposed to in the clipboard/deleted)
127
void setInUse(bool inUse);
130
QString id; // Relative to parent
131
QString fullId; // Name in tree
132
QString caption; // Visible name
133
QString genericname; // Generic description
134
QString comment; // Comment
135
QString directoryFile; // File describing this folder.
136
QString icon; // Icon
137
Q3PtrList<MenuFolderInfo> subFolders; // Sub menus in this folder
138
Q3PtrList<MenuEntryInfo> entries; // Menu entries in this folder
139
Q3PtrList<MenuInfo> initialLayout; // Layout of menu entries according to sycoca
144
class MenuEntryInfo : public MenuInfo
147
MenuEntryInfo(const KService::Ptr &_service, KDesktopFile *_df = 0)
148
: service(_service), m_desktopFile(_df),
149
shortcutLoaded(false), shortcutDirty(false), dirty(_df != 0), hidden(false)
151
caption = service->name();
152
description = service->genericName();
153
icon = service->icon();
157
void setCaption(const QString &_caption);
158
void setDescription(const QString &_description);
159
void setIcon(const QString &_icon);
161
QString menuId() const { return service->menuId(); }
163
QString file() const { return service->entryPath(); }
165
KShortcut shortcut();
166
void setShortcut(const KShortcut &_shortcut);
167
bool isShortcutAvailable(const KShortcut &_shortcut);
171
// Set whether the entry is in active use (as opposed to in the clipboard/deleted)
172
void setInUse(bool inUse);
174
// Return whether this menu should be explicitly added to its parent menu
175
bool needInsertion();
179
KDesktopFile *desktopFile();
185
KService::Ptr service;
186
KDesktopFile *m_desktopFile;