forked from qt-creator/qt-creator
Core: Use Id as values in ActionContainer
Less noise, less cycles. Change-Id: I5c924362bc3cce37f9fc63fe18479083b6a6acbf Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -178,12 +178,12 @@ ActionContainer::OnAllDisabledBehavior ActionContainerPrivate::onAllDisabledBeha
|
||||
return m_onAllDisabledBehavior;
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::appendGroup(const Id &groupId)
|
||||
void ActionContainerPrivate::appendGroup(Id groupId)
|
||||
{
|
||||
m_groups.append(Group(groupId));
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::insertGroup(const Id &before, const Id &groupId)
|
||||
void ActionContainerPrivate::insertGroup(Id before, Id groupId)
|
||||
{
|
||||
QList<Group>::iterator it = m_groups.begin();
|
||||
while (it != m_groups.end()) {
|
||||
@@ -195,7 +195,7 @@ void ActionContainerPrivate::insertGroup(const Id &before, const Id &groupId)
|
||||
}
|
||||
}
|
||||
|
||||
QList<Group>::const_iterator ActionContainerPrivate::findGroup(const Id &groupId) const
|
||||
QList<Group>::const_iterator ActionContainerPrivate::findGroup(Id groupId) const
|
||||
{
|
||||
QList<Group>::const_iterator it = m_groups.constBegin();
|
||||
while (it != m_groups.constEnd()) {
|
||||
@@ -207,7 +207,7 @@ QList<Group>::const_iterator ActionContainerPrivate::findGroup(const Id &groupId
|
||||
}
|
||||
|
||||
|
||||
QAction *ActionContainerPrivate::insertLocation(const Id &groupId) const
|
||||
QAction *ActionContainerPrivate::insertLocation(Id groupId) const
|
||||
{
|
||||
QList<Group>::const_iterator it = findGroup(groupId);
|
||||
QTC_ASSERT(it != m_groups.constEnd(), return 0);
|
||||
@@ -235,7 +235,7 @@ QAction *ActionContainerPrivate::insertLocation(QList<Group>::const_iterator gro
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::addAction(Command *command, const Id &groupId)
|
||||
void ActionContainerPrivate::addAction(Command *command, Id groupId)
|
||||
{
|
||||
if (!canAddAction(command))
|
||||
return;
|
||||
@@ -253,7 +253,7 @@ void ActionContainerPrivate::addAction(Command *command, const Id &groupId)
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *menu, const Id &groupId)
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *menu, Id groupId)
|
||||
{
|
||||
ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu);
|
||||
if (!containerPrivate->canBeAddedToMenu())
|
||||
@@ -271,7 +271,7 @@ void ActionContainerPrivate::addMenu(ActionContainer *menu, const Id &groupId)
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu, const Id &groupId)
|
||||
void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *menu, Id groupId)
|
||||
{
|
||||
ActionContainerPrivate *containerPrivate = static_cast<ActionContainerPrivate *>(menu);
|
||||
if (!containerPrivate->canBeAddedToMenu())
|
||||
@@ -300,7 +300,7 @@ void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *m
|
||||
/*! \a context \a group \a outSeparator
|
||||
* \internal
|
||||
*/
|
||||
Command *ActionContainerPrivate::addSeparator(const Context &context, const Id &group, QAction **outSeparator)
|
||||
Command *ActionContainerPrivate::addSeparator(const Context &context, Id group, QAction **outSeparator)
|
||||
{
|
||||
static int separatorIdCount = 0;
|
||||
QAction *separator = new QAction(this);
|
||||
|
||||
@@ -63,13 +63,13 @@ public:
|
||||
virtual QMenu *menu() const = 0;
|
||||
virtual QMenuBar *menuBar() const = 0;
|
||||
|
||||
virtual QAction *insertLocation(const Id &group) const = 0;
|
||||
virtual void appendGroup(const Id &group) = 0;
|
||||
virtual void insertGroup(const Id &before, const Id &group) = 0;
|
||||
virtual void addAction(Command *action, const Id &group = Id()) = 0;
|
||||
virtual void addMenu(ActionContainer *menu, const Id &group = Id()) = 0;
|
||||
virtual void addMenu(ActionContainer *before, ActionContainer *menu, const Id &group = Id()) = 0;
|
||||
virtual Command *addSeparator(const Context &context, const Id &group = Id(), QAction **outSeparator = 0) = 0;
|
||||
virtual QAction *insertLocation(Id group) const = 0;
|
||||
virtual void appendGroup(Id group) = 0;
|
||||
virtual void insertGroup(Id before, Id group) = 0;
|
||||
virtual void addAction(Command *action, Id group = Id()) = 0;
|
||||
virtual void addMenu(ActionContainer *menu, Id group = Id()) = 0;
|
||||
virtual void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id()) = 0;
|
||||
virtual Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0) = 0;
|
||||
|
||||
// This clears this menu and submenus from all actions and submenus.
|
||||
// It does not destroy the submenus and commands, just removes them from their parents.
|
||||
|
||||
@@ -56,13 +56,13 @@ public:
|
||||
void setOnAllDisabledBehavior(OnAllDisabledBehavior behavior);
|
||||
ActionContainer::OnAllDisabledBehavior onAllDisabledBehavior() const;
|
||||
|
||||
QAction *insertLocation(const Id &groupId) const;
|
||||
void appendGroup(const Id &id);
|
||||
void insertGroup(const Id &before, const Id &groupId);
|
||||
void addAction(Command *action, const Id &group = Id());
|
||||
void addMenu(ActionContainer *menu, const Id &group = Id());
|
||||
void addMenu(ActionContainer *before, ActionContainer *menu, const Id &group = Id());
|
||||
Command *addSeparator(const Context &context, const Id &group = Id(), QAction **outSeparator = 0);
|
||||
QAction *insertLocation(Id groupId) const;
|
||||
void appendGroup(Id id);
|
||||
void insertGroup(Id before, Id groupId);
|
||||
void addAction(Command *action, Id group = Id());
|
||||
void addMenu(ActionContainer *menu, Id group = Id());
|
||||
void addMenu(ActionContainer *before, ActionContainer *menu, Id group = Id());
|
||||
Command *addSeparator(const Context &context, Id group = Id(), QAction **outSeparator = 0);
|
||||
virtual void clear();
|
||||
|
||||
Id id() const;
|
||||
@@ -92,7 +92,7 @@ private slots:
|
||||
void itemDestroyed();
|
||||
|
||||
private:
|
||||
QList<Group>::const_iterator findGroup(const Id &groupId) const;
|
||||
QList<Group>::const_iterator findGroup(Id groupId) const;
|
||||
QAction *insertLocation(QList<Group>::const_iterator group) const;
|
||||
|
||||
OnAllDisabledBehavior m_onAllDisabledBehavior;
|
||||
|
||||
@@ -177,7 +177,7 @@ ActionManager *ActionManager::instance()
|
||||
Add your menu to some other menu or a menu bar via the
|
||||
ActionManager::actionContainer and ActionContainer::addMenu methods.
|
||||
*/
|
||||
ActionContainer *ActionManager::createMenu(const Id &id)
|
||||
ActionContainer *ActionManager::createMenu(Id id)
|
||||
{
|
||||
const ActionManagerPrivate::IdContainerMap::const_iterator it = m_instance->d->m_idContainerMap.constFind(id);
|
||||
if (it != m_instance->d->m_idContainerMap.constEnd())
|
||||
@@ -202,7 +202,7 @@ ActionContainer *ActionManager::createMenu(const Id &id)
|
||||
or to add menus to the menu bar. The ActionManager owns
|
||||
the returned ActionContainer.
|
||||
*/
|
||||
ActionContainer *ActionManager::createMenuBar(const Id &id)
|
||||
ActionContainer *ActionManager::createMenuBar(Id id)
|
||||
{
|
||||
const ActionManagerPrivate::IdContainerMap::const_iterator it = m_instance->d->m_idContainerMap.constFind(id);
|
||||
if (it != m_instance->d->m_idContainerMap.constEnd())
|
||||
@@ -231,7 +231,7 @@ ActionContainer *ActionManager::createMenuBar(const Id &id)
|
||||
A scriptable action can be called from a script without the need for the user
|
||||
to interact with it.
|
||||
*/
|
||||
Command *ActionManager::registerAction(QAction *action, const Id &id, const Context &context, bool scriptable)
|
||||
Command *ActionManager::registerAction(QAction *action, Id id, const Context &context, bool scriptable)
|
||||
{
|
||||
Action *a = m_instance->d->overridableAction(id);
|
||||
if (a) {
|
||||
@@ -253,7 +253,7 @@ Command *ActionManager::registerAction(QAction *action, const Id &id, const Cont
|
||||
A scriptable shortcut can be called from a script without the need for the user
|
||||
to interact with it.
|
||||
*/
|
||||
Command *ActionManager::registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable)
|
||||
Command *ActionManager::registerShortcut(QShortcut *shortcut, Id id, const Context &context, bool scriptable)
|
||||
{
|
||||
QTC_CHECK(!context.isEmpty());
|
||||
Shortcut *sc = 0;
|
||||
@@ -297,7 +297,7 @@ Command *ActionManager::registerShortcut(QShortcut *shortcut, const Id &id, cons
|
||||
|
||||
\sa ActionManager::registerAction()
|
||||
*/
|
||||
Command *ActionManager::command(const Id &id)
|
||||
Command *ActionManager::command(Id id)
|
||||
{
|
||||
const ActionManagerPrivate::IdCmdMap::const_iterator it = m_instance->d->m_idCmdMap.constFind(id);
|
||||
if (it == m_instance->d->m_idCmdMap.constEnd()) {
|
||||
@@ -316,7 +316,7 @@ Command *ActionManager::command(const Id &id)
|
||||
\sa ActionManager::createMenu()
|
||||
\sa ActionManager::createMenuBar()
|
||||
*/
|
||||
ActionContainer *ActionManager::actionContainer(const Id &id)
|
||||
ActionContainer *ActionManager::actionContainer(Id id)
|
||||
{
|
||||
const ActionManagerPrivate::IdContainerMap::const_iterator it = m_instance->d->m_idContainerMap.constFind(id);
|
||||
if (it == m_instance->d->m_idContainerMap.constEnd()) {
|
||||
@@ -348,7 +348,7 @@ QList<Command *> ActionManager::commands()
|
||||
filters. If the user removes such an action, it also has to be unregistered from the action manager,
|
||||
to make it disappear from shortcut settings etc.
|
||||
*/
|
||||
void ActionManager::unregisterAction(QAction *action, const Id &id)
|
||||
void ActionManager::unregisterAction(QAction *action, Id id)
|
||||
{
|
||||
Action *a = 0;
|
||||
CommandPrivate *c = m_instance->d->m_idCmdMap.value(id, 0);
|
||||
@@ -379,7 +379,7 @@ void ActionManager::unregisterAction(QAction *action, const Id &id)
|
||||
a corresponding shortcut also has to be unregistered from the action manager,
|
||||
to make it disappear from shortcut settings etc.
|
||||
*/
|
||||
void ActionManager::unregisterShortcut(const Core::Id &id)
|
||||
void ActionManager::unregisterShortcut(Id id)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
CommandPrivate *c = m_instance->d->m_idCmdMap.value(id, 0);
|
||||
@@ -525,7 +525,7 @@ void ActionManagerPrivate::showShortcutPopup(const QString &shortcut)
|
||||
m_presentationLabelTimer.start();
|
||||
}
|
||||
|
||||
Action *ActionManagerPrivate::overridableAction(const Id &id)
|
||||
Action *ActionManagerPrivate::overridableAction(Id id)
|
||||
{
|
||||
Action *a = 0;
|
||||
if (CommandPrivate *c = m_idCmdMap.value(id, 0)) {
|
||||
|
||||
@@ -58,19 +58,19 @@ class CORE_EXPORT ActionManager : public QObject
|
||||
public:
|
||||
static ActionManager *instance();
|
||||
|
||||
static ActionContainer *createMenu(const Id &id);
|
||||
static ActionContainer *createMenuBar(const Id &id);
|
||||
static ActionContainer *createMenu(Id id);
|
||||
static ActionContainer *createMenuBar(Id id);
|
||||
|
||||
static Command *registerAction(QAction *action, const Id &id, const Context &context, bool scriptable = false);
|
||||
static Command *registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable = false);
|
||||
static Command *registerAction(QAction *action, Id id, const Context &context, bool scriptable = false);
|
||||
static Command *registerShortcut(QShortcut *shortcut, Id id, const Context &context, bool scriptable = false);
|
||||
|
||||
static Command *command(const Id &id);
|
||||
static ActionContainer *actionContainer(const Id &id);
|
||||
static Command *command(Id id);
|
||||
static ActionContainer *actionContainer(Id id);
|
||||
|
||||
static QList<Command *> commands();
|
||||
|
||||
static void unregisterAction(QAction *action, const Id &id);
|
||||
static void unregisterShortcut(const Id &id);
|
||||
static void unregisterAction(QAction *action, Id id);
|
||||
static void unregisterShortcut(Id id);
|
||||
|
||||
static void setPresentationModeEnabled(bool enabled);
|
||||
static bool isPresentationModeEnabled();
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
|
||||
void showShortcutPopup(const QString &shortcut);
|
||||
bool hasContext(const Context &context) const;
|
||||
Action *overridableAction(const Id &id);
|
||||
Action *overridableAction(Id id);
|
||||
|
||||
public slots:
|
||||
void containerDestroyed();
|
||||
|
||||
Reference in New Issue
Block a user