6#include <QtCore/QtGlobal>
7#if QT_VERSION >= 0x050000
8#include <QtWidgets/QMenu>
9#include <QtWidgets/QMenuBar>
10#include <QtWidgets/QToolBar>
13#include <QtGui/QMenuBar>
14#include <QtGui/QToolBar>
17#if QT_VERSION >= 0x050000 && QT_VERSION < 0x060000
18#include <QtWidgets/QAction>
19#include <QtWidgets/QActionGroup>
21#include <QtGui/QAction>
22#include <QtGui/QActionGroup>
44 template <
class MenuType>
48 const QVector<int>& includedGroups = QVector<int>(),
49 const QVector<int>& excludedGroups = QVector<int>());
58 const QVector<int>& includedGroups = QVector<int>(),
59 const QVector<int>& excludedGroups = QVector<int>());
68 const QVector<int>& includedGroups = QVector<int>(),
69 const QVector<int>& excludedGroups = QVector<int>());
72 static bool IsCommandIncluded(
74 const QVector<int>& includedGroups = QVector<int>(),
75 const QVector<int>& excludedGroups = QVector<int>());
81template <
class MenuType>
85 const QVector<int>& includedGroups,
86 const QVector<int>& excludedGroups)
92 QMap<int, QActionGroup*> groups;
94 for (
int i = 0; i < childsCount; ++i){
95 QString text = command.text();
99 if (hierarchicalPtr !=
NULL){
100 QString text2 = hierarchicalPtr->text();
105 result.addSeparator();
109 prevGroupId = groupId;
113 QMenu* newMenuPtr =
new QMenu(&result);
114 newMenuPtr->setTitle(hierarchicalPtr->
GetName());
116 CreateMenu<QMenu>(*hierarchicalPtr, *newMenuPtr);
118 result.addMenu(newMenuPtr);
121 if (IsCommandIncluded(*hierarchicalPtr, includedGroups, excludedGroups)){
123 QActionGroup*& groupPtr = groups[hierarchicalPtr->
GetGroupId()];
124 if (groupPtr ==
NULL){
125 groupPtr =
new QActionGroup(&result);
126 groupPtr->setExclusive(
true);
129 groupPtr->addAction(hierarchicalPtr);
130 hierarchicalPtr->setCheckable(
true);
133 result.addAction(hierarchicalPtr);
@ CF_EXCLUSIVE
Enable exclusive selection of this command with other commands in the same node with the same group I...
@ CF_GLOBAL_MENU
Enable to use this command in global application menu.
virtual const QString & GetName() const override
Get the object name.
Implementation of hierarchical command based on QAction from Qt.
virtual ibase::ICommand * GetChild(int index) const override
virtual int GetChildsCount() const override
virtual int GetStaticFlags() const override
virtual int GetGroupId() const override
Standard GUI specific interfaces and components based on Qt.