forked from qt-creator/qt-creator
Add ActionContainer::addSeparator(...)
Gets rid of a lot of code duplication. Change-Id: I2ce38fb38a0b61cb821e0bdc7bcc9a7ccdf9da72 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "actioncontainer_p.h"
|
||||
#include "actionmanager_p.h"
|
||||
#include "actionmanager.h"
|
||||
|
||||
#include "command_p.h"
|
||||
|
||||
@@ -293,6 +294,31 @@ void ActionContainerPrivate::addMenu(ActionContainer *before, ActionContainer *m
|
||||
scheduleUpdate();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \fn Command *ActionContainer::addSeparator(const Context &context, const Id &group, QAction **outSeparator)
|
||||
*
|
||||
* Adds a separator to the end of the given \a group to the action container, which is enabled
|
||||
* for a given \a context. The created separator action is returned through \a outSeparator.
|
||||
*
|
||||
* Returns the created Command for the separator.
|
||||
*/
|
||||
/*! \a context \a group \a outSeparator
|
||||
* \internal
|
||||
*/
|
||||
Command *ActionContainerPrivate::addSeparator(const Context &context, const Id &group, QAction **outSeparator)
|
||||
{
|
||||
static int separatorIdCount = 0;
|
||||
QAction *separator = new QAction(this);
|
||||
separator->setSeparator(true);
|
||||
Command *cmd = ActionManager::registerAction(separator, Id(QString::fromLatin1("%1.Separator.%2")
|
||||
.arg(id().toString()).arg(++separatorIdCount)),
|
||||
context);
|
||||
addAction(cmd, group);
|
||||
if (outSeparator)
|
||||
*outSeparator = separator;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
void ActionContainerPrivate::clear()
|
||||
{
|
||||
QMutableListIterator<Group> it(m_groups);
|
||||
|
||||
Reference in New Issue
Block a user