moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kig / modes / edittype.cc
blobb787dbcc2f37f23e6305ca3c2296d38ff7c93192
1 /**
2 This file is part of Kig, a KDE program for Interactive Geometry...
3 Copyright (C) 2004 Dominique Devriese <devriese@kde.org>
4 Copyright (C) 2004 Pino Toscano <toscano.pino@tiscali.it>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA
20 **/
23 #include "edittype.h"
24 #include "edittype.moc"
26 #include <kapplication.h>
27 #include <kicondialog.h>
28 #include <klineedit.h>
29 #include <klocale.h>
30 #include <kmessagebox.h>
31 #include <kpushbutton.h>
32 #include <kstdguiitem.h>
34 EditType::EditType( QWidget* parent, QString name, QString desc, QString icon )
35 : EditTypeBase( parent, "edittype", true ), mname( name ), mdesc( desc ), micon( icon )
37 // improving GUI look'n'feel...
38 buttonHelp->setGuiItem( KStdGuiItem::help() );
39 buttonOk->setGuiItem( KStdGuiItem::ok() );
40 buttonCancel->setGuiItem( KStdGuiItem::cancel() );
42 editName->setText( mname );
43 editDescription->setText( mdesc );
44 typeIcon->setIcon( !micon.isEmpty() ? micon : "gear" );
47 EditType::~EditType()
51 void EditType::helpSlot()
53 kapp->invokeHelp( QString::fromLatin1( "working-with-types" ),
54 QString::fromLatin1( "kig" ) );
57 void EditType::okSlot()
59 QString tmp = editName->text();
60 if ( tmp.isEmpty() )
62 KMessageBox::information( this, i18n( "The name of the macro can not be empty." ) );
63 return;
66 bool namechanged = false;
67 bool descchanged = false;
68 bool iconchanged = false;
69 if ( tmp != mname )
71 mname = tmp;
72 namechanged = true;
74 tmp = editDescription->text();
75 if ( tmp != mdesc )
77 mdesc = tmp;
78 descchanged = true;
80 tmp = typeIcon->icon();
81 if ( tmp != micon )
83 micon = tmp;
84 iconchanged = true;
86 done( namechanged || descchanged || iconchanged );
89 void EditType::cancelSlot()
91 done( 0 );
94 const QString EditType::name() const
96 return mname;
99 const QString EditType::description() const
101 return mdesc;
104 const QString EditType::icon() const
106 return micon;