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__
25
#include <kshortcut.h>
35
virtual ~MenuInfo() {}
38
class MenuSeparatorInfo : public MenuInfo
41
MenuSeparatorInfo() {}
44
class MenuFolderInfo : public MenuInfo
47
MenuFolderInfo() : dirty(false), hidden(false) { subFolders.setAutoDelete(true); }
50
void add(MenuSeparatorInfo *, bool initial=false);
53
void add(MenuFolderInfo *, bool initial=false);
55
// Remove sub menu (without deleting it)
56
void take(MenuFolderInfo *);
58
// Remove sub menu (without deleting it)
59
// @return true if found
60
bool takeRecursive(MenuFolderInfo *info);
63
void add(MenuEntryInfo *, bool initial = false);
65
// Remove entry (without deleteing it)
66
void take(MenuEntryInfo *);
68
// Return a unique sub-menu caption inspired by @p caption
69
QString uniqueMenuCaption(const QString &caption);
71
// Return a unique item caption inspired by @p caption but different
73
QString uniqueItemCaption(const QString &caption, const QString &exclude = QString::null);
75
// Update full id's for this item and all submenus
76
void updateFullId(const QString &parentId);
78
// Return a list of existing submenu ids
79
QStringList existingMenuIds();
81
void setCaption(const QString &_caption)
83
if (_caption == caption) return;
88
void setIcon(const QString &_icon)
90
if (_icon == icon) return;
95
void setGenericName(const QString &_description)
97
if (_description == genericname) return;
98
genericname = _description;
102
void setComment(const QString &_comment)
104
if (_comment == comment) return;
109
// Mark menu as dirty
112
// Return whether this menu or any entry or submenu contained in it is dirty.
115
// Return whether this menu should be explicitly added to its parent menu
116
bool needInsertion();
118
// Save menu and all its entries and submenus
119
void save(MenuFile *);
121
// Search service by shortcut
122
KService::Ptr findServiceShortcut(const KShortcut&);
124
// Set whether the entry is in active use (as opposed to in the clipboard/deleted)
125
void setInUse(bool inUse);
128
QString id; // Relative to parent
129
QString fullId; // Name in tree
130
QString caption; // Visible name
131
QString genericname; // Generic description
132
QString comment; // Comment
133
QString directoryFile; // File describing this folder.
134
QString icon; // Icon
135
QPtrList<MenuFolderInfo> subFolders; // Sub menus in this folder
136
QPtrList<MenuEntryInfo> entries; // Menu entries in this folder
137
QPtrList<MenuInfo> initialLayout; // Layout of menu entries according to sycoca
142
class MenuEntryInfo : public MenuInfo
145
MenuEntryInfo(const KService::Ptr &_service, KDesktopFile *_df = 0)
146
: service(_service), df(_df),
147
shortcutLoaded(false), shortcutDirty(false), dirty(_df != 0), hidden(false)
149
caption = service->name();
150
description = service->genericName();
151
icon = service->icon();
155
void setCaption(const QString &_caption);
156
void setDescription(const QString &_description);
157
void setIcon(const QString &_icon);
159
QString menuId() const { return service->menuId(); }
161
QString file() const { return service->desktopEntryPath(); }
163
KShortcut shortcut();
164
void setShortcut(const KShortcut &_shortcut);
165
bool isShortcutAvailable(const KShortcut &_shortcut);
169
// Set whether the entry is in active use (as opposed to in the clipboard/deleted)
170
void setInUse(bool inUse);
172
// Return whether this menu should be explicitly added to its parent menu
173
bool needInsertion();
177
KDesktopFile *desktopFile();
183
KService::Ptr service;