Esempio n. 1
0
void FormJqgzcs::valeChanged(QWidget *obj){
    QSpinBox *spinbox = qobject_cast<QSpinBox *>(obj);
    if(spinbox){
        int val = spinbox->value();
        int index = spinbox->property("index").toInt();
        param->setData(QParam::SpaItemHd_Jqgzcs,index,val);
        if(14==index)
            pcomm->yajiaoTest(Md::POSFRONT,4,val);
        if(15==index)
            pcomm->yajiaoTest(Md::POSREAR,4,val);
        return;
    }
    QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox *>(obj);
    if(doublespinbox){
        int val =doublespinbox->value()*10;
        int index = doublespinbox->property("index").toInt();
        param->setData(QParam::SpaItemHd_Jqgzcs,index,val);
        return;
    }
    QPushButton *pushbutton = qobject_cast<QPushButton *>(obj);
    if(pushbutton){
        int val =pushbutton->isChecked();
        int index = pushbutton->property("index").toInt();
        param->setData(QParam::SpaItemHd_Jqgzcs,index,val);
        return;
    }
}
Esempio n. 2
0
void ShaderSelector::addUniform(QGridLayout* settings, const QString& section, const QString& name, float* value, float min, float max, int y, int x) {
	QDoubleSpinBox* f = new QDoubleSpinBox;
	f->setDecimals(3);
	if (min < max) {
		f->setMinimum(min);
		f->setMaximum(max);
	}
	float def = *value;
	bool ok = false;
	float v = m_config->getQtOption(name, section).toFloat(&ok);
	if (ok) {
		*value = v;
	}
	f->setValue(*value);
	f->setSingleStep(0.001);
	f->setAccelerated(true);
	settings->addWidget(f, y, x);
	connect(f, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [value](double v) {
		*value = v;
	});
	connect(this, &ShaderSelector::saved, [this, section, name, f]() {
		m_config->setQtOption(name, f->value(), section);
	});
	connect(this, &ShaderSelector::reset, [this, section, name, f]() {
		bool ok = false;
		float v = m_config->getQtOption(name, section).toFloat(&ok);
		if (ok) {
			f->setValue(v);
		}
	});
	connect(this, &ShaderSelector::resetToDefault, [def, section, name, f]() {
		f->setValue(def);
	});
}
Esempio n. 3
0
void ParamWidget::AddDouble(const QString& name,
    double min, double max, double step, double initial_value,
    DisplayHint display_hint) {
  ExpectNameNotFound(name);

  if (display_hint == DisplayHint::kSpinBox) {
    QDoubleSpinBox* spinbox = new QDoubleSpinBox(this);
    spinbox->setRange(min, max);
    spinbox->setSingleStep(step);
    spinbox->setValue(initial_value);
    spinbox->setProperty("param_widget_type", kParamDouble);
    widgets_[name] = spinbox;
    AddLabeledRow(name, spinbox);
    connect(spinbox,
        static_cast<void(QDoubleSpinBox::*)(double)>(
          &QDoubleSpinBox::valueChanged),
        [this, name](double value) {
          emit ParamChanged(name);
        });
  } else if (display_hint == DisplayHint::kSlider) {
    QWidget* row_widget = new QWidget(this);
    QHBoxLayout* row_hbox = new QHBoxLayout(row_widget);
    QSlider* slider = new QSlider(Qt::Horizontal, this);
    const int num_steps = static_cast<int>((max - min) / step);
    const int initial_value_int =
      static_cast<int>((initial_value - min) / step);
    slider->setRange(0, num_steps);
    slider->setSingleStep(1);
    slider->setValue(initial_value_int);
    slider->setProperty("min", min);
    slider->setProperty("max", max);
    slider->setProperty("step", step);
    slider->setProperty("param_widget_type", kParamDouble);
    QLabel* label = new QLabel(this);
    label->setText(QString::number((initial_value_int - min) * step));
    row_hbox->addWidget(new QLabel(name, this));
    row_hbox->addWidget(slider);
    row_hbox->addWidget(label);
    widgets_[name] = slider;
    layout_->addWidget(row_widget);
    slider->setProperty("param_widget_label", QVariant::fromValue(label));
    label->setProperty("format_str", "");
    connect(slider, &QSlider::valueChanged,
        [this, name, label, min, step](int position) {
          const double value = min + step * position;
          const QString format_str = label->property("format_str").toString();
          if (format_str == "") {
            label->setText(QString::number(value));
            label->setMinimumWidth(std::max(label->width(), label->minimumWidth()));
          } else {
            QString text;
            text.sprintf(format_str.toStdString().c_str(), value);
            label->setText(text);
          }
          emit ParamChanged(name);
        });
  } else {
    throw std::invalid_argument("Invalid display hint");
  }
}
Esempio n. 4
0
void EventDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    switch(index.column()) {
        case 0: {
            int value = index.model()->data(index, Qt::DisplayRole).toInt();
            QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
            spinBox->setValue(value);
            break;
        }

        case 1: {
            double value = index.model()->data(index, Qt::DisplayRole).toDouble();
            QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
            spinBox->setValue(value);
            break;
        }

        case 2: {
            int value = index.model()->data(index, Qt::DisplayRole).toInt();
            QComboBox *spinBox = static_cast<QComboBox*>(editor);
            spinBox->setCurrentText(QString().number(value));
            break;
        }
    }
}
Esempio n. 5
0
QWidget *EventDelegate::createEditor(QWidget *parent,
     const QStyleOptionViewItem &/* option */,
     const QModelIndex & index) const
{
    const EventModel* pEventModel = static_cast<const EventModel*>(index.model());

    switch(index.column()) {
        case 0: {
            QSpinBox *editor = new QSpinBox(parent);
            editor->setMinimum(0);
            editor->setMaximum(pEventModel->getFirstLastSample().second);
            return editor;
        }

        case 1: {
            QDoubleSpinBox *editor = new QDoubleSpinBox(parent);
            editor->setMinimum(0.0);
            editor->setMaximum(pEventModel->getFirstLastSample().second / pEventModel->getFiffInfo()->sfreq);
            editor->setSingleStep(0.01);
            return editor;
        }

        case 2: {
            QComboBox *editor = new QComboBox(parent);
            editor->addItems(pEventModel->getEventTypeList());
            return editor;
        }
    }

    QWidget *returnWidget = new QWidget();
    return returnWidget;
}
Esempio n. 6
0
void PreferencesDlg::setConfig()
{
    LayeredConfiguration &config = BasicApplication::instance().config();

    // Iterate over the _configMap and set the widgets' values to whatever the
    // configuration says depending on the respective widget type.
    QMutableMapIterator<QWidget *, const char *> kvp(_configMap);
    while (kvp.hasNext()) {
        kvp.next();
        if (kvp.key()->inherits("QCheckBox")) {
            QCheckBox *cb = static_cast<QCheckBox*>(kvp.key());
            config.setBool(kvp.value(), cb->isChecked());
        }
        else if (kvp.key()->inherits("QComboBox")) {
            QComboBox *cb = static_cast<QComboBox*>(kvp.key());
            config.setInt(kvp.value(), cb->currentIndex());
        }
        else if (kvp.key()->inherits("QSpinBox")) {
            QSpinBox *sb = static_cast<QSpinBox*>(kvp.key());
            config.setInt(kvp.value(), sb->value());
        }
        else if (kvp.key()->inherits("QDoubleSpinBox")) {
            QDoubleSpinBox *dsb = static_cast<QDoubleSpinBox*>(kvp.key());
            config.setDouble(kvp.value(), dsb->value());
        }
        else {
            throw Poco::NotImplementedException("Unknown configuration widget.");
        }
    }
}
Esempio n. 7
0
    virtual dyn_t getGuiValue(void){

      QAbstractButton *button = dynamic_cast<QAbstractButton*>(_widget);
      if (button!=NULL)
        return DYN_create_bool(button->isChecked());

      QAbstractSlider *slider = dynamic_cast<QAbstractSlider*>(_widget);
      if (slider!=NULL)
        return DYN_create_int(slider->value());

      QLabel *label = dynamic_cast<QLabel*>(_widget);
      if (label!=NULL)
        return DYN_create_string(label->text());

      QLineEdit *line_edit = dynamic_cast<QLineEdit*>(_widget);
      if (line_edit!=NULL)
        return DYN_create_string(line_edit->text());

      QTextEdit *text_edit = dynamic_cast<QTextEdit*>(_widget);
      if (text_edit!=NULL)
        return DYN_create_string(text_edit->toPlainText());

      QSpinBox *spinbox = dynamic_cast<QSpinBox*>(_widget);
      if (spinbox!=NULL)
        return DYN_create_int(spinbox->value());

      QDoubleSpinBox *doublespinbox = dynamic_cast<QDoubleSpinBox*>(_widget);
      if (doublespinbox!=NULL)
        return DYN_create_float(doublespinbox->value());
      
                  
      handleError("Gui #%d does not have a getValue method", _gui_num);
      return DYN_create_bool(false);
    }
QWidget *reDefaultItemEditorFactory::createEditor(QVariant::Type type, QWidget *parent) const
{
    switch (type) {
    case QVariant::Bool: {
        QBooleanComboBox *cb = new QBooleanComboBox(parent);
        return cb;
    }
    case QVariant::UInt: {
        QSpinBox *sb = new QSpinBox(parent);
        sb->setFrame(false);
        sb->setMaximum(INT_MAX);
        return sb;
    }
    case QVariant::Int: {
        QSpinBox *sb = new QSpinBox(parent);
        sb->setFrame(false);
        sb->setMinimum(INT_MIN);
        sb->setMaximum(INT_MAX);
        return sb;
    }
    case QVariant::Date: {
        QDateTimeEdit *ed = new QDateEdit(parent);
        ed->setFrame(false);
        return ed;
    }
    case QVariant::Time: {
        QDateTimeEdit *ed = new QTimeEdit(parent);
        ed->setFrame(false);
        return ed;
    }
    case QVariant::DateTime: {
        QDateTimeEdit *ed = new QDateTimeEdit(parent);
        ed->setFrame(false);
        return ed;
    }
    case QVariant::Pixmap:
        return new QLabel(parent);
    case QVariant::Double: {
        QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
        sb->setFrame(false);
        sb->setMinimum(-DBL_MAX);
        sb->setMaximum(DBL_MAX);
        return sb;
    }
    case QVariant::StringList: {
        QComboBox* cb = new QComboBox(parent);
        return cb;
    }
    case QVariant::String:
    default: {
        // the default editor is a lineedit
        QLineEdit *le = new QLineEdit(parent);
        //le->setFrame(le->style()->styleHint(QStyle::SH_ItemView_DrawDelegateFrame, 0, le));
        //if (!le->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, le))
        //le->setWidgetOwnsGeometry(true);
        return le;
    }
    }
    return 0;
}
QWidget* DynamicObjectItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
	if (index.column() == 1)
	{
		auto node = (DynamicObjectModel::Node*)index.internalPointer();
		if (!node)
		{
			return QStyledItemDelegate::createEditor(parent, option, index);
		}
		if (node->onCreateEditor)
		{
			return node->onCreateEditor(parent, option);
		}
		else if (node->m_getter().type() == QMetaType::Bool)
		{
			return nullptr;
		}
		else if (node->m_getter().type() == QMetaType::Float)
		{
			QDoubleSpinBox* input = new QDoubleSpinBox(parent);
			input->setMaximum(FLT_MAX);
			input->setMinimum(-FLT_MAX);
			connect(input, (void (QDoubleSpinBox::*)(double))&QDoubleSpinBox::valueChanged, [node](double value){
				node->m_setter(value);
			});
			input->setSingleStep(0.1);
			return input;
		}
	}
	return QStyledItemDelegate::createEditor(parent, option, index);
}
Esempio n. 10
0
void tst_QItemDelegate::doubleEditorNegativeInput()
{
    QStandardItemModel model;

    QStandardItem *item = new QStandardItem;
    item->setData(10.0, Qt::DisplayRole);
    model.appendRow(item);

    QListView view;
    view.setModel(&model);
    view.show();

    QModelIndex index = model.index(0, 0);
    view.setCurrentIndex(index); // the editor will only selectAll on the current index
    view.edit(index);

    QList<QDoubleSpinBox*> editors = qFindChildren<QDoubleSpinBox *>(view.viewport());
    QCOMPARE(editors.count(), 1);

    QDoubleSpinBox *editor = editors.at(0);
    QCOMPARE(editor->value(), double(10));

    QTest::keyClick(editor, Qt::Key_Minus);
    QTest::keyClick(editor, Qt::Key_1);
    QTest::keyClick(editor, Qt::Key_0);
    QTest::keyClick(editor, Qt::Key_Comma); //support both , and . locales
    QTest::keyClick(editor, Qt::Key_Period);
    QTest::keyClick(editor, Qt::Key_0);
    QTest::keyClick(editor, Qt::Key_Enter);
    QApplication::processEvents();

    QCOMPARE(index.data().toString(), QString("-10"));
}
Esempio n. 11
0
 void readConfig() {
     boost::shared_ptr<QSettings> settings = GetApplicationSettings();
     double tol = settings->value(GC_DPFG_TOLERANCE, "1.0").toDouble();
     double stop = settings->value(GC_DPFG_STOP, "1.0").toDouble();
     tolerance->setValue(tol);
     beerandburrito->setValue(stop);
 }
void LoanAssumptionDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
    if (!index.data(Qt::UserRole).isNull()) {
        switch (index.data(Qt::UserRole).toInt()) {
        case static_cast<qint8>(AssumptionType::DoubleAssumption) :
        case static_cast<qint8>(AssumptionType::DoubleAssumption0To100) : {
            QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor);
            spinBox->interpretText();
            model->setData(index, spinBox->value(), Qt::EditRole);
            break;
        }
        case static_cast<qint8>(AssumptionType::IntegerAssumption) : {
            QSpinBox *spinBox = qobject_cast<QSpinBox*>(editor);
            spinBox->interpretText();
            model->setData(index, spinBox->value(), Qt::EditRole);
            break;
        }
        case static_cast<qint8>(AssumptionType::BloombergVectorAssumption) :
        case static_cast<qint8>(AssumptionType::IntegerVectorAssumption) :
        case static_cast<qint8>(AssumptionType::DayCountVectorAssumption) :
            model->setData(index, qobject_cast<QLineEdit*>(editor)->text(), Qt::EditRole);
            break;
        default:
            model->setData(index, QVariant(), Qt::EditRole);
        }
    }
    else model->setData(index, QVariant(), Qt::EditRole);
}
Esempio n. 13
0
void
pcl::modeler::DoubleParameter::getEditorData(QWidget *editor)
{
  QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
  double value = spinBox->text().toDouble();
  current_value_ = value;
}
Esempio n. 14
0
bool ElacticMapAnalyzer::showDialog() {
    fillInputTableData();
    StatisticAnalyzeDialog *dialog = new StatisticAnalyzeDialog();
    dialog->SetDialogName(name);
    dialog->addAdditionalParam(new QSpinBox(), "Количество итераций");
    dialog->addAdditionalParam(new QSpinBox(), tr("P"));
    dialog->addAdditionalParam(new QSpinBox(), tr("Q"));
    QDoubleSpinBox* muSP = new QDoubleSpinBox();
    muSP->setMaximum(10000);
    dialog->addAdditionalParam(muSP, tr("Mu"));
    QDoubleSpinBox* lambdaSP = new QDoubleSpinBox();
    lambdaSP->setMaximum(10000);
    dialog->addAdditionalParam(lambdaSP, tr("Lambda"));

    QHashIterator<QString,QString> iterator(this->getAllParams());
    while (iterator.hasNext()) {
        iterator.next();
        dialog->addAviabledParam(iterator.value(), iterator.key());
    }
    dialog->exec();
    if (dialog->ParametersList->count()==0) {
        return false;
    }
    parametersList = dialog->ParametersList;
    p = dialog->GetIntParam("P");
    q = dialog->GetIntParam("Q");
    pq = p*q;
    iterations = dialog->GetIntParam("Количество итераций");
    lambda = dialog->GetDoubleParam("Lambda");
    mu = dialog->GetDoubleParam("Mu");
    return true;
}
Esempio n. 15
0
QWidget *OffersDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
  if (index.column() == 4 ) return QSqlRelationalDelegate::createEditor(parent, option, index);
  else {
    QWidget *editor = NULL;
    QDoubleSpinBox *dSpinbox = new QDoubleSpinBox(parent);
    QDateEdit      *dateEdit = new QDateEdit(parent);
    switch(index.column())
    {
      case 1: //discount
        editor = dSpinbox;
        dSpinbox->setMinimum(0);
        dSpinbox->setMaximum(99.99);
        dSpinbox->setSuffix(" %");
        break;
      case 2: //date
        editor  = dateEdit;
        break;
      case 3: //date
        editor  = dateEdit;
        break;
      default : //Never must be here...
        break;
    }
    return editor;
  }
}
Esempio n. 16
0
void DoubleDataInformationMethods::staticSetWidgetData(double value, QWidget* w)
{
    QDoubleSpinBox* spin = qobject_cast<QDoubleSpinBox*> (w);
    Q_CHECK_PTR(spin);
    if (spin)
        spin->setValue(value);
}
Esempio n. 17
0
void MainWindow::addSpinBoxes(bool checked, int count, Range range)
{
    if (checked) {
        QWidget *w = new QWidget(ui->quantifierValuesGroupBox);
        if (ui->quantifierValuesGroupBox->layout() == 0) {
            QHBoxLayout *hbl = new QHBoxLayout(ui->quantifierValuesGroupBox);
            ui->quantifierValuesGroupBox->setLayout(hbl);
        }
        ui->quantifierValuesGroupBox->layout()->addWidget(w);
        QFormLayout *fl = new QFormLayout(w);
        for (int i = 0; i < count; i++) {
            QAbstractSpinBox *asb;
            if (range == Absolute) {
                QSpinBox *sb = new QSpinBox(w);
                sb->setMinimum(0);
                sb->setMaximum(10000);
                asb = sb;
            } else {
                QDoubleSpinBox *sb = new QDoubleSpinBox(w);
                sb->setMinimum(0);
                sb->setMaximum(1);
                sb->setSingleStep(0.05);
                asb = sb;
            }
            fl->addRow(QString(QChar('A' + i)), asb);
        }
    } else {
        QLayout *fl = ui->quantifierValuesGroupBox->layout();
        if (fl != nullptr && fl->count() > 0) {
            QWidget *w = fl->takeAt(0)->widget();
            delete w;
            // there is no mem-leak here, qt handles qobject's children by itself
        }
    }
}
QDoubleSpinBox* RenderSettingsWindow::create_double_input(
    const string&           widget_key,
    const double            min,
    const double            max,
    const int               decimals,
    const double            step,
    const QString&          label)
{
    QDoubleSpinBox* spinbox =
        create_double_input(
            widget_key,
            min,
            max,
            decimals,
            step);

    const QString suffix = " " + label;
    spinbox->setSuffix(suffix);

    QString text;
    text.setNum(max, 'f', decimals);
    text.append(suffix);
    set_widget_width_for_text(spinbox, text, SpinBoxMargin, SpinBoxMinWidth);

    return spinbox;
}
Esempio n. 19
0
void FormXtcs::valeChanged(QWidget *obj){
    QSpinBox *spinbox = qobject_cast<QSpinBox *>(obj);
    if(spinbox){
        int val = spinbox->value();
        int index = spinbox->property("index").toInt();
        param->setData(QParam::SpaItemHd_Xtcs,index,val,FALSE);
        if((index == 11)||(index ==12))
            param->updataPivotal();
        if(14==index)
            pcomm->yajiaoTest(Md::POSFRONT,3,val); //shengke buchang
        if(15==index)
            pcomm->yajiaoTest(Md::POSREAR,3,val);  //shengke buchang
        return;
    }
    QDoubleSpinBox *doublespinbox = qobject_cast<QDoubleSpinBox *>(obj);
    if(doublespinbox){
        int val =qRound(doublespinbox->value()*10);
        int index = doublespinbox->property("index").toInt();
        param->setData(QParam::SpaItemHd_Xtcs,index,val,FALSE);
        if(index==5)
            param->updataPivotal();
        return;
    }
    QPushButton *pushbutton = qobject_cast<QPushButton *>(obj);
    if(pushbutton){
        int val =pushbutton->isChecked();
        int index = pushbutton->property("index").toInt();
        param->setData(QParam::SpaItemHd_Xtcs,index,val,FALSE);
        return;
    }

}
Esempio n. 20
0
QDoubleSpinBox* createDoubleSpinBox(QWidget* parent) {
    QDoubleSpinBox* box = new QDoubleSpinBox(parent);
    box->setDecimals(0);
    box->setRange(MIN_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES, MAX_UNUSED_MAX_SIZE / BYTES_PER_MEGABYTES);
    
    return box;
}
QWidget *DBFRedactorDelegate::createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
	const DBFRedactor::Field& field = m_redactor->field(index.column());
	switch (field.type) {
		case DBFRedactor::TYPE_DATE: {
			QDateEdit *edit = new QDateEdit(parent);
			edit->setCalendarPopup(true);
			return edit;
			break;
		}
		case DBFRedactor::TYPE_FLOAT: case DBFRedactor::TYPE_NUMERIC: {
			QDoubleSpinBox *edit = new QDoubleSpinBox(parent);
			edit->setDecimals(field.secondLenght);
			QString tempString;
			tempString.fill('9', field.firstLenght - 1);
			edit->setMinimum(tempString.toDouble() * (-1));
			tempString.fill('9', field.firstLenght);
			edit->setMaximum(tempString.toDouble());
			return edit;
			break;
		}
		default: {
			QLineEdit *edit = new QLineEdit(parent);
			edit->setMaxLength(field.firstLenght);
			return edit;
		}
	}
	return 0;
}
Esempio n. 22
0
void PropertiesRasterLayer::updateStretchValuesFromBand()
{
   RasterChannelType channel;

   // Get the current units and the default stretch values
   RegionUnits currentUnits;
   RegionUnits defaultUnits;
   double dDefaultLower = 0.0;
   double dDefaultUpper = 0.0;
   QDoubleSpinBox* pLowerSpin = NULL;
   QDoubleSpinBox* pUpperSpin = NULL;

   QComboBox* pCombo = dynamic_cast<QComboBox*>(sender());
   if (pCombo == mpGrayBandCombo)
   {
      channel = GRAY;
      defaultUnits = RasterLayer::getSettingGrayscaleStretchUnits();
      pLowerSpin = mpGrayLowerSpin;
      pUpperSpin = mpGrayUpperSpin;
   }
   else if (pCombo == mpRedBandCombo)
   {
      channel = RED;
      defaultUnits = RasterLayer::getSettingRedStretchUnits();
      pLowerSpin = mpRedLowerSpin;
      pUpperSpin = mpRedUpperSpin;
   }
   else if (pCombo == mpGreenBandCombo)
   {
      channel = GREEN;
      defaultUnits = RasterLayer::getSettingGreenStretchUnits();
      pLowerSpin = mpGreenLowerSpin;
      pUpperSpin = mpGreenUpperSpin;
   }
   else if (pCombo == mpBlueBandCombo)
   {
      channel = BLUE;
      defaultUnits = RasterLayer::getSettingBlueStretchUnits();
      pLowerSpin = mpBlueLowerSpin;
      pUpperSpin = mpBlueUpperSpin;
   }

   if ((pLowerSpin == NULL) || (pUpperSpin == NULL))
   {
      return;
   }

   currentUnits = getStretchUnits(channel);
   RasterLayerImp::getDefaultStretchValues(channel, dDefaultLower, dDefaultUpper);

   // Set the current stretch units to the default units
   setStretchUnits(channel, defaultUnits);

   // Set the current stretch values to the default values
   pLowerSpin->setValue(dDefaultLower);
   pUpperSpin->setValue(dDefaultUpper);

   // Set the current stretch units back to the previous units to update the stretch values
   setStretchUnits(channel, currentUnits);
}
Esempio n. 23
0
void EventDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                    const QModelIndex &index) const
{
    switch(index.column()) {
        case 0: {
            QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
            spinBox->interpretText();
            int value = spinBox->value();

            model->setData(index, value, Qt::EditRole);
            break;
        }

        case 1: {
            QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
            spinBox->interpretText();
            double value = spinBox->value();

            model->setData(index, value, Qt::EditRole);
            break;
        }

        case 2: {
            QComboBox *spinBox = static_cast<QComboBox*>(editor);
            QString value = spinBox->currentText();

            model->setData(index, value.toInt(), Qt::EditRole);
            break;
        }
    }
}
Esempio n. 24
0
void DataDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
                                const QModelIndex &index) const
{
    QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
    double value = spinBox->value();
    model->setData(index, value, Qt::EditRole);
}
Esempio n. 25
0
QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox*>(QStyledItemDelegate::createEditor(parent, option, index));
	w->setRange(min,max);
	w->setSingleStep(step);
	return w;
}
Esempio n. 26
0
void QmitkPropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{

  QVariant data = index.data(Qt::EditRole);
  QVariant displayData = index.data(Qt::DisplayRole);

  if(data.isValid())
  {
    if(data.type() == QVariant::Int)
    {
      QSpinBox* spinBox = qobject_cast<QSpinBox *>(editor);
      spinBox->setValue(data.toInt());
    }
    // see qt documentation. cast is correct, it would be obsolete if we
    // store doubles
    else if(static_cast<QMetaType::Type>(data.type()) == QMetaType::Float)
    {
      QDoubleSpinBox* spinBox = qobject_cast<QDoubleSpinBox *>(editor);
      spinBox->setValue(data.toDouble());
    }

    else if(data.type() == QVariant::StringList)
    {
      QComboBox* comboBox = qobject_cast<QComboBox *>(editor);
      QString displayString = displayData.value<QString>();
      comboBox->setCurrentIndex(comboBox->findData(displayString));
    }

    else
      return QStyledItemDelegate::setEditorData(editor, index);
  }
}
Esempio n. 27
0
/*! 
 * Makes a labeled spin box, with the label given by [text] to the left of the
 * box and right aligned to it, provided that [layout] is a horizontal layout 
 * box in which to place them.  (In a toolbar, [layout] can be NULL.)  
 * [minValue], [maxValue], and [step] are the  minimum, maximum, and step 
 * sizes for the spin box.  If [nDecimal] is non-zero, it creates and returns 
 * a QDoubleSpinBox with that number of decimal places.  It skips the label
 * if [text] is NULL.  The focus policy is set to ClickFocus.  Keyboard 
 * tracking is turned off.  If a pointer is supplied in the optional argument [labelPtr]
 * (which is NULL by default), it is returned with the label pointer.
 */
QAbstractSpinBox *diaLabeledSpin(int nDecimal, float minValue, float maxValue,
                                 float step, const char *text, QWidget *parent,
                                 QBoxLayout *layout, QLabel **labelPtr)
{
  QSpinBox *spin;
  QDoubleSpinBox *fspin;
  if (text) {
    QLabel *label = diaLabel(text, parent, layout);
    label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    if (labelPtr)
      *labelPtr = label;
  }
  if (nDecimal) {
    fspin = new QDoubleSpinBox(parent);
    fspin->setDecimals(nDecimal);
    fspin->setRange((double)minValue, (double)maxValue);
    fspin->setSingleStep((double)step);
    spin = (QSpinBox *)fspin;
  } else {
    spin = new QSpinBox(parent);
    spin->setRange(B3DNINT(minValue), B3DNINT(maxValue));
    spin->setSingleStep(B3DNINT(step));
  }
  if (layout)
    layout->addWidget(spin);
  spin->setFocusPolicy(Qt::ClickFocus);
  spin->setKeyboardTracking(false);
  return (QAbstractSpinBox *)spin;
}
Esempio n. 28
0
MultiSpinValueDialog::MultiSpinValueDialog(int count, QStringList strings,
										   int defValue, int min, int max,
										   QWidget *parent) :
	QDialog(parent),
	mStrings(strings)
{
	Q_ASSERT(count == strings.count());

	QVBoxLayout *vbl = new QVBoxLayout(this);
	QWidget *widget = new QWidget(this);
	vbl->addWidget(widget);

	QFormLayout *fl = new QFormLayout(widget);

	for (int i = 0; i < count; i++) {
		QDoubleSpinBox *spinner = new QDoubleSpinBox(this);
		QLabel *label = new QLabel(mStrings.at(i), this);
		mSpinners << spinner;
		mLabels << label;
		spinner->setMinimum(min);
		spinner->setMaximum(max);
		spinner->setValue(defValue);
		connect(spinner, SIGNAL(valueChanged(double)), this, SLOT(updateText(double)));
		updateText(spinner->value());
		fl->addRow(label, spinner);
	}

	QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
	connect(dbb, SIGNAL(accepted()), this, SLOT(accept()));
	connect(dbb, SIGNAL(rejected()), this, SLOT(reject()));
	vbl->addWidget(dbb);
}
Esempio n. 29
0
NLSynthesisWidget::NLSynthesisWidget(QWidget* parent, NLSynthesizer* synthesizer, TsOutputType outputType)
    : NLGLWidget(parent,synthesizer),
      _outputType(outputType)
{
    _controlWidget = new QWidget;
    _vizNormalize = true;
    _vizGain = 1.0;
    _vizMode = 0;

    if (outputType == TS_OUTPUT_RESIDUAL ||
            outputType == TS_OUTPUT_VEL_F ||
            outputType == TS_OUTPUT_VEL_B) {
        QHBoxLayout* layout = new QHBoxLayout;
        QCheckBox* normalize = new QCheckBox("Normalize");
        QDoubleSpinBox* gain = new QDoubleSpinBox();

        gain->setValue(1.0);
        gain->setSingleStep(0.1);
        normalize->setChecked(true);

        layout->addWidget(normalize,1,Qt::AlignRight);
        layout->addWidget(new QLabel("Gain"),0,Qt::AlignRight);
        layout->addWidget(gain,0,Qt::AlignLeft);

        connect(normalize, SIGNAL(stateChanged(int)), this, SLOT(vizNormalizeChanged(int)));
        connect(gain, SIGNAL(valueChanged(double)), this, SLOT(vizGainChanged(double)));
        _controlWidget->setLayout(layout);
    } else if (outputType == TS_OUTPUT_OFFSET ||
Esempio n. 30
0
void FilletRadiusDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
    double value = index.model()->data(index, Qt::EditRole).toDouble();

    QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(editor);
    spinBox->setValue(value);
}