vcleanupcmd.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002, The Karbon Developers
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tdelocale.h>
21
22#include "vcleanupcmd.h"
23#include "vlayer.h"
24#include "vdocument.h"
25
26VCleanUpCmd::VCleanUpCmd( VDocument *doc )
27 : VCommand( doc, i18n( "Clean Up" ) )
28{
29}
30
31VCleanUpCmd::~VCleanUpCmd()
32{
33}
34
35void
36VCleanUpCmd::execute()
37{
38 visit( *document() );
39}
40
41void
42VCleanUpCmd::unexecute()
43{
44}
45
46void
47VCleanUpCmd::visitVLayer( VLayer& layer )
48{
49 VObjectListIterator itr( layer.objects() );
50 for( ; itr.current(); ++itr )
51 {
52 if( itr.current()->state() == VObject::deleted )
53 {
54 delete( itr.current() );
55 layer.take( *itr.current() );
56 }
57 }
58}
The base class for all karbon commands.
Definition vcommand.h:42
All non-visual, static doc info is in here.
Definition vdocument.h:53
void take(const VObject &object)
Removes the reference to child object, not the object itself.
Definition vgroup.cpp:364
const VObjectList & objects() const
Read only access to the grouped objects.
Definition vgroup.h:110
VLayer manages a set of vobjects.
Definition vlayer.h:37
@ deleted
deleted, nearly dead
Definition vobject.h:58