ChangeConnectionPointCommand.cpp 1.98 KB
Newer Older
1
/* This file is part of the KDE project
2
 *
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 * 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.
 */

21
#include "ChangeConnectionPointCommand.h"
22 23
#include <KoShape.h>

24 25 26 27 28 29
ChangeConnectionPointCommand::ChangeConnectionPointCommand(KoShape *shape, int connectionPointId, const KoConnectionPoint &oldPoint, const KoConnectionPoint &newPoint, KUndo2Command *parent)
    : KUndo2Command(parent)
    , m_shape(shape)
    , m_connectionPointId(connectionPointId)
    , m_oldPoint(oldPoint)
    , m_newPoint(newPoint)
30 31 32 33
{
    Q_ASSERT(m_shape);
}

34
ChangeConnectionPointCommand::~ChangeConnectionPointCommand()
35 36 37
{
}

38
void ChangeConnectionPointCommand::redo()
39
{
40 41 42
    updateRoi(m_oldPoint.position);
    m_shape->setConnectionPoint(m_connectionPointId, m_newPoint);
    updateRoi(m_newPoint.position);
43

Alexander Potashev's avatar
Alexander Potashev committed
44
    KUndo2Command::redo();
45 46
}

47
void ChangeConnectionPointCommand::undo()
48
{
Alexander Potashev's avatar
Alexander Potashev committed
49
    KUndo2Command::undo();
50

51 52 53
    updateRoi(m_newPoint.position);
    m_shape->setConnectionPoint(m_connectionPointId, m_oldPoint);
    updateRoi(m_oldPoint.position);
54 55
}

56
void ChangeConnectionPointCommand::updateRoi(const QPointF &position)
57 58
{
    // TODO: is there a way we can get at the correct update size?
59 60 61
    //QRectF roi(0, 0, 10, 10);
    //roi.moveCenter(position);
    //m_shape->update(roi);
62
}