karbon

vdeletenodescmd.cpp
1/* This file is doc of the KDE project
2 Copyright (C) 2001, The Karbon Developers
3 Copyright (C) 2002, The Karbon Developers
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library 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 GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21
22#include <tdelocale.h>
23
24#include "vdeletenodescmd.h"
25#include "vselection.h"
26#include "vsegment.h"
27#include "vpath.h"
28#include "vdocument.h"
29
30VDeleteNodeCmd::VDeleteNodeCmd( VDocument *doc )
31 : VCommand( doc, i18n( "Delete Node" ) )
32{
33}
34
35VDeleteNodeCmd::~VDeleteNodeCmd()
36{
37}
38
39void
40VDeleteNodeCmd::visitVSubpath( VSubpath& path )
41{
42 VSegment* segment = path.first();
43
44 path.next(); // skip begin segment
45 while( segment )
46 {
47 if( segment->state() != VSegment::deleted && segment->knotIsSelected() )
48 {
49 segment->setState( VSegment::deleted );
50 m_segments.append( segment );
51 }
52 segment = segment->next();
53 }
54 if( m_segments.count() > 0 )
56}
57
58void
60{
61 VObjectListIterator itr( document()->selection()->objects() );
62
63 for( ; itr.current() ; ++itr )
64 visit( *itr.current() );
65
66 setSuccess( m_segments.count() > 0 );
67}
68
69void
71{
72 TQPtrListIterator<VSegment> itr( m_segments );
73 for( ; itr.current() ; ++itr )
74 itr.current()->setState( VSegment::normal );
75 setSuccess( false );
76}
77
The base class for all karbon commands.
Definition vcommand.h:42
virtual void unexecute()
Unexecutes the command.
Definition vcommand.h:75
VDocument * document() const
Returns the document the command works on.
Definition vcommand.h:121
virtual void execute()=0
Executes the command.
All non-visual, static doc info is in here.
Definition vdocument.h:53
void invalidateBoundingBox()
Invalidates the bounding box, so it has to be recalculated.
Definition vobject.h:127
bool knotIsSelected() const
Returns true if the knot is selected.
Definition vsegment.h:181
VSegment * next() const
Returns a pointer to the next not deleted segment, if stored in a VSubpath.
void setState(VState state)
Sets the segment state.
Definition vsegment.h:106
VState state() const
Returns the segment state.
Definition vsegment.h:98
VSubpath provides a sophisticated list of VSegment.
Definition vpath.h:43
virtual bool visit(VObject &object)
General visit method.
Definition vvisitor.cpp:31
void setSuccess(bool success=true)
Set the success property.
Definition vvisitor.h:142