LibrePCB Developers Documentation
exclusiveactiongroup.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_EXCLUSIVEACTIONGROUP_H
21#define LIBREPCB_EDITOR_EXCLUSIVEACTIONGROUP_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27#include <QtWidgets>
28
29/*******************************************************************************
30 * Namespace / Forward Declarations
31 ******************************************************************************/
32namespace librepcb {
33namespace editor {
34
35/*******************************************************************************
36 * Class ExclusiveActionGroup
37 ******************************************************************************/
38
54class ExclusiveActionGroup final : public QObject {
55 Q_OBJECT
56
57public:
58 // Constructors / Destructor
59 ExclusiveActionGroup() noexcept;
61 ~ExclusiveActionGroup() noexcept;
62
63 // General Methods
64 void reset() noexcept;
65 void setEnabled(bool enabled) noexcept;
66 void addAction(QPointer<QAction> action, int id,
67 const QVariant& mode = QVariant()) noexcept;
68 void setActionEnabled(int id, bool enabled) noexcept;
69 void setCurrentAction(int id) noexcept;
70
71 // Operator Overloadings
72 ExclusiveActionGroup& operator=(const ExclusiveActionGroup& rhs) = delete;
73
74signals:
75 void actionTriggered(int id, const QVariant& mode);
76
77private: // Methods
78 void actionTriggeredSlot() noexcept;
79
80private: // Data
81 QHash<int, QVector<std::pair<QPointer<QAction>, QVariant>>> mActions;
82};
83
84/*******************************************************************************
85 * End of File
86 ******************************************************************************/
87
88} // namespace editor
89} // namespace librepcb
90
91#endif
The ExclusiveActionGroup class groups multiple QAction's together.
Definition: exclusiveactiongroup.h:54
void actionTriggeredSlot() noexcept
Definition: exclusiveactiongroup.cpp:91
void reset() noexcept
Definition: exclusiveactiongroup.cpp:48
QHash< int, QVector< std::pair< QPointer< QAction >, QVariant > > > mActions
Definition: exclusiveactiongroup.h:81
void setEnabled(bool enabled) noexcept
Definition: exclusiveactiongroup.cpp:53
ExclusiveActionGroup() noexcept
Definition: exclusiveactiongroup.cpp:38
void setCurrentAction(int id) noexcept
Definition: exclusiveactiongroup.cpp:80
void addAction(QPointer< QAction > action, int id, const QVariant &mode=QVariant()) noexcept
Definition: exclusiveactiongroup.cpp:65
ExclusiveActionGroup(const ExclusiveActionGroup &other)=delete
void actionTriggered(int id, const QVariant &mode)
~ExclusiveActionGroup() noexcept
Definition: exclusiveactiongroup.cpp:41
void setActionEnabled(int id, bool enabled) noexcept
Definition: exclusiveactiongroup.cpp:74
Definition: occmodel.cpp:77