22 #include <QLatin1Char> 37 const QString &command,
38 const QKeySequence &shortcut,
40 :QObject(), m_children(), m_groups(), m_uid(uid), m_shortcut(shortcut),
41 m_name(name), m_command(command), m_parentNode(parent)
49 QStringList::iterator group =
m_groups.begin();
72 Q_ASSERT(command.length());
73 if (!command.length())
return ;
118 Q_ASSERT(dummy.isNull());
125 qWarning(
"MenuNode(%s)::setIcon(%p)",
126 DBG(
name()), reinterpret_cast<const void *>(&icon));
137 QHash<QString, Kwave::MenuGroup *> &groups =
groupList();
140 foreach (
const QString &group_name,
m_groups) {
141 if (groups.contains(group_name)) {
144 qDebug(
"MenuNode(%s).isEnabled(): group %s is disabled",
200 if (
m_uid == uid)
return this;
204 if (node)
return node;
213 Q_ASSERT(name.length());
216 if (child && (name == child->
name()))
257 const QString &position,
264 if (!position.length()) {
265 qWarning(
"MenuNode::insertNode: no position!");
270 if (!name.length()) {
272 pos = position.indexOf(QLatin1Char(
'/'));
273 if (pos < 0) pos = position.length();
276 QString n = position.left(pos);
277 QString p = position;
278 p.remove(0, pos + 1);
285 if ((!p.length()) || (p[0] == QLatin1Char(
'#'))) {
291 if (!shortcut.isEmpty()) sub->
setShortcut(shortcut);
293 if (uid.length()) sub->
setUID(uid);
308 }
else if ( !sub->
isBranch() && (p[0] != QLatin1Char(
'#'))) {
312 }
else if (!p.length() || (p[0] == QLatin1Char(
'#')) ) {
315 if (!shortcut.isEmpty()) sub->
setShortcut(shortcut);
316 if (uid.length()) sub->
setUID(uid);
320 sub->
insertNode(QString(), p, command, shortcut, uid);
322 qDebug(
"MenuNode::insertNode: branch failed!");
331 Q_ASSERT(node !=
this);
333 if (!node || (node ==
this))
return Q_NULLPTR;
337 QKeySequence old_shortcut = node->
shortcut();
338 QString old_uid = node->
uid();
339 QIcon old_icon = node->
icon();
342 QStringList old_groups = node->
m_groups;
351 foreach (
const QString &group, old_groups)
355 if (!old_icon.isNull()) sub->
setIcon(old_icon);
372 static QHash<QString, Kwave::MenuGroup *> _empty_list;
384 QHash<QString, Kwave::MenuGroup *> &group_list =
groupList();
386 if (group_list.contains(group)) {
387 grp = group_list[group];
391 if (grp) group_list.insert(group, grp);
398 if (grp) grp->
join(
this);
404 QHash<QString, Kwave::MenuGroup *> &group_list =
groupList();
406 group_list.value(group) : Q_NULLPTR;
416 if (grp->
isEmpty())
delete grp;
425 if (parser.
command() ==
_(
"#icon")) {
427 const QString &icon_name = parser.
firstParam();
428 if ( icon_name.length()) {
430 QIcon
icon = QIcon::fromTheme( icon_name );
431 if (!icon.isNull()) {
434 qWarning(
"MenuNode '%s': icon '%s' not found !",
441 if (parser.
command() ==
_(
"#listmenu")) {
446 if (!sub)
return false;
455 Q_ASSERT(placeholder);
456 if (!placeholder)
return false;
463 if (parser.
command() ==
_(
"#group")) {
465 while (group.length()) {
472 if (command ==
_(
"#disabled")) {
478 if (command ==
_(
"#enabled")) {
const QString & firstParam()
const QString & nextParam()