umbrello API Documentation

umlroleproperties.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) 2003-2007                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 // own header
00013 #include "umlroleproperties.h"
00014 
00015 // qt/kde includes
00016 #include <qradiobutton.h>
00017 #include <qtextedit.h>
00018 #include <qlineedit.h>
00019 #include <klocale.h>
00020 #include <kmessagebox.h>
00021 #include <kdebug.h>
00022 
00023 
00024 UMLRoleProperties::UMLRoleProperties ( QWidget *parent, UMLRole *role)
00025         : UMLRolePropertiesBase (parent)
00026 {
00027 
00028     m_pRole = role;
00029     constructWidget();
00030 
00031 }
00032 
00033 UMLRoleProperties::~UMLRoleProperties() { }
00034 
00035 void UMLRoleProperties::constructWidget() {
00036 
00037     // Use Parent Role to set starting Properties
00038     //
00039 
00040     // Rolename
00041     m_pRoleLE -> setText(m_pRole->getName());
00042 
00043     // Multiplicity
00044     m_pMultiLE -> setText(m_pRole->getMultiplicity());
00045 
00046     // Visibility
00047     Uml::Visibility scope = m_pRole->getVisibility();
00048     if( scope == Uml::Visibility::Public )
00049         m_pPublicRB -> setChecked( true );
00050     else if( scope == Uml::Visibility::Private )
00051         m_pPrivateRB -> setChecked( true );
00052     else if( scope == Uml::Visibility::Protected )
00053         m_pProtectedRB -> setChecked( true );
00054     else if( scope == Uml::Visibility::Implementation )
00055         m_pImplementationRB -> setChecked( true );
00056 
00057     // Changeability
00058     Uml::Changeability_Type changeability = m_pRole->getChangeability();
00059     if( changeability == Uml::chg_Changeable )
00060         m_pChangeableRB -> setChecked( true );
00061     else if( changeability == Uml::chg_Frozen )
00062         m_pFrozenRB -> setChecked( true );
00063     else
00064         m_pAddOnlyRB -> setChecked( true );
00065 
00066     // Documentation
00067     //
00068     m_pDocTE-> setText(m_pRole-> getDoc());
00069     //m_pDocTE->setWordWrap(QMultiLineEdit::WidgetWidth);
00070 }
00071 
00072 void UMLRoleProperties::updateObject() {
00073 
00074     if(m_pRole) {
00075 
00076         // block signals to save work load..we only need to emit modified once,
00077         // not each time we update an attribute of the association. I suppose
00078         // we could check to see IF anything changed, but thats a lot more code,
00079         // and not much gained. THis way is easier, if less 'beautiful'. -b.t.
00080 
00081         m_pRole->blockSignals(true);
00082 
00083         // set props
00084         m_pRole->setName(m_pRoleLE->text());
00085         m_pRole->setMultiplicity(m_pMultiLE->text());
00086 
00087         if(m_pPrivateRB->isChecked())
00088             m_pRole->setVisibility(Uml::Visibility::Private);
00089         else if(m_pProtectedRB->isChecked())
00090             m_pRole->setVisibility(Uml::Visibility::Protected);
00091         else if(m_pPublicRB->isChecked())
00092             m_pRole->setVisibility(Uml::Visibility::Public);
00093         else if(m_pImplementationRB->isChecked())
00094             m_pRole->setVisibility(Uml::Visibility::Implementation);
00095 
00096         if(m_pFrozenRB->isChecked())
00097             m_pRole->setChangeability(Uml::chg_Frozen);
00098         else if(m_pAddOnlyRB->isChecked())
00099             m_pRole->setChangeability(Uml::chg_AddOnly);
00100         else
00101             m_pRole->setChangeability(Uml::chg_Changeable);
00102 
00103         m_pRole->setDoc(m_pDocTE->text());
00104 
00105         m_pRole->blockSignals(false);
00106 
00107         m_pRole->emitModified();
00108 
00109     } //end if m_pRole
00110 
00111 }
00112 
00113 
00114 #include "umlroleproperties.moc"
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:08:01 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003