Entry 965

ChangeProperties class

   

Submitted by Bjørn on Aug. 26, 2008 at 4:47 p.m.
Language: C++. Code size: 1.5 KB.

/*
 * Tiled Map Editor (Qt)
 * Copyright 2008 Tiled (Qt) developers (see AUTHORS file)
 *
 * This file is part of Tiled (Qt).
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program 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 General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307, USA.
 */

#include "changeproperties.h"

#include <QObject>

using namespace Tiled::Internal;

ChangeProperties::ChangeProperties(QMap<QString, QString> *properties,
                                   const QMap<QString, QString> &newProperties)
    : mProperties(properties)
    , mNewProperties(newProperties)
{
    setText(QObject::tr("Change Properties"));
}

void ChangeProperties::redo()
{
    swapProperties();
}

void ChangeProperties::undo()
{
    swapProperties();
}

void ChangeProperties::swapProperties()
{
    const QMap<QString, QString> oldProperties = *mProperties;
    *mProperties = mNewProperties;
    mNewProperties = oldProperties;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).