File: MenuGroup.h

package info (click to toggle)
kwave 25.04.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 23,272 kB
  • sloc: cpp: 56,173; xml: 817; perl: 688; sh: 57; makefile: 11
file content (127 lines) | stat: -rw-r--r-- 4,072 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/***************************************************************************
                          MenuGroup.h  -  controls a group of menu nodes
                             -------------------
    begin                : Mon Jan 10 2000
    copyright            : (C) 2000 by Thomas Eschenbacher
    email                : Thomas.Eschenbacher@gmx.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef MENU_GROUP_H
#define MENU_GROUP_H

#include "config.h"

#include <QList>

class QActionGroup;

namespace Kwave
{

    class MenuNode;

    /**
     * A MenuGroup controls a group of menu nodes (items, submenus).
     */
    class MenuGroup
    {
    public:

        /** mode for group membership */
        typedef enum
        {
            NORMAL,   /**< normal group, no dependencies */
            EXCLUSIVE /**< exclusive group, one of many (radio buttons) */
        } Mode;

        /**
         * Constructor.
         * @param parent pointer to the group's parent (might be 0)
         * @param name the unique name of the group
         * @param mode the mode of the group, normal or exclusive
         */
        MenuGroup(Kwave::MenuNode *parent,
                  const QString &name,
                  Kwave::MenuGroup::Mode mode);

        /**
         * Destructor. cleans up.
         * @see #clear()
         */
        virtual ~MenuGroup();

        /**
         * add a menu node to the group
         * @param node a MenuNode to join, must not be NULL
         */
        virtual void join(Kwave::MenuNode *node);

        /**
         * remove a menu node from the group
         * @param node a MenuNode to remove, must not be NULL
         */
        virtual void leave(Kwave::MenuNode *node);

        /**
         * Enables/disables all members of the group.
         * @param enable true to enable the item, false to disable
         */
        virtual void setEnabled(bool enable);

        /**
         * returns the "enabled" state of the group
         */
        virtual bool isEnabled() const { return m_enabled; }

        /**
         * returns true if the group contains no members
         */
        virtual bool isEmpty() const { return m_members.isEmpty(); }

        /**
         * Resets all checkmarks of the group members except the one member
         * that will get the new selected one. If no new member id is given
         * no member will get selected. This method is useful for making
         * exclusive selections of menu items.
         * @param uid the unique id string of the member to be selected or 0
         */
        virtual void selectItem(const QString &uid);

        /**
         * De-registers all child nodes from us and removes them from
         * our internal list of child nodes.
         */
        virtual void clear();

    private:

        /** the parent menu node */
        Kwave::MenuNode *m_parent = nullptr;

        /** name of the group */
        QString m_name;

        /** list of group members */
        QList<Kwave::MenuNode *> m_members;

        /** a QActionGroup, in case of "exclusive" mode */
        QActionGroup *m_action_group = nullptr;

        /** the group's enabled/disabled flag */
        bool m_enabled = true;

    };
}

#endif // MENU_GROUP_H

//***************************************************************************
//***************************************************************************