Commit dd764bcb authored by Thomas Zander's avatar Thomas Zander

Actions that are associated with a shape are unique, let the API reflect that.

You can only add an action once and they are unsorted, so a QSet fits
better, with the added bonus that it removes some slow code.

svn path=/trunk/koffice/; revision=1067870
parent 298c694c
......@@ -110,9 +110,9 @@ void KoEventActionRegistry::init()
config);
}
QList<KoEventAction*> KoEventActionRegistry::createEventActionsFromOdf(const KoXmlElement & e, KoShapeLoadingContext & context) const
QSet<KoEventAction*> KoEventActionRegistry::createEventActionsFromOdf(const KoXmlElement & e, KoShapeLoadingContext & context) const
{
QList<KoEventAction *> eventActions;
QSet<KoEventAction *> eventActions;
if (e.namespaceURI() == KoXmlNS::office && e.tagName() == "event-listeners") {
KoXmlElement element;
......@@ -126,7 +126,7 @@ QList<KoEventAction*> KoEventActionRegistry::createEventActionsFromOdf(const KoX
KoEventAction * eventAction = it.value()->createEventAction();
if (eventAction) {
if (eventAction->loadOdf(element, context)) {
eventActions.append(eventAction);
eventActions.insert(eventAction);
} else {
delete eventAction;
}
......
......@@ -21,6 +21,7 @@
#define KOEVENTACTIONREGISTRY_H
#include <QList>
#include <QSet>
#include "flake_export.h"
#include "KoXmlReaderForward.h"
......@@ -48,7 +49,7 @@ public:
/**
* Create action events for the elements given
*/
QList<KoEventAction*> createEventActionsFromOdf(const KoXmlElement &element, KoShapeLoadingContext &context) const;
QSet<KoEventAction*> createEventActionsFromOdf(const KoXmlElement &element, KoShapeLoadingContext &context) const;
/**
* Add presentation event action.
......
......@@ -655,23 +655,19 @@ QList<QPointF> KoShape::connectionPoints() const
return points;
}
void KoShape::addEventAction(KoEventAction * action)
void KoShape::addEventAction(KoEventAction *action)
{
Q_D(KoShape);
if (! d->eventActions.contains(action)) {
d->eventActions.append(action);
}
d->eventActions.insert(action);
}
void KoShape::removeEventAction(KoEventAction * action)
void KoShape::removeEventAction(KoEventAction *action)
{
Q_D(KoShape);
if (d->eventActions.contains(action)) {
d->eventActions.removeAll(action);
}
d->eventActions.remove(action);
}
QList<KoEventAction *> KoShape::eventActions() const
QSet<KoEventAction *> KoShape::eventActions() const
{
Q_D(const KoShape);
return d->eventActions;
......
......@@ -322,7 +322,7 @@ public:
/**
* Get all event actions
*/
QList<KoEventAction *> eventActions() const;
QSet<KoEventAction *> eventActions() const;
/**
* Set the background of the shape.
......
......@@ -57,7 +57,7 @@ public:
KoShapeShadow * shadow; ///< the current shape shadow
QMap<QByteArray, QString> additionalAttributes;
QMap<QByteArray, QString> additionalStyleAttributes;
QList<KoEventAction *> eventActions; ///< list of event actions the shape has
QSet<KoEventAction *> eventActions; ///< list of event actions the shape has
KoFilterEffectStack *filterEffectStack; ///< stack of filter effects applied to the shape
qreal transparency; ///< the shapes tranparency
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment