entityattribute.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "entityattribute.h"
00014
00015 #include <qregexp.h>
00016 #include <kdebug.h>
00017
00018 #include "umlcanvasobject.h"
00019 #include "umldoc.h"
00020 #include "uml.h"
00021 #include "dialogs/umlentityattributedialog.h"
00022 #include "object_factory.h"
00023
00024 UMLEntityAttribute::UMLEntityAttribute( const UMLObject *parent, const QString& name,
00025 Uml::IDType id, Uml::Visibility s,
00026 UMLObject *type, const QString& iv )
00027 : UMLAttribute(parent, name, id, s, type, iv) {
00028 init();
00029 if (m_pSecondary) {
00030 m_pSecondary->setBaseType(Uml::ot_Entity);
00031 }
00032 }
00033
00034 UMLEntityAttribute::UMLEntityAttribute(const UMLObject *parent) : UMLAttribute(parent) {
00035 init();
00036 }
00037
00038 UMLEntityAttribute::~UMLEntityAttribute() { }
00039
00040 void UMLEntityAttribute::init() {
00041 m_BaseType = Uml::ot_EntityAttribute;
00042 m_indexType = Uml::None;
00043 m_autoIncrement = false;
00044 m_null = false;
00045 }
00046
00047 QString UMLEntityAttribute::getAttributes() {
00048 return m_attributes;
00049 }
00050
00051 void UMLEntityAttribute::setAttributes(const QString& attributes) {
00052 m_attributes = attributes;
00053 }
00054
00055 QString UMLEntityAttribute::getValues() {
00056 return m_values;
00057 }
00058
00059 void UMLEntityAttribute::setValues(const QString& values) {
00060 m_values = values;
00061 }
00062
00063 bool UMLEntityAttribute::getAutoIncrement() {
00064 return m_autoIncrement;
00065 }
00066
00067 void UMLEntityAttribute::setAutoIncrement(const bool autoIncrement) {
00068 m_autoIncrement = autoIncrement;
00069 }
00070
00071 Uml::DBIndex_Type UMLEntityAttribute::getIndexType() {
00072 return m_indexType;
00073 }
00074
00075 void UMLEntityAttribute::setIndexType(const Uml::DBIndex_Type indexType) {
00076 m_indexType = indexType;
00077 }
00078
00079 bool UMLEntityAttribute::getNull() {
00080 return m_null;
00081 }
00082
00083 void UMLEntityAttribute::setNull(const bool nullIn) {
00084 m_null = nullIn;
00085 }
00086
00087 QString UMLEntityAttribute::toString(Uml::Signature_Type sig) {
00088 QString s;
00089
00090
00091 if(sig == Uml::st_ShowSig || sig == Uml::st_NoSig) {
00092 s=m_Vis.toString(true) + ' ';
00093 } else
00094 s = "";
00095
00096 if(sig == Uml::st_ShowSig || sig == Uml::st_SigNoVis) {
00097 QString string = s + getName() + " : " + getTypeName();
00098 if(m_InitialValue.length() > 0)
00099 string += " = " + m_InitialValue;
00100 return string;
00101 } else
00102 return s + getName();
00103 }
00104
00105 bool UMLEntityAttribute::operator==( UMLEntityAttribute &rhs) {
00106 if( this == &rhs )
00107 return true;
00108
00109 if( !UMLObject::operator==( rhs ) )
00110 return false;
00111
00112
00113
00114 if (m_pSecondary != rhs.m_pSecondary)
00115 return false;
00116
00117 return true;
00118 }
00119
00120 void UMLEntityAttribute::copyInto(UMLEntityAttribute *rhs) const
00121 {
00122
00123 UMLClassifierListItem::copyInto(rhs);
00124
00125
00126 rhs->m_pSecondary = m_pSecondary;
00127 rhs->m_SecondaryId = m_SecondaryId;
00128 rhs->m_InitialValue = m_InitialValue;
00129 rhs->m_ParmKind = m_ParmKind;
00130 }
00131
00132 UMLObject* UMLEntityAttribute::clone() const
00133 {
00134 UMLEntityAttribute* clone = new UMLEntityAttribute( (UMLEntityAttribute*)parent() );
00135 copyInto(clone);
00136
00137 return clone;
00138 }
00139
00140
00141 void UMLEntityAttribute::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
00142 QDomElement entityattributeElement = UMLObject::save("UML:EntityAttribute", qDoc);
00143 if (m_pSecondary == NULL) {
00144 kDebug() << "UMLEntityAttribute::saveToXMI(" << m_Name
00145 << "): m_pSecondary is NULL, using local name "
00146 << m_SecondaryId << endl;
00147 entityattributeElement.setAttribute( "type", m_SecondaryId );
00148 } else {
00149 entityattributeElement.setAttribute( "type", ID2STR(m_pSecondary->getID()) );
00150 }
00151 entityattributeElement.setAttribute( "initialValue", m_InitialValue );
00152 entityattributeElement.setAttribute( "dbindex_type", m_indexType );
00153 entityattributeElement.setAttribute( "values", m_values );
00154 entityattributeElement.setAttribute( "attributes", m_attributes );
00155 entityattributeElement.setAttribute( "auto_increment", m_autoIncrement );
00156 entityattributeElement.setAttribute( "allow_null", m_null );
00157 qElement.appendChild( entityattributeElement );
00158 }
00159
00160 bool UMLEntityAttribute::load( QDomElement & element ) {
00161 if (! UMLAttribute::load(element))
00162 return false;
00163 int indexType = element.attribute( "dbindex_type", "1100" ).toInt();
00164 m_indexType = ( Uml::DBIndex_Type )indexType;
00165 m_values = element.attribute( "values", "" );
00166 m_attributes = element.attribute( "attributes", "" );
00167 m_autoIncrement = ( bool )element.attribute( "auto_increment", "" ).toInt();
00168 m_null = ( bool )element.attribute( "allow_null", "" ).toInt();
00169 return true;
00170 }
00171
00172 bool UMLEntityAttribute::showPropertiesDialog(QWidget* parent) {
00173 UMLEntityAttributeDialog dialog(parent, this);
00174 return dialog.exec();
00175 }
00176
00177
00178
This file is part of the documentation for umbrello Version 3.1.0.