コード例 #1
0
ファイル: minsecspinbox.cpp プロジェクト: muromec/qtopia-ezx
// 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;
}
コード例 #2
0
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));
}
コード例 #3
0
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;
}
コード例 #4
0
/**
 * 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));
    }
  }
}
コード例 #5
0
ファイル: DoubleSpinBox.cpp プロジェクト: liyulun/mantid
/**
 * 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));
}
コード例 #6
0
void WDoubleSpinBox::setValue(double value)
{
  if (value_ != value) {
    value_ = value;
    setText(textFromValue());
  }
}
コード例 #7
0
ファイル: WSpinBox.C プロジェクト: Dinesh-Ramakrishnan/wt
void WSpinBox::setValue(int value)
{
  if (value_ != value) {
    value_ = value;
    setText(textFromValue());
  }
}
コード例 #8
0
// 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();
}
コード例 #9
0
// 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);
}
コード例 #10
0
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));
}
コード例 #11
0
ファイル: WAbstractSpinBox.C プロジェクト: caseymcc/wt
void WAbstractSpinBox::setSuffix(const WString& suffix)
{
  if (suffix_ != suffix) {
    suffix_ = suffix;
    setText(textFromValue());
    changed_ = true;
    repaint();
  }
}
コード例 #12
0
ファイル: WAbstractSpinBox.C プロジェクト: caseymcc/wt
void WAbstractSpinBox::setPrefix(const WString& prefix)
{
  if (prefix_ != prefix) {
    prefix_ = prefix;
    setText(textFromValue());
    changed_ = true;
    repaint();
  }
}
コード例 #13
0
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);
}
コード例 #14
0
void qtractorTimeSpinBox::fixup ( QString& sText ) const
{
#ifdef CONFIG_DEBUG_0
	qDebug("qtractorTimeSpinBox[%p]::fixup(\"%s\")",
		this, sText.toUtf8().constData());
#endif

	sText = textFromValue(m_iValue);
}
コード例 #15
0
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);
}
コード例 #16
0
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);
	}
}
コード例 #17
0
ファイル: WDoubleSpinBox.C プロジェクト: GuLinux/wt
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;
  }
}
コード例 #18
0
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));
}
コード例 #19
0
ファイル: WDoubleSpinBox.C プロジェクト: GuLinux/wt
void WDoubleSpinBox::refresh()
{
  setText(textFromValue());
  WAbstractSpinBox::refresh();
}
コード例 #20
0
ファイル: WAbstractSpinBox.C プロジェクト: caseymcc/wt
void WAbstractSpinBox::setText(const WT_USTRING& text)
{
  parseValue(text);

  WLineEdit::setText(textFromValue());
}
コード例 #21
0
void WDoubleSpinBox::setDecimals(int decimals)
{
  precision_ = decimals;

  setText(textFromValue());
}