2
This file is part of Kig, a KDE program for Interactive Geometry...
3
Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22
#ifndef KIG_COMMANDS_H
23
#define KIG_COMMANDS_H
25
#include <qundostack.h>
30
#include "../objects/object_holder.h"
34
class CoordinateSystem;
41
* a KigCommand represents almost every action performed in Kig.
42
* Used mainly in the Undo/Redo stuff...
50
KigCommand( KigPart& inDoc, const QString& name );
54
* To avoid confusion, this doesn't add a command to anything, this
55
* creates an AddCommand ;)
57
static KigCommand* addCommand( KigPart& doc, const std::vector<ObjectHolder*>& os );
61
static KigCommand* addCommand( KigPart& doc, ObjectHolder* os );
63
* make sure that when you delete something, you are also deleting
64
* its parents. This class assumes you've done that.
65
* \ref KigDocument::delObjects() takes care of this for you.
67
static KigCommand* removeCommand( KigPart& doc, const std::vector<ObjectHolder*>& os );
71
static KigCommand* removeCommand( KigPart& doc, ObjectHolder* o );
74
* This creates directly a command to change the coordinate system
76
* \sa ChangeCoordSystemTask
78
static KigCommand* changeCoordSystemCommand( KigPart& doc, CoordinateSystem* s );
80
void addTask( KigCommandTask* );
85
Q_DISABLE_COPY( KigCommand )
89
* This represents a single task to be executed in a KigCommand.
95
virtual ~KigCommandTask();
97
virtual void execute( KigPart& doc ) = 0;
98
virtual void unexecute( KigPart& doc ) = 0;
102
: public KigCommandTask
105
AddObjectsTask( const std::vector<ObjectHolder*>& os);
107
void execute( KigPart& doc );
108
void unexecute( KigPart& doc );
112
std::vector<ObjectHolder*> mobjs;
115
class RemoveObjectsTask
116
: public AddObjectsTask
119
RemoveObjectsTask( const std::vector<ObjectHolder*>& os );
120
void execute( KigPart& );
121
void unexecute( KigPart& );
124
class ChangeObjectConstCalcerTask
125
: public KigCommandTask
128
ChangeObjectConstCalcerTask( ObjectConstCalcer* calcer, ObjectImp* newimp );
129
~ChangeObjectConstCalcerTask();
131
void execute( KigPart& );
132
void unexecute( KigPart& );
134
ObjectConstCalcer::shared_ptr mcalcer;
139
* this class monitors a set of DataObjects for changes and returns an
140
* appropriate ChangeObjectImpsCommand if necessary..
141
* E.g. MovingMode wants to move certain objects, so it monitors all
142
* the parents of the explicitly moving objects:
144
* MonitorDataObjects mon( getAllParents( emo ) );
146
* It then moves them around, and when it is finished, it asks to add
147
* the KigCommandTasks to a KigCommand, and applies that..
149
* KigCommand* comm = new KigCommand( doc, i18n( "Move Stuff" ) );
150
* mon.finish( comm );
153
class MonitorDataObjects
159
* all the DataObjects in \p objs will be watched..
161
MonitorDataObjects( const std::vector<ObjectCalcer*>& objs );
162
MonitorDataObjects( ObjectCalcer* c );
163
~MonitorDataObjects();
166
* add \p objs to the list of objs to be watched, and save their
169
void monitor( const std::vector<ObjectCalcer*>& objs );
172
* add the generated KigCommandTasks to the command \p comm ..
173
* monitoring stops after this is called..
175
void finish( KigCommand* comm );
179
* A task to change the coordinate system.
181
class ChangeCoordSystemTask
182
: public KigCommandTask
184
CoordinateSystem* mcs;
187
* a command that changes the coordinate-system to \p s ..
189
ChangeCoordSystemTask( CoordinateSystem* s );
190
~ChangeCoordSystemTask();
192
void execute( KigPart& doc );
193
void unexecute( KigPart& doc );
196
class ChangeParentsAndTypeTask
197
: public KigCommandTask
202
ChangeParentsAndTypeTask( ObjectTypeCalcer* o, const std::vector<ObjectCalcer*>& newparents,
203
const ObjectType* newtype );
204
~ChangeParentsAndTypeTask();
206
void execute( KigPart& doc );
207
void unexecute( KigPart& doc );
210
class KigViewShownRectChangeTask
211
: public KigCommandTask
216
KigViewShownRectChangeTask( KigWidget& v, const Rect& newrect );
217
~KigViewShownRectChangeTask();
219
void execute( KigPart& doc );
220
void unexecute( KigPart& doc );
223
class ChangeObjectDrawerTask
224
: public KigCommandTask
226
ObjectHolder* mholder;
227
ObjectDrawer* mnewdrawer;
229
ChangeObjectDrawerTask( ObjectHolder* holder, ObjectDrawer* newdrawer );
230
~ChangeObjectDrawerTask();
232
void execute( KigPart& doc );
233
void unexecute( KigPart& doc );