m_pRtypeCB->setDuplicatesEnabled(false); // only allow one of each type in box #if QT_VERSION < 0x050000 m_pRtypeCB->setCompletionMode(KGlobalSettings::CompletionPopup); #endif // add the return types insertTypesSorted(m_operation->getTypeName()); // fill in parm list box UMLAttributeList list = m_operation->getParmList(); foreach (UMLAttribute* pAtt, list) { m_pParmsLW->addItem(pAtt->toString(Uml::SignatureType::SigNoVis)); } // setup parm list box signals connect(m_pUpButton, SIGNAL(clicked()), this, SLOT(slotParameterUp())); connect(m_pDownButton, SIGNAL(clicked()), this, SLOT(slotParameterDown())); connect(m_pParmsLW, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotParamsBoxClicked(QListWidgetItem*))); connect(m_pParmsLW, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotParmRightButtonPressed(QPoint))); connect(m_pParmsLW, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotParmDoubleClick(QListWidgetItem*))); m_pNameLE->setFocus(); connect(m_pNameLE, SIGNAL(textChanged(QString)), SLOT(slotNameChanged(QString))); slotNameChanged(m_pNameLE->text()); } void UMLOperationDialog::slotNameChanged(const QString &_text)
void UMLOperationDialog::setupDialog() { int margin = fontMetrics().height(); QVBoxLayout * topLayout = new QVBoxLayout( plainPage() ); m_pGenGB = new QGroupBox(i18n("General Properties"), plainPage() ); QGridLayout * genLayout = new QGridLayout(m_pGenGB, 3, 4 ); genLayout -> setColStretch(1, 1); genLayout -> setColStretch(3, 1); genLayout -> addColSpacing(1, 200); genLayout -> addColSpacing(3, 200); genLayout -> setMargin(margin); genLayout -> setSpacing(10); Dialog_Utils::makeLabeledEditField( m_pGenGB, genLayout, 0, m_pNameL, i18n("&Name:"), m_pNameLE, m_pOperation->getName() ); m_pRtypeL = new QLabel(i18n("&Type:"), m_pGenGB ); genLayout -> addWidget(m_pRtypeL, 0, 2); m_pRtypeCB = new KComboBox(true, m_pGenGB ); genLayout -> addWidget(m_pRtypeCB, 0, 3); m_pRtypeL->setBuddy(m_pRtypeCB); m_pStereoTypeL = new QLabel( i18n("Stereotype name:"), m_pGenGB ); genLayout -> addWidget(m_pStereoTypeL, 1, 0); m_pStereoTypeCB = new KComboBox(true, m_pGenGB ); genLayout -> addWidget(m_pStereoTypeCB, 1, 1); m_pAbstractCB = new QCheckBox( i18n("&Abstract operation"), m_pGenGB ); m_pAbstractCB -> setChecked( m_pOperation->getAbstract() ); genLayout -> addWidget( m_pAbstractCB, 2, 0 ); m_pStaticCB = new QCheckBox( i18n("Classifier &scope (\"static\")"), m_pGenGB ); m_pStaticCB -> setChecked( m_pOperation->getStatic() ); genLayout -> addWidget( m_pStaticCB, 2, 1 ); m_pQueryCB = new QCheckBox( i18n("&Query (\"const\")"), m_pGenGB ); m_pQueryCB -> setChecked( m_pOperation->getConst() ); genLayout -> addWidget( m_pQueryCB, 2, 2 ); topLayout -> addWidget( m_pGenGB ); m_pScopeBG = new QButtonGroup(i18n("Visibility"), plainPage() ); QHBoxLayout * scopeLayout = new QHBoxLayout(m_pScopeBG); scopeLayout -> setMargin(margin); m_pPublicRB = new QRadioButton(i18n("P&ublic"), m_pScopeBG); scopeLayout -> addWidget(m_pPublicRB); m_pPrivateRB = new QRadioButton(i18n("P&rivate"), m_pScopeBG); scopeLayout -> addWidget(m_pPrivateRB); m_pProtectedRB = new QRadioButton(i18n("Prot&ected"), m_pScopeBG); scopeLayout -> addWidget(m_pProtectedRB); m_pImplementationRB = new QRadioButton(i18n("I&mplementation"), m_pScopeBG); scopeLayout -> addWidget(m_pImplementationRB); topLayout -> addWidget(m_pScopeBG); m_pParmsGB = new QGroupBox(i18n("Parameters"), plainPage() ); QVBoxLayout* parmsLayout = new QVBoxLayout(m_pParmsGB); parmsLayout->setMargin(margin); parmsLayout->setSpacing(10); //horizontal box contains the list box and the move up/down buttons QHBoxLayout* parmsHBoxLayout = new QHBoxLayout(parmsLayout); m_pParmsLB = new QListBox(m_pParmsGB); parmsHBoxLayout->addWidget(m_pParmsLB); //the move up/down buttons (another vertical box) QVBoxLayout* buttonLayout = new QVBoxLayout( parmsHBoxLayout ); m_pUpButton = new KArrowButton( m_pParmsGB ); m_pUpButton->setEnabled( false ); buttonLayout->addWidget( m_pUpButton ); m_pDownButton = new KArrowButton( m_pParmsGB, Qt::DownArrow ); m_pDownButton->setEnabled( false ); buttonLayout->addWidget( m_pDownButton ); KButtonBox* buttonBox = new KButtonBox(m_pParmsGB); buttonBox->addButton( i18n("Ne&w Parameter..."), this, SLOT(slotNewParameter()) ); m_pDeleteButton = buttonBox->addButton( i18n("&Delete"), this, SLOT(slotDeleteParameter()) ); m_pPropertiesButton = buttonBox->addButton( i18n("&Properties"), this, SLOT(slotParameterProperties()) ); parmsLayout->addWidget(buttonBox); topLayout -> addWidget(m_pParmsGB); m_pDeleteButton->setEnabled(false); m_pPropertiesButton->setEnabled(false); m_pUpButton->setEnabled(false); m_pDownButton->setEnabled(false); // Add "void". We use this for denoting "no return type" independent // of the programming language. // For example, the Ada generator would interpret the return type // "void" as an instruction to generate a procedure instead of a // function. insertType( "void" ); m_pRtypeCB->setDuplicatesEnabled(false);//only allow one of each type in box m_pRtypeCB->setCompletionMode( KGlobalSettings::CompletionPopup ); // add template parameters UMLClassifier *classifier = dynamic_cast<UMLClassifier*>(m_pOperation->parent()); if (classifier) { UMLClassifierListItemList tmplParams( classifier->getFilteredList(Uml::ot_Template) ); for (UMLClassifierListItem *li = tmplParams.first(); li; li = tmplParams.next()) insertType( li->getName() ); } //now add the Classes and Interfaces (both are Concepts) UMLClassifierList namesList( m_doc->getConcepts() ); UMLClassifier* pConcept = 0; for(pConcept=namesList.first(); pConcept!=0 ;pConcept=namesList.next()) { insertType( pConcept->getFullyQualifiedName() ); } //work out which one to select int returnBoxCount = 0; bool foundReturnType = false; while (returnBoxCount < m_pRtypeCB->count() && foundReturnType == false) { QString returnBoxString = m_pRtypeCB->text(returnBoxCount); if ( returnBoxString == m_pOperation->getTypeName() ) { foundReturnType = true; m_pRtypeCB->setCurrentItem(returnBoxCount); break; } returnBoxCount++; } if (!foundReturnType) { insertType( m_pOperation->getTypeName(), 0 ); m_pRtypeCB->setCurrentItem(0); } //fill in parm list box UMLAttributeList list = m_pOperation->getParmList(); UMLAttribute * pAtt = 0; for (pAtt = list.first(); pAtt; pAtt = list.next()) m_pParmsLB->insertItem( pAtt->getName() ); //set scope Uml::Visibility scope = m_pOperation -> getVisibility(); if( scope == Uml::Visibility::Public ) m_pPublicRB -> setChecked( true ); else if( scope == Uml::Visibility::Private ) m_pPrivateRB -> setChecked( true ); else if( scope == Uml::Visibility::Protected ) m_pProtectedRB -> setChecked( true ); else if( scope == Uml::Visibility::Implementation ) m_pImplementationRB -> setChecked( true ); // manage stereotypes m_pStereoTypeCB -> setDuplicatesEnabled(false);//only allow one of each type in box m_pStereoTypeCB->setCompletionMode( KGlobalSettings::CompletionPopup ); insertStereotype (QString("")); // an empty stereotype is the default int defaultStereotype=0; bool foundDefaultStereotype = false; for (UMLStereotypeListIt it(m_doc->getStereotypes()); it.current(); ++it) { if (!foundDefaultStereotype) { if ( m_pOperation->getStereotype() == it.current()->getName()) { foundDefaultStereotype = true; } defaultStereotype++; } insertStereotype (it.current()->getName()); } // lookup for a default stereotype, if the operation doesn't have one if (foundDefaultStereotype) m_pStereoTypeCB->setCurrentItem(defaultStereotype); else m_pStereoTypeCB->setCurrentItem(-1); //setup parm list box signals connect( m_pUpButton, SIGNAL( clicked() ), this, SLOT( slotParameterUp() ) ); connect( m_pDownButton, SIGNAL( clicked() ), this, SLOT( slotParameterDown() ) ); connect(m_pParmsLB, SIGNAL(clicked(QListBoxItem*)), this, SLOT(slotParamsBoxClicked(QListBoxItem*))); connect(m_pParmsLB, SIGNAL(rightButtonPressed(QListBoxItem *, const QPoint &)), this, SLOT(slotParmRightButtonPressed(QListBoxItem *, const QPoint &))); connect(m_pParmsLB, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), this, SLOT(slotParmRightButtonClicked(QListBoxItem *, const QPoint &))); connect(m_pParmsLB, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(slotParmDoubleClick(QListBoxItem *))); m_pNameLE->setFocus(); connect( m_pNameLE, SIGNAL( textChanged ( const QString & ) ), SLOT( slotNameChanged( const QString & ) ) ); slotNameChanged(m_pNameLE->text() ); }