void tst_Q3HBox::setStretchFactor() { Q3HBox box; int stretch1 = 500; QPushButton *b1 = new QPushButton(QString("Strech %1").arg(stretch1), &box); QVERIFY(box.setStretchFactor(b1, stretch1)); int stretch2 = 1; QPushButton *b2 = new QPushButton(QString("Strech %1").arg(stretch2), &box); QVERIFY(box.setStretchFactor(b2, stretch2)); }
/** No descriptions */ void SliderSpin::initWidget() { Q3HBox* hb = new Q3HBox(this); mpTitleLabel = new QLabel(hb); mpSlider = new QSlider(0,10,1,1,Qt::Horizontal,hb); mpSpinBox = new QSpinBox(0,10,1,hb); hb->setSpacing(5); hb->setStretchFactor(mpSlider,1); mpSlider->setTracking(false); connect(mpSlider,SIGNAL(valueChanged(int)), this,SLOT(slotValueChanged(int))); connect(mpSlider,SIGNAL(sliderMoved(int)), this,SLOT(slotSliderMoved(int))); connect(mpSpinBox,SIGNAL(valueChanged(int)), this,SLOT(slotSpinValueChanged(int))); }
Dialog::Dialog(WrapperStr & path, WrapperStr & encoding, WrapperStr & nomodel, WrapperStr & genview, WrapperStr & uml20, WrapperStr & pk, WrapperStr & vis, WrapperStr & primitivetype, WrapperStr & genextension, WrapperStr & geneclipse, WrapperStr & commentexporter, WrapperStr & linefeed, Language & lang) : QDialog(0, 0, TRUE), _path(path), _encoding(encoding), _nomodel(nomodel), _genview(genview), _uml20(uml20), _pk(pk), _vis(vis), _primitivetype(primitivetype), _genextension(genextension), _geneclipse(geneclipse), _commentexporter(commentexporter), _linefeed(linefeed), _lang(lang) { Q3VBoxLayout * vbox = new Q3VBoxLayout(this); Q3HBox * htab; vbox->setMargin(5); // get xmi pathname htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); new QLabel("generated \nXMI file : ", htab); ed = new QLineEdit(htab); ed->setText(_path); new QLabel(" ", htab); SmallPushButton * br = new SmallPushButton("browse", htab); connect(br, SIGNAL(clicked()), this, SLOT(browse())); // to choose encoding htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); new QLabel("Encoding : ", htab); QString charset = getenv("BOUML_CHARSET"); int index = 0; while ((index = charset.find('_')) != -1) { charset[index] = '-'; index += 1; } encoding_cb = new QComboBox(TRUE, htab); htab->setStretchFactor(encoding_cb, 1000); if (_encoding.isEmpty()) _encoding = "UTF-8"; encoding_cb->insertItem(QString(_encoding)); if (!charset.isEmpty() && (_encoding != (const char *) charset)) encoding_cb->insertItem(charset); if (_encoding != "UTF-8") encoding_cb->insertItem("UTF-8"); #ifdef WIN32 if ((_encoding != "windows-1252") && (charset != "windows-1252")) encoding_cb->insertItem("windows-1252"); if ((_encoding != "ISO-8859-1") && (charset != "ISO-8859-1")) encoding_cb->insertItem("ISO-8859-1"); #else if ((_encoding != "ISO-8859-1") && (charset != "ISO-8859-1")) encoding_cb->insertItem("ISO-8859-1"); if ((_encoding != "windows-1252") && (charset != "windows-1252")) encoding_cb->insertItem("windows-1252"); #endif // uml 2.0 or uml2.1 htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); Q3ButtonGroup * bg = new Q3ButtonGroup(2, Qt::Horizontal, "Uml", htab); uml20_rb = new QRadioButton("uml 2.0", bg); uml21_rb = new QRadioButton("uml 2.1", bg); if (uml20 == "yes") uml20_rb->setChecked(TRUE); else uml21_rb->setChecked(TRUE); // generate model htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); nomodel_cb = new QCheckBox("Don't generate model level", htab); if (_nomodel == "yes") nomodel_cb->setChecked(TRUE); // generate view checkbox htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); genview_cb = new QCheckBox("Generate views as package (not compatible with profile generation)", htab); if (_genview == "yes") genview_cb->setChecked(TRUE); // generate pk_ prefix htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); pk_cb = new QCheckBox("Generate 'pk_' prefix for parameter direction", htab); if (_pk == "yes") pk_cb->setChecked(TRUE); // generate vis_ prefix htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); vis_cb = new QCheckBox("Generate 'vis_' prefix for visibility", htab); if (_vis == "yes") vis_cb->setChecked(TRUE); // use PrimitiveType rather than DataType htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); primitivetype_cb = new QCheckBox("Use PrimitiveType rather than DataType", htab); if (_primitivetype == "yes") primitivetype_cb->setChecked(TRUE); // generate extension htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); genextension_cb = new QCheckBox("Generate extensions", htab); if (_genextension == "yes") genextension_cb->setChecked(TRUE); // generate for Eclipse htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); geneclipse_cb = new QCheckBox("Generate for Eclipse (aggregation set on other relation side)", htab); if (_geneclipse == "yes") geneclipse_cb->setChecked(TRUE); // comment exporter htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); commentexporter_cb = new QCheckBox("Comment exporter indication (needed to import in some tools like Rsa)", htab); if (_commentexporter == "yes") commentexporter_cb->setChecked(TRUE); // generate rather than linefeed htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); linefeed_cb = new QCheckBox("Generate lf and cr characters in string rather than '& ' and '& '", htab); if (_linefeed == "yes") linefeed_cb->setChecked(TRUE); // uml , c++, java, cancel buttons htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); new QLabel(htab); QPushButton * uml = new QPushButton("&Uml", htab); new QLabel(htab); QPushButton * cpp = new QPushButton("&C++", htab); new QLabel(htab); QPushButton * java = new QPushButton("&Java", htab); new QLabel(htab); QPushButton * cancel = new QPushButton("&Cancel", htab); new QLabel(htab); QSize bs(cancel->sizeHint()); uml->setFixedSize(bs); cpp->setFixedSize(bs); java->setFixedSize(bs); connect(uml, SIGNAL(clicked()), this, SLOT(accept_uml())); connect(cpp, SIGNAL(clicked()), this, SLOT(accept_cpp())); connect(java, SIGNAL(clicked()), this, SLOT(accept_java())); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); // help htab = new Q3HBox(this); htab->setMargin(5); vbox->addWidget(htab); new QLabel(htab); new QLabel("Remark : to help Eclipse to import the generated file,\n" "choose Uml 2.1 and name the file with the extension '.xmi'", htab); new QLabel(htab); }
OptimizeDialog::OptimizeDialog(Optimize_Sim *c_, Schematic *d_) : QDialog(d_, 0, TRUE, Qt::WDestructiveClose) { Comp = c_; Doc = d_; changed = false; setCaption(tr("Edit Optimization Properties")); Expr.setPattern("[\\w_]+"); Validator = new QRegExpValidator(Expr, this); numVal = new QDoubleValidator(this); intVal = new QIntValidator(this); all = new Q3VBoxLayout(this); // to provide the neccessary size QTabWidget *t = new QTabWidget(this); all->addWidget(t); // ........................................................... QWidget *Tab1 = new QWidget(t); Q3GridLayout *gp1 = new Q3GridLayout(Tab1,3,2,3,3); gp1->addWidget(new QLabel(tr("Name:"), Tab1), 0,0); NameEdit = new QLineEdit(Tab1); NameEdit->setValidator(Validator); gp1->addWidget(NameEdit,0,1); gp1->addWidget(new QLabel(tr("Simulation:"), Tab1), 1,0); SimEdit = new QComboBox(Tab1); SimEdit->setEditable(true); gp1->addWidget(SimEdit,1,1); t->addTab(Tab1, tr("General")); // ........................................................... QWidget *Tab4 = new QWidget(t); Q3GridLayout *gp4 = new Q3GridLayout(Tab4,11,2,3,3); gp4->addWidget(new QLabel(tr("Method:"), Tab4), 0,0); MethodCombo = new QComboBox(Tab4); MethodCombo->insertItem("DE/best/1/exp"); MethodCombo->insertItem("DE/rand/1/exp"); MethodCombo->insertItem("DE/rand-to-best/1/exp"); MethodCombo->insertItem("DE/best/2/exp"); MethodCombo->insertItem("DE/rand/1/exp"); MethodCombo->insertItem("DE/best/1/bin"); MethodCombo->insertItem("DE/rand/1/bin"); MethodCombo->insertItem("DE/rand-to-best/1/bin"); MethodCombo->insertItem("DE/best/2/bin"); MethodCombo->insertItem("DE/rand/2/bin"); gp4->addWidget(MethodCombo,0,1); gp4->addWidget(new QLabel(tr("Maximum number of iterations:"), Tab4), 1,0); IterEdit = new QLineEdit(Tab4); IterEdit->setValidator(intVal); gp4->addWidget(IterEdit,1,1); gp4->addWidget(new QLabel(tr("Output refresh cycle:"), Tab4), 2,0); RefreshEdit = new QLineEdit(Tab4); RefreshEdit->setValidator(intVal); gp4->addWidget(RefreshEdit,2,1); gp4->addWidget(new QLabel(tr("Number of parents:"), Tab4), 3,0); ParentsEdit = new QLineEdit(Tab4); ParentsEdit->setValidator(intVal); gp4->addWidget(ParentsEdit,3,1); gp4->addWidget(new QLabel(tr("Constant F:"), Tab4), 4,0); ConstEdit = new QLineEdit(Tab4); ConstEdit->setValidator(new QDoubleValidator(0.0,2.0,20,ConstEdit)); gp4->addWidget(ConstEdit,4,1); gp4->addWidget(new QLabel(tr("Crossing over factor:"), Tab4), 5,0); CrossEdit = new QLineEdit(Tab4); CrossEdit->setValidator(new QDoubleValidator(0.0,1.0,20,CrossEdit)); gp4->addWidget(CrossEdit,5,1); gp4->addWidget(new QLabel(tr("Pseudo random number seed:"), Tab4), 6,0); SeedEdit = new QLineEdit(Tab4); SeedEdit->setValidator(numVal); gp4->addWidget(SeedEdit,6,1); gp4->addWidget(new QLabel(tr("Minimum cost variance:"), Tab4), 7,0); CostVarEdit = new QLineEdit(Tab4); CostVarEdit->setValidator(numVal); gp4->addWidget(CostVarEdit,7,1); gp4->addWidget(new QLabel(tr("Cost objectives:"), Tab4), 8,0); CostObjEdit = new QLineEdit(Tab4); CostObjEdit->setValidator(numVal); gp4->addWidget(CostObjEdit,8,1); gp4->addWidget(new QLabel(tr("Cost constraints:"), Tab4), 9,0); CostConEdit = new QLineEdit(Tab4); CostConEdit->setValidator(numVal); gp4->addWidget(CostConEdit,9,1); t->addTab(Tab4, tr("Algorithm")); // ........................................................... QWidget *Tab2 = new QWidget(t); Q3GridLayout *gp2 = new Q3GridLayout(Tab2,5,3,3,3); VarList = new Q3ListView(Tab2); VarList->addColumn(tr("Name")); VarList->addColumn(tr("active")); VarList->addColumn(tr("initial")); VarList->addColumn(tr("min")); VarList->addColumn(tr("max")); VarList->addColumn(tr("Type")); VarList->setSorting(-1); // no sorting gp2->addMultiCellWidget(VarList,0,0,0,2); connect(VarList, SIGNAL(selectionChanged(Q3ListViewItem*)), SLOT(slotEditVariable(Q3ListViewItem*))); Q3HBox *VarLine = new Q3HBox(Tab2); VarLine->setSpacing(3); gp2->addMultiCellWidget(VarLine, 1,1,0,2); new QLabel(tr("Name:"), VarLine); VarNameEdit = new QLineEdit(VarLine); VarNameEdit->setValidator(Validator); connect(VarNameEdit, SIGNAL(textChanged(const QString&)), SLOT(slotChangeVarName(const QString&))); VarActiveCheck = new QCheckBox(tr("active"), VarLine); VarActiveCheck->setChecked(true); connect(VarActiveCheck, SIGNAL(toggled(bool)), SLOT(slotChangeVarActive(bool))); gp2->addWidget(new QLabel(tr("initial:"), Tab2), 2,0); gp2->addWidget(new QLabel(tr("min:"), Tab2), 2,1); gp2->addWidget(new QLabel(tr("max:"), Tab2), 2,2); VarInitEdit = new QLineEdit(Tab2); VarInitEdit->setValidator(numVal); gp2->addWidget(VarInitEdit,3,0); connect(VarInitEdit, SIGNAL(textChanged(const QString&)), SLOT(slotChangeVarInit(const QString&))); VarMinEdit = new QLineEdit(Tab2); VarMinEdit->setValidator(numVal); gp2->addWidget(VarMinEdit,3,1); connect(VarMinEdit, SIGNAL(textChanged(const QString&)), SLOT(slotChangeVarMin(const QString&))); VarMaxEdit = new QLineEdit(Tab2); VarMaxEdit->setValidator(numVal); gp2->addWidget(VarMaxEdit,3,2); connect(VarMaxEdit, SIGNAL(textChanged(const QString&)), SLOT(slotChangeVarMax(const QString&))); Q3HBox *VarButtons = new Q3HBox(Tab2); VarButtons->setSpacing(3); gp2->addMultiCellWidget(VarButtons, 4,4,0,2); new QLabel(tr("Type:"), VarButtons); VarTypeCombo = new QComboBox(VarButtons); VarTypeCombo->insertItem(tr("linear double")); VarTypeCombo->insertItem(tr("logarithmic double")); VarTypeCombo->insertItem(tr("linear integer")); VarTypeCombo->insertItem(tr("logarithmic integer")); connect(VarTypeCombo, SIGNAL(activated(const QString&)), SLOT(slotChangeVarType(const QString&))); VarButtons->setStretchFactor(new QWidget(VarButtons), 10); QPushButton *AddVar_Butt = new QPushButton(tr("Add"), VarButtons); connect(AddVar_Butt, SIGNAL(clicked()), SLOT(slotAddVariable())); QPushButton *DelVar_Butt = new QPushButton(tr("Delete"), VarButtons); connect(DelVar_Butt, SIGNAL(clicked()), SLOT(slotDeleteVariable())); t->addTab(Tab2, tr("Variables")); // ........................................................... QWidget *Tab3 = new QWidget(t); Q3GridLayout *gp3 = new Q3GridLayout(Tab3,4,3,3,3); GoalList = new Q3ListView(Tab3); GoalList->addColumn(tr("Name")); GoalList->addColumn(tr("Type")); GoalList->addColumn(tr("Value")); GoalList->setSorting(-1); // no sorting gp3->addMultiCellWidget(GoalList,0,0,0,2); connect(GoalList, SIGNAL(selectionChanged(Q3ListViewItem*)), SLOT(slotEditGoal(Q3ListViewItem*))); gp3->addWidget(new QLabel(tr("Name:"), Tab3), 1,0); GoalNameEdit = new QLineEdit(Tab3); GoalNameEdit->setValidator(Validator); gp3->addWidget(GoalNameEdit,1,1); connect(GoalNameEdit, SIGNAL(textChanged(const QString&)), SLOT(slotChangeGoalName(const QString&))); gp3->addWidget(new QLabel(tr("Value:"), Tab3), 2,0); GoalNumEdit = new QLineEdit(Tab3); GoalNumEdit->setValidator(numVal); gp3->addWidget(GoalNumEdit,2,1); connect(GoalNumEdit, SIGNAL(textChanged(const QString&)), SLOT(slotChangeGoalNum(const QString&))); GoalTypeCombo = new QComboBox(Tab3); GoalTypeCombo->insertItem(tr("minimize")); GoalTypeCombo->insertItem(tr("maximize")); GoalTypeCombo->insertItem(tr("less")); GoalTypeCombo->insertItem(tr("greater")); GoalTypeCombo->insertItem(tr("equal")); GoalTypeCombo->insertItem(tr("monitor")); gp3->addWidget(GoalTypeCombo,2,2); connect(GoalTypeCombo, SIGNAL(activated(const QString&)), SLOT(slotChangeGoalType(const QString&))); Q3HBox *GoalButtons = new Q3HBox(Tab3); GoalButtons->setSpacing(3); gp3->addMultiCellWidget(GoalButtons, 3,3,0,2); GoalButtons->setStretchFactor(new QWidget(GoalButtons),5); QPushButton *AddGoal_Butt = new QPushButton(tr("Add"), GoalButtons); connect(AddGoal_Butt, SIGNAL(clicked()), SLOT(slotAddGoal())); QPushButton *DelGoal_Butt = new QPushButton(tr("Delete"), GoalButtons); connect(DelGoal_Butt, SIGNAL(clicked()), SLOT(slotDeleteGoal())); t->addTab(Tab3, tr("Goals")); // ........................................................... // buttons on the bottom of the dialog (independent of the TabWidget) Q3HBox *Butts = new Q3HBox(this); Butts->setSpacing(3); Butts->setMargin(3); all->addWidget(Butts); QPushButton *OkButt = new QPushButton(tr("OK"), Butts); connect(OkButt, SIGNAL(clicked()), SLOT(slotOK())); QPushButton *ApplyButt = new QPushButton(tr("Apply"), Butts); connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply())); QPushButton *CancelButt = new QPushButton(tr("Cancel"), Butts); connect(CancelButt, SIGNAL(clicked()), SLOT(slotCancel())); OkButt->setFocus(); // ........................................................... Component *pc; for(pc=Doc->Components->first(); pc!=0; pc=Doc->Components->next()) if(pc != Comp) if(pc->Model[0] == '.' && pc->Model != ".Opt") SimEdit->insertItem(pc->Name); Property *pp; pp = Comp->Props.at(0); if(!pp->Value.isEmpty()) SimEdit->setCurrentText(pp->Value); pp = Comp->Props.at(1); if(!pp->Value.isEmpty()) { MethodCombo->setCurrentItem(pp->Value.section('|',0,0).toInt()-1); IterEdit->setText(pp->Value.section('|',1,1)); RefreshEdit->setText(pp->Value.section('|',2,2)); ParentsEdit->setText(pp->Value.section('|',3,3)); ConstEdit->setText(pp->Value.section('|',4,4)); CrossEdit->setText(pp->Value.section('|',5,5)); SeedEdit->setText(pp->Value.section('|',6,6)); CostVarEdit->setText(pp->Value.section('|',7,7)); CostObjEdit->setText(pp->Value.section('|',8,8)); CostConEdit->setText(pp->Value.section('|',9,9)); } NameEdit->setText(Comp->Name); for(pp = Comp->Props.at(2); pp != 0; pp = Comp->Props.next()) { if(pp->Name == "Var") { new Q3ListViewItem(VarList, pp->Value.section('|',0,0), pp->Value.section('|',1,1) == "yes" ? tr("yes") : tr("no"), pp->Value.section('|',2,2), pp->Value.section('|',3,3), pp->Value.section('|',4,4), ((pp->Value.section('|',5,5)=="LIN_DOUBLE")?tr("linear double") : ((pp->Value.section('|',5,5)=="LOG_DOUBLE")?tr("logarithmic double") : ((pp->Value.section('|',5,5)=="LIN_INT")?tr("linear integer") : tr("logarithmic integer"))))); } if(pp->Name == "Goal") { new Q3ListViewItem(GoalList, pp->Value.section('|',0,0), ((pp->Value.section('|',1,1) == "MIN") ? tr("minimize") : ((pp->Value.section('|',1,1) == "MAX") ? tr("maximize") : ((pp->Value.section('|',1,1) == "LE") ? tr("less") : ((pp->Value.section('|',1,1) == "GE") ? tr("greater") : ((pp->Value.section('|',1,1) == "EQ") ? tr("equal") : tr("monitor")))))), pp->Value.section('|',2,2)); } } resize(300, 250); }