assocgenpage.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "assocgenpage.h"
00014
00015
00016 #include <qlayout.h>
00017 #include <kcombobox.h>
00018
00019
00020 #include <klocale.h>
00021 #include <kmessagebox.h>
00022 #include <kdebug.h>
00023
00024
00025 #include "../association.h"
00026 #include "../dialog_utils.h"
00027
00028 AssocGenPage::AssocGenPage (UMLDoc *d, QWidget *parent, AssociationWidget *assoc)
00029 : QWidget(parent)
00030 {
00031
00032 m_pAssociationWidget = assoc;
00033 m_pWidget = 0;
00034 m_pTypeCB = 0;
00035 m_pAssocNameLE = 0;
00036 m_pUmldoc = d;
00037
00038 constructWidget();
00039
00040 }
00041
00042 AssocGenPage::~AssocGenPage() {}
00043
00044 void AssocGenPage::constructWidget() {
00045
00046
00047 int margin = fontMetrics().height();
00048 setMinimumSize(310,330);
00049 QVBoxLayout * topLayout = new QVBoxLayout(this);
00050 topLayout -> setSpacing(6);
00051
00052
00053 QGroupBox *nameGB = new QGroupBox(this);
00054 QGroupBox *docGB = new QGroupBox(this);
00055 nameGB -> setTitle(i18n("Properties"));
00056 docGB -> setTitle(i18n("Documentation"));
00057 topLayout -> addWidget(nameGB);
00058 topLayout -> addWidget(docGB);
00059
00060 QGridLayout * nameLayout = new QGridLayout(nameGB, 2, 2);
00061 nameLayout -> setSpacing(6);
00062 nameLayout -> setMargin(margin);
00063
00064
00065 QLabel *pAssocNameL = NULL;
00066 QLineEdit* nameField = Dialog_Utils::makeLabeledEditField( nameGB, nameLayout, 0,
00067 pAssocNameL, i18n("Name:"),
00068 m_pAssocNameLE, m_pAssociationWidget->getName() );
00069 nameField->setFocus();
00070
00071
00072 QHBoxLayout * docLayout = new QHBoxLayout(docGB);
00073 docLayout -> setMargin(margin);
00074
00075 m_pDoc = new QMultiLineEdit(docGB);
00076 docLayout -> addWidget(m_pDoc);
00077 m_pDoc-> setText(m_pAssociationWidget-> getDoc());
00078 Uml::Association_Type currentType = m_pAssociationWidget->getAssocType();
00079 QString currentTypeAsString = UMLAssociation::typeAsString(currentType);
00080 QLabel *pTypeL = new QLabel(i18n("Type:"), nameGB);
00081 nameLayout->addWidget(pTypeL, 1, 0);
00082
00083
00084
00085 m_AssocTypes.clear();
00086 m_AssocTypes << Uml::at_Aggregation
00087 << Uml::at_Composition << Uml::at_Containment;
00088
00089 bool found=false;
00090 m_AssocTypeStrings.clear();
00091 for (uint i=0; i<m_AssocTypes.size(); ++i) {
00092 if (m_AssocTypes[i] == currentType) found=true;
00093 QString typeStr = UMLAssociation::typeAsString(m_AssocTypes[i]);
00094 m_AssocTypeStrings << typeStr;
00095 }
00096
00097 if (!found) {
00098 m_AssocTypes.clear();
00099 m_AssocTypes << currentType;
00100 m_AssocTypeStrings.clear();
00101 m_AssocTypeStrings << currentTypeAsString;
00102 }
00103
00104 m_pTypeCB = new KComboBox(nameGB);
00105 pTypeL->setBuddy(m_pTypeCB);
00106 m_pTypeCB->insertStringList(m_AssocTypeStrings);
00107 m_pTypeCB->setCompletedItems(m_AssocTypeStrings);
00108 m_pTypeCB->setCurrentText(currentTypeAsString);
00109 m_pTypeCB->setDuplicatesEnabled(false);
00110 m_pTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup );
00111 m_pDoc->setWordWrap(QMultiLineEdit::WidgetWidth);
00112 nameLayout->addWidget(m_pTypeCB, 1, 1);
00113
00114
00115 }
00116
00117
00118 void AssocGenPage::updateObject() {
00119
00120 if (m_pAssociationWidget) {
00121 int comboBoxItem = m_pTypeCB->currentItem();
00122 Uml::Association_Type newType = m_AssocTypes[comboBoxItem];
00123 m_pAssociationWidget->setAssocType(newType);
00124 m_pAssociationWidget->setName(m_pAssocNameLE->text());
00125 m_pAssociationWidget->setDoc(m_pDoc->text());
00126
00127 }
00128 }
00129
00130
00131 #include "assocgenpage.moc"
This file is part of the documentation for umbrello Version 3.1.0.