Working on permissions
[dashstudio.git] / src / dashserver / project / commandprocessor.cpp
blobad6d80954e33f607a8b520e518e3af063ab62069
1 //
2 // C++ Implementation: commandprocessor
3 /***************************************************************************
4 * Copyright (C) 2007 by David Cuadrado *
5 * krawek@gmail.com *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
23 #include "commandprocessor.h"
25 #include "project.h"
26 #include "member.h"
28 namespace DashServer {
29 namespace Project {
31 struct CommandProcessor::Private {
32 Private() : member(0) {}
33 Member *member;
36 CommandProcessor::CommandProcessor(Project *project)
37 : YAMF::Command::Processor(project), d(new Private)
42 CommandProcessor::~CommandProcessor()
44 delete d;
47 void CommandProcessor::setCurrentMember(Member *member)
49 d->member = member;
52 bool CommandProcessor::aboutToExecute(const QString &pkgname)
54 if( !d->member )
56 qWarning("There's not member!");
57 return true;
60 Project::Part part = Project::None;
62 // LIBRARY
63 if( pkgname == "addlibraryfolder" )
65 part = Project::Library;
67 else if( pkgname == "addlibraryobject" )
69 part = Project::Library;
71 else if( pkgname == "modifysymbol" )
73 part = Project::Library;
75 else if( pkgname == "renamelibraryobject" )
77 part = Project::Library;
81 // OBJECT AND ITEM
82 if( pkgname == "additemfilter" )
84 part = Project::Object;
86 else if( pkgname == "addobject" )
88 part = Project::Object;
90 else if( pkgname == "addtweening" )
92 part = Project::Object;
94 else if( pkgname == "bringforwardsitem" )
96 part = Project::Object;
98 else if( pkgname == "bringtofrontitem" )
100 part = Project::Object;
102 else if( pkgname == "changelayervisibility" )
104 part = Project::Object;
106 else if( pkgname == "changetextfont" )
108 part = Project::Object;
110 else if( pkgname == "changetext" )
112 part = Project::Object;
114 else if( pkgname == "changetextwidth" )
116 part = Project::Object;
118 else if( pkgname == "convertitem" )
120 part = Project::Object;
122 else if( pkgname == "editnodesitem" )
124 part = Project::Object;
126 else if( pkgname == "changeitembrush" )
128 part = Project::Object;
130 else if( pkgname == "changeitempen" )
132 part = Project::Object;
134 else if( pkgname == "groupitem" )
136 part = Project::Object;
138 else if( pkgname == "modifyfilter" )
140 part = Project::Object;
142 else if( pkgname == "modifyitem" )
144 part = Project::Object;
146 else if( pkgname == "removelibraryobject" )
148 part = Project::Object;
150 else if( pkgname == "removeobject" )
152 part = Project::Object;
154 else if( pkgname == "sendbackwardsitem" )
156 part = Project::Object;
158 else if( pkgname == "sendtobackitem" )
160 part = Project::Object;
162 else if( pkgname == "ungroupitem" )
164 part = Project::Object;
168 // FRAME
169 if( pkgname == "changeframevisibility" )
171 part = Project::Frame;
173 else if( pkgname == "expandframe" )
175 part = Project::Frame;
177 else if( pkgname == "insertframe" )
179 part = Project::Frame;
181 else if( pkgname == "lockframe" )
183 part = Project::Frame;
185 else if( pkgname == "moveframe" )
187 part = Project::Frame;
189 else if( pkgname == "removeframe" )
191 part = Project::Frame;
193 else if( pkgname == "renameframe" )
195 part = Project::Frame;
198 // LAYER
199 if( pkgname == "insertlayer" )
201 part = Project::Layer;
203 else if( pkgname == "locklayer" )
205 part = Project::Layer;
207 else if( pkgname == "movelayer" )
209 part = Project::Layer;
211 else if( pkgname == "removelayer" )
213 part = Project::Layer;
215 else if( pkgname == "renamelayer" )
217 part = Project::Layer;
221 // SCENE
222 if( pkgname == "insertscene" )
224 part = Project::Scene;
226 else if( pkgname == "movescene" )
228 part = Project::Scene;
230 else if( pkgname == "removescene" )
232 part = Project::Scene;
234 else if( pkgname == "renamescene" )
236 part = Project::Scene;
239 return d->member->canWriteOn(part);