kwave
18.07.70
|
#include <MenuNode.h>
Signals | |
void | sigCommand (const QString &command) |
Public Member Functions | |
MenuNode (Kwave::MenuNode *parent, const QString &name, const QString &command, const QKeySequence &shortcut, const QString &uid) | |
virtual | ~MenuNode () |
const QString | path () const |
const QString & | name () const |
const QString & | command () const |
virtual QAction * | action () |
const QString & | uid () const |
void | setUID (const QString &uid) |
const QKeySequence & | shortcut () const |
virtual void | setShortcut (const QKeySequence &shortcut) |
virtual const QIcon | icon () |
virtual void | setIcon (const QIcon &icon) |
virtual bool | isBranch () const |
virtual void | clear () |
virtual Kwave::MenuNode * | parentNode () const |
virtual void | setVisible (bool visible) |
virtual bool | isEnabled () |
virtual void | setEnabled (bool enable) |
virtual void | setChecked (bool check) |
virtual void | setText (const QString &text) |
Kwave::MenuNode * | findUID (const QString &uid) |
Kwave::MenuNode * | findChild (const QString &name) |
virtual void | removeChild (Kwave::MenuNode *child) |
virtual Kwave::MenuSub * | insertBranch (const QString &name, const QString &command, const QKeySequence &shortcut, const QString &uid) |
virtual Kwave::MenuNode * | insertLeaf (const QString &name, const QString &command, const QKeySequence &shortcut, const QString &uid) |
virtual void | insertChild (Kwave::MenuNode *node, Kwave::MenuNode *before) |
virtual void | insertNode (const QString &name, const QString &position, const QString &command, const QKeySequence &shortcut, const QString &uid) |
virtual Kwave::MenuNode * | leafToBranch (Kwave::MenuNode *node) |
virtual bool | specialCommand (const QString &command) |
virtual void | actionSelected () |
virtual QHash< QString, Kwave::MenuGroup * > & | groupList () |
void | joinGroup (const QString &group, Kwave::MenuGroup::Mode mode) |
void | leaveGroup (const QString &group) |
Protected Member Functions | |
Kwave::MenuNode * | rootNode () |
void | emitCommand (const QString &command) |
Protected Attributes | |
QList< Kwave::MenuNode * > | m_children |
QStringList | m_groups |
Private Attributes | |
QString | m_uid |
QKeySequence | m_shortcut |
QString | m_name |
QString | m_command |
Kwave::MenuNode * | m_parentNode |
Base class for the MenuItem, MenuSub and the MenuRoot class.
Definition at line 43 of file MenuNode.h.
Kwave::MenuNode::MenuNode | ( | Kwave::MenuNode * | parent, |
const QString & | name, | ||
const QString & | command, | ||
const QKeySequence & | shortcut, | ||
const QString & | uid | ||
) |
Constructor.
parent | pointer to the node's parent (might be 0) |
name | the non-localized name of the node |
command | the command to be sent when the node is selected (optional, default=0) |
shortcut | keyboard shortcut (optional, default=0) |
uid | unique id string (optional, default=0) |
Definition at line 35 of file MenuNode.cpp.
|
virtual |
Destructor. Clears the menu node and cleans up.
Definition at line 46 of file MenuNode.cpp.
References clear(), leaveGroup(), m_groups, m_parentNode, and removeChild().
|
inlinevirtual |
Returns the corresponding menu action
Reimplemented in Kwave::MenuItem, and Kwave::MenuSub.
Definition at line 80 of file MenuNode.h.
Referenced by Kwave::MenuRoot::hideChild(), Kwave::MenuSub::insertLeaf(), Kwave::MenuGroup::join(), Kwave::MenuGroup::leave(), Kwave::MenuSub::removeChild(), Kwave::MenuRoot::removeChild(), and Kwave::MenuRoot::showChild().
|
virtual |
Called to notify the node that it has been selected.
Reimplemented in Kwave::MenuItem.
Definition at line 87 of file MenuNode.cpp.
References emitCommand(), and m_command.
Referenced by Kwave::MenuItem::actionSelected(), and isBranch().
|
virtual |
Removes all child entries from the menu node (gui) and deletes the MenuNode objects (memory).
Reimplemented in Kwave::MenuList.
Definition at line 93 of file MenuNode.cpp.
References m_children.
Referenced by Kwave::MenuManager::clearNumberedMenu(), isBranch(), ~MenuNode(), and Kwave::MenuRoot::~MenuRoot().
|
inline |
Returns the command of the node.
Definition at line 77 of file MenuNode.h.
References m_command.
Referenced by Kwave::MenuManager::addNumberedMenuEntry(), and leafToBranch().
|
protected |
Emits a command if the node is the root node. If it is a client node it will call the root node's emitCommand() function.
Definition at line 70 of file MenuNode.cpp.
References emitCommand(), parentNode(), rootNode(), and sigCommand().
Referenced by actionSelected(), emitCommand(), and isBranch().
Kwave::MenuNode * Kwave::MenuNode::findChild | ( | const QString & | name | ) |
Tries to find a child node by it's name.
name | non-localized name of the child node |
Definition at line 211 of file MenuNode.cpp.
References m_children, and name().
Referenced by insertNode(), and isBranch().
Kwave::MenuNode * Kwave::MenuNode::findUID | ( | const QString & | uid | ) |
Tries to find a menu node by it's unique id string. It descends recursively through all child nodes if necessary.
uid | the unique id string to be searched |
Definition at line 198 of file MenuNode.cpp.
References findUID(), m_children, and m_uid.
Referenced by Kwave::MenuManager::addNumberedMenuEntry(), Kwave::MenuList::clear(), Kwave::MenuManager::clearNumberedMenu(), findUID(), isBranch(), Kwave::MenuManager::setItemChecked(), Kwave::MenuManager::setItemEnabled(), Kwave::MenuManager::setItemText(), Kwave::MenuManager::setItemVisible(), and specialCommand().
|
virtual |
Returns a reference to the list of groups. It recursively calls all parent node's groupList() function until it reaches the root node of the menu structure that holds the list of groups and overwrites this function.
Reimplemented in Kwave::MenuRoot.
Definition at line 370 of file MenuNode.cpp.
References groupList(), and m_parentNode.
Referenced by groupList(), isBranch(), isEnabled(), joinGroup(), leaveGroup(), Kwave::MenuGroup::MenuGroup(), and Kwave::MenuGroup::~MenuGroup().
|
virtual |
Returns the menu nodes' icon.
Reimplemented in Kwave::MenuSub, and Kwave::MenuItem.
Definition at line 115 of file MenuNode.cpp.
Referenced by leafToBranch(), setShortcut(), and specialCommand().
|
virtual |
Inserts a new branch node into the menu structure. The new node normally is (derived from) MenuSub.
name | non-localized name of the node |
command | the command template used for creating commands of submenus (leafes) that don't have an own command but contain data for their parent's command. Should contain a s that will be replaced by some data from a child entry. (this is used for menus with data selection lists like "recent files) If not used, pass 0. |
shortcut | keyboard shortcut, 0 if unused |
uid | unique id string (might be 0) |
Reimplemented in Kwave::MenuRoot, and Kwave::MenuSub.
Definition at line 230 of file MenuNode.cpp.
Referenced by insertNode(), isBranch(), and leafToBranch().
|
virtual |
Registers a node as a child of the current node.
node | pointer to the child node |
before | the node before which the node should be inserted (optional, can be null for "append") |
Definition at line 181 of file MenuNode.cpp.
References m_children.
Referenced by Kwave::MenuSub::insertBranch(), Kwave::MenuRoot::insertBranch(), Kwave::MenuSub::insertLeaf(), Kwave::MenuRoot::insertLeaf(), isBranch(), and specialCommand().
|
virtual |
Inserts a new leaf node into the menu structure. The new node normally is (derived from) MenuItem.
name | non-localized name of the node |
command | the command to be sent when the node is selected (might be 0) |
shortcut | keyboard shortcut, 0 if unused |
uid | unique id string (might be 0) |
Reimplemented in Kwave::MenuRoot, Kwave::MenuSub, and Kwave::MenuList.
Definition at line 243 of file MenuNode.cpp.
Referenced by Kwave::MenuManager::addNumberedMenuEntry(), Kwave::MenuList::insertLeaf(), insertNode(), and isBranch().
|
virtual |
Inserts a new child node into the structure. If the specified position contains a path that doesn't completely exist, all missing branches will be appended.
name | non-localized name of the first node (might be 0) |
position | path consiting of several node names separated by a '/'. All strings are non-localized. |
command | the command to be sent when the node is selected (might be 0) |
shortcut | keyboard shortcut, 0 if unused |
uid | unique id string (might be 0) |
Reimplemented in Kwave::MenuRoot.
Definition at line 256 of file MenuNode.cpp.
References findChild(), insertBranch(), insertLeaf(), insertNode(), isBranch(), leafToBranch(), setShortcut(), setUID(), and specialCommand().
Referenced by Kwave::MenuRoot::insertNode(), insertNode(), and isBranch().
|
inlinevirtual |
Returns true if the node is a branch, false if it is a leaf. (overwritten in MenuSub etc.)
Reimplemented in Kwave::MenuSub, and Kwave::MenuList.
Definition at line 119 of file MenuNode.h.
References actionSelected(), clear(), emitCommand(), findChild(), findUID(), groupList(), insertBranch(), insertChild(), insertLeaf(), insertNode(), isEnabled(), joinGroup(), leafToBranch(), leaveGroup(), parentNode(), removeChild(), rootNode(), setChecked(), setEnabled(), setText(), setVisible(), sigCommand(), and specialCommand().
Referenced by insertNode(), and specialCommand().
|
virtual |
Returns true if the node is enabled.
Reimplemented in Kwave::MenuSub, and Kwave::MenuItem.
Definition at line 130 of file MenuNode.cpp.
References DBG, groupList(), Kwave::MenuGroup::isEnabled(), isEnabled(), m_groups, m_parentNode, name(), and rootNode().
Referenced by isBranch(), Kwave::MenuItem::isEnabled(), Kwave::MenuSub::isEnabled(), isEnabled(), and leafToBranch().
void Kwave::MenuNode::joinGroup | ( | const QString & | group, |
Kwave::MenuGroup::Mode | mode | ||
) |
Adds the node to a group. If it is already a member of the group this function will do nothing.
group | name of the group |
mode | the mode of the group (normal or exclusive) |
Definition at line 378 of file MenuNode.cpp.
References groupList(), Kwave::MenuGroup::join(), m_groups, and rootNode().
Referenced by isBranch(), leafToBranch(), Kwave::MenuItem::specialCommand(), and specialCommand().
|
virtual |
Converts a child node from leaf to branch type by removing the leaf and inserting a branch with the same properties instead.
node | the child node to be converted |
Definition at line 328 of file MenuNode.cpp.
References command(), Kwave::MenuRoot::deleteLater(), icon(), insertBranch(), isEnabled(), joinGroup(), m_groups, name(), Kwave::MenuGroup::NORMAL, removeChild(), Kwave::MenuSub::setEnabled(), Kwave::MenuSub::setIcon(), shortcut(), and uid().
Referenced by insertNode(), isBranch(), and specialCommand().
void Kwave::MenuNode::leaveGroup | ( | const QString & | group | ) |
Removes the node from a group (opposite of joinGroup).
group | name of the group |
Definition at line 402 of file MenuNode.cpp.
References groupList(), Kwave::MenuGroup::isEmpty(), Kwave::MenuGroup::leave(), and m_groups.
Referenced by isBranch(), and ~MenuNode().
|
inline |
Returns the (non-localized) name of the node.
Definition at line 74 of file MenuNode.h.
References m_name.
Referenced by Kwave::MenuList::clear(), findChild(), Kwave::MenuRoot::hideChild(), Kwave::MenuList::insertLeaf(), Kwave::MenuSub::insertLeaf(), Kwave::MenuList::isBranch(), isEnabled(), leafToBranch(), Kwave::MenuRoot::removeChild(), setIcon(), Kwave::MenuRoot::showChild(), Kwave::MenuItem::specialCommand(), and specialCommand().
|
virtual |
returns a pointer to the menu's parent node
Definition at line 103 of file MenuNode.cpp.
References m_parentNode.
Referenced by Kwave::MenuManager::addNumberedMenuEntry(), Kwave::MenuList::clear(), emitCommand(), Kwave::MenuList::insertLeaf(), isBranch(), Kwave::MenuSub::setVisible(), and specialCommand().
const QString Kwave::MenuNode::path | ( | ) | const |
Returns the path of this menu entry
Definition at line 63 of file MenuNode.cpp.
References _, m_name, m_parentNode, and path().
Referenced by Kwave::MenuItem::MenuItem(), Kwave::MenuSub::MenuSub(), and path().
|
virtual |
Removes a child node of the current node. If the child was not found or is already removed this does nothing.
child | pointer to the child node |
Reimplemented in Kwave::MenuRoot, and Kwave::MenuSub.
Definition at line 223 of file MenuNode.cpp.
References m_children.
Referenced by Kwave::MenuList::clear(), isBranch(), leafToBranch(), Kwave::MenuSub::removeChild(), Kwave::MenuRoot::removeChild(), and ~MenuNode().
|
protected |
Returns the address of the root node of the menu structure.
Definition at line 109 of file MenuNode.cpp.
References m_parentNode, and rootNode().
Referenced by emitCommand(), isBranch(), isEnabled(), joinGroup(), rootNode(), and Kwave::MenuSub::setVisible().
|
virtual |
Sets/removes the checkmark from the current menu node.
check | true to set the mark, false to remove |
Reimplemented in Kwave::MenuItem.
Definition at line 169 of file MenuNode.cpp.
Referenced by isBranch(), Kwave::MenuGroup::selectItem(), and Kwave::MenuManager::setItemChecked().
|
virtual |
Enables/disables the current menu node.
enable | true to enable the item, false to disable |
Reimplemented in Kwave::MenuSub, and Kwave::MenuItem.
Definition at line 163 of file MenuNode.cpp.
Referenced by isBranch(), Kwave::MenuGroup::setEnabled(), Kwave::MenuManager::setItemEnabled(), and specialCommand().
|
virtual |
Sets a new icon of a menu node.
icon | QIcon with the icon |
Reimplemented in Kwave::MenuSub, and Kwave::MenuItem.
Definition at line 123 of file MenuNode.cpp.
Referenced by setShortcut(), and specialCommand().
|
inlinevirtual |
Sets the bitmask of the keyboard shortcut.
Definition at line 100 of file MenuNode.h.
References icon(), m_shortcut, setIcon(), and shortcut().
Referenced by insertNode().
|
virtual |
Sets the visible text of an item to a new value. (Only useful for a MenuItem)
text | the new text |
Reimplemented in Kwave::MenuItem.
Definition at line 175 of file MenuNode.cpp.
Referenced by isBranch(), and Kwave::MenuManager::setItemText().
void Kwave::MenuNode::setUID | ( | const QString & | uid | ) |
Sets the unique id string of the node
Definition at line 192 of file MenuNode.cpp.
Referenced by insertNode(), and uid().
|
virtual |
Shows/hides the current menu node.
visible | true to show the item, false to hide |
Reimplemented in Kwave::MenuSub, and Kwave::MenuItem.
Definition at line 157 of file MenuNode.cpp.
Referenced by isBranch(), and Kwave::MenuManager::setItemVisible().
|
inline |
Returns the bitmask of the keyboard shortcut.
Definition at line 95 of file MenuNode.h.
References m_shortcut.
Referenced by Kwave::MenuList::isBranch(), leafToBranch(), and setShortcut().
|
signal |
Will be emitted if the command of the menu node should be executed. It will only be emitted by the root node, client nodes call the root node's emitCommand() function.
Referenced by emitCommand(), and isBranch().
|
virtual |
Handles/interpretes special menu commands.
command | name of a menu node or command |
Reimplemented in Kwave::MenuRoot, Kwave::MenuSub, and Kwave::MenuItem.
Definition at line 421 of file MenuNode.cpp.
References _, Kwave::Parser::command(), DBG, findUID(), Kwave::Parser::firstParam(), icon(), insertChild(), isBranch(), joinGroup(), leafToBranch(), name(), Kwave::Parser::nextParam(), Kwave::MenuGroup::NORMAL, parentNode(), setEnabled(), setIcon(), and uid().
Referenced by insertNode(), isBranch(), Kwave::MenuItem::specialCommand(), Kwave::MenuSub::specialCommand(), and Kwave::MenuRoot::specialCommand().
|
inline |
Returns the unique id string of the node.
Definition at line 85 of file MenuNode.h.
References m_uid, and setUID().
Referenced by Kwave::MenuSub::insertLeaf(), leafToBranch(), Kwave::MenuGroup::selectItem(), setUID(), and specialCommand().
|
protected |
list with pointers to child menus
Definition at line 317 of file MenuNode.h.
Referenced by clear(), findChild(), findUID(), Kwave::MenuRoot::hideChild(), insertChild(), Kwave::MenuSub::insertLeaf(), Kwave::MenuRoot::removeChild(), removeChild(), and Kwave::MenuRoot::showChild().
|
private |
command to be sent when the node is activated (optional)
Definition at line 334 of file MenuNode.h.
Referenced by actionSelected(), and command().
|
protected |
list of group names the item belongs to
Definition at line 320 of file MenuNode.h.
Referenced by isEnabled(), joinGroup(), leafToBranch(), leaveGroup(), and ~MenuNode().
|
private |
name of the node (non-localized)
Definition at line 331 of file MenuNode.h.
|
private |
parent of this entry
Definition at line 337 of file MenuNode.h.
Referenced by groupList(), isEnabled(), parentNode(), path(), rootNode(), and ~MenuNode().
|
private |
bitmask of the keyboard shortcut
Definition at line 328 of file MenuNode.h.
Referenced by setShortcut(), and shortcut().
|
private |
unique id string
Definition at line 325 of file MenuNode.h.