vclipartcmd.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001, 2002, 2003 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
21#include "vclipartcmd.h"
22#include "vdocument.h"
23#include "vselection.h"
24
25VClipartCmd::VClipartCmd( VDocument* doc, const TQString& name, VObject* clipart )
26 : VCommand( doc, name ), m_clipart( clipart->clone() ), m_executed( false )
27{
28}
29
30void
31VClipartCmd::execute()
32{
33 if( !m_clipart )
34 return;
35
36 if( m_clipart->state() == VObject::deleted )
37 m_clipart->setState( VObject::normal );
38 else
39 {
40 m_clipart->setState( VObject::normal );
41 document()->append( m_clipart );
42 document()->selection()->clear();
43 document()->selection()->append( m_clipart );
44 }
45
46 m_executed = true;
47
48 setSuccess( true );
49}
50
51void
52VClipartCmd::unexecute()
53{
54 if( !m_clipart )
55 return;
56
57 document()->selection()->take( *m_clipart );
58
59 m_clipart->setState( VObject::deleted );
60
61 m_executed = false;
62
63 setSuccess( false );
64}
65
The base class for all karbon commands.
Definition vcommand.h:42
All non-visual, static doc info is in here.
Definition vdocument.h:53
The base class for all karbon objects.
Definition vobject.h:50
@ deleted
deleted, nearly dead
Definition vobject.h:58
@ normal
visible, not active
Definition vobject.h:54