1 // Copyright (c) 2012 Dennco Project
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.
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.
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/>.
17 // Created by tkawata on Sep-30, 2012.
19 #include "dccommandutil.h"
23 #include "command/dceditcommands.h"
24 #include "command/dccommandevent.h"
25 #include "dccreator.h"
27 static void postEvent(QObject *target, DCCommand *command)
29 QEvent *event = new DCCommandEvent(command);
30 QApplication::instance()->postEvent(target, event);
35 void DCCommandUtil::postStartAddAxonTerminalCommandFromAxon(const void *requester, DCCreator *creator, DCCell *ownerCell)
37 postEvent(creator, new DCStartAddAxonTerminalCommandFromAxon(requester, creator, ownerCell));
41 void DCCommandUtil::postStartAddAxonTerminalCommandFromReceptor(const void *requester, DCCreator *creator, DCCell *ownerCell, const QString &receptorName)
43 postEvent(creator, new DCStartAddAxonTerminalCommandFromReceptor(requester, creator, ownerCell, receptorName));
47 void DCCommandUtil::postCommitAddAxonTerminalCommand(const void *requester, DCCreator *creator, DCAxon *axon, DCCell *receptorCell, const QString &receptorName)
49 postEvent(creator, new DCCommitAddAxonTerminalCommand(requester, creator, axon, receptorCell, receptorName));
53 void DCCommandUtil::postCommitAddAxonTerminalCommand(const void *requester, DCCreator *creator, DCCell *axonCell, DCReceptor *receptor)
55 postEvent(creator, new DCCommitAddAxonTerminalCommand(requester, creator, axonCell, receptor));
59 void DCCommandUtil::postRemoveAxonTerminalCommand(const void *requester, DCCreator *creator, DCCell *axonCell, DCAxonTerminal *axonTerminal)
61 postEvent(creator, new DCRemoveAxonTerminalCommand(requester, creator, axonCell, axonTerminal));
65 void DCCommandUtil::postRemoveAxonTerminalCommand(const void *requester, DCCreator *creator, DCCell *receptorCell, const QString &receptorName)
67 postEvent(creator, new DCRemoveAxonTerminalCommand(requester, creator, receptorCell, receptorName));
71 void DCCommandUtil::postUndoRequestCommand(const void *requester, DCCreator *creator)
73 QEvent *event = new DCUndoEvent();
74 QApplication::instance()->postEvent(creator, event);
78 void DCCommandUtil::postAssignCellCodeClassToCellCommand(const void *requester, DCCreator *creator, DCCell *cell, DCCellCode *cellCode)
80 postEvent(creator, new DCAssignCellCodeClassToCellCommand(requester, creator, cell, cellCode));
84 void DCCommandUtil::postUnassignCellCodeClassFromCellCommand(const void *requester, DCCreator *creator, DCCell *cell)
86 postEvent(creator, new DCUnassignCellCodeClassFromCellCommand(requester, creator, cell));
90 void DCCommandUtil::postAddCellCodeClassCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString &name, const QString &type)
92 postEvent(creator, new DCAddCellCodeClassCommand(requester, creator, container, name, type));
96 void DCCommandUtil::postChangeCellCodeClassTypeCommand(const void *requester, DCCreator *creator, DCCellCode *cellCode, const QString &newType)
98 postEvent(creator, new DCChangeCellCodeClassTypeCommand(requester, creator, cellCode, newType));
102 void DCCommandUtil::postAddCellCommand(const void *requester, DCCreator *creator, DCContainer *container, const QString &containerBasedPath, const QString &name, const QString &type, float pageX, float pageY)
104 postEvent(creator, new DCAddCellCommand(requester, creator, container, containerBasedPath, name, type, pageX, pageY));
108 void DCCommandUtil::postChangeCellTypeCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &newType)
110 postEvent(creator, new DCChangeCellTypeCommand(requester, creator, cell, newType));
114 void DCCommandUtil::postRenameCellCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &newContainerBasedPath, const QString &newName)
116 postEvent(creator, new DCRenameCellCommand(requester, creator, cell, newContainerBasedPath, newName));
120 void DCCommandUtil::postRemoveCellCommand(const void *requester, DCCreator *creator, DCContainer *container, DCCell* cell)
122 postEvent(creator, new DCRemoveCellCommand(requester, creator, container, cell));
126 void DCCommandUtil::postRemoveCellsCommand(const void *requester, DCCreator *creator, DCContainer *container, const QList<DCCell*> &cells)
128 postEvent(creator, new DCRemoveCellCommand(requester, creator, container, cells));
132 void DCCommandUtil::postAddPageCommand(const void *requester, DCCreator *creator, const QString& containerBasedPath)
134 postEvent(creator, new DCAddPageCommand(requester, creator, containerBasedPath));
138 void DCCommandUtil::postMovePageCommand(const void *requester, DCCreator *creator, const QString &oldContainerBasedPath, const QString &newContainerBasedPath)
140 postEvent(creator, new DCMovePageCommand(requester, creator, oldContainerBasedPath, newContainerBasedPath));
144 void DCCommandUtil::postRemovePageCommand(const void *requester, DCCreator *creator, DCVCPage *page)
146 postEvent(creator, new DCRemovePageCommand(requester, creator, page));
150 void DCCommandUtil::postAddDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysFilePath)
152 postEvent(creator, new DCAddDirectoryCommand(requester, creator, sysFilePath));
156 void DCCommandUtil::postRenameDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysOldFilePath, const QString &sysNewFilePath)
158 postEvent(creator, new DCRenameDirectoryCommand(requester, creator, sysOldFilePath, sysNewFilePath));
162 void DCCommandUtil::postRemoveDirectoryCommand(const void *requester, DCCreator *creator, const QString &sysFilePath)
164 postEvent(creator, new DCRemoveDirectoryCommand(requester, creator, sysFilePath));
168 void DCCommandUtil::postRenameReceptorNameCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &oldName, const QString &newName)
170 postEvent(creator, new DCRenameReceptorNameCommand(requester, creator, cell, oldName, newName));
174 DCCommand* DCCommandUtil::createRenameReceptorNameCommand(const void *requester, DCCreator *creator, DCCell *cell, const QString &oldName, const QString &newName)
176 return new DCRenameReceptorNameCommand(requester, creator, cell, oldName, newName);