diff --git a/libs/flake/commands/KoPathShapeMarkerCommand.cpp b/libs/flake/commands/KoPathShapeMarkerCommand.cpp index 8aeacef885..d7a545e428 100644 --- a/libs/flake/commands/KoPathShapeMarkerCommand.cpp +++ b/libs/flake/commands/KoPathShapeMarkerCommand.cpp @@ -1,104 +1,105 @@ /* This file is part of the KDE project * Copyright (C) 2010 Jeremy Lugagne * Copyright (C) 2011 Jean-Nicolas Artaud * * 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 "KoPathShapeMarkerCommand.h" #include "KoMarker.h" #include "KoPathShape.h" #include #include "kis_command_ids.h" #include struct Q_DECL_HIDDEN KoPathShapeMarkerCommand::Private { QList shapes; ///< the shapes to set marker for QList> oldMarkers; ///< the old markers, one for each shape QExplicitlySharedDataPointer marker; ///< the new marker to set KoFlake::MarkerPosition position; QList oldAutoFillMarkers; }; KoPathShapeMarkerCommand::KoPathShapeMarkerCommand(const QList &shapes, KoMarker *marker, KoFlake::MarkerPosition position, KUndo2Command *parent) : KUndo2Command(kundo2_i18n("Set marker"), parent), m_d(new Private) { m_d->shapes = shapes; m_d->marker = marker; m_d->position = position; // save old markers Q_FOREACH (KoPathShape *shape, m_d->shapes) { m_d->oldMarkers.append(QExplicitlySharedDataPointer(shape->marker(position))); m_d->oldAutoFillMarkers.append(shape->autoFillMarkers()); } } KoPathShapeMarkerCommand::~KoPathShapeMarkerCommand() { } void KoPathShapeMarkerCommand::redo() { KUndo2Command::redo(); Q_FOREACH (KoPathShape *shape, m_d->shapes) { - shape->update(); + const QRectF oldDirtyRect = shape->boundingRect(); shape->setMarker(m_d->marker.data(), m_d->position); // we have no GUI for selection auto-filling yet! So just enable it! shape->setAutoFillMarkers(true); - shape->update(); + shape->updateAbsolute(oldDirtyRect | shape->boundingRect()); } } void KoPathShapeMarkerCommand::undo() { KUndo2Command::undo(); auto markerIt = m_d->oldMarkers.begin(); auto autoFillIt = m_d->oldAutoFillMarkers.begin(); Q_FOREACH (KoPathShape *shape, m_d->shapes) { - shape->update(); + const QRectF oldDirtyRect = shape->boundingRect(); shape->setMarker((*markerIt).data(), m_d->position); shape->setAutoFillMarkers(*autoFillIt); - shape->update(); + shape->updateAbsolute(oldDirtyRect | shape->boundingRect()); ++markerIt; + ++autoFillIt; } } int KoPathShapeMarkerCommand::id() const { return KisCommandUtils::ChangeShapeMarkersId; } bool KoPathShapeMarkerCommand::mergeWith(const KUndo2Command *command) { const KoPathShapeMarkerCommand *other = dynamic_cast(command); if (!other || other->m_d->shapes != m_d->shapes || other->m_d->position != m_d->position) { return false; } m_d->marker = other->m_d->marker; return true; }