Commit 88aebf94 authored by Jan Hambrecht's avatar Jan Hambrecht

added function to change a connection point position

parent e178b030
......@@ -2,7 +2,7 @@
Copyright (C) 2006 Casper Boemann Rasmussen <cbr@boemann.dk>
Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
Copyright (C) 2006-2010 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2007-2009 Jan Hambrecht <jaham@gmx.net>
Copyright (C) 2007-2009,2011 Jan Hambrecht <jaham@gmx.net>
CopyRight (C) 2010 Boudewijn Rempt <boud@kogmbh.com>
This library is free software; you can redistribute it and/or
......@@ -785,6 +785,25 @@ QPointF KoShape::connectionPoint(int connectionPointId) const
return p;
}
bool KoShape::setConnectionPointPosition(int connectionPointId, const QPointF &newPosition)
{
// do not allow to change position of default connection points
if (connectionPointId < KoFlake::FirstCustomConnectionPoint)
return false;
Q_D(KoShape);
KoConnectionPoints::iterator cp = d->connectors.find(connectionPointId);
// check if connection point exists
if(cp == d->connectors.end())
return false;
QSizeF s = size();
cp->rx() = newPosition.x() / s.width();
cp->ry() = newPosition.y() / s.height();
return true;
}
KoConnectionPoints KoShape::connectionPoints() const
{
Q_D(const KoShape);
......
......@@ -2,7 +2,7 @@
Copyright (C) 2006-2008 Thorsten Zachmann <zachmann@kde.org>
Copyright (C) 2006, 2008 Casper Boemann <cbr@boemann.dk>
Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
Copyright (C) 2007-2009 Jan Hambrecht <jaham@gmx.net>
Copyright (C) 2007-2009,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
......@@ -332,6 +332,14 @@ public:
/// Returns connection point with specified connection point id
QPointF connectionPoint(int connectionPointId) const;
/**
* Sets new position for specified custom connection point
* @param connectionPointId the id of the custom connection point to change
* @param newPosition the new position of the custom connection point in shape coordinates
* @return true if position could be changed, else false
*/
bool setConnectionPointPosition(int connectionPointId, const QPointF &newPosition);
/**
* Return a list of the connection points that have been added to this shape.
* All the points are relative to the shape position, see absolutePosition().
......
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