~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to kmenuedit/menuinfo.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-27 12:09:48 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20080527120948-dottsyd5rcwhzd36
Tags: 4:4.0.80-1ubuntu1
* Merge with Debian
 - remove 97_fix_target_link_libraries.diff
 - Add replaces/conflicts on -kde4 packages

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#include <qstring.h>
24
 
 
25
 
#include <kshortcut.h>
26
 
#include <kservice.h>
27
 
 
28
 
class MenuFile;
29
 
class MenuEntryInfo;
30
 
 
31
 
class MenuInfo
32
 
{
33
 
public:
34
 
    MenuInfo() {}
35
 
    virtual ~MenuInfo() {}
36
 
};
37
 
 
38
 
class MenuSeparatorInfo : public MenuInfo
39
 
{
40
 
public:
41
 
    MenuSeparatorInfo() {}
42
 
};
43
 
 
44
 
class MenuFolderInfo : public MenuInfo
45
 
{
46
 
public:
47
 
    MenuFolderInfo() : dirty(false), hidden(false) { subFolders.setAutoDelete(true); }
48
 
 
49
 
    // Add separator
50
 
    void add(MenuSeparatorInfo *, bool initial=false);
51
 
 
52
 
    // Add sub menu
53
 
    void add(MenuFolderInfo *, bool initial=false);
54
 
 
55
 
    // Remove sub menu (without deleting it)
56
 
    void take(MenuFolderInfo *);
57
 
 
58
 
    // Remove sub menu (without deleting it)
59
 
    // @return true if found
60
 
    bool takeRecursive(MenuFolderInfo *info);
61
 
    
62
 
    // Add entry
63
 
    void add(MenuEntryInfo *, bool initial = false);
64
 
    
65
 
    // Remove entry (without deleteing it)
66
 
    void take(MenuEntryInfo *);
67
 
 
68
 
    // Return a unique sub-menu caption inspired by @p caption
69
 
    QString uniqueMenuCaption(const QString &caption);
70
 
 
71
 
    // Return a unique item caption inspired by @p caption but different
72
 
    // from @p exclude
73
 
    QString uniqueItemCaption(const QString &caption, const QString &exclude = QString::null);
74
 
 
75
 
    // Update full id's for this item and all submenus
76
 
    void updateFullId(const QString &parentId);
77
 
 
78
 
    // Return a list of existing submenu ids
79
 
    QStringList existingMenuIds();
80
 
 
81
 
    void setCaption(const QString &_caption)
82
 
    {
83
 
       if (_caption == caption) return;
84
 
       caption = _caption;
85
 
       setDirty();
86
 
    }
87
 
 
88
 
    void setIcon(const QString &_icon)
89
 
    {
90
 
       if (_icon == icon) return;
91
 
       icon = _icon;
92
 
       setDirty();
93
 
    }
94
 
 
95
 
    void setGenericName(const QString &_description)
96
 
    {
97
 
       if (_description == genericname) return;
98
 
       genericname = _description;
99
 
       setDirty();
100
 
    }
101
 
 
102
 
    void setComment(const QString &_comment)
103
 
    {
104
 
       if (_comment == comment) return;
105
 
       comment = _comment;
106
 
       setDirty();
107
 
    }
108
 
 
109
 
    // Mark menu as dirty
110
 
    void setDirty();
111
 
    
112
 
    // Return whether this menu or any entry or submenu contained in it is dirty.
113
 
    bool hasDirt();
114
 
 
115
 
    // Return whether this menu should be explicitly added to its parent menu
116
 
    bool needInsertion();
117
 
    
118
 
    // Save menu and all its entries and submenus
119
 
    void save(MenuFile *);
120
 
 
121
 
    // Search service by shortcut
122
 
    KService::Ptr findServiceShortcut(const KShortcut&);
123
 
 
124
 
    // Set whether the entry is in active use (as opposed to in the clipboard/deleted)
125
 
    void setInUse(bool inUse);
126
 
    
127
 
public:
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
138
 
    bool dirty;
139
 
    bool hidden;
140
 
};
141
 
 
142
 
class MenuEntryInfo : public MenuInfo
143
 
{
144
 
public:
145
 
    MenuEntryInfo(const KService::Ptr &_service, KDesktopFile *_df = 0) 
146
 
     : service(_service), df(_df), 
147
 
       shortcutLoaded(false), shortcutDirty(false), dirty(_df != 0), hidden(false)
148
 
    {
149
 
       caption = service->name();
150
 
       description = service->genericName();
151
 
       icon = service->icon();
152
 
    }
153
 
    ~MenuEntryInfo();
154
 
 
155
 
    void setCaption(const QString &_caption);
156
 
    void setDescription(const QString &_description);
157
 
    void setIcon(const QString &_icon);
158
 
    
159
 
    QString menuId() const { return service->menuId(); }
160
 
    
161
 
    QString file() const { return service->desktopEntryPath(); }
162
 
    
163
 
    KShortcut shortcut();
164
 
    void setShortcut(const KShortcut &_shortcut);
165
 
    bool isShortcutAvailable(const KShortcut &_shortcut);
166
 
    
167
 
    void setDirty();
168
 
 
169
 
    // Set whether the entry is in active use (as opposed to in the clipboard/deleted)
170
 
    void setInUse(bool inUse);
171
 
 
172
 
    // Return whether this menu should be explicitly added to its parent menu
173
 
    bool needInsertion();
174
 
    
175
 
    void save();
176
 
 
177
 
    KDesktopFile *desktopFile();
178
 
 
179
 
public:
180
 
    QString caption;
181
 
    QString description;
182
 
    QString icon;
183
 
    KService::Ptr service;
184
 
    KDesktopFile *df;
185
 
    KShortcut shortCut;
186
 
    bool shortcutLoaded;
187
 
    bool shortcutDirty;
188
 
    bool dirty;
189
 
    bool hidden;
190
 
};
191
 
 
192
 
#endif