selectopdlg.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "selectopdlg.h"
00014
00015
00016 #include <qlayout.h>
00017
00018
00019 #include <klocale.h>
00020 #include <kdebug.h>
00021
00022
00023 #include "../attribute.h"
00024 #include "../operation.h"
00025 #include "../umlclassifierlistitemlist.h"
00026 #include "../umlview.h"
00027 #include "../dialog_utils.h"
00028
00029 SelectOpDlg::SelectOpDlg(UMLView * parent, UMLClassifier * c)
00030 : KDialogBase(Plain, i18n("Select Operation"), Ok | Cancel , Ok, parent, "_SELOPDLG_", true, true)
00031 {
00032 m_pView = parent;
00033 QVBoxLayout * topLayout = new QVBoxLayout(plainPage());
00034
00035 m_pOpGB = new QGroupBox(i18n("Select Operation"), plainPage());
00036 topLayout -> addWidget(m_pOpGB);
00037
00038 QGridLayout * mainLayout = new QGridLayout(m_pOpGB, 3, 2);
00039 mainLayout -> setSpacing(spacingHint());
00040 mainLayout -> setMargin(fontMetrics().height());
00041
00042 Dialog_Utils::makeLabeledEditField( m_pOpGB, mainLayout, 0,
00043 m_pSeqL, i18n("Sequence number:"),
00044 m_pSeqLE );
00045
00046 m_pOpRB = new QRadioButton(i18n("Class operation:"), m_pOpGB);
00047 mainLayout -> addWidget(m_pOpRB, 1, 0);
00048
00049 m_pOpCB = new KComboBox(m_pOpGB);
00050 m_pOpCB->setCompletionMode( KGlobalSettings::CompletionPopup );
00051 m_pOpCB->setDuplicatesEnabled(false);
00052 mainLayout -> addWidget(m_pOpCB, 1, 1);
00053
00054 m_pCustomRB = new QRadioButton(i18n("Custom operation:"), m_pOpGB);
00055 mainLayout -> addWidget(m_pCustomRB, 2, 0);
00056
00057 m_pOpLE = new QLineEdit(m_pOpGB);
00058 mainLayout -> addWidget(m_pOpLE, 2, 1);
00059
00060 m_pOpBG = new QButtonGroup(0);
00061 m_pOpBG -> insert(m_pOpRB, OP);
00062 m_pOpBG -> insert(m_pCustomRB, CUSTOM);
00063 m_pOpBG -> setExclusive(true);
00064 m_pOpBG -> setButton(OP);
00065
00066 UMLOperationList list = c -> getOpList(true);
00067 for (UMLOperation *obj = list.first(); obj; obj=list.next()) {
00068 insertOperation( obj->toString(Uml::st_SigNoVis) );
00069 }
00070
00071 connect(m_pOpBG, SIGNAL(clicked(int)), this, SLOT(slotSelected(int)));
00072 m_nOpCount = c -> operations();
00073 slotSelected(OP);
00074 }
00075
00076 SelectOpDlg::~SelectOpDlg() {
00077 disconnect(m_pOpBG, SIGNAL(clicked(int)), this, SLOT(slotSelected(int)));
00078 delete m_pOpBG;
00079 }
00080
00081 void SelectOpDlg::insertOperation( const QString& type, int index )
00082 {
00083 m_pOpCB->insertItem( type, index );
00084 m_pOpCB->completionObject()->addItem( type );
00085 }
00086
00087 QString SelectOpDlg::getOpText() {
00088 if(m_pOpRB -> isChecked())
00089 return m_pOpCB -> currentText();
00090 else
00091 return m_pOpLE -> text();
00092 }
00093
00094 bool SelectOpDlg::isClassOp() const {
00095 return (m_id == OP);
00096 }
00097
00098 void SelectOpDlg::slotSelected(int id) {
00099 if(id == OP) {
00100 m_pOpLE -> setEnabled(false);
00101 if(m_nOpCount > 0)
00102 m_pOpCB -> setEnabled(true);
00103 } else {
00104 m_pOpLE -> setEnabled(true);
00105 m_pOpCB -> setEnabled(false);
00106 }
00107 m_id = id;
00108 }
00109
00110 void SelectOpDlg::setCustomOp(const QString &op) {
00111 m_pOpLE -> setText(op);
00112 if(op.length() > 0) {
00113 slotSelected(CUSTOM);
00114 m_pCustomRB -> setChecked(true);
00115 }
00116 }
00117
00118 bool SelectOpDlg::setClassOp(const QString &op) {
00119 for (int i = 1; i!= m_pOpCB->count(); ++i)
00120 {
00121 if ( m_pOpCB->text(i) == op ) {
00122 m_pOpCB->setCurrentItem(i);
00123 m_pCustomRB -> setChecked(false);
00124 slotSelected(OP);
00125 return true;
00126 }
00127 }
00128 return false;
00129 }
00130
00131 QString SelectOpDlg::getSeqNumber() {
00132 return m_pSeqLE->text();
00133 }
00134
00135 void SelectOpDlg::setSeqNumber(const QString &num) {
00136 m_pSeqLE->setText(num);
00137 }
00138
00139
00140
00141 #include "selectopdlg.moc"
This file is part of the documentation for umbrello Version 3.1.0.