GTUtilsOptionPanelMsa::ThresholdComparison GTUtilsOptionPanelMsa::getThresholdComparison(GUITestOpStatus &os) { openTab(os, Highlighting); QRadioButton *thresholdLessRb = GTWidget::findExactWidget<QRadioButton *>(os, "thresholdLessRb"); GT_CHECK_RESULT(NULL != thresholdLessRb, "thresholdLessRb is NULL", LessOrEqual); QRadioButton *thresholdMoreRb = GTWidget::findExactWidget<QRadioButton *>(os, "thresholdMoreRb"); GT_CHECK_RESULT(NULL != thresholdMoreRb, "thresholdMoreRb is NULL", LessOrEqual); const bool lessOrEqual = thresholdLessRb->isChecked(); const bool greaterOrEqual = thresholdMoreRb->isChecked(); GT_CHECK_RESULT(lessOrEqual ^ greaterOrEqual, "Incorrect state of threshold comparison radiobuttons", LessOrEqual); return lessOrEqual ? LessOrEqual : GreaterOrEqual; }
bool PEUtils::fillInMetadata(int senderIndex, QWidget * parent, ConnectorMetadata & cmd) { bool result = false; QList<QWidget *> widgets = parent->findChildren<QWidget *>(); foreach (QWidget * widget, widgets) { bool ok; int index = widget->property("index").toInt(&ok); if (!ok) continue; if (index != senderIndex) continue; QString type = widget->property("type").toString(); if (type == "name") { QLineEdit * lineEdit = qobject_cast<QLineEdit *>(widget); if (lineEdit == NULL) continue; cmd.connectorName = lineEdit->text(); cmd.connectorID = widget->property("id").toString(); result = true; } else if (type == "radio") { QRadioButton * radioButton = qobject_cast<QRadioButton *>(widget); if (radioButton == NULL) continue; if (!radioButton->isChecked()) continue; cmd.connectorType = (Connector::ConnectorType) radioButton->property("value").toInt(); } else if (type == "description") { QLineEdit * lineEdit = qobject_cast<QLineEdit *>(widget); if (lineEdit == NULL) continue; cmd.connectorDescription = lineEdit->text(); } }
void uitabdelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QVariant data; switch (typeeditor) { case TComboBox:{ QComboBox *cmbox = static_cast<QComboBox *> (editor); data = cmbox->currentText(); break;} case TRadioButton:{ QRadioButton *cradio = static_cast<QRadioButton *> (editor); data = cradio->isChecked(); break;} case TCheckBox:{ QCheckBox *checkb = static_cast<QCheckBox *> (editor); data = checkb->isChecked(); break;} case TButton:{ break;} default:{ QSpinBox *spinBox = static_cast<QSpinBox *> (editor); spinBox->interpretText(); data = spinBox->value();}} model->setData(index, data, Qt::EditRole);}
/** * Send the settings to the core. A connection to a core must be established. */ void SettingsWidget::saveCoreSettings() { if (!this->getAtLeastOneState) return; Protos::GUI::CoreSettings settings; Common::ProtoHelper::setStr(settings, &Protos::GUI::CoreSettings::set_nick, this->ui->txtNick->text()); settings.set_enable_integrity_check(this->ui->chkEnableIntegrityCheck->isChecked()); for (QListIterator<Common::SharedDir> i(this->sharedDirsModel.getDirs()); i.hasNext();) Common::ProtoHelper::addRepeatedStr(*settings.mutable_shared_directories(), &Protos::GUI::CoreSettings::SharedDirectories::add_dir, i.next().path); if (this->ui->radIPv6->isChecked()) settings.set_listen_any(Protos::Common::Interface::Address::IPv6); else if (this->ui->radIPv4->isChecked()) settings.set_listen_any(Protos::Common::Interface::Address::IPv4); else { for (QListIterator<QRadioButton*> i(this->ui->grpInterfaces->findChildren<QRadioButton*>()); i.hasNext();) { QRadioButton* button = i.next(); if (button->isChecked()) { Common::ProtoHelper::setStr(settings, &Protos::GUI::CoreSettings::set_listen_address, button->text()); break; } } } this->coreConnection->setCoreSettings(settings); }
// Figure out which port was selected and return it, or nothing if none are QString ChoosePortDialog::getSelectedPortName() { QListIterator<QRadioButton*> i(m_portButtonList); while(i.hasNext()) { QRadioButton *button = i.next(); if(button->isChecked()) return button->text(); } return QString(); }
void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout) { m_debugDetailsContainer = new Utils::DetailsWidget(this); QWidget *debugWidget = new QWidget; m_debugDetailsContainer->setWidget(debugWidget); mainLayout->addWidget(m_debugDetailsContainer); QFormLayout *debugLayout = new QFormLayout(debugWidget); QHBoxLayout *debugRadioButtonsLayout = new QHBoxLayout; debugLayout->addRow(debugRadioButtonsLayout); QRadioButton *gdbButton = new QRadioButton(tr("Use remote gdb")); QRadioButton *gdbServerButton = new QRadioButton(tr("Use remote gdbserver")); debugRadioButtonsLayout->addWidget(gdbButton); debugRadioButtonsLayout->addWidget(gdbServerButton); debugRadioButtonsLayout->addStretch(1); gdbButton->setChecked(m_runConfiguration->useRemoteGdb()); gdbServerButton->setChecked(!gdbButton->isChecked()); connect(gdbButton, SIGNAL(toggled(bool)), this, SLOT(handleDebuggingTypeChanged(bool))); handleDebuggingTypeChanged(gdbButton->isChecked()); }
void InstallDialog::SlotOkButtonClicked() { Action installAction("org.kde.kcontrol.kcmgrub2.install"); installAction.setHelperId("org.kde.kcontrol.kcmgrub2"); for (int i = 0; i < ui->treeWidget_recover->topLevelItemCount(); i++) { QRadioButton *radio = qobject_cast<QRadioButton *>(ui->treeWidget_recover->itemWidget(ui->treeWidget_recover->topLevelItem(i), 0)); if (radio && radio->isChecked()) { installAction.addArgument("partition", ui->treeWidget_recover->topLevelItem(i)->text(1)); installAction.addArgument("mountPoint", ui->treeWidget_recover->topLevelItem(i)->text(2)); installAction.addArgument("mbrInstall", !ui->checkBox_partition->isChecked()); break; } } if (installAction.arguments().value("partition").toString().isEmpty()) { KMessageBox::sorry(this, i18nc("@info", "Sorry, you have to select a partition with a proper name!")); return; } QProgressDialog progressDlg(this, Qt::Dialog); progressDlg.setWindowTitle(i18nc("@title:window", "Installing")); progressDlg.setLabelText(i18nc("@info:progress", "Installing GRUB...")); progressDlg.setCancelButton(0); progressDlg.setModal(true); progressDlg.setRange(0,0); progressDlg.show(); ExecuteJob* reply = installAction.execute(); reply->exec(); if (reply->action().status() != Action::AuthorizedStatus ) { progressDlg.hide(); return; } //connect(reply, SIGNAL(result()), &progressDlg, SLOT(hide())); progressDlg.hide(); if (reply->error()) { KMessageBox::detailedError(this, i18nc("@info", "Failed to install GRUB."), reply->data().value("errorDescription").toString()); this->reject(); } else { progressDlg.hide(); QDialog *dialog = new QDialog(this, Qt::Dialog); dialog->setWindowTitle(i18nc("@title:window", "Information")); dialog->setModal(true); QDialogButtonBox *btnbox = new QDialogButtonBox(QDialogButtonBox::Ok); KMessageBox::createKMessageBox(dialog, btnbox, QMessageBox::Information, i18nc("@info", "Successfully installed GRUB."), QStringList(), QString(), 0, KMessageBox::Notify, reply->data().value("output").toString()); // krazy:exclude=qclasses this->accept(); } //this->accept(); }
// new groups void KNGroupDialog::slotUser2() { QDate lastDate = a_ccount->lastNewFetch(); KDialog *dlg = new KDialog( this ); dlg->setCaption( i18n("New Groups") ); dlg->setButtons( Ok | Cancel ); QGroupBox *btnGrp = new QGroupBox( i18n("Check for New Groups"), dlg ); dlg->setMainWidget(btnGrp); QGridLayout *topL = new QGridLayout( btnGrp ); QRadioButton *takeLast = new QRadioButton( i18n("Created since last check:"), btnGrp ); topL->addWidget(takeLast, 0, 0, 1, 2 ); QLabel *l = new QLabel(KGlobal::locale()->formatDate(lastDate, KLocale::LongDate),btnGrp); topL->addWidget(l, 1, 1, Qt::AlignLeft); connect(takeLast, SIGNAL(toggled(bool)), l, SLOT(setEnabled(bool))); QRadioButton *takeCustom = new QRadioButton( i18n("Created since this date:"), btnGrp ); topL->addWidget(takeCustom, 2, 0, 1, 2 ); dateSel = new KDatePicker( lastDate, btnGrp ); dateSel->setMinimumSize(dateSel->sizeHint()); topL->addWidget(dateSel, 3, 1, Qt::AlignLeft); connect(takeCustom, SIGNAL(toggled(bool)), this, SLOT(slotDatePickerEnabled(bool))); takeLast->setChecked(true); dateSel->setEnabled(false); topL->addItem( new QSpacerItem(30, 0 ), 0, 0 ); if (dlg->exec()) { if (takeCustom->isChecked()) lastDate = dateSel->date(); a_ccount->setLastNewFetch(QDate::currentDate()); leftLabel->setText(i18n("Checking for new groups...")); enableButton(User1,false); enableButton(User2,false); filterEdit->clear(); subCB->setChecked(false); newCB->setChecked(true); emit(checkNew(a_ccount,lastDate)); incrementalFilter=false; slotRefilter(); } delete dlg; }
void MainWindow::ChangeLanguage() { std::clog<<"MainWindow::ChangeLanguage()"<<std::endl; QList<QRadioButton*> list = ui->groupBox->findChildren<QRadioButton*>(); for(int i=0;i<list.size();i++) { QRadioButton* rb = list.at(i); if(rb->isChecked()) { lang->ChangeLanguage(rb->property(("lang_file")).toString()); // lang_file is dynamic property break; } } ui->retranslateUi(this); }
int SongcastDLG::selectedSenderIdx() { int senderidx = -1; // Note: quite unbelievably, gridLayout::rowCount() is not the number // of actual rows, but the size of the internal allocation. So can't use it // after deleting rows... for (int i = 0; i < numSenderRows(); i++) { QRadioButton *btn = (QRadioButton*) sndGridLayout->itemAtPosition(i, 0)->widget(); if (btn->isChecked()) { senderidx = i; break; } } return senderidx; }
void CSysSettingDialog::Precision( int &nPrecision, bool bGet ) { QString strName = "rdxPrecision%1"; QRadioButton* pRB; if ( bGet ) { for ( int nIndex = 0; nIndex < 9; nIndex++ ) { pRB = ui->gbPrecision->findChild< QRadioButton* >( strName.arg( QString::number( nIndex ) ) ); if ( pRB->isChecked( ) ) { nPrecision = nIndex; break; } } } else { pRB = ui->gbPrecision->findChild< QRadioButton* >( strName.arg( QString::number( nPrecision ) ) ); pRB->setChecked( true ); } }
QString DataSerieDialog::radioSelection(QGroupBox *groupBox) { QString selection; QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(groupBox->layout()); Q_ASSERT(layout); for (int i(0); i < layout->count(); i++) { QLayoutItem *item = layout->itemAt(i); Q_ASSERT(item); QRadioButton *radio = qobject_cast<QRadioButton *>(item->widget()); Q_ASSERT(radio); if (radio->isChecked()) { selection = radio->text(); break; } } qDebug() << "radioSelection: " << selection; return selection; }
void Persistence::Store(QWidget* widget, QString storageName) { if (storageName.isEmpty()) storageName = widget->objectName(); if (qobject_cast<QLineEdit*>(widget)) { QLineEdit* lineEdit = qobject_cast<QLineEdit*>(widget); GetStore()[storageName] = QVariant(lineEdit->text()); } else if (qobject_cast<QCheckBox*>(widget)) { QCheckBox* cb = qobject_cast<QCheckBox*>(widget); GetStore()[storageName] = QVariant(cb->isChecked()); } else if (qobject_cast<QSpinBox*>(widget)) { QSpinBox* sb = qobject_cast<QSpinBox*>(widget); GetStore()[storageName] = QVariant(sb->value()); } else if (qobject_cast<QRadioButton*>(widget)) { QRadioButton* rb = qobject_cast<QRadioButton*>(widget); GetStore()[storageName] = QVariant(rb->isChecked()); } else if (qobject_cast<QComboBox*>(widget)) { QComboBox* cb = qobject_cast<QComboBox*>(widget); GetStore()[storageName] = QVariant(cb->currentText()); } else { WARNING("Unsupported widget: " + widget->objectName()); } }
void CSysSettingDialog::VideoMode( int &nMode, bool bGet ) { QString strName = "rdxVideoWay%1"; QRadioButton* pRB; if ( 2 > nMode ) { return; } if ( bGet ) { for ( int nIndex = 2; nIndex < 5; nIndex++ ) { pRB = ui->gbVideo->findChild< QRadioButton* >( strName.arg( QString::number( nIndex ) ) ); if ( pRB->isChecked( ) ) { nMode = nIndex; break; } } } else { pRB = ui->gbVideo->findChild< QRadioButton* >( strName.arg( QString::number( nMode ) ) ); pRB->setChecked( true ); } }
void RandomImgOp::operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>&) { QDialog* dialog = new QDialog(qApp->activeWindow()); dialog->setWindowTitle(qApp->translate("RandomImgOp", "Parameters")); dialog->setMinimumWidth(180); QFormLayout* layout = new QFormLayout(dialog); QGroupBox* radioGroup = new QGroupBox(qApp->translate("RandomImgOp", "Image type"), dialog); QRadioButton* intButton = new QRadioButton(qApp->translate("RandomImgOp", "8-bit integer")); QRadioButton* floatButton = new QRadioButton(qApp->translate("RandomImgOp", "Floating point")); QHBoxLayout* radioLayout = new QHBoxLayout(radioGroup); radioLayout->addWidget(intButton); radioLayout->addWidget(floatButton); intButton->setChecked(true); layout->insertRow(0, radioGroup); QSpinBox* widthBox = new QSpinBox(dialog); widthBox->setRange(0, 65536); widthBox->setValue(512); layout->insertRow(1, qApp->translate("RandomImgOp", "Width : "), widthBox); QSpinBox* heightBox = new QSpinBox(dialog); heightBox->setRange(0, 65536); heightBox->setValue(512); layout->insertRow(2, qApp->translate("RandomImgOp", "Height : "), heightBox); QSpinBox* channelBox = new QSpinBox(dialog); channelBox->setRange(1, 4); channelBox->setValue(3); layout->insertRow(3, qApp->translate("RandomImgOp", "Number of channels : "), channelBox); QWidget* intRangeWidget = new QWidget(dialog); QHBoxLayout* intRangeLayout = new QHBoxLayout(intRangeWidget); QSpinBox* intMinBox = new QSpinBox(dialog); QSpinBox* intMaxBox = new QSpinBox(dialog); intMinBox->setRange(0, 255); intMaxBox->setRange(0, 255); intMinBox->setValue(0); intMaxBox->setValue(255); intRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", "Range : "))); intRangeLayout->addWidget(intMinBox); intRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", " to "))); intRangeLayout->addWidget(intMaxBox); layout->insertRow(4, intRangeWidget); QWidget* floatRangeWidget = new QWidget(dialog); QHBoxLayout* floatRangeLayout = new QHBoxLayout(floatRangeWidget); QDoubleSpinBox* floatMinBox = new QDoubleSpinBox(dialog); QDoubleSpinBox* floatMaxBox = new QDoubleSpinBox(dialog); floatMinBox->setValue(0.0); floatMaxBox->setValue(1.0); floatMinBox->setRange(-65536, 65536); floatMaxBox->setRange(-65536, 65536); floatRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", "Range : "))); floatRangeLayout->addWidget(floatMinBox); floatRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", " to "))); floatRangeLayout->addWidget(floatMaxBox); layout->insertRow(5, floatRangeWidget); floatRangeWidget->hide(); layout->setSizeConstraint(QLayout::SetFixedSize); QObject::connect(intButton, SIGNAL(toggled(bool)), intRangeWidget, SLOT(setVisible(bool))); QObject::connect(floatButton, SIGNAL(toggled(bool)), floatRangeWidget, SLOT(setVisible(bool))); QPushButton *okButton = new QPushButton(qApp->translate("Operations", "Validate"), dialog); okButton->setDefault(true); layout->addWidget(okButton); QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept())); QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec()); if(code!=QDialog::Accepted) { return; } if(intButton->isChecked()) { Image* resImg = new Image(widthBox->value(), heightBox->value(), channelBox->value()); RandomLib::Random random; for(unsigned int c = 0; c < resImg->getNbChannels(); ++c) { for(unsigned int j = 0; j < resImg->getHeight(); ++j) { for(unsigned int i = 0; i < resImg->getWidth(); ++i) { Image::depth_t value = random.IntegerC<Image::depth_t>(intMinBox->value(), intMaxBox->value()); // Image::depth_t value = 256. * (rand() / (RAND_MAX + 1.));; resImg->setPixel(i, j, c, value); } } } this->outImage(resImg, qApp->translate("Operations", "Random image").toStdString()); } else if(floatButton->isChecked()) { Image_t<double>* resImg = new Image_t<double>(widthBox->value(), heightBox->value(), channelBox->value()); RandomLib::Random random; for(unsigned int c = 0; c < resImg->getNbChannels(); ++c) { for(unsigned int j = 0; j < resImg->getHeight(); ++j) { for(unsigned int i = 0; i < resImg->getWidth(); ++i) { double min = floatMinBox->value(); double max = floatMaxBox->value(); // double width = max - min; // double value = min + (double)rand() * width / RAND_MAX; double value = random.FixedN<double>(); value = value*(max-min) + min; resImg->setPixel(i, j, c, value); } } } this->outDoubleImage(resImg, qApp->translate("Operations", "Random image").toStdString(), true); } }
// Update associated CLI widget based on QWidget / QObject data void QtWidgetObject::updateCLI() { // Check treeGuiWidget_ pointer first if (treeGuiWidget_ == NULL) { printf("Internal Error: treeGuiWidget_ pointer is NULL in updateCLI().\n"); return; } // Now, check widget type to see what we do if (treeGuiWidget_->type() == TreeGuiWidget::RadioGroupWidget) { QButtonGroup *butgroup = static_cast<QButtonGroup*>(qObject_); if (!butgroup) printf("Critical Error: Couldn't cast stored qObject_ pointer into QButtonGroup.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, butgroup->checkedId()); } else if (treeGuiWidget_->type() == TreeGuiWidget::CheckWidget) { QCheckBox *check = static_cast<QCheckBox*>(qWidget_); if (!check) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QCheckBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, check->isChecked()); } else if (treeGuiWidget_->type() == TreeGuiWidget::ComboWidget) { QComboBox* combo = static_cast<QComboBox*>(qWidget_); if (!combo) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QComboBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, combo->currentIndex()+1); } else if (treeGuiWidget_->type() == TreeGuiWidget::DoubleSpinWidget) { QDoubleSpinBox* spin = static_cast<QDoubleSpinBox*>(qWidget_); if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QDoubleSpinBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value()); } else if (treeGuiWidget_->type() == TreeGuiWidget::EditWidget) { QLineEdit *edit = static_cast<QLineEdit*>(qWidget_); if (!edit) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTextEdit.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, qPrintable(edit->text())); } else if (treeGuiWidget_->type() == TreeGuiWidget::IntegerSpinWidget) { QSpinBox *spin = static_cast<QSpinBox*>(qWidget_); if (!spin) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QSpinBox.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, spin->value()); } else if (treeGuiWidget_->type() == TreeGuiWidget::LabelWidget) { QLabel *label = static_cast<QLabel*>(qWidget_); if (!label) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QLabel.\n"); } else if (treeGuiWidget_->type() == TreeGuiWidget::RadioButtonWidget) { QRadioButton *button = static_cast<QRadioButton*>(qWidget_); if (!button) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QRadioButton.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, button->isChecked()); } else if (treeGuiWidget_->type() == TreeGuiWidget::TabWidget) { QTabWidget *tabs = static_cast<QTabWidget*>(qWidget_); if (!tabs) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QTabWidget.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, tabs->currentIndex()+1); } else if (treeGuiWidget_->type() == TreeGuiWidget::StackWidget) { QStackedWidget *stack = static_cast<QStackedWidget*>(qWidget_); if (!stack) printf("Critical Error: Couldn't cast stored qWidget_ pointer into QStackedWidget.\n"); else treeGuiWidget_->setProperty(TreeGuiWidgetEvent::ValueProperty, stack->currentIndex()+1); } else printf("Internal Error: No handler written to update CLI controls of this type (%s).\n", TreeGuiWidget::widgetType(treeGuiWidget_->type())); }
QVariant UIPropertyGetters::DefaultGetter(QWidget* editor, SettingsPropertyMapper::WidgetType editorType, SettingsPropertyMapper::PropertyType) { switch (editorType) { case SettingsPropertyMapper::CHECKBOX: { QCheckBox* pCheckBox = qobject_cast<QCheckBox*>(editor); if (pCheckBox == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pCheckBox->isChecked()); } case SettingsPropertyMapper::RADIOBUTTON: { QRadioButton* pRadioButton = qobject_cast<QRadioButton*>(editor); if (pRadioButton == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pRadioButton->isChecked()); } case SettingsPropertyMapper::CHECKABLE_GROUPBOX: { QGroupBox* pGroupBox = qobject_cast<QGroupBox*>(editor); if (pGroupBox == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } if (!pGroupBox->isCheckable()) { qCritical() << "Given QGroupBox is not checkable"; } return QVariant::fromValue(pGroupBox->isChecked()); } case SettingsPropertyMapper::LINE_EDIT: { QLineEdit* pLineEdit = qobject_cast<QLineEdit*>(editor); if (pLineEdit == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pLineEdit->text()); } case SettingsPropertyMapper::TEXT_EDIT: { QTextEdit* pTextEdit = qobject_cast<QTextEdit*>(editor); if (pTextEdit == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pTextEdit->toPlainText()); } case SettingsPropertyMapper::COMBOBOX: { QComboBox* pComboBox = qobject_cast<QComboBox*>(editor); if (pComboBox == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pComboBox->currentIndex()); } case SettingsPropertyMapper::SPINBOX: { QSpinBox* pSpinBox = qobject_cast<QSpinBox*>(editor); if (pSpinBox == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pSpinBox->value()); } case SettingsPropertyMapper::DOUBLE_SPINBOX: { QDoubleSpinBox* pDoubleSpinBox = qobject_cast<QDoubleSpinBox*>(editor); if (pDoubleSpinBox == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pDoubleSpinBox->value()); } case SettingsPropertyMapper::TIME_EDIT: { QTimeEdit* pTimeEdit = qobject_cast<QTimeEdit*>(editor); if (pTimeEdit == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pTimeEdit->time()); } case SettingsPropertyMapper::DATETIME_EDIT: { QDateTimeEdit* pDateTimeEdit = qobject_cast<QDateTimeEdit*>(editor); if (pDateTimeEdit == NULL) { qCritical() << "Invalid editor given"; return QVariant(); } return QVariant::fromValue(pDateTimeEdit->dateTime()); } default: { return QVariant(); } } }
void MesytecMadc32UI::uiInput(QString _name) { if(applyingSettings == true) return; QGroupBox* gb = findChild<QGroupBox*>(_name); if(gb != 0) { if(_name.startsWith("enable_channel")) { QRegExp reg("[0-9]{1,2}"); reg.indexIn(_name); int ch = reg.cap().toInt(); if(gb->isChecked()) module->conf_.enable_channel[ch] = true; else module->conf_.enable_channel[ch] = false; printf("Changed enable_channel %d\n",ch); fflush(stdout); } } QCheckBox* cb = findChild<QCheckBox*>(_name); if(cb != 0) { if(_name == "enable_multi_event_send_different_eob_marker") { module->conf_.enable_multi_event_send_different_eob_marker = cb->isChecked(); } if(_name == "enable_multi_event_compare_with_max_transfer_data") { module->conf_.enable_multi_event_compare_with_max_transfer_data = cb->isChecked(); } if(_name == "enable_adc_override") { module->conf_.enable_adc_override = cb->isChecked(); } if(_name == "enable_switch_off_sliding_scale") { module->conf_.enable_switch_off_sliding_scale = cb->isChecked(); } if(_name == "enable_skip_out_of_range") { module->conf_.enable_skip_out_of_range = cb->isChecked(); } if(_name == "enable_ignore_thresholds") { module->conf_.enable_ignore_thresholds = cb->isChecked(); } if(_name == "enable_termination_input_gate0") { module->conf_.enable_termination_input_gate0 = cb->isChecked(); } if(_name == "enable_termination_input_fast_clear") { module->conf_.enable_termination_input_fast_clear = cb->isChecked(); } if(_name == "enable_external_time_stamp_reset") { module->conf_.enable_external_time_stamp_reset = cb->isChecked(); } //QMessageBox::information(this,"uiInput","You changed the checkbox "+_name); } QComboBox* cbb = findChild<QComboBox*>(_name); if(cbb != 0) { if(_name == "addr_source") { module->conf_.addr_source = static_cast<MesytecMadc32ModuleConfig::AddressSource>(cbb->currentIndex()); } if(_name == "multi_event_mode") { module->conf_.multi_event_mode = static_cast<MesytecMadc32ModuleConfig::MultiEventMode>(cbb->currentIndex()); } if(_name == "data_length_format") { module->conf_.data_length_format = static_cast<MesytecMadc32ModuleConfig::DataLengthFormat>(cbb->currentIndex()); } if(_name == "vme_mode") { module->conf_.vme_mode = static_cast<MesytecMadc32ModuleConfig::VmeMode>(cbb->currentIndex()); std::cout << "Changed vme_mode to" << module->conf_.vme_mode << std::endl; } if(_name == "time_stamp_source") { module->conf_.time_stamp_source = static_cast<MesytecMadc32ModuleConfig::TimeStampSource>(cbb->currentIndex()); } if(_name == "adc_resolution") { module->conf_.adc_resolution = static_cast<MesytecMadc32ModuleConfig::AdcResolution>(cbb->currentIndex()); } if(_name == "output_format") { module->conf_.output_format = static_cast<MesytecMadc32ModuleConfig::OutputFormat>(cbb->currentIndex()); } if(_name == "gate_generator_mode") { module->conf_.gate_generator_mode = static_cast<MesytecMadc32ModuleConfig::GateGeneratorMode>(cbb->currentIndex()); } if(_name == "ecl_gate1_mode") { module->conf_.ecl_gate1_mode = static_cast<MesytecMadc32ModuleConfig::EclGate1Mode>(cbb->currentIndex()); } if(_name == "ecl_fclear_mode") { module->conf_.ecl_fclear_mode = static_cast<MesytecMadc32ModuleConfig::EclFClearMode>(cbb->currentIndex()); } if(_name == "ecl_busy_mode") { module->conf_.ecl_busy_mode = static_cast<MesytecMadc32ModuleConfig::EclBusyMode>(cbb->currentIndex()); } if(_name == "nim_gate1_mode") { module->conf_.nim_gate1_mode = static_cast<MesytecMadc32ModuleConfig::NimGate1Mode>(cbb->currentIndex()); } if(_name == "nim_fclear_mode") { module->conf_.nim_fclear_mode = static_cast<MesytecMadc32ModuleConfig::NimFClearMode>(cbb->currentIndex()); } if(_name == "nim_busy_mode") { module->conf_.nim_busy_mode = static_cast<MesytecMadc32ModuleConfig::NimBusyMode>(cbb->currentIndex()); if(module->conf_.nim_busy_mode == MesytecMadc32ModuleConfig::nbRes5) module->conf_.nim_busy_mode = MesytecMadc32ModuleConfig::nbBufOverThr; } if(_name == "input_range") { switch(cbb->currentIndex()) { case 0: module->conf_.input_range = MesytecMadc32ModuleConfig::ir4V; break; case 1: module->conf_.input_range = MesytecMadc32ModuleConfig::ir8V; break; case 2: default: module->conf_.input_range = MesytecMadc32ModuleConfig::ir10V; break; } } if(_name == "marking_type") { switch(cbb->currentIndex()) { case 0: module->conf_.marking_type = MesytecMadc32ModuleConfig::mtEventCounter; break; case 1: module->conf_.marking_type = MesytecMadc32ModuleConfig::mtTimestamp; break; case 2: module->conf_.marking_type = MesytecMadc32ModuleConfig::mtExtendedTs; break; default: module->conf_.marking_type = MesytecMadc32ModuleConfig::mtEventCounter; break; } } if(_name == "bank_operation") { switch(cbb->currentIndex()) { case 0: module->conf_.bank_operation = MesytecMadc32ModuleConfig::boConnected; break; case 1: module->conf_.bank_operation = MesytecMadc32ModuleConfig::boIndependent; break; case 2: module->conf_.bank_operation = MesytecMadc32ModuleConfig::boToggle; break; default: module->conf_.bank_operation = MesytecMadc32ModuleConfig::boConnected; break; } } if(_name == "test_pulser_mode") { switch(cbb->currentIndex()) { case 0: module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpOff; break; case 1: module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpAmp0; break; case 2: module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpAmpLow; break; case 3: module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpAmpHigh; break; case 4: module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpToggle; break; default: module->conf_.test_pulser_mode = MesytecMadc32ModuleConfig::tpOff; break; } } //QMessageBox::information(this,"uiInput","You changed the combobox "+_name); } QSpinBox* sb = findChild<QSpinBox*>(_name); if(sb != 0) { if(_name == "irq_level") module->conf_.irq_level = sb->value(); if(_name == "irq_vector"){ module->conf_.irq_vector = sb->value(); } if(_name == "irq_threshold"){ module->conf_.irq_threshold = sb->value(); } if(_name == "base_addr_register"){ module->conf_.base_addr_register = sb->value(); } if(_name == "time_stamp_divisor"){ module->conf_.time_stamp_divisor = sb->value(); } if(_name == "max_transfer_data"){ module->conf_.max_transfer_data= sb->value(); } if(_name == "rc_module_id_read"){ module->conf_.rc_module_id_read = sb->value(); } if(_name == "rc_module_id_write"){ module->conf_.rc_module_id_write = sb->value(); } if(_name.startsWith("hold_delay_")) { int ch = _name.right(1).toInt(); module->conf_.hold_delay[ch] = sb->value(); } if(_name.startsWith("hold_width_")) { int ch = _name.right(1).toInt(); module->conf_.hold_width[ch] = sb->value(); } if(_name.startsWith("thresholds")) { QRegExp reg("[0-9]{1,2}"); reg.indexIn(_name); int ch = reg.cap().toInt(); module->conf_.thresholds[ch] = sb->value(); } } QRadioButton* rb = findChild<QRadioButton*>(_name); if(rb != 0) { if(_name == "mcst_cblt_none" && rb->isChecked()) { module->conf_.cblt_mcst_ctrl = 0; module->conf_.mcst_cblt_none = true; } if(_name == "enable_cblt_mode" && rb->isChecked()) { module->conf_.cblt_mcst_ctrl |= (1 << MADC32V2_OFF_CBLT_MCST_CTRL_ENABLE_CBLT); module->conf_.enable_cblt_mode = true; } if(_name == "enable_mcst_mode" && rb->isChecked()) { module->conf_.cblt_mcst_ctrl |= (1 << MADC32V2_OFF_CBLT_MCST_CTRL_ENABLE_MCST); module->conf_.enable_mcst_mode = true; } if(_name == "enable_cblt_first" && rb->isChecked()) { module->conf_.cblt_mcst_ctrl |= (1 << MADC32V2_OFF_CBLT_MCST_CTRL_ENABLE_FIRST_MODULE); module->conf_.enable_cblt_first = true; } if(_name == "enable_cblt_last" && rb->isChecked()) { module->conf_.cblt_mcst_ctrl |= (1 << MADC32V2_OFF_CBLT_MCST_CTRL_ENABLE_LAST_MODULE); module->conf_.enable_cblt_last = true; } if(_name == "enable_cblt_middle" && rb->isChecked()) { module->conf_.cblt_mcst_ctrl &= ~((1 << MADC32V2_OFF_CBLT_MCST_CTRL_ENABLE_FIRST_MODULE) |(1 << MADC32V2_OFF_CBLT_MCST_CTRL_ENABLE_LAST_MODULE)); module->conf_.enable_cblt_middle = true; } } QPushButton* pb = findChild<QPushButton*>(_name); if(pb != 0) { if(_name == "trigger_button") clicked_start_button(); if(_name == "stop_button") clicked_start_button(); if(_name == "stop_button") clicked_stop_button(); if(_name == "reset_button") clicked_reset_button(); if(_name == "fifo_reset_button") clicked_fifo_reset_button(); if(_name == "readout_reset_button") clicked_readout_reset_button(); if(_name == "configure_button") clicked_configure_button(); if(_name == "counter_update_button") clicked_counter_update_button(); if(_name == "singleshot_button") clicked_singleshot_button(); if(_name == "update_firmware_button") clicked_update_firmware_button(); } }
void MemoryEditor::search() { QDialog dlg(this); dlg.setWindowTitle("Search Memory"); QVBoxLayout *vbox = new QVBoxLayout; dlg.setLayout(vbox); vbox->addWidget(new QLabel("Enter a hex string, or \"ASCII text\" (in quotes)")); QLineEdit *edit = new QLineEdit; edit->setFont(QFont(Style::Monospace)); // TODO: put existing search string in box vbox->addWidget(edit); QGridLayout *grid = new QGridLayout; vbox->addLayout(grid); grid->addWidget(new QLabel("Search:"), 0, 0); grid->addWidget(new QLabel("Start from:"), 1, 0); QButtonGroup bgrpSearch, bgrpStart; QRadioButton *searchDown = new QRadioButton("Down"); bgrpSearch.addButton(searchDown); grid->addWidget(searchDown, 0, 1); searchDown->setChecked(true); QRadioButton *searchUp = new QRadioButton("Up"); bgrpSearch.addButton(searchUp); grid->addWidget(searchUp, 0, 2); QRadioButton *searchFromEnd = new QRadioButton("From start/end"); bgrpStart.addButton(searchFromEnd); grid->addWidget(searchFromEnd, 1, 1); searchFromEnd->setChecked(true); QRadioButton *searchFromCur = new QRadioButton("From cursor"); bgrpStart.addButton(searchFromCur); grid->addWidget(searchFromCur, 1, 2); QDialogButtonBox *bbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(bbox, SIGNAL(accepted()), &dlg, SLOT(accept())); connect(bbox, SIGNAL(rejected()), &dlg, SLOT(reject())); grid->addWidget(bbox); if (dlg.exec()) { QString searchText = edit->text().trimmed(); // try quoted text if (searchText.startsWith("\"") && searchText.endsWith("\"")) { searchStr = searchText.mid(1, searchText.size() - 2).toUtf8(); } else { searchStr = QByteArray::fromHex(edit->text().toUtf8()); } int offset = (int)editor->cursorPosition() / 2; if (searchDown->isChecked()) { searchPos = searchFromEnd->isChecked() ? -1 : offset; searchNext(); } else { searchPos = searchFromEnd->isChecked() ? editor->editorSize() : offset; searchPrev(); } } }
QByteArray TableItem::GenHTMLForm() { QString ret; QString objTypeName = obj->metaObject()->className(); if(objTypeName == "QPlainTextEdit") { QPlainTextEdit *item = (QPlainTextEdit *) obj; #if 0 ret = QString("<form method=\"post\">" " <input type=\"hidden\" name=\"action\" value=\"%2\">" "<div class=\"form_info\">%1</div>" "<div class=\"form_editor\"><textarea name=\"%2\" cols=\"20\" rows=\"4\">%3</textarea></div>" "<div class=\"form_submitter\"><input type=\"submit\" value=\">>\"></div>" "<div class=\"form_tooltip\">%4</div>" "</form>") .arg(desc).arg(short_d).arg(item->toPlainText()).arg(item->toolTip()); #endif ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p><textarea name=\"%2\" cols=\"16\" rows=\"3\">%3</textarea></p></div>" "<div class=\"submit\"><p> %4</p></div>" "<div class=\"tooltip\"><p> %5</p></div>" "</div></form>\n") .arg(desc) .arg(short_d) .arg(item->toPlainText()) .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip()); } else if(objTypeName == "QLineEdit") { QLineEdit *item = (QLineEdit *) obj; ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p><input type=\"text\" name=\"%2\" value=\"%3\" /></p></div>" "<div class=\"submit\"><p> %4</p></div>" "<div class=\"tooltip\"><p> %5</p></div>" "</div></form>\n") .arg(desc) .arg(short_d) .arg(item->text()) .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip()); } else if(objTypeName == "QCheckBox") { QCheckBox *item = (QCheckBox *) obj; ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p><input type=\"checkbox\" name=\"%2\" value=\"true\" %3/></p></div>" "<div class=\"submit\"><p> %4</p></div>" "<div class=\"tooltip\"><p> %5</p></div>" "</div></form>\n") .arg(desc) .arg(short_d) .arg(item->isChecked() ? "checked" : "") .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip()); } else if(objTypeName == "QSpinBox") { QSpinBox *item = (QSpinBox *) obj; ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>" "<div class=\"submit\"><p> %7</p></div>" "<div class=\"tooltip\"><p> %8</p></div>" "</div></form>\n") .arg(desc) .arg(short_d) .arg(item->value()) .arg(item->minimum()) .arg(item->maximum()) .arg(item->singleStep()) .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip()); } else if(objTypeName == "QDoubleSpinBox") { QDoubleSpinBox *item = (QDoubleSpinBox *) obj; ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p><input type=\"number\" name=\"%2\" value=\"%3\" min=\"%4\" max=\"%5\" step=\"%6\" /></p></div>" "<div class=\"submit\"><p> %7</p></div>" "<div class=\"tooltip\"><p> %8</p></div>" "</div></form>\n") .arg(desc) .arg(short_d) .arg(item->value()) .arg(item->minimum()) .arg(item->maximum()) .arg(item->singleStep()) .arg((!item->isEnabled() || item->isReadOnly()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip()); } else if(objTypeName == "QComboBox") { QComboBox *item = (QComboBox *) obj; ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p>\n<select name=\"%2\" style=\"max-width:170px;\">\n").arg(desc).arg(short_d); int current = item->currentIndex(); for (int i = 0; i < item->count(); i++) { ret.append(QString("<option value=\"%1\" %2>%3</option>\n").arg(i).arg(i==current ? "selected" : "").arg(item->itemText(i))); } ret.append(QString("</select>\n</p></div>" "<div class=\"submit\"><p> %1</p></div>" "<div class=\"tooltip\"><p> %2</p></div>" "</div></form>\n") .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip())); } else if(objTypeName == "QRadioButton") { QRadioButton *item = (QRadioButton *) obj; QString rb_vals; if(item->objectName() == "radioButton_rds_music") { rb_vals = QString("<input type=\"radio\" name=\"%1\" value=\"true\" %2/> Music <input type=\"radio\" name=\"%1\" value=\"false\" %3/> Speech") .arg(short_d).arg(item->isChecked() ? "checked" : "").arg(item->isChecked() ? "" : "checked"); } ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p>%3</p></div>" "<div class=\"submit\"><p> %4</p></div>" "<div class=\"tooltip\"><p> %5</p></div>" "</div></form>\n") .arg(desc) .arg(short_d) .arg(rb_vals) .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip()); } else if(objTypeName == "QPushButton") { QPushButton *item = (QPushButton *) obj; ret = QString("<form method=\"post\"><input type=\"hidden\" name=\"action\" value=\"%2\" />" "<div class=\"row\">" "<div class=\"prop\"><p>%1:</p></div>" "<div class=\"val\"><p>%3</p></div>" "<div class=\"submit\"><p> %4</p></div>" "<div class=\"tooltip\"><p> %5</p></div>" "</div></form>\n") .arg(desc) .arg(short_d) .arg("action") .arg((!item->isEnabled()) ? "" : "<input type=\"submit\" value=\">>\" />") .arg(item->toolTip()); } else { qDebug() << "unimplemented obj_type: " << objTypeName; } return ret.toUtf8(); };
void MTPageNym_AltLocation::PrepareOutputData() { // Step 1: wipe the old data. // MTWizardAddNym * pWizardAdd = dynamic_cast<MTWizardAddNym *>(wizard()); WizardEditProfile * pWizardEdit = dynamic_cast<WizardEditProfile *>(wizard()); if (nullptr != pWizardAdd) pWizardAdd ->listContactDataTuples_.clear(); else if (nullptr != pWizardEdit) pWizardEdit->listContactDataTuples_.clear(); // Step 2: reconstruct it from the widgets. QMap<uint32_t, QList<GroupBoxContactItems *> * >::iterator it_mapGroupBoxLists; for (it_mapGroupBoxLists = mapGroupBoxLists_.begin(); it_mapGroupBoxLists != mapGroupBoxLists_.end(); it_mapGroupBoxLists++) { const uint32_t indexSection = it_mapGroupBoxLists.key(); QList<GroupBoxContactItems *> * pList = it_mapGroupBoxLists.value(); if (nullptr != pList) { QList<GroupBoxContactItems *>::iterator it_list; for (it_list = pList->begin(); it_list != pList->end(); it_list++) { GroupBoxContactItems * pGroupBox = *it_list; if (nullptr != pGroupBox) { uint32_t indexSectionType = pGroupBox->indexSectionType_; for (int nItemIndex = 0; nItemIndex < pGroupBox->layout()->count(); ++nItemIndex) { QWidget * pItemWidget = pGroupBox->layout()->itemAt(nItemIndex)->widget(); QLineEdit * pLineEdit = VPtr<QLineEdit>::asPtr(pItemWidget->property("lineedit")); QRadioButton * pBtnRadio = VPtr<QRadioButton>::asPtr(pItemWidget->property("radiobtn")); const QString & qstrText = pLineEdit->text(); if (!qstrText.isEmpty()) { std::string str_text(qstrText.toStdString()); if (nullptr != pWizardAdd) pWizardAdd->listContactDataTuples_.push_back( tupleContactDataItem{indexSection, indexSectionType, str_text, pBtnRadio->isChecked()} ); else if (nullptr != pWizardEdit) pWizardEdit->listContactDataTuples_.push_back( tupleContactDataItem{indexSection, indexSectionType, str_text, pBtnRadio->isChecked()} ); } } } } } } }