void CustomMakeConfigWidget::envAdded() { QString env = envs_combo->currentText(); m_allEnvironments.append(env); envs_combo->clear(); envs_combo->insertStringList(m_allEnvironments); envChanged(env); }
void CustomMakeConfigWidget::envRemoved() { QString env = envs_combo->currentText(); QDomNode node = DomUtil::elementByPath(m_dom, m_configGroup + "/make/environments"); node.removeChild(node.namedItem(env)); m_allEnvironments.remove(env); envs_combo->clear(); envs_combo->insertStringList(m_allEnvironments); m_currentEnvironment = QString::null; envChanged( m_allEnvironments[0] ); }
CRunGui::CRunGui():Env() { //Env=new CEnvironment(); //setting of central widget of the window QWidget *mainWidget = new QWidget; setCentralWidget(mainWidget); newEnvDialog = new NewEnvDialog (this); //non-gui attributes: // Env=NULL;Env is now non dynamic attribute. // emit envIsEmpty(true); No need NumSteps=-1; Timer = new QTimer(this); connect(Timer,SIGNAL(timeout()),this,SLOT(make1Step())); //ComboBox - Type of view QLabel *typeViewLabel = new QLabel(tr("Type of view: ")); typeViewLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); TypeViewCombo = new QComboBox; TypeViewCombo->addItem(TYPE_VIEW_1); TypeViewCombo->addItem(TYPE_VIEW_2); TypeViewCombo->addItem(TYPE_VIEW_3); TypeViewCombo->addItem(TYPE_VIEW_4); TypeViewCombo->addItem(TYPE_VIEW_5); TypeViewCombo->addItem(TYPE_VIEW_6); TypeViewCombo->addItem(TYPE_VIEW_7); TypeViewCombo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); QVBoxLayout * typeViewLayout= new QVBoxLayout(); typeViewLayout->addWidget(typeViewLabel); typeViewLayout->addWidget(TypeViewCombo); //typeViewLayout->addStretch(1); //Field Field= new CField(&Env); connect(TypeViewCombo, SIGNAL(currentIndexChanged(const QString &)),Field, SLOT(setTypeView(const QString &))); connect(this,SIGNAL(envChanged()),Field,SLOT(renewField())); connect (Field,SIGNAL(cellDetails(int,int)),this,SLOT(showCellDetails(int,int))); //Legend CLegend * legend = new CLegend(); connect(TypeViewCombo, SIGNAL(activated(const QString &)),legend, SLOT(setTypeView(const QString &))); //ScrollArea QScrollArea * scrollArea = new QScrollArea (); scrollArea->setBackgroundRole(QPalette::Dark); scrollArea->setWidget(Field); //Zoom ZoomSlid = new ZoomSlider(tr("Zoom: ")); ZoomSlid->setDisabled(true); connect(ZoomSlid,SIGNAL(valueChanged(int)),Field,SLOT(setZoom(int))); //Growing Flowers Ratio Slider GFSlider = new QSlider(Qt::Horizontal); GFSlider->setRange(0, FLOWERGROWINGRATIO_NUM-1); GFSlider->setValue(FLOWERGROWINGRATIO_INIT); GFSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); connect(GFSlider,SIGNAL(valueChanged(int)),this,SLOT(FlowerGrowingRatioInEnvChanged(int))); QLabel * GFLabel=new QLabel("Ratio of growth of flowers: "); GFLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QVBoxLayout * GFLayout= new QVBoxLayout(); GFLayout->addWidget(GFLabel); GFLayout->addWidget(GFSlider); //connect(this,SIGNAL(envIsEmpty(bool)),ZoomSlid,SLOT(setDisabled(bool))); //CheckBox for display DisplayCheck = new QCheckBox(tr("&Display On")); //DisplayCheck->resize(100,30); //DisplayCheck->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); connect(DisplayCheck, SIGNAL(stateChanged(int)),this,SLOT(DisplayChanged(int))); DisplayCheck->setCheckState(Qt::Checked); //CheckBox for LearningOn LearningCheck = new QCheckBox(tr("&Learning On")); connect(LearningCheck, SIGNAL(stateChanged(int)),this,SLOT(LearningChanged(int))); if (Env.LearningOn) LearningCheck->setCheckState(Qt::Checked); else LearningCheck->setCheckState(Qt::Unchecked); QVBoxLayout * checksLayout= new QVBoxLayout(); checksLayout->addWidget(DisplayCheck); checksLayout->addWidget(LearningCheck); //Time LCD TimeLCD = new LabeledLCD(tr("Time")); //Start, Stop, Make n steps buttons RunBut = new QPushButton(tr("&Run")); RunBut-> setCheckable(true); NumStepsSpin = new QSpinBox(); NumStepsSpin ->setMaximum(MAXTIME); NumStepsSpin->setMinimum(1); NumStepsSpin->setValue(100); MakeNStepsBut = new QPushButton(tr("&Make steps")); MakeNStepsBut-> setCheckable(true); RunBut->setDisabled(true);MakeNStepsBut->setDisabled(true);NumStepsSpin->setDisabled(true); connect(RunBut,SIGNAL(toggled(bool)),MakeNStepsBut,SLOT(setDisabled(bool))); connect(MakeNStepsBut,SIGNAL(toggled(bool)),RunBut,SLOT(setDisabled(bool))); connect(RunBut,SIGNAL(toggled(bool)),NumStepsSpin,SLOT(setDisabled(bool))); connect(MakeNStepsBut,SIGNAL(toggled(bool)),this,SLOT(runNSteps(bool))); connect(RunBut,SIGNAL(toggled(bool)),this,SLOT(run(bool))); //If there is no environment opened, all buttons are disabled connect(this, SIGNAL(envIsEmpty(bool)),RunBut,SLOT(setDisabled(bool))); connect(this, SIGNAL(envIsEmpty(bool)),NumStepsSpin,SLOT(setDisabled(bool))); connect(this, SIGNAL(envIsEmpty(bool)),MakeNStepsBut,SLOT(setDisabled(bool))); //Legend Field: QVBoxLayout * rightLayout= new QVBoxLayout(); rightLayout->addWidget(TimeLCD); //rightLayout->addStretch(1); rightLayout->addWidget(RunBut); rightLayout->addWidget(NumStepsSpin); rightLayout->addWidget(MakeNStepsBut); rightLayout->addStretch(1); rightLayout->addLayout(checksLayout,Qt::AlignHCenter); rightLayout->addWidget(legend); //numBeetles LCD NumBeetlesLCD = new LabeledLCD(tr("Beetles")); //numFlowers LCD NumFlowersLCD = new LabeledLCD(tr("Flowers")); //numBirths LCD NumBirthsLCD= new LabeledLCD(tr("Births")); //Bottom layout strip QHBoxLayout * bottomLayout= new QHBoxLayout(); bottomLayout->addWidget(NumBeetlesLCD); bottomLayout->addWidget(NumFlowersLCD); bottomLayout->addWidget(NumBirthsLCD); // QMessageBox::information(this,"MyApp","7"); QGridLayout * gridLayout = new QGridLayout; //gridLayout->setMargin(5); gridLayout->addWidget(scrollArea,0,0,1,2); gridLayout->addLayout(typeViewLayout,1,2); gridLayout->addWidget(ZoomSlid,1,0); gridLayout->addLayout(GFLayout,1,1);//DisplayCheck,1,1,Qt::AlignHCenter); gridLayout->addLayout(rightLayout,0,2); gridLayout->addLayout(bottomLayout,2,0,1,3); //gridLayout->addLayout( gridLayout->setRowStretch(0, 1); mainWidget->setLayout(gridLayout); // QMessageBox::information(this,"MyApp","8"); //creation of menu and its actions createActions(); createMenus(); QString message = tr("Environment can be opened or created in the menu in \"File\" section."); statusBar()->showMessage(message); // QMessageBox::information(this,"MyApp","9"); setWindowTitle(tr("Abeetles")); setMinimumSize(400, 520); resize(480, 530); renewAllChildren(); // QMessageBox::information(this,"MyApp","10"); }