void MocapPlugin::updateId(const std_msgs::Int32::ConstPtr &msg) { QComboBox *cameraIDs = this->findChild<QComboBox *>("cameraIDs"); int index = cameraIDs->findText(QString::number(msg->data)); if (index == -1) { cameraIDs->addItem(QString::number(msg->data)); cameraIDs->repaint(); } }
void DesktopThemeDetails::replacementItemChanged() { //Check items to see if theme has been customized m_themeCustomized = true; QHashIterator<QString, int> i(m_items); while (i.hasNext()) { i.next(); QComboBox *itemComboBox = static_cast<QComboBox*>(m_themeItemList->cellWidget(i.value(), 1)); int replacement = itemComboBox->currentIndex(); if (replacement <= (m_themes.size() - 1)) { // Item replacement source is a theme m_itemThemeReplacements[i.value()] = itemComboBox->currentIndex(); } else if (replacement > (m_themes.size() - 1)) { // Item replacement source is a file if (itemComboBox->currentText() == i18n("File...")) { //Get the filename for the replacement item QString translated_key = i18nc("plasma name", qPrintable( i.key() ) ); QString fileReplacement = QFileDialog::getOpenFileName(this, i18n("Select File to Use for %1",translated_key)); if (!fileReplacement.isEmpty()) { m_itemFileReplacements[i.value()] = fileReplacement; int index = itemComboBox->findText(fileReplacement); if (index == -1) itemComboBox->addItem(fileReplacement); disconnect(itemComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DesktopThemeDetails::replacementItemChanged); itemComboBox->setCurrentIndex(itemComboBox->findText(fileReplacement)); connect(itemComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DesktopThemeDetails::replacementItemChanged); m_itemThemeReplacements[i.value()] = -1; //source is not a theme m_itemFileReplacements[i.value()] = itemComboBox->currentText(); } else { // Reset combobox to previous value if no file is selected if (m_itemThemeReplacements[i.value()] != -1) { itemComboBox->setCurrentIndex(m_itemThemeReplacements[i.value()]); } else { itemComboBox->setCurrentIndex(itemComboBox->findText(m_itemFileReplacements[i.value()])); } m_themeCustomized = false; } } else { m_itemThemeReplacements[i.value()] = -1; //source is not a theme m_itemFileReplacements[i.value()] = itemComboBox->currentText(); } } } if (m_themeCustomized) emit changed(); }
void PretrazivanjeSredstavaD1::setModelSredstva() { QComboBox *view = ui->cbSredstva; modelSredstva = new QSqlQueryModel(); modelSredstva->setQuery("select -1 as A, 'Svi' as B union select * from artikal;"); view->setModel(modelSredstva); view->setModelColumn(1); view->setCurrentIndex(view->findText("Svi")); }
void PretrazivanjeSredstavaD1::setModelGodina() { QComboBox *view = ui->cbGodina; modelGodina = new QSqlQueryModel(); modelGodina->setQuery("select 'Sve' union select distinct(substr(datum, -4)) as godina from spisak order by godina;"); view->setModel(modelGodina); view->setModelColumn(0); view->setCurrentIndex(view->findText("Sve")); }
void ComboDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString str = index.model()->data(index).toString(); QComboBox *box = static_cast<QComboBox*>(editor); int i = box->findText(str); box->setCurrentIndex(i); }
void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::DisplayRole).toString(); kDebug()<<value<<":"<<m_list; QComboBox *comboBox = static_cast<QComboBox*>(editor); comboBox->insertItems(0, m_list); comboBox->setCurrentIndex(comboBox->findText(value)); }
//----------------------------------------------------------------------------- // Function: PortsDelegate::setEditorData() //----------------------------------------------------------------------------- void PortsDelegate::setEditorData(QWidget* editor, QModelIndex const& index) const { if (index.column() == PortColumns::DIRECTION) { QString text = index.data(Qt::DisplayRole).toString(); QComboBox* combo = qobject_cast<QComboBox*>(editor); int comboIndex = combo->findText(text); combo->setCurrentIndex(comboIndex); } else if (index.column() == PortColumns::TYPE_NAME || index.column() == PortColumns::TYPE_DEF) { QString text = index.data(Qt::DisplayRole).toString(); QComboBox* combo = qobject_cast<QComboBox*>(editor); int comboIndex = combo->findText(text); // if the text is not found if (comboIndex < 0) { combo->setEditText(text); } else { combo->setCurrentIndex(comboIndex); } } else if (index.column() == PortColumns::TAG_GROUP) { ListEditor* tagEditor = qobject_cast<ListEditor*>(editor); Q_ASSERT(tagEditor); QString portTagGroup = index.model()->data(index, Qt::DisplayRole).toString(); if (!portTagGroup.isEmpty()) { QStringList portTags = portTagGroup.split(", "); tagEditor->setItems(portTags); } } else { ExpressionDelegate::setEditorData(editor, index); } }
void ComboBoxDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { QComboBox *c = qobject_cast<QComboBox*>(editor); QString data = index.model()->data(index, Qt::DisplayRole).toString(); int i = c->findText(data); if (i != -1) c->setCurrentIndex(i); else c->setEditText(data); }
void ExportSequenceOfSelectedAnnotationsFiller::commonScenario() { QWidget *dialog = QApplication::activeModalWidget(); GT_CHECK(dialog != NULL, "dialog not found"); QLineEdit *fileNameEdit = dialog->findChild<QLineEdit*>("fileNameEdit"); GT_CHECK(fileNameEdit != NULL, "fileNameEdit not found"); GTLineEdit::setText(os, fileNameEdit, path); GTGlobals::sleep(200); QComboBox *comboBox = dialog->findChild<QComboBox*>(); GT_CHECK(comboBox != NULL, "ComboBox not found"); int index = comboBox->findText(comboBoxItems[format]); GT_CHECK(index != -1, QString("item \"%1\" in combobox not found").arg(comboBoxItems[format])); if (comboBox->currentIndex() != index){ GTComboBox::setCurrentIndex(os, comboBox, index, true, useMethod); } GTGlobals::sleep(200); QCheckBox *projectCheckBox = dialog->findChild<QCheckBox*>(QString::fromUtf8("addToProjectBox")); GT_CHECK(projectCheckBox != NULL, "addToProjectBox not found"); GTCheckBox::setChecked(os, projectCheckBox, addToProject); GTGlobals::sleep(200); QCheckBox *annotationsCheckBox = dialog->findChild<QCheckBox*>(QString::fromUtf8("withAnnotationsBox")); GT_CHECK(annotationsCheckBox != NULL, "Check box not found"); if(annotationsCheckBox->isEnabled()){ GTCheckBox::setChecked(os, annotationsCheckBox, exportWithAnnotations); } GTGlobals::sleep(200); QRadioButton *mergeButton = dialog->findChild<QRadioButton*>(mergeRadioButtons[options]); GT_CHECK(mergeButton != NULL, "Radio button " + mergeRadioButtons[options] + " not found"); if (mergeButton->isEnabled()){ GTRadioButton::click(os, mergeButton); } GTGlobals::sleep(200); if (gapLength){ QSpinBox *mergeSpinBox = dialog->findChild<QSpinBox*>("mergeSpinBox"); GT_CHECK(mergeSpinBox != NULL, "SpinBox not found"); GTSpinBox::setValue(os, mergeSpinBox, gapLength, useMethod); } GTGlobals::sleep(200); GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok); }
void GrainDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QComboBox *combo; QDoubleSpinBox *spin; int comboindex; QVariant value = index.model()->data(index, Qt::EditRole); // different kind of editor for each column switch (index.column()) { case GrainModel::NAME: combo = static_cast<QComboBox*>(editor); if (!combo) return; comboindex = combo->findText(value.toString()); if (comboindex > 0) { combo->setCurrentIndex(comboindex); } else { combo->setEditText(value.toString()); } break; case GrainModel::WEIGHT: case GrainModel::EXTRACT: case GrainModel::COLOR: spin = static_cast<QDoubleSpinBox*>(editor); if (!spin) return; spin->setValue(value.toDouble()); break; case GrainModel::TYPE: case GrainModel::USE: combo = static_cast<QComboBox*>(editor); if (!combo) return; combo->setCurrentIndex(combo->findText(value.toString())); break; default: QItemDelegate::setEditorData(editor, index); break; } }
//! [2] void ImageDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QComboBox *comboBox = qobject_cast<QComboBox *>(editor); if (!comboBox) return; int pos = comboBox->findText(index.model()->data(index).toString(), Qt::MatchExactly); comboBox->setCurrentIndex(pos); }
void PolicyComboBoxDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { QString value = index.model()->data(index, Qt::DisplayRole).toString(); QComboBox* policyComboBox = static_cast<QComboBox*>(editor); int idx = policyComboBox->findText(value); if( idx != -1 ) { policyComboBox->setCurrentIndex(idx); } }
void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { if (index.column() >= 2) { QItemDelegate::setEditorData(editor, index); return; } QString data = index.model()->data(index, Qt::DisplayRole).toString(); QComboBox* cb = static_cast<QComboBox*>(editor); cb->setCurrentIndex(cb->findText(data)); }
void FieldTypeDelegate::setEditorData(QWidget* pEditor, const QModelIndex& index) const { QComboBox* pTypeCombo = dynamic_cast<QComboBox*>(pEditor); if (pTypeCombo == NULL) { return; } QString typeText = index.model()->data(index, Qt::EditRole).toString(); int typeIndex = pTypeCombo->findText(typeText); pTypeCombo->setCurrentIndex(typeIndex); }
void DataTypeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { if (index.column() == dataTypeColumn) { QString text = index.model()->data(index, Qt::DisplayRole).toString(); QComboBox *comboBox = qobject_cast<QComboBox*>(editor); comboBox->setCurrentIndex(comboBox->findText(text)); } else { QItemDelegate::setEditorData(editor, index); } }
void Delegate::setEditorData(QWidget *editor, const QModelIndex &index) const { /*int value = index.model()->data(index, Qt::EditRole).toInt(); QSpinBox *spinBox = static_cast<QSpinBox*>(editor); spinBox->setValue(value);*/ QString value = index.model()->data(index, Qt::DisplayRole).toString(); QComboBox *cmbBox = static_cast<QComboBox*>(editor); cmbBox->setCurrentIndex(cmbBox->findText(value, Qt::MatchCaseSensitive)); temp_editor = cmbBox; //connect(cmbBox, SIGNAL(valueChanged(int)), this, SLOT(indexChanged(int))); connect(cmbBox, SIGNAL(currentIndexChanged(int)), this, SLOT(indexChanged(int))); connect(cmbBox, SIGNAL(editTextChanged(QString)), this, SLOT(editTextChangedSlot(QString))); }
void CustCharacteristicDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::DisplayRole).toString(); QComboBox *comboBox = static_cast<QComboBox*>(editor); int curIdx = comboBox->findText(value); if(curIdx != -1) comboBox->setCurrentIndex(curIdx); else comboBox->setEditText(value); }
void Setting::save(const QString& section, const QString& prefix, const QComboBox& cmb, bool all) { QSettings& store = storage(); store.beginGroup(section); QString tkey = prefix + SET_PFX_CMBTXT; QString tval = cmb.currentText().trimmed(); if (!tval.isEmpty()) store.setValue(tkey, tval); if (all) { QStringList keys, vals; keys = store.childKeys(); qint32 n = keys.size(); if (n > 0) { keys.sort(); while (n--) { QString k = keys[n]; if ((k!=tkey) && k.startsWith(prefix)) { QString v = store.value(k).toString().trimmed(); if (!v.isEmpty() && (-1 == cmb.findText(v))) vals.prepend(v); store.remove(k); } } } n = cmb.count(); if (n > SET_MAX_CMBITM) n = SET_MAX_CMBITM; qint32 i = 0; for (i=0; i<n; ++i) store.setValue(prefix+QString::number(i), cmb.itemText(i)); n = (vals.count() > SET_MAX_CMBITM) ? SET_MAX_CMBITM : vals.count(); for (qint32 j=0; i<n; ++i,++j) store.setValue(prefix+QString::number(i), vals[j]); } store.endGroup(); }
void BusPortsDelegate::setEditorData( QWidget* editor, const QModelIndex& index ) const { switch (index.column()) { // name and comment or default value case 0: { QLineEdit* line = qobject_cast<QLineEdit*>(editor); Q_ASSERT_X(line, "BusPortsDelegate::setEditorData", "Type conversion failed for QLineEdit"); QString text = index.model()->data(index, Qt::DisplayRole).toString(); if (QString::compare(text, "unnamed") != 0) { line->setText(text); } break; } case 2: case 8: case 3: { QLineEdit* line = qobject_cast<QLineEdit*>(editor); Q_ASSERT_X(line, "BusPortsDelegate::setEditorData", "Type conversion failed for QLineEdit"); QString text = index.model()->data(index, Qt::DisplayRole).toString(); line->setText(text); break; } // qualifier, mode, direction, presence, driver case 1: case 4: case 5: case 6: case 7: { QComboBox* box = qobject_cast<QComboBox*>(editor); Q_ASSERT_X(box, "BusPortsDelegate::setEditorData", "Type conversion failed for combo box"); QString text = index.model()->data(index, Qt::DisplayRole).toString(); int index = box->findText(text); box->setCurrentIndex(index); break; } default: { QStyledItemDelegate::setEditorData(editor, index); break; } } }
void ImportCsvDialog::setEncoding(const QString& sEnc) { QComboBox* combo = ui->comboEncoding; int index = combo->findText(sEnc); if(index == -1) { combo->setCurrentIndex(combo->count()); ui->editCustomEncoding->setText(sEnc); } else { combo->setCurrentIndex(index); } }
void ImportCsvDialog::setQuoteChar(const QChar& c) { QComboBox* combo = ui->comboQuote; int index = combo->findText(c); if(index == -1) { combo->setCurrentIndex(combo->count()); ui->editCustomQuote->setText(c); } else { combo->setCurrentIndex(index); } }
void PropertyEditorDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::DisplayRole).toString(); QLineEdit *lineEdit = dynamic_cast<QLineEdit*>(editor); if (lineEdit) lineEdit->setText(value); else { QComboBox *comboEdit = dynamic_cast<QComboBox*>(editor); if (comboEdit) comboEdit->setCurrentIndex(comboEdit->findText(value)); } }
void ChengjiaoQianyueDialog::on_tableViewqianyue_clicked() { qDebug() << "clicked"; QSqlRecord record = this->dbcon->qianyue->record(this->tableViewqianyue->currentIndex().row()); QComboBox * combo; QString * value; int a; combo = this->comboBoxFang; value = &(record.value(0).toString()); if(-1 != (a = combo->findText(*value))) combo->setCurrentIndex(a); else combo->insertItem(0,*value); combo = this->comboBoxKe; value = &(record.value(1).toString()); if(-1 != (a = combo->findText(*value))) combo->setCurrentIndex(a); else combo->insertItem(0,*value); combo = this->comboBoxRen; value = &(record.value(2).toString()); if(-1 != (a = combo->findText(*value))) combo->setCurrentIndex(a); else combo->insertItem(0,*value); combo = this->comboBoxFen; value = &(record.value(4).toString()); if(-1 != (a = combo->findText(*value))) combo->setCurrentIndex(a); else combo->insertItem(0,*value); this->spinBoxYongjin->setValue(record.value(3).toInt()); this->spinBoxBianhao->setValue(record.value(5).toInt()); }
void MicroSelectWidget::setMicro( const QString & id ) { MicroInfo * info = MicroLibrary::self()->microInfoWithID(id); if (!info) return; m_pMicro->clear(); m_pMicro->insertItems( m_pMicro->count(), MicroLibrary::self()->microIDs( info->instructionSet()->set() ) ); //m_pMicro->setCurrentText(id); // 2018.12.07 { QComboBox *c = m_pMicro; QString text = id; int i = c->findText(text); if (i != -1) c->setCurrentIndex(i); else if (c->isEditable()) c->setEditText(text); else c->setItemText(c->currentIndex(), text); } //m_pMicroFamily->setCurrentText( AsmInfo::setToString( info->instructionSet()->set() ) ); // 2018.12.07 { QComboBox *c = m_pMicroFamily; QString text = AsmInfo::setToString( info->instructionSet()->set() ); int i = c->findText(text); if (i != -1) c->setCurrentIndex(i); else if (c->isEditable()) c->setEditText(text); else c->setItemText(c->currentIndex(), text); } }
void ImportCsvDialog::setSeparatorChar(const QChar& c) { QComboBox* combo = ui->comboSeparator; QString sText = c == '\t' ? QString("Tab") : QString(c); int index = combo->findText(sText); if(index == -1) { combo->setCurrentIndex(combo->count()); ui->editCustomSeparator->setText(c); } else { combo->setCurrentIndex(index); } }
void MainWindow::updateFileSelection(const QString &t_file, QComboBox &t_qcb) { if (!t_file.isEmpty()) { QString filename = toQString(toPath(t_file).external_file_string()); int i = t_qcb.findText(filename); if (i == -1) { t_qcb.addItem(filename); t_qcb.setCurrentIndex(t_qcb.count() - 1); } else { t_qcb.setCurrentIndex(i); } } }
void MidiTable::midiSensePressed( int row ){ currentMidiAutosenseRow = row; MidiSenseWidget mW( this ); mW.exec(); QComboBox * eventCombo = dynamic_cast <QComboBox *> ( cellWidget( row, 1 ) ); QSpinBox * eventSpinner = dynamic_cast <QSpinBox *> ( cellWidget( row, 2 ) ); eventCombo->setCurrentIndex( eventCombo->findText( mW.lastMidiEvent ) ); eventSpinner->setValue( mW.lastMidiEventParameter ); m_pUpdateTimer->start( 100 ); }
/*! * \brief Setzen der spezifischen Typen gemäss den Daten im Modell */ void KontaktDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QLineEdit *edit = qobject_cast<QLineEdit *>(editor); QComboBox *comboEditor = qobject_cast<QComboBox *>(editor); QSpinBox *spinEditor = qobject_cast<QSpinBox *>(editor); if (edit) { edit->setText(index.model()->data(index, Qt::EditRole).toString()); } else if (comboEditor) { comboEditor->setCurrentIndex( comboEditor->findText( index.model()->data( index, Qt::EditRole).toString())); } else if (spinEditor) { spinEditor->setValue(index.model()->data(index, Qt::EditRole).toInt()); } }
QWidget* DataTypeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() == dataTypeColumn) { QComboBox *comboBox = new QComboBox(parent); comboBox->addItems(typeList); QString text = index.data(Qt::DisplayRole).toString(); int index = comboBox->findText(text); comboBox->setCurrentIndex(index); connect(comboBox, SIGNAL(editTextChanged(QString)), this, SLOT(comboBoxEditTextChanged())); return comboBox; } else { return QItemDelegate::createEditor(parent, option, index); } }
void FormDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { const CGeorgesFormProxyModel * mp = dynamic_cast<const CGeorgesFormProxyModel *>(index.model()); const CGeorgesFormModel * m = dynamic_cast<const CGeorgesFormModel *>(mp->sourceModel()); const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType(); int numDefinitions = type->getNumDefinition(); QString value = index.model()->data(index, Qt::DisplayRole).toString(); if (numDefinitions) { QComboBox *cb = static_cast<QComboBox*>(editor); cb->setCurrentIndex(cb->findText(value)); //cb->setIconSize() } else { switch (type->getType()) { case NLGEORGES::UType::UnsignedInt: case NLGEORGES::UType::SignedInt: { QSpinBox *spinBox = static_cast<QSpinBox*>(editor); spinBox->setValue((int)value.toDouble()); break; } case NLGEORGES::UType::Double: { QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor); spinBox->setValue(value.toDouble()); break; } case NLGEORGES::UType::Color: { break; } default: { QLineEdit *textEdit = static_cast<QLineEdit*>(editor); textEdit->setText(value); break; } } } }