OSDN Git Service

53e43d8b3e2180bd4ead9fac335450826d77a175
[dennco/denncoCreator.git] / Source / utils / dccommandutil.cpp
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on Sep-30, 2012.
18 //
19 #include "dccommandutil.h"
20
21 #include <QtGui>
22
23 #include "command/dceditcommands.h"
24 #include "command/dccommandevent.h"
25 #include "dccreator.h"
26
27 static void postEvent(QObject *target, DCCommand *command)
28 {
29     QEvent *event = new DCCommandEvent(command);
30     QApplication::instance()->postEvent(target, event);
31 }
32
33
34 //static
35 void DCCommandUtil::postStartAddAxonTerminalCommandFromAxon(const void *requester, DCCreator *creator, DCCell *ownerCell)
36 {
37     postEvent(creator, new DCStartAddAxonTerminalCommandFromAxon(requester, creator, ownerCell));
38 }
39
40 //static
41 void DCCommandUtil::postStartAddAxonTerminalCommandFromReceptor(const void *requester, DCCreator *creator, DCCell *ownerCell, const QString &receptorName)
42 {
43     postEvent(creator, new DCStartAddAxonTerminalCommandFromReceptor(requester, creator, ownerCell, receptorName));
44 }
45
46 //static
47 void DCCommandUtil::postCommitAddAxonTerminalCommand(const void *requester, DCCreator *creator, DCAxon *axon, DCCell *receptorCell, const QString &receptorName)
48 {
49     postEvent(creator, new DCCommitAddAxonTerminalCommand(requester, creator, axon, receptorCell, receptorName));
50 }
51
52 //static
53 void DCCommandUtil::postCommitAddAxonTerminalCommand(const void *requester, DCCreator *creator, DCCell *axonCell, DCReceptor *receptor)
54 {
55     postEvent(creator, new DCCommitAddAxonTerminalCommand(requester, creator, axonCell, receptor));
56 }
57
58 //static
59 void DCCommandUtil::postRemoveAxonTerminalCommand(const void *requester, DCCreator *creator, DCCell *axonCell, DCAxonTerminal *axonTerminal)
60 {
61     postEvent(creator, new DCRemoveAxonTerminalCommand(requester, creator, axonCell, axonTerminal));
62 }
63
64 //static
65 void DCCommandUtil::postRemoveAxonTerminalCommand(const void *requester, DCCreator *creator, DCCell *receptorCell, const QString &receptorName)
66 {
67     postEvent(creator, new DCRemoveAxonTerminalCommand(requester, creator, receptorCell, receptorName));
68 }
69
70 //static
71 void DCCommandUtil::postUndoRequestCommand(const void *requester, DCCreator *creator)
72 {
73     QEvent *event = new DCUndoEvent();
74     QApplication::instance()->postEvent(creator, event);
75 }
76
77 //static
78 void DCCommandUtil::postAssignCellCodeClassToCellCommand(const void *requester, DCCreator *creator, DCCell *cell, DCCellCode *cellCode)
79 {
80     postEvent(creator, new DCAssignCellCodeClassToCellCommand(requester, creator, cell, cellCode));
81 }
82
83 //static
84 void DCCommandUtil::postUnassignCellCodeClassFromCellCommand(const void *requester, DCCreator *creator, DCCell *cell)
85 {
86     postEvent(creator, new DCUnassignCellCodeClassFromCellCommand(requester, creator, cell));
87 }
88
89 //static
90 void DCCommandUtil::postAddCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString &name, const QString &type)
91 {
92     postEvent(creator, new DCAddCellCodeClassCommand(requester, creator, container, name, type));
93 }
94
95 //static
96 void DCCommandUtil::postChangeCellCodeClassTypeCommand(const void *requester, DCCreator *creator, DCCellCode *cellCode, const QString &newType)
97 {
98     postEvent(creator, new DCChangeCellCodeClassTypeCommand(requester, creator, cellCode, newType));
99 }
100
101 //static
102 void DCCommandUtil::postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString &containerBasedPath, const QString &name, const QString &type, float pageX, float pageY)
103 {
104     postEvent(creator, new DCAddCellCommand(requester, creator, container, containerBasedPath, name, type, pageX, pageY));
105 }
106
107 //static
108 void DCCommandUtil::postChangeCellTypeCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &newType)
109 {
110     postEvent(creator, new DCChangeCellTypeCommand(requester, creator, cell, newType));
111 }
112
113 //static
114 void DCCommandUtil::postRenameCellCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &newContainerBasedPath, const QString &newName)
115 {
116     postEvent(creator, new DCRenameCellCommand(requester, creator, cell, newContainerBasedPath, newName));
117 }
118
119 //static
120 void DCCommandUtil::postRemoveCellCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCell* cell)
121 {
122     postEvent(creator, new DCRemoveCellCommand(requester, creator, container, cell));
123 }
124
125 //static
126 void DCCommandUtil::postRemoveCellsCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells)
127 {
128     postEvent(creator, new DCRemoveCellCommand(requester, creator, container, cells));
129 }
130
131 //static
132 void DCCommandUtil::postAddPageCommand(const void *requester, DCCreator *creator, const QString& containerBasedPath)
133 {
134     postEvent(creator, new DCAddPageCommand(requester, creator, containerBasedPath));
135 }
136
137 //static
138 void DCCommandUtil::postMovePageCommand(const void *requester, DCCreator *creator, const QString &oldContainerBasedPath, const QString &newContainerBasedPath)
139 {
140     postEvent(creator, new DCMovePageCommand(requester, creator, oldContainerBasedPath, newContainerBasedPath));
141 }
142
143 //static
144 void DCCommandUtil::postRemovePageCommand(const void *requester, DCCreator *creator, DCVCPage *page)
145 {
146     postEvent(creator, new DCRemovePageCommand(requester, creator, page));
147 }
148
149 //static
150 void DCCommandUtil::postAddDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysFilePath)
151 {
152     postEvent(creator, new DCAddDirectoryCommand(requester, creator, sysFilePath));
153 }
154
155 //static
156 void DCCommandUtil::postRenameDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysOldFilePath, const QString &sysNewFilePath)
157 {
158     postEvent(creator, new DCRenameDirectoryCommand(requester, creator, sysOldFilePath, sysNewFilePath));
159 }
160
161 //static
162 void DCCommandUtil::postRemoveDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysFilePath)
163 {
164     postEvent(creator, new DCRemoveDirectoryCommand(requester, creator, sysFilePath));
165 }
166
167 //static
168 void DCCommandUtil::postRenameReceptorNameCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &oldName, const QString &newName)
169 {
170     postEvent(creator, new DCRenameReceptorNameCommand(requester, creator, cell, oldName, newName));
171 }
172
173 //static
174 DCCommand* DCCommandUtil::createRenameReceptorNameCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &oldName, const QString &newName)
175 {
176     return new DCRenameReceptorNameCommand(requester, creator, cell, oldName, newName);
177 }
178