// normal sizeHint doesn't always work right for our case, // because the min/max/special text aren't necessarily the longest text QSize MinSecSpinBox::sizeHint() const { QSize normal = QSpinBox::sizeHint(); //this first portion copied from QAbstractSpinBox const QFontMetrics fm(fontMetrics()); int w = 0; QString s; s = prefix() + textFromValue(minimum()) + suffix() + QLatin1Char(' '); s.truncate(18); w = qMax(w, fm.width(s)); s = prefix() + textFromValue(maximum()) + suffix() + QLatin1Char(' '); s.truncate(18); w = qMax(w, fm.width(s)); if (specialValueText().size()) { s = specialValueText(); w = qMax(w, fm.width(s)); } w += 2; // cursor blinking space //new part (see if max - singlestep is longer) s = textFromValue(maximum()-singleStep()) + QLatin1Char(' '); int longwidth = fm.width(s) + 2; int dif = longwidth - w; if (dif > 0) normal += QSize(dif, 0); return normal; }
void DoubleSpinBox::interpretText() { bool ok = false; QString s = text(); double value = locale().toDouble(s, &ok); if (ok && value == d_value) return; if (!ok){ MyParser parser; parser.setLocale(QLocale()); parser.addGSLConstants(); try { parser.SetExpr(s.toAscii().constData()); value = parser.Eval(); } catch (mu::ParserError &e){ lineEdit()->setText(textFromValue(d_value)); return; } } if (setValue(value)) emit valueChanged(d_value); else lineEdit()->setText(textFromValue(d_value)); }
bool DoubleSpinBox::setValue(double val) { if (val >= d_min_val && val <= d_max_val) { d_value = val; lineEdit()->setText(textFromValue(d_value)); return true; } lineEdit()->setText(textFromValue(d_value)); return false; }
/** * Interpret the text and update the stored value. * @param notify If true then emit signals to indicate if the value has changed * (default=true) * The default is important so that connected signals ensure the correct updates * are pushed * through but we need to be able to turn them off as there are cases where this * causes * a recursive call. */ void DoubleSpinBox::interpretText(bool notify) { // RJT: Keep our version of this, which contains a bug fix (see [10521]). // Also, there are lines referring to methods that don't exist in our (older) // MyParser class. bool ok = false; double value = locale().toDouble(text(), &ok); if (ok && setValue(value)) { if (notify) emit valueChanged(d_value); } else { QString val = text().remove(","); value = locale().toDouble(val, &ok); if (ok && setValue(value)) { if (notify) emit valueChanged(d_value); } else { // Check for any registered test strings that map to a given value for (auto &specialTextMapping : m_specialTextMappings) { if (specialTextMapping.first == text()) { // Found a matching string, try to set the value if (setValue(specialTextMapping.second)) { lineEdit()->setText(text()); if (notify) emit valueChanged(d_value); } } } lineEdit()->setText(textFromValue(d_value)); } } }
/** * Interpret the text and update the stored value. * @param notify If true then emit signals to indicate if the value has changed * (default=true) * The default is important so that connected signals ensure the correct updates * are pushed * through but we need to be able to turn them off as there are cases where this * causes * a recursive call. */ void DoubleSpinBox::interpretText(bool notify) { // RJT: Keep our version of this, which contains a bug fix (see [10521]). // Also, there are lines referring to methods that don't exist in our (older) // MyParser class. bool ok = false; double value = locale().toDouble(text(), &ok); if (ok && setValue(value)) { if (notify) emit valueChanged(d_value); } else { QString val = text().remove(","); value = locale().toDouble(val, &ok); if (ok && setValue(value)) { if (notify) emit valueChanged(d_value); } else { // Check for any registered test strings that map to a given value for (auto it = m_specialTextMappings.begin(); it != m_specialTextMappings.end(); ++it) { if (it->first == text()) { // Found a matching string, try to set the value if (setValue(it->second)) { lineEdit()->setText(text()); if (notify) emit valueChanged(d_value); } } } lineEdit()->setText(textFromValue(d_value)); } } // bool ok = false; // QString s = text(); // double value = locale().toDouble(s, &ok); // if (ok && value == d_value) // return; // // if (!ok) // { // MyParser parser; // parser.setLocale(QLocale()); // parser.addGSLConstants(); // try // { // parser.SetExpr(s.toAscii().constData()); // value = parser.Eval(); // } catch (mu::ParserError &e) // { // lineEdit()->setText(textFromValue(d_value)); // return; // } // } // // if (setValue(value)) // emit valueChanged( d_value); // else // lineEdit()->setText(textFromValue(d_value)); }
void WDoubleSpinBox::setValue(double value) { if (value_ != value) { value_ = value; setText(textFromValue()); } }
void WSpinBox::setValue(int value) { if (value_ != value) { value_ = value; setText(textFromValue()); } }
// Mark that we got actual value. void qtractorTempoSpinBox::showEvent ( QShowEvent */*pShowEvent*/ ) { QLineEdit *pLineEdit = QAbstractSpinBox::lineEdit(); const bool bBlockSignals = pLineEdit->blockSignals(true); pLineEdit->setText(textFromValue(m_fTempo, m_iBeatsPerBar, m_iBeatDivisor)); pLineEdit->blockSignals(bBlockSignals); // QAbstractSpinBox::interpretText(); }
// Mark that we got actual value. void qtractorTimeSpinBox::showEvent ( QShowEvent */*pShowEvent*/ ) { QLineEdit *pLineEdit = QAbstractSpinBox::lineEdit(); const bool bBlockSignals = pLineEdit->blockSignals(true); pLineEdit->setText(textFromValue(m_iValue)); QAbstractSpinBox::interpretText(); pLineEdit->blockSignals(bBlockSignals); }
void DoubleSpinBox::interpretText() { bool ok = false; double value = locale().toDouble(text(), &ok); if (ok && setValue(value)) emit valueChanged(d_value); else lineEdit()->setText(textFromValue(d_value)); }
void WAbstractSpinBox::setSuffix(const WString& suffix) { if (suffix_ != suffix) { suffix_ = suffix; setText(textFromValue()); changed_ = true; repaint(); } }
void WAbstractSpinBox::setPrefix(const WString& prefix) { if (prefix_ != prefix) { prefix_ = prefix; setText(textFromValue()); changed_ = true; repaint(); } }
void qtractorTempoSpinBox::fixup ( QString& sText ) const { #ifdef CONFIG_DEBUG_0 qDebug("qtractorTempoSpinBox[%p]::fixup(\"%s\")", this, sText.toUtf8().constData()); #endif sText = textFromValue(m_fTempo, m_iBeatsPerBar, m_iBeatDivisor); }
void qtractorTimeSpinBox::fixup ( QString& sText ) const { #ifdef CONFIG_DEBUG_0 qDebug("qtractorTimeSpinBox[%p]::fixup(\"%s\")", this, sText.toUtf8().constData()); #endif sText = textFromValue(m_iValue); }
void ULongLongSpinBox::setValue(qulonglong value) { qulonglong clampedValue = std::min(m_max, std::max(value, m_min)); if (clampedValue == m_value) return; m_value = clampedValue; lineEdit()->setText(textFromValue(m_value)); emit valueChanged(m_value); }
void qtractorTimeSpinBox::updateText (void) { if (QAbstractSpinBox::isVisible()) { QLineEdit *pLineEdit = QAbstractSpinBox::lineEdit(); const bool bBlockSignals = pLineEdit->blockSignals(true); const int iCursorPos = pLineEdit->cursorPosition(); pLineEdit->setText(textFromValue(m_iValue)); // QAbstractSpinBox::interpretText(); pLineEdit->setCursorPosition(iCursorPos); pLineEdit->blockSignals(bBlockSignals); } }
bool WDoubleSpinBox::parseNumberValue(const std::string& text) { try { char buf[30]; if (textFromValue().toUTF8() != text) // to prevent loss of precision value_ = WLocale::currentLocale().toDouble(WString::fromUTF8(text)); return true; } catch (boost::bad_lexical_cast &e) { return false; } }
void DoubleSpinBox::interpretText() { // RJT: Keep our version of this, which contains a bug fix (see [10521]). // Also, there are lines referring to methods that don't exist in our (older) MyParser class. bool ok = false; double value = locale().toDouble(text(), &ok); if (ok && setValue(value)) { emit valueChanged(d_value); } else { QString val = text().remove(","); value = locale().toDouble(val, &ok); if ( ok && setValue(value) ) { emit valueChanged(d_value); } else { lineEdit()->setText(textFromValue(d_value)); } } // bool ok = false; // QString s = text(); // double value = locale().toDouble(s, &ok); // if (ok && value == d_value) // return; // // if (!ok) // { // MyParser parser; // parser.setLocale(QLocale()); // parser.addGSLConstants(); // try // { // parser.SetExpr(s.toAscii().constData()); // value = parser.Eval(); // } catch (mu::ParserError &e) // { // lineEdit()->setText(textFromValue(d_value)); // return; // } // } // // if (setValue(value)) // emit valueChanged( d_value); // else // lineEdit()->setText(textFromValue(d_value)); }
void WDoubleSpinBox::refresh() { setText(textFromValue()); WAbstractSpinBox::refresh(); }
void WAbstractSpinBox::setText(const WT_USTRING& text) { parseValue(text); WLineEdit::setText(textFromValue()); }
void WDoubleSpinBox::setDecimals(int decimals) { precision_ = decimals; setText(textFromValue()); }