Commit 444efa4a authored by Thomas Zander's avatar Thomas Zander

Introduce new concept; 'toolDelegates'

From the API docs;
In Flake a shape being selected will cause the tool manager to make available
all tools that can edit the selected shapes.  In some cases selecting one
shape should allow the tool to edit a related shape be available too.  The
tool delegates allows this to happen by taking all the shapes in the set
into account on tool selection.

This is step one to fix headers/footers in KWord properly.
This is inspired by the needs for things like text-on-shape and caption-shape

svn path=/trunk/koffice/; revision=1096387
parent 20b5277d
......@@ -1451,6 +1451,18 @@ void KoShape::setFilterEffectStack(KoFilterEffectStack *filterEffectStack)
notifyChanged();
}
QSet<KoShape*> KoShape::toolDelegates() const
{
Q_D(const KoShape);
return d->toolDelegates;
}
void KoShape::setToolDelegates(const QSet<KoShape*> &delegates)
{
Q_D(KoShape);
d->toolDelegates = delegates;
}
KoShapePrivate *KoShape::priv()
{
Q_D(KoShape);
......
/* This file is part of the KDE project
Copyright (C) 2006-2008 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2006, 2008 Casper Boemann <cbr@boemann.dk>
Copyright (C) 2006-2009 Thomas Zander <zander@kde.org>
Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
Copyright (C) 2007-2009 Jan Hambrecht <jaham@gmx.net>
This library is free software; you can redistribute it and/or
......@@ -835,6 +835,24 @@ public:
*/
bool collisionDetection();
/**
* Return the tool delegates for this shape.
* In Flake a shape being selected will cause the tool manager to make available all tools that
* can edit the selected shapes. In some cases selecting one shape should allow the tool to
* edit a related shape be available too. The tool delegates allows this to happen by taking
* all the shapes in the set into account on tool selection.
* Notice that if you the set is non-empty 'this' shape is no longer looked at. You can choose
* to add itself to the set too.
*/
QSet<KoShape*> toolDelegates() const;
/**
* Set the tool delegates.
* @param delegates the new delegates.
* @see toolDelegates()
*/
void setToolDelegates(const QSet<KoShape*> &delegates);
/**
* \internal
* Returns the private object for use withing the flake lib
......
......@@ -53,6 +53,7 @@ public:
KoShapeContainer *parent;
QSet<KoShapeManager *> shapeManagers;
QSet<KoShape *> toolDelegates;
KoShapeUserData *userData;
KoShapeApplicationData *appData;
KoShapeBackground * fill; ///< Stands for the background color / fill etc.
......
......@@ -517,8 +517,16 @@ void KoToolManager::Private::selectionChanged(QList<KoShape*> shapes)
{
QList<QString> types;
foreach(KoShape *shape, shapes) {
if (! types.contains(shape->shapeId())) {
types.append(shape->shapeId());
QSet<KoShape*> delegates = shape->toolDelegates();
if (delegates.isEmpty()) { // no delegates, just the orig shape
delegates << shape;
}
foreach (KoShape *shape2, delegates) {
Q_ASSERT(shape2);
if (! types.contains(shape2->shapeId())) {
types.append(shape2->shapeId());
}
}
}
......
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