File indexing completed on 2025-02-02 04:14:48

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #include "KoPathReverseCommand.h"
0008 #include "KoPathShape.h"
0009 #include <klocalizedstring.h>
0010 
0011 class Q_DECL_HIDDEN KoPathReverseCommand::Private
0012 {
0013 public:
0014     Private(const QList<KoPathShape*> &p)
0015             : paths(p) {
0016     }
0017     ~Private() {
0018     }
0019 
0020     void reverse() {
0021         if (! paths.size())
0022             return;
0023 
0024         Q_FOREACH (KoPathShape* shape, paths) {
0025             int subpathCount = shape->subpathCount();
0026             for (int i = 0; i < subpathCount; ++i)
0027                 shape->reverseSubpath(i);
0028         }
0029     }
0030 
0031     QList<KoPathShape*> paths;
0032 };
0033 
0034 KoPathReverseCommand::KoPathReverseCommand(const QList<KoPathShape*> &paths, KUndo2Command *parent)
0035         : KUndo2Command(parent),
0036         d(new Private(paths))
0037 {
0038     setText(kundo2_i18n("Reverse paths"));
0039 }
0040 
0041 KoPathReverseCommand::~KoPathReverseCommand()
0042 {
0043     delete d;
0044 }
0045 
0046 void KoPathReverseCommand::redo()
0047 {
0048     KUndo2Command::redo();
0049 
0050     d->reverse();
0051 }
0052 
0053 void KoPathReverseCommand::undo()
0054 {
0055     KUndo2Command::undo();
0056 
0057     d->reverse();
0058 }