inline QString CSVLogger::buildLogLine(QVariantList const& data){ QString line = ""; //Timestamp if(logTime){ if(logMillis) line += QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss.zzz"); else line += QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"); } //Rest of data if(data.size() != header.size()) qWarning() << "CSVLogger::buildLogLine(): Data and header don't have the same length, log file will not be correct."; if(data.size() > 0){ if(logTime) line += ", "; QVariant datum = data.at(0); line += (datum.type() == QVariant::Double ? QString::number(datum.toReal(), 'f', precision) : datum.toString()); } for(int i = 1; i < data.size(); i++){ QVariant datum = data.at(i); line += ", " + (datum.type() == QVariant::Double ? QString::number(datum.toReal(), 'f', precision) : datum.toString()); } return line; }
bool CameraBinExposure::setExposureParameter(ExposureParameter parameter, const QVariant& value) { QVariant oldValue = exposureParameter(parameter); switch (parameter) { case QCameraExposureControl::ExposureCompensation: gst_photography_set_ev_compensation(m_session->photography(), value.toReal()); break; case QCameraExposureControl::ISO: gst_photography_set_iso_speed(m_session->photography(), value.toInt()); break; case QCameraExposureControl::Aperture: gst_photography_set_aperture(m_session->photography(), guint(value.toReal()*1000000)); break; case QCameraExposureControl::ShutterSpeed: gst_photography_set_exposure(m_session->photography(), guint(value.toReal()*1000000)); break; default: return false; } QVariant newValue = exposureParameter(parameter); if (!qFuzzyCompare(oldValue.toReal(), newValue.toReal())) emit exposureParameterChanged(parameter); return true; }
void GraphicsComponent::setProperty(const QString &name, const QVariant &value) { if (name == "x") { this->setX(value.toReal()); } else if (name == "y") { this->setY(value.toReal()); } else if (name == "angle") { this->setRotation(value.toDouble()); } Component::setProperty(name, value); }
QRectF LinearChart::itemRect( const QModelIndex& index ) const { QRect r; Marb::Types t = this->columnType( index.column() ); QVariant var = index.data(); if ( !var.isValid() ) { return QRect(0,0,1,1); } qreal value = var.toReal(); qreal y = this->valueToPx(value); qreal x = myOrigin.x() + index.row() * myX; qreal space = myX * 0.1; if ( t == Marb::Bar ) { QList<int> bars = this->barStyleColumns(); qreal w = myX / bars.count(); x += w * /*index.column()*/ bars.indexOf( index.column() ); QPoint tl = QPoint( x + space/2, y ); // top left QPoint br = QPoint( x + w, myOrigin.y() ); // bottom right r = QRect( tl, br ); if ( value < 0 ) { r.translate( 0, 1 ); } else { r.translate( 0, -2 ); } } else { r = QRect( -5, -5, 10 ,10 ).translated( x + myX/2, y ); } return r.normalized(); }
QString FillCellHelper::displayText( const QVariant& value ) const { QLocale locale; // in QStyledItemDelegate this is configurable, it comes from QWidget::locale()... QString text; switch (value.userType()) { case QMetaType::Float: case QVariant::Double: text = locale.toString(value.toReal()); break; case QVariant::Int: case QVariant::LongLong: text = locale.toString(value.toLongLong()); break; case QVariant::UInt: case QVariant::ULongLong: text = locale.toString(value.toULongLong()); break; case QVariant::Date: text = locale.toString(value.toDate(), QLocale::ShortFormat); break; case QVariant::Time: text = locale.toString(value.toTime(), QLocale::ShortFormat); break; case QVariant::DateTime: text = locale.toString(value.toDateTime().date(), QLocale::ShortFormat); text += QLatin1Char(' '); text += locale.toString(value.toDateTime().time(), QLocale::ShortFormat); break; default: text = value.toString(); break; } return text; }
bool LayerTree::setData(const QModelIndex& index, const QVariant& value, int role) { if ( !index.isValid() || !document_ ) return false; Layer* layer = static_cast<Layer*>(index.internalPointer()); if ( role == Qt::DisplayRole || role == Qt::EditRole ) { switch ( index.column() ) { case Name: layer->setName(value.toString()); return true; case Visible: layer->setVisible(value.toBool()); return true; case Locked: layer->setLocked(value.toBool()); return true; case Opacity: layer->setOpacity(value.toReal()); return true; case BlendMode: layer->setBlendMode(QPainter::CompositionMode(value.toInt())); return true; case BackgroundColor: layer->setBackgroundColor(value.value<QColor>()); return true; } } return false; }
void CameraBinV4LImageProcessing::setParameter( ProcessingParameter parameter, const QVariant &value) { QMap<ProcessingParameter, SourceParameterValueInfo>::const_iterator sourceValueInfo = m_parametersInfo.constFind(parameter); if (sourceValueInfo == m_parametersInfo.constEnd()) { qWarning() << "Unable to set the parameter value: the parameter is not supported."; return; } const QString deviceName = m_session->device(); const int fd = qt_safe_open(deviceName.toLocal8Bit().constData(), O_WRONLY); if (fd == -1) { qWarning() << "Unable to open the camera" << deviceName << "for write to set the parameter value:" << qt_error_string(errno); return; } struct v4l2_control control; ::memset(&control, 0, sizeof(control)); control.id = (*sourceValueInfo).cid; switch (parameter) { case QCameraImageProcessingControl::WhiteBalancePreset: { const QCameraImageProcessing::WhiteBalanceMode m = value.value<QCameraImageProcessing::WhiteBalanceMode>(); if (m != QCameraImageProcessing::WhiteBalanceAuto && m != QCameraImageProcessing::WhiteBalanceManual) { qt_safe_close(fd); return; } control.value = (m == QCameraImageProcessing::WhiteBalanceAuto) ? true : false; } break; case QCameraImageProcessingControl::ColorTemperature: control.value = value.toInt(); break; case QCameraImageProcessingControl::ContrastAdjustment: // falling back case QCameraImageProcessingControl::SaturationAdjustment: // falling back case QCameraImageProcessingControl::BrightnessAdjustment: // falling back case QCameraImageProcessingControl::SharpeningAdjustment: control.value = sourceImageProcessingParameterValue( value.toReal(), (*sourceValueInfo)); break; default: qt_safe_close(fd); return; } if (::ioctl(fd, VIDIOC_S_CTRL, &control) != 0) qWarning() << "Unable to set the parameter value:" << qt_error_string(errno); qt_safe_close(fd); }
qreal SettingsPrivate::bigCoverOpacity() const { QVariant vOpacity = value("bigCoverOpacity"); if (vOpacity.isNull()) { return 0.66; } else { return vOpacity.toReal(); } }
qreal BooksListWatcher::getRealProperty(const char *name, qreal defaultValue) { QVariant value = iListView->property(name); bool ok = false; if (value.isValid()) { ok = false; qreal r = value.toReal(&ok); if (ok) return r; } return defaultValue; }
KisKeyframeSP KisScalarKeyframeChannel::loadKeyframe(const QDomElement &keyframeNode) { int time = keyframeNode.toElement().attribute("time").toUInt(); QVariant value = keyframeNode.toElement().attribute("value"); KUndo2Command tempParentCommand; KisKeyframeSP keyframe = createKeyframe(time, KisKeyframeSP(), &tempParentCommand); setScalarValue(keyframe, value.toReal()); return keyframe; }
void AudioPlayer::configChanged(QString key, QVariant value) { if (key == "playback.replaygain") replaygain_ = replayGainFromString(value.toString()); else if (key == "playback.replaygain.preamp_with_rg") preamp_with_rg_ = value.toReal(); else if (key == "playback.enqueue.onlyOnce") queue_.setEnqueueOnlyOnce(value.toBool()); else if (key == "library.length_hack") lengthHack_ = value.toBool(); }
bool CameraBinV4LImageProcessing::isParameterValueSupported( ProcessingParameter parameter, const QVariant &value) const { QMap<ProcessingParameter, SourceParameterValueInfo>::const_iterator sourceValueInfo = m_parametersInfo.constFind(parameter); if (sourceValueInfo == m_parametersInfo.constEnd()) return false; switch (parameter) { case QCameraImageProcessingControl::WhiteBalancePreset: { const QCameraImageProcessing::WhiteBalanceMode checkedValue = value.value<QCameraImageProcessing::WhiteBalanceMode>(); const QCameraImageProcessing::WhiteBalanceMode firstAllowedValue = (*sourceValueInfo).minimumValue ? QCameraImageProcessing::WhiteBalanceAuto : QCameraImageProcessing::WhiteBalanceManual; const QCameraImageProcessing::WhiteBalanceMode secondAllowedValue = (*sourceValueInfo).maximumValue ? QCameraImageProcessing::WhiteBalanceAuto : QCameraImageProcessing::WhiteBalanceManual; if (checkedValue != firstAllowedValue && checkedValue != secondAllowedValue) { return false; } } break; case QCameraImageProcessingControl::ColorTemperature: { const qint32 checkedValue = value.toInt(); if (checkedValue < (*sourceValueInfo).minimumValue || checkedValue > (*sourceValueInfo).maximumValue) { return false; } } break; case QCameraImageProcessingControl::ContrastAdjustment: // falling back case QCameraImageProcessingControl::SaturationAdjustment: // falling back case QCameraImageProcessingControl::BrightnessAdjustment: // falling back case QCameraImageProcessingControl::SharpeningAdjustment: { const qint32 sourceValue = sourceImageProcessingParameterValue( value.toReal(), (*sourceValueInfo)); if (sourceValue < (*sourceValueInfo).minimumValue || sourceValue > (*sourceValueInfo).maximumValue) { return false; } } break; default: return false; } return true; }
QVariant RobotItem::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionHasChanged) { mRobotModel.setPosition(value.value<QPointF>()); } if (change == ItemRotationHasChanged) { mRobotModel.setRotation(value.toReal()); } return RotateItem::itemChange(change, value); }
bool CameraBinImageProcessing::isParameterValueSupported(QCameraImageProcessingControl::ProcessingParameter parameter, const QVariant &value) const { switch (parameter) { case ContrastAdjustment: case BrightnessAdjustment: case SaturationAdjustment: { const bool isGstColorBalanceValueSupported = GST_IS_COLOR_BALANCE(m_session->cameraBin()) && qAbs(value.toReal()) <= 1.0; #ifdef USE_V4L if (!isGstColorBalanceValueSupported) return m_v4lImageControl->isParameterValueSupported(parameter, value); #endif return isGstColorBalanceValueSupported; } case SharpeningAdjustment: { #ifdef USE_V4L return m_v4lImageControl->isParameterValueSupported(parameter, value); #else return false; #endif } case WhiteBalancePreset: { const QCameraImageProcessing::WhiteBalanceMode mode = value.value<QCameraImageProcessing::WhiteBalanceMode>(); const bool isPhotographyWhiteBalanceSupported = isWhiteBalanceModeSupported(mode); #ifdef USE_V4L if (!isPhotographyWhiteBalanceSupported) return m_v4lImageControl->isParameterValueSupported(parameter, value); #endif return isPhotographyWhiteBalanceSupported; } case ColorTemperature: { #ifdef USE_V4L return m_v4lImageControl->isParameterValueSupported(parameter, value); #else return false; #endif } case ColorFilter: { const QCameraImageProcessing::ColorFilter filter = value.value<QCameraImageProcessing::ColorFilter>(); #ifdef HAVE_GST_PHOTOGRAPHY return m_filterMap.contains(filter); #else return filter == QCameraImageProcessing::ColorFilterNone; #endif } default: break; } return false; }
void ChartsTimeGraph::graphDataInserted( QDateTime d, QVariant v ) { // qDebug() << "CPP inserted(): d=" << d.toMSecsSinceEpoch() << " v=" << v; if ( _lineSeries1 != nullptr ) { QVector<QPointF> points = _lineSeries1->pointsVector(); auto point = std::lower_bound( points.begin(), points.end(), QPointF( d.toMSecsSinceEpoch(), 0. ), [&](QPointF l, QPointF r) -> bool { return l.x() < r.x(); } ); if ( point != points.end() ) { int pointIndex = point - points.begin(); if ( pointIndex >= 0 && pointIndex < points.size() ) _lineSeries1->insert( pointIndex, QPointF( d.toMSecsSinceEpoch(), v.toReal() ) ); else { // Error or unknown behaviour graphDataUpdated(); return; } } else _lineSeries1->append( d.toMSecsSinceEpoch(), v.toReal() ); updateTimeAxis( _lineSeries1 ); updateValueAxis( _lineSeries1 ); } }
void CameraBinImageProcessing::setParameter(QCameraImageProcessingControl::ProcessingParameter parameter, const QVariant &value) { switch (parameter) { case ContrastAdjustment: setColorBalanceValue("contrast", value.toReal()); break; case BrightnessAdjustment: setColorBalanceValue("brightness", value.toReal()); break; case SaturationAdjustment: setColorBalanceValue("saturation", value.toReal()); break; case WhiteBalancePreset: setWhiteBalanceMode(value.value<QCameraImageProcessing::WhiteBalanceMode>()); break; case QCameraImageProcessingControl::ColorFilter: #ifdef HAVE_GST_PHOTOGRAPHY if (GstPhotography *photography = m_session->photography()) { #if GST_CHECK_VERSION(1, 0, 0) gst_photography_set_color_tone_mode(photography, m_filterMap.value( value.value<QCameraImageProcessing::ColorFilter>(), GST_PHOTOGRAPHY_COLOR_TONE_MODE_NORMAL)); #else gst_photography_set_colour_tone_mode(photography, m_filterMap.value( value.value<QCameraImageProcessing::ColorFilter>(), GST_PHOTOGRAPHY_COLOUR_TONE_MODE_NORMAL)); #endif } #endif break; default: break; } updateColorBalanceValues(); }
bool Bend::setProperty(Pid id, const QVariant& v) { switch (id) { case Pid::FONT_FACE: _fontFace = v.toString(); break; case Pid::FONT_SIZE: _fontSize = v.toReal(); break; case Pid::FONT_STYLE: _fontStyle = FontStyle(v.toInt()); break; case Pid::PLAY: setPlayBend(v.toBool()); break; case Pid::LINE_WIDTH: _lineWidth = v.toReal(); break; default: return Element::setProperty(id, v); } triggerLayout(); return true; }
int EnvironmentalReverb::effectParameterChanged(const EffectParameter ¶m, const QVariant &value) { const qreal externalLevel = value.toReal(); const int internalLevel = param.toInternalValue(externalLevel); TInt err = 0; switch(param.id()) { case DecayHFRatio: TRAP(err, concreteEffect()->SetDecayHFRatioL(internalLevel)); break; case DecayTime: TRAP(err, concreteEffect()->SetDecayTimeL(internalLevel)); break; case Density: TRAP(err, concreteEffect()->SetDensityL(internalLevel)); break; case Diffusion: TRAP(err, concreteEffect()->SetDiffusionL(internalLevel)); break; case ReflectionsDelay: TRAP(err, concreteEffect()->SetReflectionsDelayL(internalLevel)); break; case ReflectionsLevel: TRAP(err, concreteEffect()->SetReflectionsLevelL(internalLevel)); break; case ReverbDelay: TRAP(err, concreteEffect()->SetReverbDelayL(internalLevel)); break; case ReverbLevel: TRAP(err, concreteEffect()->SetReverbLevelL(internalLevel)); break; case RoomHFLevel: TRAP(err, concreteEffect()->SetRoomHFLevelL(internalLevel)); break; case RoomLevel: TRAP(err, concreteEffect()->SetRoomLevelL(internalLevel)); break; default: Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown parameter"); } return err; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); timer = new QTimer(); connect(ui->btnToggleKeepalive, SIGNAL(toggled(bool)), this, SLOT(toggleKeepalive(bool))); connect(ui->btnToggleAfk, SIGNAL(toggled(bool)), this, SLOT(toggleAfk(bool))); connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(togliBlank(bool))); connect(timer, SIGNAL(timeout()), this, SLOT(doKeepalive())); connect(ui->btnZoomIn, SIGNAL(clicked()), this, SLOT(btnZoomInClicked())); connect(ui->btnZoomOut, SIGNAL(clicked()), this, SLOT(btnZoomOutClicked())); connect(ui->btnRula, SIGNAL(clicked()), this, SLOT(btnRulaClicked())); connect(ui->btnList, SIGNAL(clicked()), this, SLOT(btnListClicked())); connect(ui->btnMove, SIGNAL(clicked()), this, SLOT(btnMoveClicked())); connect(ui->btnSkipKeepalive, SIGNAL(clicked()), this, SLOT(btnSkipClicked())); ui->btnToggleKeepalive->hide(); ui->statusBar->hide(); // applicationSettings = new QSettings("iccanobif", "idlepoi"); applicationSettings = new QSettings("idlepoi.ini", QSettings::IniFormat); ui->webView->setPage(new GikopoiWebPage()); QVariant zoomFactor = applicationSettings->value("zoomFactor"); if (!zoomFactor.isNull()) ui->webView->setZoomFactor(zoomFactor.toReal()); QVariant keepAliveDelay = applicationSettings->value("keepAliveDelay"); if (!keepAliveDelay.isNull()) this->keepAliveDelay = keepAliveDelay.toInt(); else { applicationSettings->setValue("keepAliveDelay", DEFAULT_KEEPALIVE_DELAY); this->keepAliveDelay = DEFAULT_KEEPALIVE_DELAY; } toggleKeepalive(true); }
void QgsCompassPluginGui::handleAzimuth( const QVariant &azimuth, const QVariant &calLevel ) { this->mAzimutDisplay->setText( QString( "%1" ).arg( azimuth.toInt() ) + QString::fromUtf8( "°" ) ); //TODO check when https://sourceforge.net/p/necessitas/tickets/153/ is fixed qreal calibrationLevel = calLevel.toReal() / 3; if ( calibrationLevel == 1 ) { this->mCalibrationLabel->setStyleSheet( "Background-color:green" ); } else if ( calibrationLevel <= 1 / 3 ) { this->mCalibrationLabel->setStyleSheet( "Background-color:red" ); this->mWarningLabel->setText( "<font color='red'><a href='http://www.youtube.com/watch?v=oNJJPeoG8lQ'>Compass calibration</a> needed</font>" ); } else { this->mCalibrationLabel->setStyleSheet( "Background-color:yellow" ); } rotatePixmap( this->mArrowPixmapLabel, QString( ":/images/north_arrows/default.png" ), -azimuth.toInt() ); }
bool CameraBinImageProcessing::isParameterValueSupported(QCameraImageProcessingControl::ProcessingParameter parameter, const QVariant &value) const { switch (parameter) { case ContrastAdjustment: case BrightnessAdjustment: case SaturationAdjustment: return GST_IS_COLOR_BALANCE(m_session->cameraBin()) && qAbs(value.toReal()) <= 1.0; case WhiteBalancePreset: return isWhiteBalanceModeSupported(value.value<QCameraImageProcessing::WhiteBalanceMode>()); case ColorFilter: { const QCameraImageProcessing::ColorFilter filter = value.value<QCameraImageProcessing::ColorFilter>(); #ifdef HAVE_GST_PHOTOGRAPHY return m_filterMap.contains(filter); #else return filter == QCameraImageProcessing::ColorFilterNone; #endif } default: break; } return false; }
QWidget* PropertyEditor::buildUi(QObject *obj) { if (mMetaProperties.isEmpty()) return 0; QWidget *w = new QWidget(); QGridLayout *gl = new QGridLayout(); w->setLayout(gl); int row = 0; QVariant value; foreach (QMetaProperty mp, mMetaProperties) { if (qstrcmp(mp.name(), "objectName") == 0) continue; value = mProperties[QString::fromLatin1(mp.name())]; if (mp.isEnumType()) { if (mp.isFlagType()) { gl->addWidget(createWidgetForFlags(QString::fromLatin1(mp.name()), value, mp.enumerator(), obj ? obj->property(QByteArray("detail_").append(mp.name()).constData()).toString() : QString()), row, 0, Qt::AlignLeft | Qt::AlignVCenter); } else { gl->addWidget(new QLabel(QObject::tr(mp.name())), row, 0, Qt::AlignRight | Qt::AlignVCenter); gl->addWidget(createWidgetForEnum(QString::fromLatin1(mp.name()), value, mp.enumerator(), obj ? obj->property(QByteArray("detail_").append(mp.name()).constData()).toString() : QString()), row, 1, Qt::AlignLeft | Qt::AlignVCenter); } } else if (mp.type() == QVariant::Int || mp.type() == QVariant::UInt || mp.type() == QVariant::LongLong || mp.type() == QVariant::ULongLong){ gl->addWidget(new QLabel(QObject::tr(mp.name())), row, 0, Qt::AlignRight | Qt::AlignVCenter); gl->addWidget(createWidgetForInt(QString::fromLatin1(mp.name()), value.toInt(), obj ? obj->property(QByteArray("detail_").append(mp.name()).constData()).toString() : QString()), row, 1, Qt::AlignLeft | Qt::AlignVCenter); } else if (mp.type() == QVariant::Double) { gl->addWidget(new QLabel(QObject::tr(mp.name())), row, 0, Qt::AlignRight | Qt::AlignVCenter); gl->addWidget(createWidgetForReal(QString::fromLatin1(mp.name()), value.toReal(), obj ? obj->property(QByteArray("detail_").append(mp.name()).constData()).toString() : QString()), row, 1, Qt::AlignLeft | Qt::AlignVCenter); } else if (mp.type() == QVariant::Bool) { gl->addWidget(createWidgetForBool(QString::fromLatin1(mp.name()), value.toBool(), obj ? obj->property(QByteArray("detail_").append(mp.name()).constData()).toString() : QString()), row, 0, 1, 2, Qt::AlignLeft); } else { gl->addWidget(new QLabel(QObject::tr(mp.name())), row, 0, Qt::AlignRight | Qt::AlignVCenter); gl->addWidget(createWidgetForText(QString::fromLatin1(mp.name()), value.toString(), !mp.isWritable(), obj ? obj->property(QByteArray("detail_").append(mp.name()).constData()).toString() : QString()), row, 1, Qt::AlignLeft | Qt::AlignVCenter); } ++row; } return w; }
QString PropertyField::valueToString(QVariant val) { QString text; switch (val.type()) { case QVariant::Double: text = QString("%1").arg(val.toReal(), 0, 'f', 4); break; case QVariant::Size: text = QString("%1 x %2").arg(val.toSize().width()).arg(val.toSize().height()); break; case QVariant::SizeF: text = QString("%1 x %2").arg(val.toSizeF().width()).arg(val.toSizeF().height()); break; case QVariant::Rect: { QRect rect = val.toRect(); text = QString("%1 x %2 %3%4 %5%6").arg(rect.width()) .arg(rect.height()).arg(rect.x() < 0 ? "" : "+").arg(rect.x()) .arg(rect.y() < 0 ? "" : "+").arg(rect.y()); } break; default: text = val.toString(); } return text; }
void AnemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { DEBUG_FUNC_NAME QComboBox *combo; QDoubleSpinBox *dspin; QLineEdit *ledit; QLabel *label; QString currentModel = index.model()->data(index.model()->index(AnemModel::MODEL, index.column())).toString(); QVariant value = index.model()->data(index, Qt::EditRole); // different kind of editor for each row switch (index.row()) { case AnemModel::MANUFACTURER: case AnemModel::MODEL: case AnemModel::WINDFORMAT: case AnemModel::NORTHALIGNMENT: combo = static_cast<QComboBox*>(editor); if (!combo) { return; } combo->setCurrentIndex(combo->findText(value.toString())); break; case AnemModel::ID: ledit = static_cast<QLineEdit*>(editor); if (!ledit) { return; } ledit->setText(value.toString()); break; case AnemModel::HEIGHT: case AnemModel::NORTHOFFSET: dspin = static_cast<QDoubleSpinBox*>(editor); if (!dspin) { return; } dspin->setValue(value.toReal()); break; case AnemModel::VPATHLENGTH: case AnemModel::HPATHLENGTH: case AnemModel::TAU: if (currentModel != AnemDesc::getANEM_MODEL_STRING_12()) { label = static_cast<QLabel*>(editor); if (!label) { return; } } else { dspin = static_cast<QDoubleSpinBox*>(editor); if (!dspin) { return; } dspin->setValue(value.toReal()); } break; case AnemModel::ESEPARATION: case AnemModel::VSEPARATION: case AnemModel::NSEPARATION: if (index.column() == 0) { label = static_cast<QLabel*>(editor); if (!label) { return; } } else { dspin = static_cast<QDoubleSpinBox*>(editor); if (!dspin) { return; } dspin->setValue(value.toReal()); } break; default: QItemDelegate::setEditorData(editor, index); break; } }
void QKineticScroller::setScrollMetric(ScrollMetric metric, const QVariant &value) { Q_D(QKineticScroller); switch (metric) { case DragVelocitySmoothingFactor: d->dragVelocitySmoothingFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; case LinearDecelerationFactor: d->linearDecelerationFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; case ExponentialDecelerationBase: d->exponentialDecelerationBase = qBound(qreal(0), value.toReal(), qreal(1)); break; case OvershootSpringConstant: d->overshootSpringConstantRoot = qSqrt(value.toReal()); break; case OvershootDragResistanceFactor: d->overshootDragResistanceFactor = value.toReal(); break; case OvershootMaximumDistance: d->overshootMaximumDistance = value.toPointF(); break; case DragStartDistance: d->dragStartDistance = value.toReal(); break; case DragStartDirectionErrorMargin: d->dragStartDirectionErrorMargin = value.toReal(); break; case MinimumVelocity: d->minimumVelocity = value.toReal(); break; case MaximumVelocity: d->maximumVelocity = value.toReal(); break; case MaximumNonAcceleratedVelocity: d->maximumNonAcceleratedVelocity = value.toReal(); break; case MaximumClickThroughVelocity: d->maximumClickThroughVelocity = value.toReal(); break; case AxisLockThreshold: d->axisLockThreshold = qBound(qreal(0), value.toReal(), qreal(1)); break; case FramesPerSecond: d->framesPerSecond = qBound(1, value.toInt(), 100); break; case FastSwipeMaximumTime: d->fastSwipeMaximumTime = value.toReal(); break; case FastSwipeMinimumVelocity: d->fastSwipeMinimumVelocity = value.toReal(); break; case FastSwipeBaseVelocity: d->fastSwipeBaseVelocity = value.toReal(); break; case ScrollMetricCount: break; } }
void StatusBarItemGroup::slotOverlayAnimValueChanged(const QVariant& value) { qreal opacity = value.toReal(); if(m_menuObj) m_menuObj->setOpacity(opacity); }
/*! Set a specific value of the \a metric ScrollerMetric to \a value. \sa scrollMetric(), ScrollMetric */ void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &value) { switch (metric) { case MousePressEventDelay: d->mousePressEventDelay = value.toReal(); break; case DragStartDistance: d->dragStartDistance = value.toReal(); break; case DragVelocitySmoothingFactor: d->dragVelocitySmoothingFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; case AxisLockThreshold: d->axisLockThreshold = qBound(qreal(0), value.toReal(), qreal(1)); break; case ScrollingCurve: d->scrollingCurve = value.toEasingCurve(); break; case DecelerationFactor: d->decelerationFactor = value.toReal(); break; case MinimumVelocity: d->minimumVelocity = value.toReal(); break; case MaximumVelocity: d->maximumVelocity = value.toReal(); break; case MaximumClickThroughVelocity: d->maximumClickThroughVelocity = value.toReal(); break; case AcceleratingFlickMaximumTime: d->acceleratingFlickMaximumTime = value.toReal(); break; case AcceleratingFlickSpeedupFactor:d->acceleratingFlickSpeedupFactor = value.toReal(); break; case SnapPositionRatio: d->snapPositionRatio = qBound(qreal(0), value.toReal(), qreal(1)); break; case SnapTime: d->snapTime = value.toReal(); break; case OvershootDragResistanceFactor: d->overshootDragResistanceFactor = value.toReal(); break; case OvershootDragDistanceFactor: d->overshootDragDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; case OvershootScrollDistanceFactor: d->overshootScrollDistanceFactor = qBound(qreal(0), value.toReal(), qreal(1)); break; case OvershootScrollTime: d->overshootScrollTime = value.toReal(); break; case HorizontalOvershootPolicy: d->hOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break; case VerticalOvershootPolicy: d->vOvershootPolicy = value.value<QScrollerProperties::OvershootPolicy>(); break; case FrameRate: d->frameRate = value.value<QScrollerProperties::FrameRates>(); break; case ScrollMetricCount: break; } }
bool QTAIMWavefunction::initializeWithMoleculeProperties( Molecule*& mol ) { if( mol->property( "QTAIMNumberOfMolecularOrbitals" ).isValid() ) { QVariant numberOfMolecularOrbitalsVariant = mol->property( "QTAIMNumberOfMolecularOrbitals" ); m_numberOfMolecularOrbitals=numberOfMolecularOrbitalsVariant.toLongLong(); QVariant numberOfGaussianPrimitivesVariant = mol->property( "QTAIMNumberOfGaussianPrimitives" ); m_numberOfGaussianPrimitives=numberOfGaussianPrimitivesVariant.toLongLong(); QVariant numberOfNucleiVariant = mol->property( "QTAIMNumberOfNuclei" ); m_numberOfNuclei=numberOfNucleiVariant.toLongLong(); QVariant xNuclearCoordinatesVariant = mol->property( "QTAIMXNuclearCoordinates"); QVariant yNuclearCoordinatesVariant = mol->property( "QTAIMYNuclearCoordinates"); QVariant zNuclearCoordinatesVariant = mol->property( "QTAIMZNuclearCoordinates"); QVariant nuclearChargesVariant = mol->property( "QTAIMNuclearCharges" ); QVariantList xNuclearCoordinatesVariantList = xNuclearCoordinatesVariant.toList(); QVariantList yNuclearCoordinatesVariantList = yNuclearCoordinatesVariant.toList(); QVariantList zNuclearCoordinatesVariantList = zNuclearCoordinatesVariant.toList(); QVariantList nuclearChargesVariantList = nuclearChargesVariant.toList(); QList<qreal> xNuclearCoordinatesList; QList<qreal> yNuclearCoordinatesList; QList<qreal> zNuclearCoordinatesList; QList<qint64> nuclearChargesList; for( qint64 i=0 ; i < m_numberOfNuclei ; ++i ) { xNuclearCoordinatesList.append( xNuclearCoordinatesVariantList.at(i).toReal() ); yNuclearCoordinatesList.append( yNuclearCoordinatesVariantList.at(i).toReal() ); zNuclearCoordinatesList.append( zNuclearCoordinatesVariantList.at(i).toReal() ); nuclearChargesList.append( nuclearChargesVariantList.at(i).toLongLong() ); } m_xNuclearCoordinates=xNuclearCoordinatesList.toVector(); m_yNuclearCoordinates=yNuclearCoordinatesList.toVector(); m_zNuclearCoordinates=zNuclearCoordinatesList.toVector(); m_nuclearCharges=nuclearChargesList.toVector(); QVariant xGaussianPrimitiveCenterCoordinatesVariant = mol->property( "QTAIMXGaussianPrimitiveCenterCoordinates" ); QVariant yGaussianPrimitiveCenterCoordinatesVariant = mol->property( "QTAIMYGaussianPrimitiveCenterCoordinates" ); QVariant zGaussianPrimitiveCenterCoordinatesVariant = mol->property( "QTAIMZGaussianPrimitiveCenterCoordinates" ); QVariant xGaussianPrimitiveAngularMomentaVariant = mol->property( "QTAIMXGaussianPrimitiveAngularMomenta" ); QVariant yGaussianPrimitiveAngularMomentaVariant = mol->property( "QTAIMYGaussianPrimitiveAngularMomenta" ); QVariant zGaussianPrimitiveAngularMomentaVariant = mol->property( "QTAIMZGaussianPrimitiveAngularMomenta" ); QVariant gaussianPrimitiveExponentCoefficientsVariant = mol->property( "QTAIMGaussianPrimitiveExponentCoefficients" ); QVariantList xGaussianPrimitiveCenterCoordinatesVariantList = xGaussianPrimitiveCenterCoordinatesVariant.toList(); QVariantList yGaussianPrimitiveCenterCoordinatesVariantList = yGaussianPrimitiveCenterCoordinatesVariant.toList(); QVariantList zGaussianPrimitiveCenterCoordinatesVariantList = zGaussianPrimitiveCenterCoordinatesVariant.toList(); QVariantList xGaussianPrimitiveAngularMomentaVariantList = xGaussianPrimitiveAngularMomentaVariant.toList(); QVariantList yGaussianPrimitiveAngularMomentaVariantList = yGaussianPrimitiveAngularMomentaVariant.toList(); QVariantList zGaussianPrimitiveAngularMomentaVariantList = zGaussianPrimitiveAngularMomentaVariant.toList(); QVariantList gaussianPrimitiveExponentCoefficientsVariantList = gaussianPrimitiveExponentCoefficientsVariant.toList(); QList<qreal> xGaussianPrimitiveCenterCoordinatesList; QList<qreal> yGaussianPrimitiveCenterCoordinatesList; QList<qreal> zGaussianPrimitiveCenterCoordinatesList; QList<qint64> xGaussianPrimitiveAngularMomentaList; QList<qint64> yGaussianPrimitiveAngularMomentaList; QList<qint64> zGaussianPrimitiveAngularMomentaList; QList<qreal> gaussianPrimitiveExponentCoefficientsList; for( qint64 p=0 ; p < m_numberOfGaussianPrimitives ; ++p ) { xGaussianPrimitiveCenterCoordinatesList.append(xGaussianPrimitiveCenterCoordinatesVariantList.at(p).toReal()); yGaussianPrimitiveCenterCoordinatesList.append(yGaussianPrimitiveCenterCoordinatesVariantList.at(p).toReal()); zGaussianPrimitiveCenterCoordinatesList.append(zGaussianPrimitiveCenterCoordinatesVariantList.at(p).toReal()); xGaussianPrimitiveAngularMomentaList.append(xGaussianPrimitiveAngularMomentaVariantList.at(p).toLongLong()); yGaussianPrimitiveAngularMomentaList.append(yGaussianPrimitiveAngularMomentaVariantList.at(p).toLongLong()); zGaussianPrimitiveAngularMomentaList.append(zGaussianPrimitiveAngularMomentaVariantList.at(p).toLongLong()); gaussianPrimitiveExponentCoefficientsList.append(gaussianPrimitiveExponentCoefficientsVariantList.at(p).toReal()); } m_xGaussianPrimitiveCenterCoordinates=xGaussianPrimitiveCenterCoordinatesList.toVector(); m_yGaussianPrimitiveCenterCoordinates=yGaussianPrimitiveCenterCoordinatesList.toVector(); m_zGaussianPrimitiveCenterCoordinates=zGaussianPrimitiveCenterCoordinatesList.toVector(); m_xGaussianPrimitiveAngularMomenta=xGaussianPrimitiveAngularMomentaList.toVector(); m_yGaussianPrimitiveAngularMomenta=yGaussianPrimitiveAngularMomentaList.toVector(); m_zGaussianPrimitiveAngularMomenta=zGaussianPrimitiveAngularMomentaList.toVector(); m_gaussianPrimitiveExponentCoefficients=gaussianPrimitiveExponentCoefficientsList.toVector(); QVariant molecularOrbitalOccupationNumbersVariant = mol->property( "QTAIMMolecularOrbitalOccupationNumbers" ); QVariant molecularOrbitalEigenvaluesVariant = mol->property( "QTAIMMolecularOrbitalEigenvalues" ); QVariant molecularOrbitalCoefficientsVariant = mol->property( "QTAIMMolecularOrbitalCoefficients" ); QVariantList molecularOrbitalOccupationNumbersVariantList = molecularOrbitalOccupationNumbersVariant.toList(); QVariantList molecularOrbitalEigenvaluesVariantList = molecularOrbitalEigenvaluesVariant.toList(); QVariantList molecularOrbitalCoefficientsVariantList = molecularOrbitalCoefficientsVariant.toList(); QList<qreal> molecularOrbitalOccupationNumbersList; QList<qreal> molecularOrbitalEigenvaluesList; QList<qreal> molecularOrbitalCoefficientsList; for( qint64 m=0; m < m_numberOfMolecularOrbitals ; ++m ) { molecularOrbitalOccupationNumbersList.append(molecularOrbitalOccupationNumbersVariantList.at(m).toReal()); molecularOrbitalEigenvaluesList.append(molecularOrbitalEigenvaluesVariantList.at(m).toReal()); } for( qint64 i=0; i < (m_numberOfMolecularOrbitals * m_numberOfGaussianPrimitives) ; ++i) { molecularOrbitalCoefficientsList.append(molecularOrbitalCoefficientsVariantList.at(i).toReal()); } m_molecularOrbitalOccupationNumbers=molecularOrbitalOccupationNumbersList.toVector(); m_molecularOrbitalEigenvalues=molecularOrbitalEigenvaluesList.toVector(); m_molecularOrbitalCoefficients=molecularOrbitalCoefficientsList.toVector(); QVariant totalEnergyVariant = mol->property("QTAIMTotalEnergy"); QVariant virialRatioVariant = mol->property("QTAIMVirialRatio"); m_totalEnergy=totalEnergyVariant.toReal(); m_virialRatio=virialRatioVariant.toReal(); } return true; }
bool TextLineBase::setProperty(P_ID id, const QVariant& v) { switch (id) { case P_ID::BEGIN_TEXT_PLACE: _beginTextPlace = PlaceText(v.toInt()); break; case P_ID::BEGIN_TEXT_ALIGN: _beginTextAlign = Align(v.toInt()); break; case P_ID::CONTINUE_TEXT_ALIGN: _continueTextAlign = Align(v.toInt()); break; case P_ID::END_TEXT_ALIGN: _endTextAlign = Align(v.toInt()); break; case P_ID::CONTINUE_TEXT_PLACE: _continueTextPlace = PlaceText(v.toInt()); break; case P_ID::END_TEXT_PLACE: _endTextPlace = PlaceText(v.toInt()); break; case P_ID::BEGIN_HOOK_HEIGHT: _beginHookHeight = v.value<Spatium>(); break; case P_ID::END_HOOK_HEIGHT: _endHookHeight = v.value<Spatium>(); break; case P_ID::BEGIN_HOOK_TYPE: _beginHookType = HookType(v.toInt()); break; case P_ID::END_HOOK_TYPE: _endHookType = HookType(v.toInt()); break; case P_ID::BEGIN_TEXT: setBeginText(v.toString()); break; case P_ID::BEGIN_TEXT_OFFSET: setBeginTextOffset(v.toPointF()); break; case P_ID::CONTINUE_TEXT_OFFSET: setContinueTextOffset(v.toPointF()); break; case P_ID::END_TEXT_OFFSET: setEndTextOffset(v.toPointF()); break; case P_ID::CONTINUE_TEXT: setContinueText(v.toString()); break; case P_ID::END_TEXT: setEndText(v.toString()); break; case P_ID::LINE_VISIBLE: setLineVisible(v.toBool()); break; case P_ID::BEGIN_FONT_FACE: setBeginFontFamily(v.toString()); break; case P_ID::BEGIN_FONT_SIZE: if (v.toReal() <= 0) qDebug("font size is %f", v.toReal()); setBeginFontSize(v.toReal()); break; case P_ID::BEGIN_FONT_BOLD: setBeginFontBold(v.toBool()); break; case P_ID::BEGIN_FONT_ITALIC: setBeginFontItalic(v.toBool()); break; case P_ID::BEGIN_FONT_UNDERLINE: setBeginFontUnderline(v.toBool()); break; case P_ID::CONTINUE_FONT_FACE: setContinueFontFamily(v.toString()); break; case P_ID::CONTINUE_FONT_SIZE: setContinueFontSize(v.toReal()); break; case P_ID::CONTINUE_FONT_BOLD: setContinueFontBold(v.toBool()); break; case P_ID::CONTINUE_FONT_ITALIC: setContinueFontItalic(v.toBool()); break; case P_ID::CONTINUE_FONT_UNDERLINE: setContinueFontUnderline(v.toBool()); break; case P_ID::END_FONT_FACE: setEndFontFamily(v.toString()); break; case P_ID::END_FONT_SIZE: setEndFontSize(v.toReal()); break; case P_ID::END_FONT_BOLD: setEndFontBold(v.toBool()); break; case P_ID::END_FONT_ITALIC: setEndFontItalic(v.toBool()); break; case P_ID::END_FONT_UNDERLINE: setEndFontUnderline(v.toBool()); break; default: return SLine::setProperty(id, v); } triggerLayout(); return true; }
bool CameraBinExposure::setValue(ExposureParameter parameter, const QVariant& value) { QVariant oldValue = actualValue(parameter); switch (parameter) { case QCameraExposureControl::ExposureCompensation: gst_photography_set_ev_compensation(m_session->photography(), value.toReal()); break; case QCameraExposureControl::ISO: gst_photography_set_iso_speed(m_session->photography(), value.toInt()); break; case QCameraExposureControl::Aperture: gst_photography_set_aperture(m_session->photography(), guint(value.toReal()*1000000)); break; case QCameraExposureControl::ShutterSpeed: gst_photography_set_exposure(m_session->photography(), guint(value.toReal()*1000000)); break; case QCameraExposureControl::ExposureMode: { QCameraExposure::ExposureMode mode = QCameraExposure::ExposureMode(value.toInt()); GstSceneMode sceneMode; gst_photography_get_scene_mode(m_session->photography(), &sceneMode); switch (mode) { case QCameraExposure::ExposureManual: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_MANUAL; break; case QCameraExposure::ExposurePortrait: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT; break; case QCameraExposure::ExposureSports: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_SPORT; break; case QCameraExposure::ExposureNight: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_NIGHT; break; case QCameraExposure::ExposureAuto: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_AUTO; break; default: break; } gst_photography_set_scene_mode(m_session->photography(), sceneMode); break; } default: return false; } if (!qFuzzyCompare(m_requestedValues.value(parameter).toReal(), value.toReal())) { m_requestedValues[parameter] = value; emit requestedValueChanged(parameter); } QVariant newValue = actualValue(parameter); if (!qFuzzyCompare(oldValue.toReal(), newValue.toReal())) emit actualValueChanged(parameter); return true; }