24 if ((index < 0) || (index > container->actions().count())) {
25 qWarning() <<
"Index " << index <<
" is not within range (0 - " << container->actions().count();
26 }
else if (index != container->actions().count()) {
27 before = container->actions().at(index);
30 Q_FOREACH (QAction *action, *
this) {
31 container->insertAction(before, action);
38 Q_FOREACH (QAction *action, *
this) {
39 if (container->actions().contains(action)) {
40 container->removeAction(action);
48 QAction *_containerAction,
const QString &_mergingName,
49 const QString &_groupName,
const QStringList &customTags,
51 : parent(_parent), client(_client), builder(_builder),
52 builderCustomTags(customTags), builderContainerTags(containerTags),
53 container(_container), containerAction(_containerAction), tagName(_tagName), name(_name),
54 groupName(_groupName), index(0), mergingName(_mergingName)
77 MergingIndexList::Iterator mergingIt =
findIndex(childIterator.peekNext()->mergingName);
79 delete childIterator.next();
80 childIterator.remove();
91 for (; it != end; ++it)
92 if ((*it).mergingName ==
name) {
119 if ((tag &&
tagName == _name) ||
120 (!tag &&
name == _name)) {
144 ContainerNodeList::ConstIterator nIt =
children.constBegin();
146 if (!
name.isEmpty()) {
147 for (; nIt !=
children.constEnd(); ++nIt)
148 if ((*nIt)->name ==
name &&
149 !excludeList->contains((*nIt)->container)) {
158 for (; nIt !=
children.constEnd(); ++nIt) {
159 if ((*nIt)->tagName ==
tagName &&
160 !excludeList->contains((*nIt)->container)
186 const QString &groupName,
187 const MergingIndexList::Iterator &mergingIdx)
191 if (
client->client == currentGUIClient) {
203 client->client = currentGUIClient;
207 client->mergingName = (*mergingIdx).mergingName;
219 for (; mIt != mEnd; ++mIt) {
230 static const QString &tagActionList = QString::fromLatin1(
"actionlist");
236 if (k.indexOf(tagActionList) == -1) {
240 k = k.mid(tagActionList.length());
265 for (; mIt != mEnd; ++mIt) {
276 static const QString &tagActionList = QString::fromLatin1(
"actionlist");
282 if (k.indexOf(tagActionList) == -1) {
286 k = k.mid(tagActionList.length());
300 ActionListMap::Iterator lIt(
client->actionLists.find(k));
301 if (lIt ==
client->actionLists.end()) {
309 client->actionLists.erase(lIt);
313 const MergingIndexList::Iterator &it)
315 MergingIndexList::Iterator mergingIt = it;
318 for (; mergingIt != mergingEnd; ++mergingIt) {
319 (*mergingIt).value += offset;
333 while (cmIt.hasNext())
334 if (cmIt.next().clientName == state.
clientName) {
341 QWidget *parentContainer = 0L;
366 QMutableListIterator<ContainerNode *> childIt =
children;
367 while (childIt.hasNext()) {
373 if (childNode->
destruct(childElement, state)) {
385 for (QDomNode n = baseElement.firstChild(); !n.isNull();
386 n = n.nextSibling()) {
387 QDomElement e = n.toElement();
388 if (e.tagName().toLower() == childNode->
tagName &&
389 e.attribute(QStringLiteral(
"name")) == childNode->
name) {
394 return QDomElement();
403 QMutableListIterator<ContainerClient *> clientIt(
clients);
416 while (clientIt.hasNext())
419 if (clientIt.peekNext()->client == state.
guiClient) {
421 delete clientIt.next();
436 for (; custIt != custEnd; ++custIt) {
452 +
client->customElements.count()),
457 ActionListMap::ConstIterator alIt =
client->actionLists.constBegin();
458 ActionListMap::ConstIterator alEnd =
client->actionLists.constEnd();
459 for (; alIt != alEnd; ++alIt) {
464 QString mergingKey = alIt.key();
465 mergingKey.prepend(QStringLiteral(
"actionlist"));
467 MergingIndexList::Iterator mIt =
findIndex(mergingKey);
492 MergingIndexList::Iterator &it,
494 bool ignoreDefaultMergingIndex)
496 MergingIndexList::Iterator mergingIt;
508 ignoreDefaultMergingIndex) {
512 if (mergingIt != mergingEnd) {
523 const QLatin1String attrGroup(
"group");
525 bool haveGroup =
false;
526 group = element.attribute(attrGroup);
527 if (!group.isEmpty()) {
528 group.prepend(attrGroup);
545 : containerClient(0), ignoreDefaultMergingIndex(false), m_state(state),
569 for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) {
570 QDomElement e = n.toElement();
580 QString tag(e.tagName().toLower());
581 QString currName(e.attribute(QStringLiteral(
"name")));
583 bool isActionTag = (tag == QStringLiteral(
"action"));
585 if (isActionTag ||
customTags.indexOf(tag) != -1) {
589 }
else if (tag == QStringLiteral(
"merge") || tag == QLatin1String(
"definegroup")
590 || tag == QStringLiteral(
"actionlist")) {
592 }
else if (tag == QStringLiteral(
"state")) {
610 bool guiElementCreated =
false;
617 if (guiElementCreated)
636 QAction *before = 0L;
637 if (idx >= 0 && idx < parentNode->container->actions().count()) {
664 QString stateName = element.attribute(QStringLiteral(
"name"));
666 if (stateName.isNull() || !stateName.length()) {
670 for (QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling()) {
671 QDomElement e = n.toElement();
676 QString tagName = e.tagName().toLower();
678 if (tagName != QStringLiteral(
"enable") && tagName != QLatin1String(
"disable")) {
682 bool processingActionsToEnable = (tagName == QStringLiteral(
"enable"));
685 for (QDomNode n2 = n.firstChild(); !n2.isNull(); n2 = n2.nextSibling()) {
686 QDomElement actionEl = n2.toElement();
687 if (actionEl.tagName().toLower() != QStringLiteral(
"action")) {
691 QString actionName = actionEl.attribute(QStringLiteral(
"name"));
692 if (actionName.isEmpty()) {
696 if (processingActionsToEnable) {
708 const QLatin1String tagDefineGroup(
"definegroup");
709 const QLatin1String tagActionList(
"actionlist");
710 const QLatin1String defaultMergingName(
"<default>");
711 const QLatin1String attrGroup(
"group");
713 QString mergingName(name);
714 if (mergingName.isEmpty()) {
715 if (tag == tagDefineGroup) {
716 qCritical() <<
"cannot define group without name!" << Qt::endl;
719 if (tag == tagActionList) {
720 qCritical() <<
"cannot define actionlist without name!" << Qt::endl;
723 mergingName = defaultMergingName;
726 if (tag == tagDefineGroup) {
727 mergingName.prepend(attrGroup);
730 else if (tag == tagActionList) {
731 mergingName.prepend(tagActionList);
740 QString group(e.attribute(attrGroup));
741 if (!group.isEmpty()) {
742 group.prepend(attrGroup);
761 if (mergingName == defaultMergingName)
780 if (!containerNode) {
786 QAction *containerAction;
805 mergingName = (*it).mergingName;
817 mergingName, group, cusTags, conTags);
819 if (tag == QStringLiteral(
"toolbar")) {
826 qWarning() <<
"toolbar container is not a KisToolBar";
840 const QDomElement &element, QAction *&containerAction,
float value(const T *src, size_t ch)
virtual QAction * createCustomElement(QWidget *parent, int index, const QDomElement &element)
virtual QWidget * createContainer(QWidget *parent, int index, const QDomElement &element, QAction *&containerAction)
virtual void removeCustomElement(QWidget *parent, QAction *action)
virtual void removeContainer(QWidget *container, QWidget *parent, QDomElement &element, QAction *containerAction)
void setBuilderClient(KisKXMLGUIClient *client)
KisKXMLGUIClient * builderClient() const
void setFactory(KisKXMLGUIFactory *factory)
virtual QString xmlFile() const
QAction * action(const char *name) const
void addStateActionEnabled(const QString &state, const QString &action)
void addStateActionDisabled(const QString &state, const QString &action)
void unplug(QWidget *container) const
void plug(QWidget *container, int index) const
void processActionOrCustomElement(const QDomElement &e, bool isActionTag)
void processStateElement(const QDomElement &element)
bool processActionElement(const QDomElement &e, int idx)
BuildHelper(BuildState &state, ContainerNode *node)
QWidget * createContainer(QWidget *parent, int index, const QDomElement &element, QAction *&containerAction, KisKXMLGUIBuilder **builder)
ContainerNode * parentNode
bool ignoreDefaultMergingIndex
QStringList containerTags
bool processCustomElement(const QDomElement &e, int idx)
void processElement(const QDomElement &element)
void build(const QDomElement &element)
QList< QWidget * > containerList
void processMergeElement(const QString &tag, const QString &name, const QDomElement &e)
int calcMergingIndex(const QDomElement &element, MergingIndexList::Iterator &it, QString &group)
ContainerClient * containerClient
void processContainerElement(const QDomElement &e, const QString &tag, const QString &name)
MergingIndexList::Iterator currentDefaultMergingIt
QStringList clientBuilderContainerTags
QStringList builderCustomTags
QStringList builderContainerTags
QStringList clientBuilderCustomTags
KisKXMLGUIBuilder * builder
KisKXMLGUIClient * guiClient
KisKXMLGUIBuilder * clientBuilder
MergingIndexList::Iterator currentClientMergingIt
QList< QAction * > customElements
ContainerNode * findContainerNode(QWidget *container)
QStringList builderContainerTags
void unplugActionList(BuildState &state)
MergingIndexList::Iterator findIndex(const QString &name)
KisKXMLGUIClient * client
MergingIndexList mergingIndices
void removeChild(ContainerNode *child)
static QDomElement findElementForChild(const QDomElement &baseElement, ContainerNode *childNode)
ContainerClient * findChildContainerClient(KisKXMLGUIClient *currentGUIClient, const QString &groupName, const MergingIndexList::Iterator &mergingIdx)
void unplugActions(BuildState &state)
void plugActionList(BuildState &state)
int calcMergingIndex(const QString &mergingName, MergingIndexList::Iterator &it, BuildState &state, bool ignoreDefaultMergingIndex)
ContainerClientList clients
ContainerNode * findContainer(const QString &_name, bool tag)
QStringList builderCustomTags
QList< ContainerNode * > children
void destructChildren(const QDomElement &element, BuildState &state)
void adjustMergingIndices(int offset, const MergingIndexList::Iterator &it)
bool destruct(QDomElement element, BuildState &state)
void unplugClient(ContainerClient *client)
KisKXMLGUIBuilder * builder
ContainerNode(QWidget *_container, const QString &_tagName, const QString &_name, ContainerNode *_parent=0L, KisKXMLGUIClient *_client=0L, KisKXMLGUIBuilder *_builder=0L, QAction *containerAction=0, const QString &_mergingName=QString(), const QString &groupName=QString(), const QStringList &customTags=QStringList(), const QStringList &containerTags=QStringList())
QAction * containerAction