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:
Eike Ziller
2012-06-05 14:22:20 +02:00
committed by hjk
parent d90264d6c2
commit cdd44befff
34 changed files with 132 additions and 394 deletions

View File

@@ -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);