/** * Replots the currently loaded workspaces. */ void DataComparison::plotWorkspaces() { int globalSpecIndex = m_uiForm.sbSpectrum->value(); int maxGlobalSpecIndex = 0; int numRows = m_uiForm.twCurrentData->rowCount(); for(int row = 0; row < numRows; row++) { // Get workspace QString workspaceName = m_uiForm.twCurrentData->item(row, WORKSPACE_NAME)->text(); MatrixWorkspace_const_sptr workspace = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(workspaceName.toStdString()); int numSpec = static_cast<int>(workspace->getNumberHistograms()); // Calculate spectrum number QSpinBox *specOffsetSpin = dynamic_cast<QSpinBox *>(m_uiForm.twCurrentData->cellWidget(row, SPEC_OFFSET)); int specOffset = specOffsetSpin->value(); int specIndex = globalSpecIndex - specOffset; g_log.debug() << "Spectrum index for workspace " << workspaceName.toStdString() << " is " << specIndex << ", with offset " << specOffset << std::endl; // See if this workspace extends the reach of the global spectrum selector int maxGlobalSpecIndexForWs = numSpec + specOffset - 1; if(maxGlobalSpecIndexForWs > maxGlobalSpecIndex) maxGlobalSpecIndex = maxGlobalSpecIndexForWs; // Check the spectrum index is in range if(specIndex >= numSpec || specIndex < 0) { g_log.debug() << "Workspace " << workspaceName.toStdString() << ", spectrum index out of range." << std::endl;; // Give "n/a" in current spectrum display m_uiForm.twCurrentData->item(row, CURRENT_SPEC)->setText(tr("n/a")); // Detech the curve from the plot if(m_curves.contains(workspaceName)) m_curves[workspaceName]->attach(NULL); continue; } // Update current spectrum display m_uiForm.twCurrentData->item(row, CURRENT_SPEC)->setText(tr(QString::number(specIndex))); // Create the curve data const bool logScale(false), distribution(false); QwtWorkspaceSpectrumData wsData(*workspace, static_cast<int>(specIndex), logScale, distribution); // Detach the old curve from the plot if it exists if(m_curves.contains(workspaceName)) m_curves[workspaceName]->attach(NULL); QComboBox *colourSelector = dynamic_cast<QComboBox *>(m_uiForm.twCurrentData->cellWidget(row, COLOUR)); QColor curveColour = colourSelector->itemData(colourSelector->currentIndex()).value<QColor>(); // Create a new curve and attach it to the plot auto curve = boost::make_shared<QwtPlotCurve>(); curve->setData(wsData); curve->setPen(curveColour); curve->attach(m_plot); m_curves[workspaceName] = curve; } // Plot the diff plotDiffWorkspace(); // Update the plot m_plot->replot(); // Set the max value for global spectrum spin box m_uiForm.sbSpectrum->setMaximum(maxGlobalSpecIndex); m_uiForm.sbSpectrum->setSuffix(" / " + QString::number(maxGlobalSpecIndex)); }
SpotMapperWindow::SpotMapperWindow(DeltaViewer* dv, int gw, int gh, int gd, int texSize, QWidget* parent) : QWidget(parent) { textureSize = texSize; globalWidth = gw; globalHeight = gh; globalDepth = gd; sectionNo = gd / 2; // default to the middle slice currentNuclearPerimeter = -1; deltaViewer = dv; x_origin = y_origin = 0; // then the backgroundImage = 0; // Make the relevant widgets.. plotter = new PerimeterPlotter(textureSize, this); connect(plotter, SIGNAL(mousePos(int, int)), this, SLOT(newMousePos(int, int)) ); // The following are elements that are used to control the mapping process checksBox = new QHBoxLayout(); // insert this layout into the appropriate position lower down QLabel* repLabel = new QLabel("Repulse", this); QDoubleSpinBox* repBox = new QDoubleSpinBox(this); repBox->setRange(1, 100); repBox->setValue(20); QLabel* difLabel = new QLabel("Spread", this); QDoubleSpinBox* diffuserSelector = new QDoubleSpinBox(this); diffuserSelector->setRange(1, 100); diffuserSelector->setValue(20); QLabel* ssLabel = new QLabel("Step size", this); QDoubleSpinBox* stepSizeSelector = new QDoubleSpinBox(this); stepSizeSelector->setRange(1, 100); stepSizeSelector->setValue(20); QLabel* mfLabel = new QLabel("Min force", this); QDoubleSpinBox* minForceSelector = new QDoubleSpinBox(this); minForceSelector->setRange(0.01, 0.99); minForceSelector->setSingleStep(0.01); QLabel* sNoLabel = new QLabel("Max step no.", this); QSpinBox* stepNumberSelector = new QSpinBox(this); stepNumberSelector->setRange(1, 500); stepNumberSelector->setValue(200); spotMapper = new SpotMapper(stepNumberSelector->value(), stepSizeSelector->value(), diffuserSelector->value(), minForceSelector->value(), repBox->value()); // and make the set of connections I need to make sure that everything is kept up to date: connect(stepNumberSelector, SIGNAL(valueChanged(int)), spotMapper, SLOT(setMaxSteps(int)) ); connect(stepSizeSelector, SIGNAL(valueChanged(double)), spotMapper, SLOT(setStepSize(double)) ); connect(diffuserSelector, SIGNAL(valueChanged(double)), spotMapper, SLOT(setSigma(double)) ); connect(minForceSelector, SIGNAL(valueChanged(double)), spotMapper, SLOT(setLimit(double)) ); connect(repBox, SIGNAL(valueChanged(double)), spotMapper, SLOT(setRepSigma(double)) ); /// some labels and a margin input for the nearest neighbour mapper QLabel* nnLabel = new QLabel("Nearest Neighbor", this); QLabel* nnMarginLabel = new QLabel("Margin", this); QSpinBox* nnMargin = new QSpinBox(this); nnMargin->setRange(10, 200); nnMargin->setValue(60); nnMapper = new NearestNeighborMapper(nnMargin->value()); connect(nnMargin, SIGNAL(valueChanged(int)), nnMapper, SLOT(setMargin(int)) ); QPushButton* nnMapButton = new QPushButton("Map", this); connect(nnMapButton, SIGNAL(clicked()), this, SLOT(mapAllByNeighbor()) ); QPushButton* nnMapOneButton = new QPushButton("Map One", this); connect(nnMapOneButton, SIGNAL(clicked()), this, SLOT(mapOneByNeighbor()) ); QLabel* maxPerimeterLabel = new QLabel("Perimeter max D", this); QSpinBox* maxPerimeterD = new QSpinBox(this); maxPerimeterD->setRange(10, 200); maxPerimeterD->setValue(30); spotPerimeterMapper = new SpotPerimeterMapper(maxPerimeterD->value()); connect(maxPerimeterD, SIGNAL(valueChanged(int)), spotPerimeterMapper, SLOT(setMaxDistance(int)) ); QPushButton* mapPerimeterButton = new QPushButton("Map Perimeter", this); connect(mapPerimeterButton, SIGNAL(clicked()), this, SLOT(mapPerimeter()) ); QPushButton* makeCellsButton = new QPushButton("Make Cells", this); connect(makeCellsButton, SIGNAL(clicked()), this, SLOT(makeCells()) ); QLabel* nucleusLabel = new QLabel("Selected nucleus", this); selectedPerimeterLabel = new QLabel("----", this); QLabel* bLabel = new QLabel("Blob", this); blobSelector = new QSpinBox(this); blobSelector->setRange(0, 0); connect(blobSelector, SIGNAL(valueChanged(int)), this, SLOT(setBlob(int)) ); selBlobLabel = new QLabel("----, ----", this); mouse_X_label = new QLabel("-----"); mouse_Y_label = new QLabel("-----"); QLabel* scaleLabel = new QLabel("Scale", this); QDoubleSpinBox* scaleBox = new QDoubleSpinBox(this); scaleBox->setRange(0.1, 10.0); scaleBox->setSingleStep(0.1); scaleBox->setValue(1.0); connect(scaleBox, SIGNAL(valueChanged(double)), plotter, SLOT(setScale(double)) ); QLabel* mapLabel = new QLabel("Map", this); QPushButton* mapOne = new QPushButton("one", this); QPushButton* mapVis = new QPushButton("visible", this); QPushButton* mapAll = new QPushButton("all", this); connect(mapOne, SIGNAL(clicked()), this, SLOT(mapOneBlob()) ); connect(mapVis, SIGNAL(clicked()), this, SLOT(mapAllVisible()) ); connect(mapAll, SIGNAL(clicked()), this, SLOT(mapAllBlobs() ) ); // and then a label for the perimeters.. -just to give some information at the moment. // later we can try to do something a little bit more complex like centering on the given perimeters perimeterLabel = new QLabel("No Perimeters Loaded", this); // and then the things for other stuff.. ArrowButton* upButton = new ArrowButton(0, this); ArrowButton* downButton = new ArrowButton(180, this); ArrowButton* leftButton = new ArrowButton(270, this); ArrowButton* rightButton = new ArrowButton(90, this); connect(upButton, SIGNAL(clicked()), this, SLOT(goUp()) ); connect(downButton, SIGNAL(clicked()), this, SLOT(goDown()) ); connect(leftButton, SIGNAL(clicked()), this, SLOT(goLeft()) ); connect(rightButton, SIGNAL(clicked()), this, SLOT(goRight()) ); QLabel* posLabel = new QLabel("Position"); positionLabel = new QLabel("0, 0"); QLabel* h_delta = new QLabel("Horizontal"); QLabel* v_delta = new QLabel("Vertical"); // and then .. vertDeltaBox = new QSpinBox(this); horDeltaBox = new QSpinBox(this); vertDeltaBox->setRange(1, textureSize); horDeltaBox->setRange(1, textureSize); vertDeltaBox->setValue(textureSize); horDeltaBox->setValue(textureSize); // and then try to work out the layout for the stuff.. QVBoxLayout* mainBox = new QVBoxLayout(this); mainBox->addWidget(plotter); mainBox->setStretchFactor(plotter, 10); QHBoxLayout* blobBox = new QHBoxLayout(); mainBox->addLayout(blobBox); blobBox->addLayout(checksBox); blobBox->addStretch(); blobBox->addWidget(repLabel); blobBox->addWidget(repBox); blobBox->addWidget(difLabel); blobBox->addWidget(diffuserSelector); blobBox->addWidget(ssLabel); blobBox->addWidget(stepSizeSelector); blobBox->addWidget(mfLabel); blobBox->addWidget(minForceSelector); blobBox->addWidget(sNoLabel); blobBox->addWidget(stepNumberSelector); blobBox->addWidget(mapLabel); blobBox->addWidget(mapOne); blobBox->addWidget(mapVis); blobBox->addWidget(mapAll); QHBoxLayout* perimeterBox = new QHBoxLayout(); mainBox->addLayout(perimeterBox); perimeterBox->addStretch(); perimeterBox->addWidget(perimeterLabel); /// make a gridlayout inside hboxlayout.. maybe .. QHBoxLayout* positionBox = new QHBoxLayout(); mainBox->addLayout(positionBox); QGridLayout* positionGrid= new QGridLayout(); positionBox->addLayout(positionGrid); positionGrid->addWidget(upButton, 0, 1); positionGrid->addWidget(leftButton, 1, 0); positionGrid->addWidget(downButton, 2, 1); positionGrid->addWidget(rightButton, 1, 2); positionGrid->addWidget(posLabel, 0, 3); positionGrid->addWidget(positionLabel, 0, 4); positionGrid->addWidget(h_delta, 1, 3); positionGrid->addWidget(horDeltaBox, 1, 4); positionGrid->addWidget(v_delta, 2, 3); positionGrid->addWidget(vertDeltaBox, 2, 4); positionBox->addStretch(); QVBoxLayout* lowerRightVBox = new QVBoxLayout(); positionBox->addLayout(lowerRightVBox); QHBoxLayout* nnBox = new QHBoxLayout(); lowerRightVBox->addLayout(nnBox); nnBox->addStretch(); nnBox->addWidget(nnLabel); nnBox->addSpacing(2); nnBox->addWidget(nnMarginLabel); nnBox->addWidget(nnMargin); nnBox->addWidget(nnMapOneButton); nnBox->addWidget(nnMapButton); QHBoxLayout* nucleusBox = new QHBoxLayout(); lowerRightVBox->addLayout(nucleusBox); nucleusBox->addStretch(); nucleusBox->addWidget(maxPerimeterLabel); nucleusBox->addWidget(maxPerimeterD); nucleusBox->addWidget(mapPerimeterButton); nucleusBox->addWidget(makeCellsButton); nucleusBox->addSpacing(10); nucleusBox->addWidget(nucleusLabel); nucleusBox->addSpacing(3); nucleusBox->addWidget(selectedPerimeterLabel); lowerRightVBox->addStretch(); QHBoxLayout* lowerRightHBox = new QHBoxLayout(); lowerRightVBox->addLayout(lowerRightHBox); lowerRightHBox->addStretch(); lowerRightHBox->addWidget(bLabel); lowerRightHBox->addWidget(blobSelector); lowerRightHBox->addWidget(selBlobLabel); lowerRightHBox->addWidget(scaleLabel); lowerRightHBox->addWidget(scaleBox); lowerRightHBox->addWidget(mouse_X_label); lowerRightHBox->addSpacing(3); lowerRightHBox->addWidget(mouse_Y_label); // at this point mouse_X_label->setFixedWidth(mouse_X_label->sizeHint().width()); mouse_Y_label->setFixedWidth(mouse_Y_label->sizeHint().width()); // ? selBlobLabel->setFixedWidth(selBlobLabel->sizeHint().width() + 10); selectedPerimeterLabel->setFixedWidth(selectedPerimeterLabel->sizeHint().width()); }
void ChimeryMainWindow::cyc() { // Get info cycs = cycNum->value(); QGridLayout * lay = (QGridLayout *) centralWidget()->layout(); // Delete all times in list (we recompute them in this loop) while(!times->isEmpty()) delete times->takeFirst(); // Init stuff if(gogogo) { delete gogogo; gogogo = NULL; } if(gapL) { delete gapL; gapL = NULL; } int cycle; QDateTime Tstart = QDateTime(QDate::currentDate(), cycStart->time()); QDateTime Tend = QDateTime(Tstart); QDateTime * insert; QLinkedList<QPushButton *> * cycButtons_old = cycButtons; QLinkedList<QPushButton *> * cycButtons_new = new QLinkedList<QPushButton *>(); QLinkedList<QSpinBox *> * cycGaps_old = cycGaps; QLinkedList<QSpinBox *> * cycGaps_new = new QLinkedList<QSpinBox *>(); QPushButton * cycB; QSpinBox * cycGap; // Build widgets for cycles for(cycle = 0; cycle < cycs; cycle++) { if(!cycGaps_old->isEmpty() && cycle < (cycs - 1)) { cycGap = cycGaps_old->takeFirst(); cycGaps_new->append(cycGap); } else if(cycle < (cycs - 1)) { cycGap = new QSpinBox(centralWidget()); cycGap->setRange(5, 90); cycGap->setValue(20); cycGap->setSingleStep(5); lay->addWidget(cycGap, 2+cycle, 2); QObject::connect(cycGap, SIGNAL(valueChanged(int)), this, SLOT(cyc()), Qt::QueuedConnection); cycGaps_new->append(cycGap); } Tend = Tstart.addSecs(cycDur->value() * 60); if(!cycButtons_old->isEmpty()) { cycB = cycButtons_old->takeFirst(); cycB->setText(Tstart.toString("hh:mm") + "-" + Tend.toString("hh:mm")); cycButtons_new->append(cycB); } else { cycB = new QPushButton(Tstart.toString("hh:mm") + "-" + Tend.toString("hh:mm"), centralWidget()); cycB->setCheckable(true); cycB->setChecked(true); lay->addWidget(cycB, 2+cycle, 0); QObject::connect(cycB, SIGNAL(clicked()), this, SLOT(cyc()), Qt::QueuedConnection); cycButtons_new->append(cycB); } if(cycle == 0 && cycs > 1) { gapL = new QLabel("Gap:", centralWidget()); lay->addWidget(gapL, 2, 1, Qt::AlignRight); } if(cycB->isChecked()) { insert = new QDateTime(Tstart); times->append(insert); insert = new QDateTime(Tend); times->append(insert); } if(cycle < cycs - 1) Tstart = Tstart.addSecs((cycDur->value() + cycGap->value()) * 60); }
bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value ) { if ( !widget ) return false; const QgsField &theField = vl->pendingFields()[idx]; QgsVectorLayer::EditType editType = vl->editType( idx ); bool modified = false; QString text; QSettings settings; QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString(); QLineEdit *le = qobject_cast<QLineEdit *>( widget ); if ( le ) { text = le->text(); modified = le->isModified(); if ( text == nullValue ) { text = QString::null; } } QTextEdit *te = qobject_cast<QTextEdit *>( widget ); if ( te ) { text = te->toHtml(); modified = te->document()->isModified(); if ( text == nullValue ) { text = QString::null; } } QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget ); if ( pte ) { text = pte->toPlainText(); modified = pte->document()->isModified(); if ( text == nullValue ) { text = QString::null; } } QComboBox *cb = qobject_cast<QComboBox *>( widget ); if ( cb ) { if ( editType == QgsVectorLayer::UniqueValues || editType == QgsVectorLayer::ValueMap || editType == QgsVectorLayer::Classification || editType == QgsVectorLayer::ValueRelation ) { text = cb->itemData( cb->currentIndex() ).toString(); if ( text == nullValue ) { text = QString::null; } } else { text = cb->currentText(); } modified = true; } QListWidget *lw = qobject_cast<QListWidget *>( widget ); if ( lw ) { if ( editType == QgsVectorLayer::ValueRelation ) { text = '{'; for ( int i = 0, n = 0; i < lw->count(); i++ ) { if ( lw->item( i )->checkState() == Qt::Checked ) { if ( n > 0 ) { text.append( ',' ); } text.append( lw->item( i )->data( Qt::UserRole ).toString() ); n++; } } text.append( '}' ); } else { text = QString::null; } modified = true; } QSpinBox *sb = qobject_cast<QSpinBox *>( widget ); if ( sb ) { text = QString::number( sb->value() ); } QAbstractSlider *slider = qobject_cast<QAbstractSlider *>( widget ); if ( slider ) { text = QString::number( slider->value() ); } QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( widget ); if ( dsb ) { text = QString::number( dsb->value() ); } QCheckBox *ckb = qobject_cast<QCheckBox *>( widget ); if ( ckb ) { QPair<QString, QString> states = vl->checkedState( idx ); text = ckb->isChecked() ? states.first : states.second; } QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( widget ); if ( cw ) { text = cw->selectedDate().toString(); } le = widget->findChild<QLineEdit *>(); if ( le ) { text = le->text(); } switch ( theField.type() ) { case QVariant::Int: { bool ok; int myIntValue = text.toInt( &ok ); if ( ok && !text.isEmpty() ) { value = QVariant( myIntValue ); modified = true; } else if ( modified ) { value = QVariant(); } } break; case QVariant::LongLong: { bool ok; qlonglong myLongValue = text.toLong( &ok ); if ( ok && !text.isEmpty() ) { value = QVariant( myLongValue ); modified = true; } else if ( modified ) { value = QVariant(); } } case QVariant::Double: { bool ok; double myDblValue = text.toDouble( &ok ); if ( ok && !text.isEmpty() ) { value = QVariant( myDblValue ); modified = true; } else if ( modified ) { value = QVariant(); } } break; case QVariant::Date: { QDate myDateValue = QDate::fromString( text, Qt::ISODate ); if ( myDateValue.isValid() && !text.isEmpty() ) { value = myDateValue; modified = true; } else if ( modified ) { value = QVariant(); } } break; default: //string modified = true; value = QVariant( text ); break; } return modified; }
void qtractorMidiEventItemDelegate::setModelData ( QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex& index ) const { const qtractorMidiEventListModel *pListModel = static_cast<const qtractorMidiEventListModel *> (pModel); qtractorMidiEvent *pEvent = pListModel->eventOfIndex(index); if (pEvent == NULL) return; qtractorMidiEditor *pMidiEditor = pListModel->editor(); if (pMidiEditor == NULL) return; #ifdef CONFIG_DEBUG qDebug("qtractorMidiEventItemDelegate::setModelData(%p, %p, %d, %d)", pEditor, pListModel, index.row(), index.column()); #endif qtractorTimeScale *pTimeScale = pMidiEditor->timeScale(); qtractorMidiEditCommand *pEditCommand = new qtractorMidiEditCommand(pMidiEditor->midiClip(), tr("edit %1").arg(pListModel->headerData( index.column(), Qt::Horizontal, Qt::DisplayRole) .toString().toLower())); switch (index.column()) { case 0: // Time. { qtractorTimeSpinBox *pTimeSpinBox = qobject_cast<qtractorTimeSpinBox *> (pEditor); if (pTimeSpinBox) { unsigned long iTime = pTimeScale->tickFromFrame(pTimeSpinBox->valueFromText()); if (iTime > pMidiEditor->timeOffset()) iTime -= pMidiEditor->timeOffset(); else iTime = 0; unsigned long iDuration = 0; if (pEvent->type() == qtractorMidiEvent::NOTEON) iDuration = pEvent->duration(); pEditCommand->resizeEventTime(pEvent, iTime, iDuration); } break; } case 2: // Name. { QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor); if (pComboBox) { const int iNote = pComboBox->currentIndex(); const unsigned long iTime = pEvent->time(); pEditCommand->moveEvent(pEvent, iNote, iTime); } break; } case 3: // Value. { QSpinBox *pSpinBox = qobject_cast<QSpinBox *> (pEditor); if (pSpinBox) { const int iValue = pSpinBox->value(); pEditCommand->resizeEventValue(pEvent, iValue); } break; } case 4: // Duration/Data. { qtractorTimeSpinBox *pTimeSpinBox = qobject_cast<qtractorTimeSpinBox *> (pEditor); if (pTimeSpinBox) { const unsigned long iTime = pEvent->time(); const unsigned long iDuration = pTimeScale->tickFromFrame(pTimeSpinBox->value()); pEditCommand->resizeEventTime(pEvent, iTime, iDuration); } break; } default: break; } // Do it. pMidiEditor->commands()->exec(pEditCommand); }
void WidgetIOProperties::createIOProperties() { ui->mainLayout->setColumnMinimumWidth(0, 150); ui->optionLayout->setColumnMinimumWidth(0, 150); QString lang = Utils::GetLocale(); QString rsc = QString(":/doc/%1/io_doc.json").arg(lang); QFile f(rsc); if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::warning(this, tr("Error"), tr("Failed to load IO documentation from %1").arg(rsc)); return; } QJsonParseError jerr; QJsonDocument jdoc = QJsonDocument::fromJson(f.readAll(), &jerr); if (jerr.error != QJsonParseError::NoError || !jdoc.isObject()) { QMessageBox::warning(this, tr("Error"), tr("Failed to parse JSON IO documentation from %1").arg(rsc)); return; } QString iotype = QString::fromUtf8(params["type"].c_str()); QJsonObject jobj = jdoc.object(); for (auto it = jobj.begin();it != jobj.end();it++) jobj.insert(it.key().toLower(), it.value()); QJsonObject jobjAlias; if (!jobj.contains(iotype)) { //Search in aliases bool aliasfound = false; for (auto it = jobj.constBegin();it != jobj.constEnd();it++) { QJsonObject o = it.value().toObject(); QJsonArray jalias = o["alias"].toArray(); for (int i = 0;i < jalias.size();i++) { if (jalias.at(i).toString() == iotype) { aliasfound = true; jobjAlias = o; } } } if (!aliasfound) { QMessageBox::warning(this, tr("Error"), tr("IO type %1 is not found in %2").arg(iotype).arg(rsc)); return; } } QJsonObject jioobj; if (jobjAlias.isEmpty()) jioobj = jobj[iotype].toObject(); else jioobj = jobjAlias; ui->labelTitle->setText(iotype); ui->labelDesc->setText(jioobj["description"].toString()); int rowMain = 0, rowOption = 0; QJsonArray jparams = jioobj["parameters"].toArray(); for (int i = 0;i < jparams.size();i++) { QJsonObject jparam = jparams[i].toObject(); QGridLayout *layout = jparam["mandatory"].toString() == "true"?ui->mainLayout:ui->optionLayout; int row = jparam["mandatory"].toBool()?rowMain:rowOption; QLabel *title = new QLabel(jparam["name"].toString()); layout->addWidget(title, row, 0); QPushButton *revert = new QPushButton(); revert->setIcon(QIcon(":/img/document-revert.png")); revert->setToolTip(tr("Revert modification")); layout->addWidget(revert, row, 1); hider.hide(revert); QString pvalue; string prop = jparam["name"].toString().toUtf8().constData(); if (params.Exists(prop)) pvalue = QString::fromUtf8(params[prop].c_str()); else pvalue = jparam["default"].toString(); if (jparam["type"].toString() == "string") { QLineEdit *w = new QLineEdit(); w->setEnabled(jparam["readonly"].toString() != "true" && editable); w->setText(pvalue); layout->addWidget(w, row, 2); UiObject uiObject; uiObject.type = UiObjectType::LineEdit; uiObject.lineEdit = w; uiObjectMap[prop] = uiObject; connect(w, &QLineEdit::textChanged, [=]() { updateChangedParam(prop, w->text(), pvalue, title, revert); }); connect(revert, &QPushButton::clicked, [=]() { w->setText(pvalue); }); } else if (jparam["type"].toString() == "bool") { QCheckBox *w = new QCheckBox(); w->setEnabled(jparam["readonly"].toString() != "true" && editable); w->setChecked(pvalue == "true"); layout->addWidget(w, row, 2); UiObject uiObject; uiObject.type = UiObjectType::CheckBox; uiObject.checkBox = w; uiObjectMap[prop] = uiObject; connect(w, &QCheckBox::stateChanged, [=]() { updateChangedParam(prop, w->isChecked()?"true":"false", pvalue, title, revert); }); connect(revert, &QPushButton::clicked, [=]() { w->setChecked(pvalue == "true"); }); } else if (jparam["type"].toString() == "int") { QSpinBox *w = new QSpinBox(); w->setEnabled(jparam["readonly"].toString() != "true" && editable); if (!jparam["min"].toString().isEmpty()) w->setMinimum(jparam["min"].toString().toInt()); else w->setMinimum(-999999999); if (!jparam["max"].toString().isEmpty()) w->setMaximum(jparam["max"].toString().toInt()); else w->setMaximum(999999999); w->setValue(pvalue.toInt()); layout->addWidget(w, row, 2); UiObject uiObject; uiObject.type = UiObjectType::SpinBox; uiObject.spinBox = w; uiObjectMap[prop] = uiObject; connect(w, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=]() { updateChangedParam(prop, QString("%1").arg(w->value()), pvalue.isEmpty()?"0":pvalue, title, revert); }); connect(revert, &QPushButton::clicked, [=]() { w->setValue(pvalue.toInt()); }); } else if (jparam["type"].toString() == "float") { QDoubleSpinBox *w = new QDoubleSpinBox(); w->setEnabled(jparam["readonly"].toString() != "true" && editable); if (!jparam["min"].toString().isEmpty()) w->setMinimum(jparam["min"].toString().toDouble()); else w->setMinimum(-999999999.0); if (!jparam["max"].toString().isEmpty()) w->setMaximum(jparam["max"].toString().toDouble()); else w->setMaximum(999999999.0); w->setValue(pvalue.toDouble()); layout->addWidget(w, row, 2); w->setDecimals(3); UiObject uiObject; uiObject.type = UiObjectType::DoubleSpinBox; uiObject.doubleSpinBox = w; uiObjectMap[prop] = uiObject; connect(w, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=]() { updateChangedParam(prop, QString("%1").arg(w->value()), pvalue.isEmpty()?"0":pvalue, title, revert); }); connect(revert, &QPushButton::clicked, [=]() { w->setValue(pvalue.toDouble()); }); } else if (jparam["type"].toString() == "list") { QComboBox *w = new QComboBox(); int defIndex = 0; w->setEnabled(jparam["readonly"].toString() != "true" && editable); //fill combobox with values, if no value, set editable to true QJsonObject jvalues = jparam["list_value"].toObject(); if (jvalues.empty()) w->setEditable(true); else { w->setEditable(false); for (auto it = jvalues.begin();it != jvalues.end();it++) { w->addItem(it.value().toString(), it.key()); if (it.key() == pvalue) { defIndex = w->count() - 1; w->setCurrentIndex(defIndex); } } } layout->addWidget(w, row, 2); UiObject uiObject; uiObject.type = UiObjectType::ComboBox; uiObject.comboBox = w; uiObjectMap[prop] = uiObject; if (w->isEditable()) { connect(w, &QComboBox::currentTextChanged, [=]() { updateChangedParam(prop, w->currentText(), pvalue, title, revert); }); } else { connect(w, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=]() { updateChangedParam(prop, w->currentData().toString(), pvalue, title, revert); }); } connect(revert, &QPushButton::clicked, [=]() { if (w->isEditable()) w->setEditText(pvalue); else w->setCurrentIndex(defIndex); }); } QPushButton *help = new QPushButton(); help->setIcon(QIcon(":/img/icon_unkown.png")); help->setFlat(true); layout->addWidget(help, row, 3); if((i==0)&&(entryHelper != nullptr)) { QPushButton *entryHelperButton = new QPushButton(); entryHelperButton->setIcon(QIcon(":/img/icon_entry_helper.png")); entryHelperButton->setFlat(true); layout->addWidget(entryHelperButton, row, 4); connect(entryHelperButton, &QPushButton::clicked, [=]() { if (entryHelper->exec() == QDialog::Accepted) setValues(entryHelper->getParams()); }); } //avoid copy the QJsonObject in the lambda QString helpInfo = jparam["description"].toString(); connect(help, &QPushButton::clicked, [=]() { if (balloonTip) delete balloonTip; balloonTip = new BalloonTip(QPixmap(":/img/icon_unkown.png"), title->text(), helpInfo, 800, help); balloonTip->setArrowPosition(BalloonTip::TopLeft); balloonTip->move(QCursor::pos()); balloonTip->show(); }); if (jparam["mandatory"].toBool()) rowMain++; else rowOption++; } }
// 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())); }
void PropertiesEditorItem::slotSpinBoxValueChanged() { QSpinBox *spinBox = qobject_cast<QSpinBox*>(mWidget.data()); mProperty.write(mObject.data(), spinBox->value()); }
/* FIXME make this less of a hack. */ QRect TestCalendarWidget::visualRect(QString const &item) const { TestWidgetsLog() << item << "my geometry is" << geometry(); QRect ret; QAbstractItemView *view = q->findChild<QAbstractItemView*>(); QtUiTest::ListWidget *calendarView = qtuitest_cast<QtUiTest::ListWidget*>(view); if (!calendarView) { return ret; } ret = calendarView->visualRect(item); if (!ret.isNull()) { ret.moveTopLeft( q->mapFromGlobal( view->mapToGlobal(ret.topLeft()) ) ); TestWidgetsLog() << item << "is a visible day at" << ret; return ret; } QToolButton *yearButton = 0; QToolButton *monthButton = 0; QSpinBox *yearSpin = q->findChild<QSpinBox*>(); QMenu *monthMenu = 0; QList<QToolButton*> blist = q->findChildren<QToolButton*>(); foreach(QToolButton *b, blist) { if (!monthButton && (monthMenu = b->menu())) { monthButton = b; } if (!b->menu()) { yearButton = b; } } TestWidgetsLog() << "monthButton" << monthButton << "yearButton" << yearButton; TestWidgetsLog() << "item" << item << "monthMenu" << monthMenu; if (yearButton && yearButton->isVisible() && yearButton->text() == item) { QPoint p = q->mapFromGlobal( yearButton->mapToGlobal(QPoint(yearButton->width()+5, yearButton->height()/2)) ); ret = QRect(p.x() - 2, p.y() - 2, 5, 5); TestWidgetsLog() << "click near yearbutton"; } else if (yearSpin && yearSpin->isVisible() && yearSpin->value() == item.toInt()) { TestWidgetsLog() << "confirm spinbox"; QPoint p = q->mapFromGlobal( yearSpin->mapToGlobal(QPoint(yearSpin->width()+5, yearSpin->height()/2)) ); ret = QRect(p.x() - 2, p.y() - 2, 5, 5); } else if (monthButton && monthButton->isVisible() && monthButton->text() == item) { QPoint p = q->mapFromGlobal( monthButton->mapToGlobal(QPoint(-5, monthButton->height()/2)) ); ret = QRect(p.x() - 2, p.y() - 2, 5, 5); TestWidgetsLog() << "click near monthbutton"; } else if (monthMenu && monthMenu->isVisible() && qtuitest_cast<QtUiTest::ListWidget*>(monthMenu) && qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->list().contains(item)) { ret = qtuitest_cast<QtUiTest::ListWidget*>(monthMenu)->visualRect(item); ret.moveTopLeft( q->mapFromGlobal( monthMenu->mapToGlobal(ret.topLeft()) ) ); TestWidgetsLog() << "click on monthmenu"; } else { do { QStringList items = list(); if (items.contains(item)) { ret = QRect(-1, -1, 1, 1); ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) ); break; } foreach (QString s, items) { if (!s.startsWith(GetListRegExp)) continue; QRegExp re(s.mid(GetListRegExp.length())); if (re.exactMatch(item)) { ret = QRect(-1, -1, 1, 1); ret.moveTopLeft( q->mapFromGlobal(QPoint(-1,-1)) ); break; } } if (!ret.isNull()) break; } while(0); } TestWidgetsLog() << "returning rect" << ret; return ret; }
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); } }
void SceneTableUi::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { QVariant value; switch (index.column()) { case QTV_DELAY1: case QTV_DELAY2: { QSpinBox *spinBox = static_cast<QSpinBox*>(editor); spinBox->interpretText(); value = spinBox->value(); } break; case QTV_SCENE1: case QTV_SCENE2: case QTV_TRANSITION: { QComboBox *comboBox = static_cast<QComboBox*>(editor); value = comboBox->currentText(); } break; } model->setData(index, value, Qt::EditRole); ObsAction* action = 0; if (ObsActions) { action = (*ObsActions)[index.row()+1]; } if (action) { bool changed = false; switch (index.column()) { case QTV_DELAY1: if (action->GetDelay1() != value.toInt()) { action->SetDelay1(value.toInt()); changed = true; } break; case QTV_DELAY2: if (action->GetDelay2() != value.toInt()) { action->SetDelay2(value.toInt()); changed = true; } break; case QTV_SCENE1: if (QString::compare(action->GetScene1Name(), value.toString())) { action->SetScene1(ObsSwitcher->GetScene(value.toString())); changed = true; if (value.toString().isEmpty() || value.toString().isNull()) { QModelIndex index = model->index(index.row(), 4, QModelIndex()); model->setData(index, value, Qt::EditRole); } } break; case QTV_SCENE2: if (QString::compare(action->GetScene2Name(), value.toString())) { action->SetScene2(ObsSwitcher->GetScene(value.toString())); changed = true; } break; case QTV_TRANSITION: if (QString::compare(action->GetTransitionName(), value.toString())) { action->SetTransition(ObsSwitcher->GetTransition(value.toString())); changed = true; } break; } if (changed) { ObsSwitcher->SaveActions(); } } }
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 FormDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, 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(); if (numDefinitions) { QComboBox *comboBox = static_cast<QComboBox*>(editor); QString value = comboBox->currentText(); QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); if (value == oldValue) { // nothing's changed } else { nldebug(QString("setModelData from %1 to %2") .arg(oldValue).arg(value).toUtf8().constData()); model->setData(index, value, Qt::EditRole); } } else { switch (type->getType()) { case NLGEORGES::UType::UnsignedInt: case NLGEORGES::UType::SignedInt: { QSpinBox *spinBox = static_cast<QSpinBox*>(editor); int value = spinBox->value(); QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); if (QString("%1").arg(value) == oldValue) { // nothing's changed } else { nldebug(QString("setModelData from %1 to %2") .arg(oldValue).arg(value).toUtf8().constData()); model->setData(index, value, Qt::EditRole); } break; } case NLGEORGES::UType::Double: { QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor); double value = spinBox->value(); QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); if (QString("%1").arg(value) == oldValue) { // nothing's changed } else { nldebug(QString("setModelData from %1 to %2") .arg(oldValue).arg(value).toUtf8().constData()); model->setData(index, value, Qt::EditRole); } break; } case NLGEORGES::UType::Color: { break; // TODO } default: // UType::String { QLineEdit *textEdit = static_cast<QLineEdit*>(editor); QString value = textEdit->text(); QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); if (value == oldValue) { // nothing's changed } else { nldebug(QString("setModelData from %1 to %2") .arg(oldValue).arg(value).toUtf8().constData()); model->setData(index, value, Qt::EditRole); } break; } } } }
void PointItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QSpinBox *spinBox = qobject_cast<QSpinBox *>(editor); model->setData(index, spinBox->value()); }
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QSpinBox *box = static_cast<QSpinBox*>(editor); model->setData( index, box->value(), Qt::EditRole ); }
void synthv1widget_controls_item_delegate::setModelData ( QWidget *pEditor, QAbstractItemModel *pModel, const QModelIndex& index ) const { #ifdef CONFIG_DEBUG_0 qDebug("synthv1widget_controls_item_delegate::setModelData(%p, %d, %d)", pEditor, index.row(), index.column()); #endif switch (index.column()) { case 0: // Channel. { QSpinBox *pSpinBox = qobject_cast<QSpinBox *> (pEditor); if (pSpinBox) { const int iChannel = pSpinBox->value(); const QString& sText = (iChannel > 0 ? QString::number(iChannel) : tr("Auto")); pModel->setData(index, sText); } break; } case 1: // Type. { QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor); if (pComboBox) { const QString& sType = pComboBox->currentText(); pModel->setData(index, sType); } break; } case 2: // Parameter. { QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor); if (pComboBox) { const int iIndex = pComboBox->currentIndex(); QString sText; int iParam; if (iIndex >= 0) { sText = pComboBox->itemText(iIndex); iParam = pComboBox->itemData(iIndex).toInt(); } else { sText = pComboBox->currentText(); iParam = sText.toInt(); } pModel->setData(index, sText); pModel->setData(index, iParam, Qt::UserRole); } break; } case 3: // Subject. { QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor); if (pComboBox) { const int iIndex = pComboBox->currentIndex(); pModel->setData(index, synthv1_param::paramName(synthv1::ParamIndex(iIndex))); pModel->setData(index, iIndex, Qt::UserRole); } break; } default: break; } // Done. }
void RenderOptions::setUpConfigurator() { auto tr = [](const char *s, const char *c = 0, int n = -1) { return QObject::tr(s, c, n); }; _configurator = new QWidget(); QFormLayout* formLayout = new QFormLayout(); QHBoxLayout* fileLayout = new QHBoxLayout(); QLineEdit* filePathEdit = new QLineEdit(filePath(), _configurator); QPushButton* browseButton = new QPushButton("...", _configurator); fileLayout->addWidget(filePathEdit); fileLayout->addWidget(browseButton); QPushButton* dontSaveButton = new QPushButton(dontSaveButtonCaption[1], _configurator); dontSaveButton->setCheckable(true); dontSaveButton->setChecked(true); formLayout->addRow(dontSaveButton); formLayout->addRow(tr("File:"), fileLayout); //== Resolution == QHBoxLayout* resolutionLayout = new QHBoxLayout(); QSpinBox* xResolutionSpinBox = new QSpinBox(_configurator); xResolutionSpinBox->setRange(0,300000); xResolutionSpinBox->setValue(resolution().width()); QSpinBox* yResolutionSpinBox = new QSpinBox(_configurator); yResolutionSpinBox->setRange(0,300000); yResolutionSpinBox->setValue(resolution().height()); resolutionLayout->addWidget(xResolutionSpinBox); resolutionLayout->addWidget(yResolutionSpinBox); formLayout->addRow(tr("Resolution:"), resolutionLayout); QVBoxLayout* layout = new QVBoxLayout(); layout->addLayout(formLayout); _configurator->setLayout(layout); QObject::connect(filePathEdit, &QLineEdit::editingFinished, [=](){ _filePath = filePathEdit->text(); }); QObject::connect(browseButton, &QPushButton::clicked, [=]() { QString newFilePath = QFileDialog::getSaveFileName(_configurator, tr("Save image"), _filePath); if (!newFilePath.isEmpty()) { _filePath = newFilePath; } }); QObject::connect(dontSaveButton, &QPushButton::clicked, [=](bool checked) { if (checked) { dontSaveButton->setText(dontSaveButtonCaption[1]); _saveFile = true; } else { dontSaveButton->setText(dontSaveButtonCaption[0]); _saveFile = false; } filePathEdit->setEnabled(_saveFile); browseButton->setEnabled(_saveFile); }); QObject::connect(xResolutionSpinBox, &QSpinBox::editingFinished, [=]() { _resolution.setWidth(xResolutionSpinBox->value()); }); QObject::connect(yResolutionSpinBox, &QSpinBox::editingFinished, [=]() { _resolution.setHeight(yResolutionSpinBox->value()); }); }
void BrainTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { const BrainTreeModel* pBrainTreeModel = static_cast<const BrainTreeModel*>(index.model()); const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pBrainTreeModel->itemFromIndex(index)); switch(pAbstractItem->type()) { case BrainTreeModelItemTypes::SurfaceColorGyri: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, BrainTreeItemRoles::SurfaceColorGyri); model->setData(index, data, Qt::DecorationRole); return; } case BrainTreeModelItemTypes::SurfaceColorSulci: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, BrainTreeItemRoles::SurfaceColorSulci); model->setData(index, data, Qt::DecorationRole); return; } case BrainTreeModelItemTypes::SurfaceColorInfoOrigin: { QComboBox* pColorDialog = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pColorDialog->currentText()); model->setData(index, data, BrainTreeItemRoles::SurfaceColorInfoOrigin); model->setData(index, data, Qt::DisplayRole); return; } case BrainTreeModelItemTypes::RTDataColormapType: { QComboBox* pColorDialog = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pColorDialog->currentText()); model->setData(index, data, BrainTreeItemRoles::RTDataColormapType); model->setData(index, data, Qt::DisplayRole); return; } case BrainTreeModelItemTypes::RTDataNormalizationValue: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, BrainTreeItemRoles::RTDataNormalizationValue); model->setData(index, data, Qt::DisplayRole); break; } case BrainTreeModelItemTypes::RTDataTimeInterval: { QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); QVariant data; data.setValue(pSpinBox->value()); model->setData(index, data, BrainTreeItemRoles::RTDataTimeInterval); model->setData(index, data, Qt::DisplayRole); break; } } QItemDelegate::setModelData(editor, model, index); }
bool CDlgAlmSPO2::eventFilter(QObject *o,QEvent *e) { QObject *obj[]={ m_cmbb_spo ,m_spb_spo_h ,m_spb_spo_l ,m_cmbb_mailv ,m_spb_mailv_h ,m_spb_mailv_l ,m_btn_ok, m_btn_cancel }; int iTotalObj = 8;//11 int iOkPos = iTotalObj -2; int iCancelPos = iTotalObj -1; if(e->type() == QEvent::KeyPress) { QKeyEvent *event=(QKeyEvent *)e; switch (event->key()) { case Qt::Key_Up: case Qt::Key_Left: if(bCursorSta == false) { if(iCursor == 0) { iCursor = iTotalObj-1; } else { iCursor -=1; } if((iCursor>=0) &&(iCursor<iOkPos)) { QComboBox *p = (QComboBox *)obj[iCursor]; p->setFocus(); } else { QPushButton *p = (QPushButton *)obj[iCursor]; p->setFocus(); } } else { if((iCursor == 1)|| (iCursor == 2)|| (iCursor == 4)|| (iCursor == 5)|| (iCursor == 7)|| (iCursor == 8) ) { QSpinBox *p = (QSpinBox *)obj[iCursor]; if(p->value()!= p->minimum()) { p->setValue(p->value()-1); } else { p->setValue(p->maximum()); } } } return true; break; case Qt::Key_Down: case Qt::Key_Right: if(bCursorSta == false) { if(iCursor == iTotalObj-1) { iCursor = 0; } else { iCursor +=1; } if((iCursor>=0) &&(iCursor<(iOkPos-1))) { QComboBox *p = (QComboBox *)obj[iCursor]; p->setFocus(); } else { QPushButton *p = (QPushButton *)obj[iCursor]; p->setFocus(); } } else { if((iCursor == 1)|| (iCursor == 2)|| (iCursor == 4)|| (iCursor == 5)|| (iCursor == 7)|| (iCursor == 8) ) { QSpinBox *p = (QSpinBox *)obj[iCursor]; if(p->value()!= p->maximum()) { p->setValue(p->value()+1); } else { p->setValue(p->minimum()); } } } return true; break; case Qt::Key_Return: if(bCursorSta == false) { if(iCursor == iOkPos) { do_ok_clicked(); } else if(iCursor == iCancelPos) { do_cancel_clicked(); } else if((iCursor==0) ||(iCursor==3)||(iCursor==6)) { //btn[iCursor]->showPopup(); bCursorSta = false; QComboBox *p = (QComboBox *)obj[iCursor]; p->showPopup(); //p->setStyleSheet("background-color: rgb(35, 53, 234,255);"); } else if((iCursor == 1)|| (iCursor == 2)|| (iCursor == 4)|| (iCursor == 5)|| (iCursor == 7)|| (iCursor == 8) ) { bCursorSta = true; QSpinBox *p = (QSpinBox *)obj[iCursor]; } } else { bCursorSta = false; } return true; break; default: CMainForm *p = (CMainForm *)pMainForm; p->f_process_key(event->key()); return true; break; } } else { return false; } }
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(); };
//Reading ad writing parameters from/to selected widget to/from parameters container void SynchronizeInterfaceWindow(QWidget *window, cParameterContainer *par, enumReadWrite mode) { WriteLog("cInterface::SynchronizeInterface: QLineEdit", 3); //----------- QLineEdit ------------------- { QList<QLineEdit *> widgetListLineEdit = window->findChildren<QLineEdit *>(); QList<QLineEdit *>::iterator it; for (it = widgetListLineEdit.begin(); it != widgetListLineEdit.end(); ++it) { //qDebug() << "QLineEdit:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl; QString name = (*it)->objectName(); QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (className == QString("QLineEdit") || className == QString("MyLineEdit"))) { QLineEdit *lineEdit = *it; // QString text = lineEdit->text(); //qDebug() << name << " - text: " << text << endl; QString type, parameterName; GetNameAndType(name, ¶meterName, &type); //qDebug() << name << " - type: " << type << endl; if (className == QString("MyLineEdit")) { MyLineEdit *mylineedit = (MyLineEdit*) *it; mylineedit->AssignParameterContainer(par); mylineedit->AssingParameterName(parameterName); } //----- get vectors ------------ if (type == QString("vect3") || type == QString("logvect3")) { char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1(); QString nameVect = parameterName.left(parameterName.length() - 2); if (mode == read) { double value = systemData.locale.toDouble(lineEdit->text()); //qDebug() << nameVect << " - " << lastChar << " axis = " << value << endl; CVector3 vect = par->Get<CVector3>(nameVect); switch (lastChar) { case 'x': vect.x = value; break; case 'y': vect.y = value; break; case 'z': vect.z = value; break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } par->Set(nameVect, vect); } else if (mode == write) { CVector3 vect = par->Get<CVector3>(nameVect); QString qtext; switch (lastChar) { case 'x': qtext = QString("%L1").arg(vect.x, 0, 'g', 16); break; case 'y': qtext = QString("%L1").arg(vect.y, 0, 'g', 16); break; case 'z': qtext = QString("%L1").arg(vect.z, 0, 'g', 16); break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } lineEdit->setText(qtext); lineEdit->setCursorPosition(0); } } //----- get vectors 4D ------------ if (type == QString("vect4")) { char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1(); QString nameVect = parameterName.left(parameterName.length() - 2); if (mode == read) { double value = systemData.locale.toDouble(lineEdit->text()); //qDebug() << nameVect << " - " << lastChar << " axis = " << value << endl; CVector4 vect = par->Get<CVector4>(nameVect); switch (lastChar) { case 'x': vect.x = value; break; case 'y': vect.y = value; break; case 'z': vect.z = value; break; case 'w': vect.w = value; break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } par->Set(nameVect, vect); } else if (mode == write) { CVector4 vect = par->Get<CVector4>(nameVect); QString qtext; switch (lastChar) { case 'x': qtext = QString("%L1").arg(vect.x, 0, 'g', 16); break; case 'y': qtext = QString("%L1").arg(vect.y, 0, 'g', 16); break; case 'z': qtext = QString("%L1").arg(vect.z, 0, 'g', 16); break; case 'w': qtext = QString("%L1").arg(vect.w, 0, 'g', 16); break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): edit field " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } lineEdit->setText(qtext); lineEdit->setCursorPosition(0); } } //---------- get double scalars -------- else if (type == QString("edit") || type == QString("logedit")) { if (mode == read) { double value = systemData.locale.toDouble(lineEdit->text()); par->Set(parameterName, value); } else if (mode == write) { double value = par->Get<double>(parameterName); lineEdit->setText(QString("%L1").arg(value, 0, 'g', 16)); lineEdit->setCursorPosition(0); } } //----------- get texts ------------ else if (type == QString("text")) { if (mode == read) { QString value = lineEdit->text(); par->Set(parameterName, value); } else if (mode == write) { QString value = par->Get<QString>(parameterName); lineEdit->setText(value); } } } } //end foreach } WriteLog("cInterface::SynchronizeInterface: QDoubleSpinBox", 3); //------------ Double spin-box -------------- { QList<QDoubleSpinBox *> widgetListDoubleSpinBox = window->findChildren<QDoubleSpinBox*>(); QList<QDoubleSpinBox *>::iterator it; for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it) { QString name = (*it)->objectName(); //qDebug() << "QDoubleSpinBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl; QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (className == QString("QDoubleSpinBox") || className == QString("MyDoubleSpinBox"))) { QDoubleSpinBox *spinbox = *it; QString type, parameterName; GetNameAndType(name, ¶meterName, &type); if (className == QString("MyDoubleSpinBox")) { MyDoubleSpinBox *mydoublespinbox = (MyDoubleSpinBox*) *it; mydoublespinbox->AssignParameterContainer(par); mydoublespinbox->AssingParameterName(parameterName); } if (type == QString("spinbox") || type == QString("spinboxd")) { if (mode == read) { double value = spinbox->value(); par->Set(parameterName, value); } else if (mode == write) { double value = par->Get<double>(parameterName); spinbox->setValue(value); } } else if (type == QString("spinbox3") || type == QString("spinboxd3")) { char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1(); QString nameVect = parameterName.left(parameterName.length() - 2); if (mode == read) { double value = spinbox->value(); CVector3 vect = par->Get<CVector3>(nameVect); switch (lastChar) { case 'x': vect.x = value; break; case 'y': vect.y = value; break; case 'z': vect.z = value; break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } par->Set(nameVect, vect); } else if (mode == write) { CVector3 vect = par->Get<CVector3>(nameVect); double value = 0; switch (lastChar) { case 'x': value = vect.x; break; case 'y': value = vect.y; break; case 'z': value = vect.z; break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } spinbox->setValue(value); } } else if (type == QString("spinbox4") || type == QString("spinboxd4")) { char lastChar = (parameterName.at(parameterName.length() - 1)).toLatin1(); QString nameVect = parameterName.left(parameterName.length() - 2); if (mode == read) { double value = spinbox->value(); CVector4 vect = par->Get<CVector4>(nameVect); switch (lastChar) { case 'x': vect.x = value; break; case 'y': vect.y = value; break; case 'z': vect.z = value; break; case 'w': vect.w = value; break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } par->Set(nameVect, vect); } else if (mode == write) { CVector4 vect = par->Get<CVector4>(nameVect); double value = 0; switch (lastChar) { case 'x': value = vect.x; break; case 'y': value = vect.y; break; case 'z': value = vect.z; break; case 'w': value = vect.w; break; default: qWarning() << "cInterface::SynchronizeInterfaceWindow(): " << type << " " << nameVect << " has wrong axis name (is " << lastChar << ")" << endl; break; } spinbox->setValue(value); } } } } } WriteLog("cInterface::SynchronizeInterface: QSpinBox", 3); //------------ integer spin-box -------------- { QList<QSpinBox *> widgetListDoubleSpinBox = window->findChildren<QSpinBox*>(); QList<QSpinBox *>::iterator it; for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it) { QString name = (*it)->objectName(); //qDebug() << "QDoubleSpinBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl; QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (className == QString("QSpinBox") || className == QString("MySpinBox"))) { QSpinBox *spinbox = *it; QString type, parameterName; GetNameAndType(name, ¶meterName, &type); if (className == QString("MySpinBox")) { MySpinBox *myspinbox = (MySpinBox*) *it; myspinbox->AssignParameterContainer(par); myspinbox->AssingParameterName(parameterName); } if (type == QString("spinboxInt")) { if (mode == read) { int value = spinbox->value(); par->Set(parameterName, value); } else if (mode == write) { int value = par->Get<int>(parameterName); spinbox->setValue(value); } } } } } WriteLog("cInterface::SynchronizeInterface: QCheckBox", 3); //checkboxes { QList<QCheckBox *> widgetListDoubleSpinBox = window->findChildren<QCheckBox*>(); QList<QCheckBox *>::iterator it; for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it) { QString name = (*it)->objectName(); //qDebug() << "QCheckBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl; QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (className == QString("QCheckBox") || className == QString("MyCheckBox"))) { QCheckBox *checkbox = *it; QString type, parameterName; GetNameAndType(name, ¶meterName, &type); if (className == QString("MyCheckBox")) { MyCheckBox *mycheckbox = (MyCheckBox*) *it; mycheckbox->AssignParameterContainer(par); mycheckbox->AssingParameterName(parameterName); } if (type == QString("checkBox")) { if (mode == read) { bool value = checkbox->isChecked(); par->Set(parameterName, value); } else if (mode == write) { bool value = par->Get<bool>(parameterName); checkbox->setChecked(value); } } } } } WriteLog("cInterface::SynchronizeInterface: QGroupBox", 3); //groupsBox with checkbox { QList<QGroupBox *> widgetListDoubleSpinBox = window->findChildren<QGroupBox*>(); QList<QGroupBox *>::iterator it; for (it = widgetListDoubleSpinBox.begin(); it != widgetListDoubleSpinBox.end(); ++it) { QString name = (*it)->objectName(); //qDebug() << "QGroupBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl; QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (className == QString("QGroupBox") || className == QString("MyGroupBox"))) { QGroupBox *groupbox = *it; QString type, parameterName; GetNameAndType(name, ¶meterName, &type); if (className == QString("MyGroupBox")) { MyGroupBox *mygroupbox = (MyGroupBox*) *it; mygroupbox->AssignParameterContainer(par); mygroupbox->AssingParameterName(parameterName); } if (type == QString("groupCheck")) { if (mode == read) { bool value = groupbox->isChecked(); par->Set(parameterName, value); } else if (mode == write) { bool value = par->Get<bool>(parameterName); groupbox->setChecked(value); } } } } } WriteLog("cInterface::SynchronizeInterface: FileSelectWidget", 3); //---------- file select widgets ----------- { QList<FileSelectWidget *> widgetListPushButton = window->findChildren<FileSelectWidget*>(); QList<FileSelectWidget *>::iterator it; for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it) { QString name = (*it)->objectName(); // QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (*it)->metaObject()->className() == QString("FileSelectWidget")) { QString type, parameterName; GetNameAndType(name, ¶meterName, &type); FileSelectWidget *fileSelectWidget = *it; fileSelectWidget->AssignParameterContainer(par); fileSelectWidget->AssingParameterName(parameterName); if (mode == read) { par->Set(parameterName, fileSelectWidget->GetPath()); } else if (mode == write) { fileSelectWidget->SetPath(par->Get<QString>(parameterName)); } } } } WriteLog("cInterface::SynchronizeInterface: MyColorButton", 3); //---------- color buttons ----------- { QList<MyColorButton *> widgetListPushButton = window->findChildren<MyColorButton*>(); QList<MyColorButton *>::iterator it; for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it) { QString name = (*it)->objectName(); // QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (*it)->metaObject()->className() == QString("MyColorButton")) { QString type, parameterName; GetNameAndType(name, ¶meterName, &type); MyColorButton *colorButton = *it; colorButton->AssignParameterContainer(par); colorButton->AssingParameterName(parameterName); if (mode == read) { par->Set(parameterName, colorButton->GetColor()); } else if (mode == write) { colorButton->setText(""); colorButton->SetColor(par->Get<sRGB>(parameterName)); } } } } WriteLog("cInterface::SynchronizeInterface: ColorPaletteWidget", 3); //---------- colorpalette ----------- { QList<ColorPaletteWidget *> widgetListColorPalette = window->findChildren<ColorPaletteWidget*>(); QList<ColorPaletteWidget *>::iterator it; for (it = widgetListColorPalette.begin(); it != widgetListColorPalette.end(); ++it) { QString name = (*it)->objectName(); //qDebug() << "ColorPalette:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl; if (name.length() > 1 && (*it)->metaObject()->className() == QString("ColorPaletteWidget")) { ColorPaletteWidget *colorPaletteWidget = *it; QString type, parameterName; GetNameAndType(name, ¶meterName, &type); colorPaletteWidget->AssignParameterContainer(par); colorPaletteWidget->AssingParameterName(parameterName); if (type == QString("colorpalette")) { if (mode == read) { cColorPalette palette = colorPaletteWidget->GetPalette(); par->Set(parameterName, palette); } else if (mode == write) { cColorPalette palette = par->Get<cColorPalette>(parameterName); colorPaletteWidget->SetPalette(palette); } } } } } WriteLog("cInterface::SynchronizeInterface: QComboBox", 3); //combo boxes { QList<QComboBox *> widgetListPushButton = window->findChildren<QComboBox*>(); QList<QComboBox *>::iterator it; for (it = widgetListPushButton.begin(); it != widgetListPushButton.end(); ++it) { QString name = (*it)->objectName(); //qDebug() << "QComboBox:" << (*it)->objectName() << " Type:" << (*it)->metaObject()->className() << endl; if (name.length() > 1 && (*it)->metaObject()->className() == QString("QComboBox")) { QComboBox *comboBox = *it; QString type, parameterName; GetNameAndType(name, ¶meterName, &type); if (type == QString("comboBox")) { if (mode == read) { int selection = comboBox->currentIndex(); if (parameterName.left(7) == QString("formula")) { selection = fractalList[comboBox->itemData(selection).toInt()].internalID; } par->Set(parameterName, selection); } else if (mode == write) { int selection = par->Get<int>(parameterName); if (parameterName.left(7) == QString("formula")) { for (int i = 0; i < fractalList.size(); i++) { if (fractalList[i].internalID == selection) { selection = comboBox->findData(i); break; } } } comboBox->setCurrentIndex(selection); } } } } } WriteLog("cInterface::SynchronizeInterface: cMaterialSelector", 3); //---------- material selector ----------- { QList<cMaterialSelector *> widgetListMaterialSelector = window->findChildren<cMaterialSelector*>(); QList<cMaterialSelector *>::iterator it; for (it = widgetListMaterialSelector.begin(); it != widgetListMaterialSelector.end(); ++it) { QString name = (*it)->objectName(); // QString className = (*it)->metaObject()->className(); if (name.length() > 1 && (*it)->metaObject()->className() == QString("cMaterialSelector")) { QString type, parameterName; GetNameAndType(name, ¶meterName, &type); cMaterialSelector *materialSelector = *it; materialSelector->AssignParameterContainer(par); materialSelector->AssingParameterName(parameterName); if (type == QString("materialselector")) { if (mode == read) { par->Set(parameterName, materialSelector->GetMaterialIndex()); } else if (mode == write) { materialSelector->SetMaterialIndex(par->Get<int>(parameterName)); } } } } } WriteLog("cInterface::SynchronizeInterface: Done", 3); }
void Data3DTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model()); const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index)); //Set data manually here so we can use our own item roles. switch(pAbstractItem->type()) { case MetaTreeItemTypes::SurfaceColorGyri: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, MetaTreeItemRoles::SurfaceColorGyri); model->setData(index, data, Qt::DecorationRole); break; } case MetaTreeItemTypes::SurfaceColorSulci: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, MetaTreeItemRoles::SurfaceColorSulci); model->setData(index, data, Qt::DecorationRole); break; } case MetaTreeItemTypes::ColormapType: { QComboBox* pColorMapType = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pColorMapType->currentText()); model->setData(index, data, MetaTreeItemRoles::ColormapType); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::DataThreshold: { if(Spline* pSpline = dynamic_cast<Spline*>(editor)) { QVector3D returnVector; returnVector = pSpline->getThreshold(); QString displayThreshold; displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z()); QVariant data; data.setValue(displayThreshold); model->setData(index, data, Qt::DisplayRole); data.setValue(returnVector); model->setData(index, data, MetaTreeItemRoles::DataThreshold); } break; } case MetaTreeItemTypes::StreamingTimeInterval: { QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); QVariant data; data.setValue(pSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::StreamingTimeInterval); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::VisualizationType: { QComboBox* pVisType = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pVisType->currentText()); model->setData(index, data, MetaTreeItemRoles::VisualizationType); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::Color: { QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor); QColor color = pColorDialog->currentColor(); QVariant data; data.setValue(color); model->setData(index, data, MetaTreeItemRoles::Color); model->setData(index, data, Qt::DecorationRole); break; } case MetaTreeItemTypes::NumberAverages: { QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor); QVariant data; data.setValue(pSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::NumberAverages); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::AlphaValue: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::AlphaValue); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::SurfaceTessInner: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::SurfaceTessInner); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::SurfaceTessOuter: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::SurfaceTessOuter); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::SurfaceTriangleScale: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::SurfaceTriangleScale); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::TranslateX: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::TranslateX); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::TranslateY: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::TranslateY); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::TranslateZ: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::TranslateZ); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::Scale: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::Scale); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::MaterialType: { QComboBox* pComboBox = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pComboBox->currentText()); model->setData(index, data, MetaTreeItemRoles::SurfaceMaterial); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::CancelDistance: { QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor); QVariant data; data.setValue(pDoubleSpinBox->value()); model->setData(index, data, MetaTreeItemRoles::CancelDistance); model->setData(index, data, Qt::DisplayRole); break; } case MetaTreeItemTypes::InterpolationFunction: { QComboBox* pColorMapType = static_cast<QComboBox*>(editor); QVariant data; data.setValue(pColorMapType->currentText()); model->setData(index, data, MetaTreeItemRoles::InterpolationFunction); model->setData(index, data, Qt::DisplayRole); break; } // Handle all other item types via QItemDelegate::setModelData handling default: { QItemDelegate::setModelData(editor, model, index); break; } } }
void VarInteger::updateFrom( QWidget* widg) const { QSpinBox* spin = dynamic_cast<QSpinBox*>(widg); m_val = spin->value(); }