Commit cc393bc7 authored by Jan Hambrecht's avatar Jan Hambrecht

added a struct KoConnectionPoint to save additional data along the connection point position

parent 72c88f71
......@@ -85,6 +85,7 @@ set(flake_SRCS
KoDragOdfSaveHelper.cpp
KoShapeOdfSaveHelper.cpp
KoShapePaste.cpp
KoConnectionPoint.cpp
KoConnectionShape.cpp
KoConnectionShapeLoadingUpdater.cpp
KoConnectionShapeFactory.cpp
......
/* This file is part of the KDE project
*
* Copyright (C) 2011 Jan Hambrecht <jaham@gmx.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoConnectionPoint.h"
KoConnectionPoint::KoConnectionPoint()
: position(0, 0), escapeDirection(AllDirections)
{
}
KoConnectionPoint::KoConnectionPoint(const QPointF& pos)
: position(pos), escapeDirection(AllDirections)
{
}
KoConnectionPoint::KoConnectionPoint(const QPointF& pos, EscapeDirection direction)
: position(pos), escapeDirection(direction)
{
}
KoConnectionPoint KoConnectionPoint::defaultConnectionPoint(PointId connectionPointId)
{
switch(connectionPointId)
{
case TopConnectionPoint:
return KoConnectionPoint(QPointF(0.5, 0.0));
case RightConnectionPoint:
return KoConnectionPoint(QPointF(1.0, 0.5));
case BottomConnectionPoint:
return KoConnectionPoint(QPointF(0.5, 1.0));
case LeftConnectionPoint:
return KoConnectionPoint(QPointF(0.0, 0.5));
default:
return KoConnectionPoint();
}
}
/* This file is part of the KDE project
*
* Copyright (C) 2011 Jan Hambrecht <jaham@gmx.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOCONNECTIONPOINT_H
#define KOCONNECTIONPOINT_H
#include "KoFlake.h"
#include "flake_export.h"
#include <QtCore/QPointF>
/// Data of a single connection point
struct FLAKE_EXPORT KoConnectionPoint
{
/// Default connection point ids
enum PointId {
TopConnectionPoint = 0, ///< default connection point on the middle of the top edge
RightConnectionPoint = 1, ///< default connection point on the middle of the right edge
BottomConnectionPoint = 2, ///< default connection point on the middle of the bottom edge
LeftConnectionPoint = 3, ///< default connection point on the middle of the left edge
FirstCustomConnectionPoint = 4 ///< first custom connection point id
};
/// Escape directions for connections connected to connection points
enum EscapeDirection {
AllDirections, ///< connection can escape in all directions
HorizontalDirections, ///< connection can escape left and right
VerticalDirections, ///< connection can escape top and down
LeftDirection, ///< connection can escape left
RightDirection, ///< connection can escape right
UpDirection, ///< connection can escape up
DownDirection ///< connection can escape down
};
/// Default constructor
KoConnectionPoint();
/// Creates connection point with specified position
KoConnectionPoint(const QPointF &position);
/// Creates connection point with specified position and escape direction
KoConnectionPoint(const QPointF &position, EscapeDirection escapeDirection);
/// Returns default connection point with specified id
static KoConnectionPoint defaultConnectionPoint(KoConnectionPoint::PointId connectionPointId);
QPointF position; ///< the position of the connection point in shape coordinates
EscapeDirection escapeDirection; ///< the escape direction for connection attached to that connection point
};
/// Connection point container storing connection point data along their id
typedef QMap<int, KoConnectionPoint> KoConnectionPoints;
#endif // KOCONNECTIONPOINT_H
......@@ -216,7 +216,7 @@ void KoConnectionShape::updateConnections()
if (d->handleConnected(StartHandle)) {
if (d->shape1->hasConnectionPoint(d->connectionPointId1)) {
// map connection point into our shape coordinates
QPointF p = documentToShape(d->shape1->absoluteTransformation(0).map(d->shape1->connectionPoint(d->connectionPointId1)));
QPointF p = documentToShape(d->shape1->absoluteTransformation(0).map(d->shape1->connectionPoint(d->connectionPointId1).position));
if (d->handles[StartHandle] != p) {
d->handles[StartHandle] = p;
updateHandles = true;
......@@ -226,7 +226,7 @@ void KoConnectionShape::updateConnections()
if (d->handleConnected(EndHandle)) {
if (d->shape2->hasConnectionPoint(d->connectionPointId2)) {
// map connection point into our shape coordinates
QPointF p = documentToShape(d->shape2->absoluteTransformation(0).map(d->shape2->connectionPoint(d->connectionPointId2)));
QPointF p = documentToShape(d->shape2->absoluteTransformation(0).map(d->shape2->connectionPoint(d->connectionPointId2).position));
if (d->handles[EndHandle] != p) {
d->handles[EndHandle] = p;
updateHandles = true;
......@@ -347,7 +347,7 @@ bool KoConnectionShape::loadOdf(const KoXmlElement & element, KoShapeLoadingCont
d->shape1->addDependee(this);
if (d->shape1->hasConnectionPoint(d->connectionPointId1)) {
kDebug(30006) << "connecting to start-shape";
d->handles[StartHandle] = d->shape1->absoluteTransformation(0).map(d->shape1->connectionPoint(d->connectionPointId1));
d->handles[StartHandle] = d->shape1->absoluteTransformation(0).map(d->shape1->connectionPoint(d->connectionPointId1).position);
kDebug(30006) << "start handle position =" << d->handles[StartHandle];
}
} else {
......@@ -369,7 +369,7 @@ bool KoConnectionShape::loadOdf(const KoXmlElement & element, KoShapeLoadingCont
d->shape2->addDependee(this);
if (d->shape2->hasConnectionPoint(d->connectionPointId2)) {
kDebug(30006) << "connecting to end-shape";
d->handles[EndHandle] = d->shape2->absoluteTransformation(0).map(d->shape2->connectionPoint(d->connectionPointId2));
d->handles[EndHandle] = d->shape2->absoluteTransformation(0).map(d->shape2->connectionPoint(d->connectionPointId2).position);
kDebug(30006) << "end handle position =" << d->handles[EndHandle];
}
} else {
......@@ -430,14 +430,14 @@ void KoConnectionShape::finishLoadingConnection()
QPointF p1, p2;
if (d->handleConnected(StartHandle)) {
if (d->shape1->hasConnectionPoint(d->connectionPointId1)) {
p1 = d->shape1->absoluteTransformation(0).map(d->shape1->connectionPoint(d->connectionPointId1));
p1 = d->shape1->absoluteTransformation(0).map(d->shape1->connectionPoint(d->connectionPointId1).position);
}
} else {
p1 = d->handles[StartHandle];
}
if (d->handleConnected(EndHandle)) {
if (d->shape2->hasConnectionPoint(d->connectionPointId2)) {
p2 = d->shape2->absoluteTransformation(0).map(d->shape2->connectionPoint(d->connectionPointId2));
p2 = d->shape2->absoluteTransformation(0).map(d->shape2->connectionPoint(d->connectionPointId2).position);
}
} else {
p2 = d->handles[EndHandle];
......
......@@ -81,15 +81,6 @@ namespace KoFlake
Foreground ///< the foreground / border style is active
};
/// Default connection point ids
enum ConnectionPointId {
TopConnectionPoint = 0,
RightConnectionPoint = 1,
BottomConnectionPoint = 2,
LeftConnectionPoint = 3,
FirstCustomConnectionPoint = 4
};
/// clones the given gradient
FLAKE_EXPORT QGradient *cloneGradient(const QGradient *gradient);
......
......@@ -105,10 +105,10 @@ KoShapePrivate::KoShapePrivate(KoShape *shape)
textRunAroundSide(KoShape::BiggestRunAroundSide),
textRunAroundDistance(1.0)
{
connectors[KoFlake::TopConnectionPoint] = defaultConnectionPoint(KoFlake::TopConnectionPoint);
connectors[KoFlake::RightConnectionPoint] = defaultConnectionPoint(KoFlake::RightConnectionPoint);
connectors[KoFlake::BottomConnectionPoint] = defaultConnectionPoint(KoFlake::BottomConnectionPoint);
connectors[KoFlake::LeftConnectionPoint] = defaultConnectionPoint(KoFlake::LeftConnectionPoint);
connectors[KoConnectionPoint::TopConnectionPoint] = KoConnectionPoint::defaultConnectionPoint(KoConnectionPoint::TopConnectionPoint);
connectors[KoConnectionPoint::RightConnectionPoint] = KoConnectionPoint::defaultConnectionPoint(KoConnectionPoint::RightConnectionPoint);
connectors[KoConnectionPoint::BottomConnectionPoint] = KoConnectionPoint::defaultConnectionPoint(KoConnectionPoint::BottomConnectionPoint);
connectors[KoConnectionPoint::LeftConnectionPoint] = KoConnectionPoint::defaultConnectionPoint(KoConnectionPoint::LeftConnectionPoint);
}
KoShapePrivate::~KoShapePrivate()
......@@ -203,29 +203,12 @@ void KoShapePrivate::removeShapeCache()
}
}
QPointF KoShapePrivate::defaultConnectionPoint(KoFlake::ConnectionPointId connectionPointId)
{
switch(connectionPointId)
{
case KoFlake::TopConnectionPoint:
return QPointF(0.5, 0.0);
case KoFlake::RightConnectionPoint:
return QPointF(1.0, 0.5);
case KoFlake::BottomConnectionPoint:
return QPointF(0.5, 1.0);
case KoFlake::LeftConnectionPoint:
return QPointF(0.0, 0.5);
default:
return QPointF();
}
}
void KoShapePrivate::setConnectionPoint(int id, const QPointF &position)
void KoShapePrivate::setConnectionPoint(int id, KoConnectionPoint &point)
{
// restrict position of connection point to bounding box
const qreal x = qBound<qreal>(0.0, position.x(), 1.0);
const qreal y = qBound<qreal>(0.0, position.y(), 1.0);
connectors[id] = QPointF(x, y);
point.position.rx() = qBound<qreal>(0.0, point.position.x(), 1.0);
point.position.ry() = qBound<qreal>(0.0, point.position.y(), 1.0);
connectors[id] = point;
}
// static
......@@ -626,7 +609,7 @@ void KoShape::copySettings(const KoShape *shape)
Q_D(KoShape);
d->size = shape->size();
d->connectors.clear();
foreach(const QPointF &point, shape->connectionPoints())
foreach(const KoConnectionPoint &point, shape->connectionPoints())
addConnectionPoint(point);
d->zIndex = shape->zIndex();
d->visible = shape->isVisible();
......@@ -752,47 +735,50 @@ QPointF KoShape::position() const
return d->localMatrix.map(center) - center;
}
int KoShape::addConnectionPoint(const QPointF &point)
int KoShape::addConnectionPoint(const KoConnectionPoint &point)
{
Q_D(KoShape);
QSizeF s = size();
// get next glue point id
int nextConnectionPointId = KoFlake::FirstCustomConnectionPoint;
int nextConnectionPointId = KoConnectionPoint::FirstCustomConnectionPoint;
if (d->connectors.size())
nextConnectionPointId = qMax(nextConnectionPointId, (--d->connectors.end()).key()+1);
KoConnectionPoint p = point;
p.position = KoFlake::toRelative(p.position, size());
// convert glue point from shape coordinates to factors of size
d->setConnectionPoint(nextConnectionPointId, QPointF(point.x()/s.width(), point.y()/s.height()));
d->setConnectionPoint(nextConnectionPointId, p);
return nextConnectionPointId;
}
bool KoShape::insertConnectionPoint(const QPointF &point, int connectionPointId)
bool KoShape::insertConnectionPoint(const KoConnectionPoint &point, int connectionPointId)
{
Q_D(KoShape);
if (connectionPointId < 0 || d->connectors.contains(connectionPointId))
return false;
QPointF connectionPoint;
switch(connectionPointId) {
case KoFlake::TopConnectionPoint:
case KoFlake::RightConnectionPoint:
case KoFlake::BottomConnectionPoint:
case KoFlake::LeftConnectionPoint:
connectionPoint = d->defaultConnectionPoint(static_cast<KoFlake::ConnectionPointId>(connectionPointId));
case KoConnectionPoint::TopConnectionPoint:
case KoConnectionPoint::RightConnectionPoint:
case KoConnectionPoint::BottomConnectionPoint:
case KoConnectionPoint::LeftConnectionPoint:
{
KoConnectionPoint::PointId id = static_cast<KoConnectionPoint::PointId>(connectionPointId);
KoConnectionPoint p = KoConnectionPoint::defaultConnectionPoint(id);
d->setConnectionPoint(connectionPointId, p);
break;
}
default:
{
QSizeF s = size();
KoConnectionPoint p = point;
// convert glue point from shape coordinates to factors of size
connectionPoint.rx() = point.x() / s.width();
connectionPoint.ry() = point.y() / s.height();
p.position = KoFlake::toRelative(point.position, size());
d->setConnectionPoint(connectionPointId, p);
break;
}
}
d->setConnectionPoint(connectionPointId, connectionPoint);
return true;
}
......@@ -803,31 +789,28 @@ bool KoShape::hasConnectionPoint(int connectionPointId) const
return d->connectors.contains(connectionPointId);
}
QPointF KoShape::connectionPoint(int connectionPointId) const
KoConnectionPoint KoShape::connectionPoint(int connectionPointId) const
{
Q_D(const KoShape);
QSizeF s = size();
QPointF p = d->connectors.value(connectionPointId, QPointF());
p.rx() *= s.width();
p.ry() *= s.height();
KoConnectionPoint p = d->connectors.value(connectionPointId, KoConnectionPoint());
p.position = KoFlake::toAbsolute(p.position, size());
return p;
}
bool KoShape::setConnectionPointPosition(int connectionPointId, const QPointF &newPosition)
{
// do not allow to change position of default connection points
if (connectionPointId < KoFlake::FirstCustomConnectionPoint)
if (connectionPointId < KoConnectionPoint::FirstCustomConnectionPoint)
return false;
Q_D(KoShape);
if (!d->connectors.contains(connectionPointId))
return false;
QSizeF s = size();
KoConnectionPoint p = connectionPoint(connectionPointId);
// convert glue point from shape coordinates to factors of size
const qreal x = newPosition.x() / s.width();
const qreal y = newPosition.y() / s.height();
d->setConnectionPoint(connectionPointId, QPointF(x, y));
p.position = KoFlake::toRelative(newPosition, size());
d->setConnectionPoint(connectionPointId, p);
d->shapeChanged(ConnectionPointChanged);
return true;
......@@ -842,8 +825,7 @@ KoConnectionPoints KoShape::connectionPoints() const
KoConnectionPoints::iterator lastPoint = points.end();
// convert glue points to shape coordinates
for(; point != lastPoint; ++point) {
point->rx() *= s.width();
point->ry() *= s.height();
point->position = KoFlake::toAbsolute(point->position, s);
}
return points;
......@@ -1396,7 +1378,7 @@ bool KoShape::loadOdfAttributes(const KoXmlElement &element, KoShapeLoadingConte
if (child.localName() == "glue-point") {
const QString id = child.attributeNS(KoXmlNS::draw, "id", QString());
const int index = id.toInt();
if(id.isEmpty() || index < 4) {
if(id.isEmpty() || index < 4 || d->connectors.contains(index)) {
kWarning(30006) << "glue-point with no or invalid id";
continue;
}
......@@ -1447,7 +1429,8 @@ bool KoShape::loadOdfAttributes(const KoXmlElement &element, KoShapeLoadingConte
connectorPos.rx() += 1.0;
}
}
d->setConnectionPoint(index, connectorPos);
KoConnectionPoint connector(connectorPos);
d->setConnectionPoint(index, connector);
kDebug(30006) << "loaded glue-point" << index << "at position" << connectorPos;
}
}
......@@ -1787,8 +1770,8 @@ void KoShape::saveOdfCommonChildElements(KoShapeSavingContext &context) const
if(cp.key() < 4)
continue;
// convert to percent from center
const qreal x = cp.value().x() * 100.0 - 50.0;
const qreal y = cp.value().y() * 100.0 -50.0;
const qreal x = cp.value().position.x() * 100.0 - 50.0;
const qreal y = cp.value().position.y() * 100.0 -50.0;
context.xmlWriter().startElement("draw:glue-point");
context.xmlWriter().addAttribute("draw:id", QString("%1").arg(cp.key()));
context.xmlWriter().addAttribute("svg:x", QString("%1%").arg(x));
......
......@@ -25,6 +25,7 @@
#include "KoInsets.h"
#include "KoFlake.h"
#include "KoConnectionPoint.h"
#include <QTransform>
#include <QVector>
......@@ -34,6 +35,7 @@
#include <QMetaType>
#include <KoXmlReaderForward.h>
//#include <KoSnapData.h>
#include "flake_export.h"
......@@ -61,9 +63,6 @@ class KoShapePrivate;
class KoFilterEffectStack;
class KoSnapData;
/// Connection point container with id, position
typedef QMap<int, QPointF> KoConnectionPoints;
/**
*
* Base class for all flake shapes. Shapes extend this class
......@@ -319,13 +318,10 @@ public:
* A connector is a place on the shape that allows a graphical connection to be made
* using a line, for example.
*
* @param point the position where to place the connector. The points coordinate system
* are based around the zero-pos which is the top-left of the shape. The position of
* the connector is restricted to the bounding rectangle of the shape. The point is in pt,
* just like the rest of the KoShape class uses.
* @param point the connection point to add
* @return the id of the new connection point
*/
int addConnectionPoint(const QPointF &point);
int addConnectionPoint(const KoConnectionPoint &point);
/**
* Tries to insert connection point with specified id.
......@@ -337,13 +333,13 @@ public:
* @return true if inserting connection point was successful;
* false if connection point did already exists or id is invalid
*/
bool insertConnectionPoint(const QPointF &point, int connectionPointId);
bool insertConnectionPoint(const KoConnectionPoint &point, int connectionPointId);
/// Checks if a connection point with the specified id exists
bool hasConnectionPoint(int connectionPointId) const;
/// Returns connection point with specified connection point id
QPointF connectionPoint(int connectionPointId) const;
KoConnectionPoint connectionPoint(int connectionPointId) const;
/**
* Sets new position for specified custom connection point
......
......@@ -142,11 +142,8 @@ public:
*/
void removeShapeCache();
/// Returns the specified default connection point
QPointF defaultConnectionPoint(KoFlake::ConnectionPointId connectionPointId);
/// Sets the specified connection point
void setConnectionPoint(int id, const QPointF &position);
void setConnectionPoint(int id, KoConnectionPoint &point);
Q_DECLARE_PUBLIC(KoShape)
};
......
......@@ -92,22 +92,22 @@ void KoPathConnectionPointStrategy::handleMouseMove(const QPointF &mouseLocation
connectionPoints[-2] = QPointF(size.width(), 0.0);
connectionPoints[-3] = QPointF(size.width(), size.height());
connectionPoints[-4] = QPointF(0.0, size.height());
connectionPoints[-5] = 0.5 * (connectionPoints[-1] + connectionPoints[-2]);
connectionPoints[-6] = 0.5 * (connectionPoints[-2] + connectionPoints[-3]);
connectionPoints[-7] = 0.5 * (connectionPoints[-3] + connectionPoints[-4]);
connectionPoints[-8] = 0.5 * (connectionPoints[-4] + connectionPoints[-1]);
connectionPoints[-5] = 0.5 * (connectionPoints[-1].position + connectionPoints[-2].position);
connectionPoints[-6] = 0.5 * (connectionPoints[-2].position + connectionPoints[-3].position);
connectionPoints[-7] = 0.5 * (connectionPoints[-3].position + connectionPoints[-4].position);
connectionPoints[-8] = 0.5 * (connectionPoints[-4].position + connectionPoints[-1].position);
}
QPointF localMousePosition = shape->absoluteTransformation(0).inverted().map(mouseLocation);
KoConnectionPoints::const_iterator cp = connectionPoints.constBegin();
KoConnectionPoints::const_iterator lastCp = connectionPoints.constEnd();
for(; cp != lastCp; ++cp) {
QPointF difference = localMousePosition - cp.value();
QPointF difference = localMousePosition - cp.value().position;
qreal distance = difference.x() * difference.x() + difference.y() * difference.y();
if (distance > MAX_DISTANCE_SQR)
continue;
if (distance < minimalDistance) {
nearestShape = shape;
nearestPoint = cp.value();
nearestPoint = cp.value().position;
nearestPointId = cp.key();
minimalDistance = distance;
}
......
......@@ -95,7 +95,7 @@ void ConnectionTool::paint(QPainter &painter, const KoViewConverter &converter)
KoConnectionPoints::const_iterator cp = connectionPoints.constBegin();
KoConnectionPoints::const_iterator lastCp = connectionPoints.constEnd();
for(; cp != lastCp; ++cp) {
handleRect.moveCenter(transform.map(cp.value()));
handleRect.moveCenter(transform.map(cp.value().position));
Qt::GlobalColor fillColor = Qt::white;
if(m_editMode == EditConnectionPoint) {
fillColor = cp.key() == m_activeHandle ? Qt::red : Qt::darkGreen;
......@@ -124,7 +124,7 @@ void ConnectionTool::repaintDecorations()
KoConnectionPoints::const_iterator cp = connectionPoints.constBegin();
KoConnectionPoints::const_iterator lastCp = connectionPoints.constEnd();
for(; cp != lastCp; ++cp) {
repaint(handleGrabRect(m_currentShape->shapeToDocument(cp.value())));
repaint(handleGrabRect(m_currentShape->shapeToDocument(cp.value().position)));
}
}
}
......@@ -156,7 +156,7 @@ void ConnectionTool::mousePressEvent(KoPointerEvent * event)
return;
}
// get the position of the connection point we start our connection from
QPointF cp = m_currentShape->shapeToDocument(m_currentShape->connectionPoint(m_activeHandle));
QPointF cp = m_currentShape->shapeToDocument(m_currentShape->connectionPoint(m_activeHandle).position);
// move both handles to that point
connectionShape->moveHandle(0, cp);
connectionShape->moveHandle(1, cp);
......@@ -193,7 +193,7 @@ void ConnectionTool::mousePressEvent(KoPointerEvent * event)
}
}
} else {
if (m_activeHandle >= KoFlake::FirstCustomConnectionPoint) {
if (m_activeHandle >= KoConnectionPoint::FirstCustomConnectionPoint) {
m_currentStrategy = new MoveConnectionPointStrategy(m_currentShape, m_activeHandle, this);
}
}
......@@ -376,7 +376,7 @@ int ConnectionTool::handleAtPoint(KoShape *shape, const QPointF &mousePoint)
KoConnectionPoints::const_iterator cp = connectionPoints.constBegin();
KoConnectionPoints::const_iterator lastCp = connectionPoints.constEnd();
for(; cp != lastCp; ++cp) {
qreal d = squareDistance(shapePoint, cp.value());
qreal d = squareDistance(shapePoint, cp.value().position);
if (d <= grabSensitivity && d < minDistance) {
handleId = cp.key();
minDistance = d;
......@@ -450,7 +450,7 @@ void ConnectionTool::updateStatusText()
emit statusTextChanged(i18n("Drag to edit connection."));
break;
case EditConnectionPoint:
if (m_activeHandle >= KoFlake::FirstCustomConnectionPoint)
if (m_activeHandle >= KoConnectionPoint::FirstCustomConnectionPoint)
emit statusTextChanged(i18n("Drag to move connection point. Double click to remove connection point"));
else if (m_activeHandle >= 0)
emit statusTextChanged(i18n("Double click to remove connection point"));
......
......@@ -29,7 +29,7 @@ MoveConnectionPointStrategy::MoveConnectionPointStrategy(KoShape *shape, int con
: KoInteractionStrategy(parent), m_shape(shape), m_connectionPointId(connectionPointId)
{
Q_ASSERT(m_shape);
m_oldPosition = m_newPosition = m_shape->connectionPoint(m_connectionPointId);
m_oldPosition = m_newPosition = m_shape->connectionPoint(m_connectionPointId).position;
}
MoveConnectionPointStrategy::~MoveConnectionPointStrategy()
......
......@@ -54,6 +54,6 @@ void RemoveConnectionPointCommand::updateRoi()
{
// TODO: is there a way we can get at the correct update size?
QRectF roi(0, 0, 10, 10);
roi.moveCenter(m_connectionPoint);
roi.moveCenter(m_connectionPoint.position);
m_shape->update(roi);
}
......@@ -21,6 +21,7 @@
#ifndef REMOVECONNECTIONPOINTCOMMAND_H
#define REMOVECONNECTIONPOINTCOMMAND_H
#include <KoConnectionPoint.h>
#include <QtGui/QUndoCommand>
#include <QtCore/QPointF>
......@@ -41,7 +42,7 @@ private:
void updateRoi();
KoShape * m_shape;
QPointF m_connectionPoint;
KoConnectionPoint m_connectionPoint;
int m_connectionPointId;
};
......
......@@ -198,7 +198,7 @@ KoShape* Layout::proposePosition(KoShape* shape)
QPointF pos;
switch (m_structure) {
case TreeShape::OrgDown:
pos = shape->shapeToDocument(shape->connectionPoints().value(0));
pos = shape->shapeToDocument(shape->connectionPoints().value(0).position);
pos = m_container->documentToShape(pos);
nextShape = m_children.first();
......@@ -211,7 +211,7 @@ KoShape* Layout::proposePosition(KoShape* shape)
nextShape = 0;
break;
case TreeShape::OrgUp:
pos = shape->shapeToDocument(shape->connectionPoints().value(2));
pos = shape->shapeToDocument(shape->connectionPoints().value(2).position);
pos = m_container->documentToShape(pos);
nextShape = m_children.first();
......@@ -224,7 +224,7 @@ KoShape* Layout::proposePosition(KoShape* shape)
nextShape = 0;
break;
case TreeShape::OrgLeft:
pos = shape->shapeToDocument(shape->connectionPoints().value(1));
pos = shape->shapeToDocument(shape->connectionPoints().value(1).position);
pos = m_container->documentToShape(pos);
nextShape = m_children.first();
......@@ -237,7 +237,7 @@ KoShape* Layout::proposePosition(KoShape* shape)