Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++
992 B
Raw Blame
/* This file is part of the KDE project
 * SPDX-FileCopyrightText: 2008 Thorsten Zachmann <[email protected]>
 *
 * SPDX-License-Identifier: LGPL-2.0-or-later
 */

#include "KoShapeRenameCommand.h"

#include <QString>
#include <klocalizedstring.h>
#include "KoShape.h"

class Q_DECL_HIDDEN KoShapeRenameCommand::Private
{
public:
    Private(KoShape *shape, const QString &newName)
    : shape(shape)
    , newName(newName)
    , oldName(shape->name())
    {}

    KoShape *shape;
    QString newName;
    QString oldName;
};

KoShapeRenameCommand::KoShapeRenameCommand(KoShape *shape, const QString &newName, KUndo2Command *parent)
    : KUndo2Command(kundo2_i18n("Rename Shape"), parent)
, d(new Private(shape, newName))
{
}

KoShapeRenameCommand::~KoShapeRenameCommand()
{
   delete d;
}

void KoShapeRenameCommand::redo()
{
    KUndo2Command::redo();
    d->shape->setName(d->newName);
}

void KoShapeRenameCommand::undo()
{
    KUndo2Command::undo();
    d->shape->setName(d->oldName);
}