umbrello API Documentation

classwizard.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "classwizard.h"
00014 
00015 // system includes
00016 #include <khelpmenu.h>
00017 #include <klocale.h>
00018 
00019 // local includes
00020 #include "classifierlistpage.h"
00021 #include "../uml.h"
00022 #include "../umldoc.h"
00023 #include "../classifier.h"
00024 #include "../attribute.h"
00025 #include "../operation.h"
00026 #include "../umlclassifierlistitemlist.h"
00027 #include "../classifierlistitem.h"
00028 
00029 ClassWizard::ClassWizard( UMLDoc * pDoc ) : KWizard( (QWidget*)pDoc -> parent(), "_CLASSWIZARD_", true) {
00030     m_pDoc = pDoc;
00031     //create a unique class to start with
00032     UMLObject * pTemp = 0;
00033     QString name = i18n("new_class");
00034     QString newName = name;
00035     QString num = "";
00036     int i = 0;
00037     m_pClass = new UMLClassifier( newName );
00038     do {
00039         m_pClass -> setName( newName );
00040         pTemp = m_pDoc -> findUMLObject( newName );
00041         num.setNum( ++i);
00042         newName = name;
00043         newName.append("_").append( num );
00044     } while( pTemp );
00045     //setup pages
00046     setupPages();
00047 }
00048 
00049 ClassWizard::~ClassWizard() {}
00050 
00051 void ClassWizard::setupPages() {
00052     //Setup General Page
00053     m_pGenPage = new ClassGenPage( m_pDoc, this, m_pClass );
00054     addPage( m_pGenPage, i18n("New Class") );
00055     setHelpEnabled(m_pGenPage, false);
00056 
00057     //Setup Attribute Page
00058     m_pAttPage = new ClassifierListPage(this, m_pClass, m_pDoc, Uml::ot_Attribute);
00059     addPage( m_pAttPage, i18n("Class Attributes") );
00060 
00061     //Setup Operation Page
00062     m_pOpPage = new ClassifierListPage(this, m_pClass, m_pDoc, Uml::ot_Operation);
00063     addPage( m_pOpPage, i18n("Class Operations") );
00064 }
00065 
00066 void ClassWizard::showPage( QWidget * pWidget ) {
00067     QWizard::showPage( pWidget );
00068     if( pWidget == m_pOpPage )
00069         finishButton() -> setEnabled( true );
00070 }
00071 
00072 void ClassWizard::next() {
00073     QWidget * pWidget = currentPage();
00074     if( pWidget == m_pGenPage ) {
00075         m_pGenPage -> updateObject();
00076     } else if( pWidget == m_pAttPage ) {
00077         m_pAttPage -> updateObject();
00078     }
00079     QWizard::next();
00080 }
00081 
00082 void ClassWizard::back() {
00083     QWidget * pWidget = currentPage();
00084     if( pWidget == m_pAttPage ) {
00085         m_pAttPage -> updateObject();
00086     } else if( pWidget == m_pOpPage ) {
00087         m_pOpPage -> updateObject();
00088     }
00089     QWizard::back();
00090 }
00091 
00092 void ClassWizard::accept() {
00093     m_pDoc -> addUMLObject( m_pClass );
00094     m_pDoc->signalUMLObjectCreated(m_pClass);
00095 
00096     QWizard::accept();
00097 }
00098 
00099 void ClassWizard::reject() {
00100     delete m_pClass;
00101     QWizard::reject();
00102 }
00103 
00104 void ClassWizard::help() {
00105     KHelpMenu helpMenu(this);
00106     helpMenu.appHelpActivated();
00107 }
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:55 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003