1 /*******************************************************************
2
3 Part of the Fritzing project - http://fritzing.org
4 Copyright (c) 2007-2014 Fachhochschule Potsdam - http://fh-potsdam.de
5
6 Fritzing is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 Fritzing is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Fritzing. If not, see <http://www.gnu.org/licenses/>.
18
19 ********************************************************************
20
21 $Revision: 6904 $:
22 $Author: irascibl@gmail.com $:
23 $Date: 2013-02-26 16:26:03 +0100 (Di, 26. Feb 2013) $
24
25 ********************************************************************/
26
27
28
29 #include "partsbincommands.h"
30 #include "partsbinpalettewidget.h"
31
32 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
33
PartsBinBaseCommand(class PartsBinPaletteWidget * bin,QUndoCommand * parent)34 PartsBinBaseCommand::PartsBinBaseCommand(class PartsBinPaletteWidget* bin, QUndoCommand* parent)
35 : QUndoCommand(parent)
36 {
37 m_bin = bin;
38 }
39
bin()40 class PartsBinPaletteWidget* PartsBinBaseCommand::bin() {
41 return m_bin;
42 }
43
44 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
45
PartsBinAddRemoveArrangeCommand(class PartsBinPaletteWidget * bin,QString moduleID,QUndoCommand * parent)46 PartsBinAddRemoveArrangeCommand::PartsBinAddRemoveArrangeCommand(class PartsBinPaletteWidget* bin, QString moduleID, QUndoCommand *parent)
47 : PartsBinBaseCommand(bin, parent)
48 {
49 m_moduleID = moduleID;
50 }
51
52 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
53
PartsBinAddRemoveCommand(class PartsBinPaletteWidget * bin,QString moduleID,QString path,int index,QUndoCommand * parent)54 PartsBinAddRemoveCommand::PartsBinAddRemoveCommand(class PartsBinPaletteWidget* bin, QString moduleID, QString path, int index, QUndoCommand *parent)
55 : PartsBinAddRemoveArrangeCommand(bin, moduleID, parent)
56 {
57 m_index = index;
58 m_path = path;
59 }
60
add()61 void PartsBinAddRemoveCommand::add() {
62 m_bin->addPart(m_moduleID, m_index);
63 }
64
remove()65 void PartsBinAddRemoveCommand::remove() {
66 m_bin->removePart(m_moduleID, m_path);
67 }
68
69 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
70
PartsBinAddCommand(class PartsBinPaletteWidget * bin,QString moduleID,QString path,int index,QUndoCommand * parent)71 PartsBinAddCommand::PartsBinAddCommand(class PartsBinPaletteWidget* bin, QString moduleID, QString path, int index, QUndoCommand *parent)
72 : PartsBinAddRemoveCommand(bin, moduleID, path, index, parent) {}
73
undo()74 void PartsBinAddCommand::undo() {
75 remove();
76 }
77
redo()78 void PartsBinAddCommand::redo() {
79 add();
80 }
81
82 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83
PartsBinRemoveCommand(class PartsBinPaletteWidget * bin,QString moduleID,QString path,int index,QUndoCommand * parent)84 PartsBinRemoveCommand::PartsBinRemoveCommand(class PartsBinPaletteWidget* bin, QString moduleID, QString path, int index, QUndoCommand *parent)
85 : PartsBinAddRemoveCommand(bin, moduleID, path, index, parent) {}
86
undo()87 void PartsBinRemoveCommand::undo() {
88 add();
89 }
90
redo()91 void PartsBinRemoveCommand::redo() {
92 remove();
93 }
94
95 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
96
PartsBinArrangeCommand(class PartsBinPaletteWidget * bin,QString moduleID,int oldIndex,int newIndex,QUndoCommand * parent)97 PartsBinArrangeCommand::PartsBinArrangeCommand(class PartsBinPaletteWidget* bin, QString moduleID, int oldIndex, int newIndex, QUndoCommand *parent)
98 : PartsBinAddRemoveArrangeCommand(bin, moduleID, parent)
99 {
100 m_oldIndex = oldIndex;
101 m_newIndex = newIndex;
102 }
103
undo()104 void PartsBinArrangeCommand::undo() {
105
106 }
107
redo()108 void PartsBinArrangeCommand::redo() {
109
110 }
111
112 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
113