File indexing completed on 2024-09-08 10:59:26
0001 /*************************************************************************** 0002 * Copyright (C) 2017 by Renaud Guezennec * 0003 * https://rolisteam.org/contact * 0004 * * 0005 * rolisteam is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #include "undoCmd/changecoloritem.h" 0021 #include "controller/item_controllers/visualitemcontroller.h" 0022 #include <QDebug> 0023 0024 ChangeColorItemCmd::ChangeColorItemCmd(vmap::VisualItemController* item, QColor newColor, QUndoCommand* parent) 0025 : QUndoCommand(parent), m_ctrl(item), m_newColor(newColor) 0026 { 0027 m_oldColor= m_ctrl->color(); 0028 0029 setText(QObject::tr("Change Item Color to %1").arg(newColor.name())); 0030 } 0031 void ChangeColorItemCmd::redo() 0032 { 0033 qInfo() << QStringLiteral("Redo command ChangeColorItemCmd: %1 ").arg(text()); 0034 m_ctrl->setColor(m_newColor); 0035 } 0036 void ChangeColorItemCmd::undo() 0037 { 0038 qInfo() << QStringLiteral("undo command ChangeColorItemCmd: %1 ").arg(text()); 0039 m_ctrl->setColor(m_oldColor); 0040 } 0041 0042 /*void ChangeColorItemCmd::sendOffColor() 0043 { 0044 NetworkMessageWriter msg(NetMsg::VMapCategory, NetMsg::ColorChanged); 0045 msg.string8(m_mapId); // id map 0046 msg.string16(m_item->getId()); // id item 0047 // msg.rgb(m_item->getColor().rgb()); 0048 msg.sendToServer(); 0049 }*/