forked from qt-creator/qt-creator
analyze: create a top level menu entry
Change-Id: I17c4d17583d401fb537d5956f5b07a1dc12906e1 Reviewed-on: http://codereview.qt.nokia.com/893 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -272,6 +272,29 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const QString &group
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu, const QString &groupId)
|
||||
{
|
||||
ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu);
|
||||
if (!containerPrivate->canBeAddedToMenu())
|
||||
return;
|
||||
MenuActionContainer *container = static_cast<MenuActionContainer *>(containerPrivate);
|
||||
|
||||
QString actualGroupId;
|
||||
if (groupId.isEmpty())
|
||||
actualGroupId = QLatin1String(Constants::G_DEFAULT_TWO);
|
||||
else
|
||||
actualGroupId = groupId;
|
||||
|
||||
QList<Group>::const_iterator groupIt = findGroup(actualGroupId);
|
||||
QTC_ASSERT(groupIt != m_groups.constEnd(), return);
|
||||
QAction *beforeAction = before->menu()->menuAction();
|
||||
m_groups[groupIt-m_groups.constBegin()].items.append(menu);
|
||||
|
||||
connect(menu, SIGNAL(destroyed()), this, SLOT(itemDestroyed()));
|
||||
insertMenu(beforeAction, container->menu());
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::clear()
|
||||
{
|
||||
QMutableListIterator<Group> it(m_groups);
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
virtual void appendGroup(const QString &group) = 0;
|
||||
virtual void addAction(Core::Command *action, const QString &group = QString()) = 0;
|
||||
virtual void addMenu(Core::ActionContainer *menu, const QString &group = QString()) = 0;
|
||||
virtual void addMenu(Core::ActionContainer *before, Core::ActionContainer *menu, const QString &group = QString()) = 0;
|
||||
|
||||
// clears this menu and submenus from all actions and submenus
|
||||
// doesn't destroy the submenus and commands, just removes them from their parents
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
void appendGroup(const QString &id);
|
||||
void addAction(Command *action, const QString &group = QString());
|
||||
void addMenu(ActionContainer *menu, const QString &group = QString());
|
||||
void addMenu(ActionContainer *before, ActionContainer *menu, const QString &group = QString());
|
||||
virtual void clear();
|
||||
|
||||
int id() const;
|
||||
|
||||
Reference in New Issue
Block a user