Exemplo n.º 1
0
void Sequence::setValues(QString minv, QString maxv, QString inc, QString start, QString cache)
{
	minv=formatValue(minv);
	maxv=formatValue(maxv);
	inc=formatValue(inc);
	start=formatValue(start);
	cache=formatValue(cache);

	//Raises an error when some values are empty
	if(minv==""   || maxv=="" || inc=="" ||
		 start=="" || cache=="")
		throw Exception(ERR_ASG_INV_VALUE_SEQ_ATTRIBS,__PRETTY_FUNCTION__,__FILE__,__LINE__);
	//Raises an error when the min value is greater than max value
	else if(compareValues(minv,maxv) > 0)
		throw Exception(ERR_ASG_INV_SEQ_MIN_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
	//Raises an error when the start value is less that min value or grater than max value
	else if(compareValues(start, minv) < 0 ||
					compareValues(start, maxv) > 0)
		throw Exception(ERR_ASG_INV_SEQ_START_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
	//Raises an error when the increment value is null (0)
	else if(isNullValue(inc))
		throw Exception(ERR_ASG_INV_SEQ_INCR_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
	//Raises an error when the cache value is null (0)
	else if(isNullValue(cache))
		throw Exception(ERR_ASG_INV_SEQ_CACHE_VALUE,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	this->min_value=minv;
	this->max_value=maxv;
	this->increment=inc;
	this->cache=cache;
	this->start=start;
}
Exemplo n.º 2
0
void QgsMeasureDialog::updateUi()
{
  // Set tooltip to indicate how we calculate measurments
  QString toolTip = tr( "The calculations are based on:" );
  if ( ! mTool->canvas()->hasCrsTransformEnabled() )
  {
    toolTip += "<br> * " + tr( "Project CRS transformation is turned off." ) + " ";
    toolTip += tr( "Canvas units setting is taken from project properties setting (%1)." ).arg( QGis::tr( mCanvasUnits ) );
    toolTip += "<br> * " + tr( "Ellipsoidal calculation is not possible, as project CRS is undefined." );
    setWindowTitle( tr( "Measure (OTF off)" ) );
  }
  else
  {
    if ( mDa.ellipsoidalEnabled() )
    {
      toolTip += "<br> * " + tr( "Project CRS transformation is turned on and ellipsoidal calculation is selected." ) + " ";
      toolTip += "<br> * " + tr( "The coordinates are transformed to the chosen ellipsoid (%1), and the result is in meters" ).arg( mDa.ellipsoid() );
    }
    else
    {
      toolTip += "<br> * " + tr( "Project CRS transformation is turned on but ellipsoidal calculation is not selected." );
      toolTip += "<br> * " + tr( "The canvas units setting is taken from the project CRS (%1)." ).arg( QGis::tr( mCanvasUnits ) );
    }
    setWindowTitle( tr( "Measure (OTF on)" ) );
  }

  if (( mCanvasUnits == QGis::Meters && mDisplayUnits == QGis::Feet ) || ( mCanvasUnits == QGis::Feet && mDisplayUnits == QGis::Meters ) )
  {
    toolTip += "<br> * " + tr( "Finally, the value is converted from %1 to %2." ).arg( QGis::tr( mCanvasUnits ) ).arg( QGis::tr( mDisplayUnits ) );
  }

  editTotal->setToolTip( toolTip );
  mTable->setToolTip( toolTip );
  mNotesLabel->setText( toolTip );

  QGis::UnitType newDisplayUnits;
  double dummy = 1.0;
  convertMeasurement( dummy, newDisplayUnits, true );
  mTable->setHeaderLabels( QStringList() << tr( "Parts" ) );

  mTable->clear();
  const QList< QList< QgsPoint > >& points = mTool->getPoints();
  double total = 0.;
  for ( int i = 0, n = points.size(); i < n; ++i )
  {
    double value = measureGeometry( points[i], mMeasureArea );
    QTreeWidgetItem* item = new QTreeWidgetItem( QStringList() << formatValue( value, mMeasureArea ) );
    item->setTextAlignment( 0, Qt::AlignRight );
    mTable->addTopLevelItem( item );
    total += value;
  }
  editTotal->setText( formatValue( total, mMeasureArea ) );

  mTool->updateLabels();
}
Exemplo n.º 3
0
QString FLManager::formatValue(FLFieldMetaData *fMD, const QVariant &v, const bool upper)
{
  if (!fMD)
    return QString::null;

  return formatValue(fMD->type(), v, upper);
}
Exemplo n.º 4
0
float DateTimeNumericFieldElement::maximumWidth(const Font& font)
{
    float maximumWidth = font.width(m_placeholder);
    maximumWidth = std::max(maximumWidth, font.width(formatValue(maximum())));
    maximumWidth = std::max(maximumWidth, font.width(value()));
    return maximumWidth + DateTimeFieldElement::maximumWidth(font);
}
Exemplo n.º 5
0
bool IniFormatter::writeToStream(const Node* root, Stream* stream, unsigned int tcount, unsigned int nameformat, unsigned int varformat) {
	if (root && stream) {
		UnicodeString temp;
		if (root->getParent() && root->getName().length()>0) { // cheap way of saying the node is not a root node
			writeTabs(stream, tcount, false);
			root->getNameFormatted(temp, nameformat);
			stream->writeChar16('[');
			temp.append(']');
			stream->writeLine(temp);
		}
		Node* node;
		ValueVariable* value;
		for (VarList::const_iterator iter=root->begin(); iter!=root->end(); ++iter) {
			value=dynamic_cast<ValueVariable*>(*iter);
			node=dynamic_cast<Node*>(*iter);
			if (node) {
				writeToStream(node, stream, tcount, nameformat, varformat);
			} else if (value) {
				if (formatValue(*value, temp, nameformat, varformat)) {
					writeTabs(stream, tcount, false);
					stream->writeLine(temp);
				}
			}
		}
		return true;
	}
	return false;
}
DateTimeNumericFieldElement::DateTimeNumericFieldElement(
    Document& document,
    FieldOwner& fieldOwner,
    const Range& range,
    const Range& hardLimits,
    const String& placeholder,
    const DateTimeNumericFieldElement::Step& step)
    : DateTimeFieldElement(document, fieldOwner),
      m_placeholder(placeholder),
      m_range(range),
      m_hardLimits(hardLimits),
      m_step(step),
      m_value(0),
      m_hasValue(false) {
  DCHECK_NE(m_step.step, 0);
  DCHECK_LE(m_range.minimum, m_range.maximum);
  DCHECK_LE(m_hardLimits.minimum, m_hardLimits.maximum);

  // We show a direction-neutral string such as "--" as a placeholder. It
  // should follow the direction of numeric values.
  if (localeForOwner().isRTL()) {
    CharDirection dir = direction(formatValue(this->maximum())[0]);
    if (dir == LeftToRight || dir == EuropeanNumber || dir == ArabicNumber) {
      setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueBidiOverride);
      setInlineStyleProperty(CSSPropertyDirection, CSSValueLtr);
    }
  }
}
float DateTimeNumericFieldElement::maximumWidth(const ComputedStyle& style) {
  float maximumWidth = computeTextWidth(style, m_placeholder);
  maximumWidth =
      std::max(maximumWidth, computeTextWidth(style, formatValue(maximum())));
  maximumWidth = std::max(maximumWidth, computeTextWidth(style, value()));
  return maximumWidth + DateTimeFieldElement::maximumWidth(style);
}
Exemplo n.º 8
0
void JsonPrettify::formatArray (web::json::array &arr, utility::ostream_t &stream) {
	stream << U("[\n") ;
	if ( arr.size () ) {
		_level++ ;
		auto lastElement =arr.end () - 1 ;
		for ( auto iter =arr.begin () ; iter != lastElement ; ++iter ) {
			indent (stream) ;
			formatValue (*iter, stream) ;
			stream << U(",\n") ;
		}
		indent (stream) ;
		formatValue (*lastElement, stream) ;
		stream << U("\n") ;
		_level-- ;
	}
	indent (stream) ;
	stream << U("]") ;
}
Exemplo n.º 9
0
/*
    Generate a value given an array of floating point number, using formatting defined within this class.
    The formatting mainly applies if formatting as a string. For example, was is
    the number base? should a sign always be included? are leading zeros requried?
    The formatting could include properties related to other types. For example, generate
    an error if attempting to convert a negative floating point number to an unsigned integer.
*/
QVariant QEFloatingFormatting::formatValue( const QVector<double> &floatingValue, generic::generic_types valueType ) {
    QList<QVariant> array;
    int arraySize = floatingValue.size();
    for( int i = 0; i < arraySize; i++ )
    {
        array.append( formatValue( floatingValue[i], valueType ));
    }
    return array;
}
Exemplo n.º 10
0
void QgsMeasureDialog::updateMeasurements()
{
  int idx = mTable->topLevelItemCount() - 1;
  if ( mTool->getPoints().size() <= idx )
  {
    return;
  }

  QTreeWidgetItem *item = mTable->topLevelItem( idx );
  double value = measureGeometry( mTool->getPoints()[idx], mMeasureArea );
  item->setText( 0, formatValue( value, mMeasureArea ) );
  item->setData( 0, Qt::UserRole, value );
  double total = 0;
  for ( int i = 0, n = mTable->topLevelItemCount(); i < n; ++i )
  {
    total += mTable->topLevelItem( i )->data( 0, Qt::UserRole ).toDouble();
  }
  editTotal->setText( formatValue( total, mMeasureArea ) );
}
Exemplo n.º 11
0
void ParameterEditor::updateProperty() {
  auto mgr =
      dynamic_cast<ParameterPropertyManager *>(m_property->propertyManager());
  if (mgr) {
    // To find out whether the value was really changed, we format it and
    // compare string values. This
    // ensures that we don't suffer from double precision loss and consider only
    // real changes in value

    QString prevVal = formatValue(mgr->value(m_property));
    QString newVal = formatValue(text().toDouble());

    if (prevVal != newVal) {
      // As the value was changed, the error becomes invalid, so clear it
      mgr->clearError(m_property);
    }
  }

  DoubleEditor::updateProperty();
}
Exemplo n.º 12
0
void MSVGauge::updateSliderSize(double value_)
{
  if (gaugeHeight()<=slider()->shadowThickness()||value_<=valueMin()||value_>=valueMax()) 
   {
     drawSliderArea();
     drawGauge();
   }
  else updateGauge((int)(value_));
  MSString buffer;
  valueWin()->updateValue(formatValue(buffer,value_));
}
Exemplo n.º 13
0
void VariablesWidget::fillTable()
{
    setUpdatesEnabled(false);

    m_filterTimer->stop();
    m_variables->clear();
    QString term = m_searchFilter->text();
    QVector<Variable> variables = Evaluator::instance()->variables();

    for (int k = 0; k < variables.count(); ++k) {

        QString upper = variables.at(k).name.toUpper();

        if (m_itemPolicy == ShowUser
            && (upper == QLatin1String("ANS")
                || upper == QLatin1String("E")
                || upper == QLatin1String("PHI")
                || upper == QLatin1String("PI")))
        {
            continue;
        }

        QStringList str;
        str << variables.at(k).name
            << formatValue(variables.at(k).value);

        if (term.isEmpty()
            || str.at(0).contains(term, Qt::CaseInsensitive)
            || str.at(1).contains(term, Qt::CaseInsensitive))
        {
            QTreeWidgetItem *item = new QTreeWidgetItem(m_variables, str);
            item->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
            item->setTextAlignment(1, Qt::AlignLeft | Qt::AlignVCenter);
        }
    }

    m_variables->resizeColumnToContents(0);
    m_variables->resizeColumnToContents(1);

    if (m_variables->topLevelItemCount() > 0 || m_itemPolicy != ShowAll) {
        m_noMatchLabel->hide();
        m_variables->sortItems(0, Qt::AscendingOrder);
    } else {
        m_noMatchLabel->setGeometry(m_variables->geometry());
        m_noMatchLabel->show();
        m_noMatchLabel->raise();
    }

    m_searchFilter->setFocus();
    setUpdatesEnabled(true);
}
Exemplo n.º 14
0
QString FLManager::formatAssignValue(const QString &fieldName, int t, const QVariant &v, const bool upper)
{
  if (fieldName.isEmpty() || t == QVariant::Invalid)
    return "1 = 1";

  bool isText = (t == QVariant::String || t == QVariant::StringList);
  QString formatV(formatValue(t, v, upper));

  if (formatV.isEmpty())
    return "1 = 1";

  QString fName((upper && isText ? QString::fromLatin1("upper(") + fieldName +
                 QString::fromLatin1(")") : fieldName));
  return fName + "=" + formatV;
}
Exemplo n.º 15
0
DateTimeNumericFieldElement::DateTimeNumericFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum, const String& placeholder)
    : DateTimeFieldElement(document, fieldOwner)
    , m_lastDigitCharTime(0)
    , m_placeholder(placeholder)
    , m_range(minimum, maximum)
    , m_value(0)
    , m_hasValue(false)
{
    // We show a direction-neutral string such as "--" as a placeholder. It
    // should follow the direction of numeric values.
    if (localeForOwner().isRTL()) {
        Direction dir = direction(formatValue(this->maximum())[0]);
        if (dir == LeftToRight || dir == EuropeanNumber || dir == ArabicNumber) {
            setInlineStyleProperty(CSSPropertyUnicodeBidi, CSSValueBidiOverride);
            setInlineStyleProperty(CSSPropertyDirection, CSSValueLtr);
        }
    }
}
Exemplo n.º 16
0
tstring QueryRunner::run(WMI::Connection& connection, const ConstQueryPtr& query)
{
	tstring formattedValue;

	try
	{
		WMI::ObjectIterator end;

		tstring text = Core::fmt(TXT("SELECT * FROM %s"), query->m_wmiClass.c_str());

		if (!query->m_filterProperty.empty())
		{
			text += Core::fmt(TXT(" WHERE %s = '%s'"), query->m_filterProperty.c_str(),
														query->m_filterValue.c_str());
		}

		WMI::ObjectIterator it = connection.execQuery(text.c_str());

		if (it != end)
		{
			if (it->hasProperty(query->m_wmiProperty))
			{
				WCL::Variant value;

				it->getProperty(query->m_wmiProperty, value);

				formattedValue = formatValue(value, query->m_format);
			}
			else
			{
				formattedValue = TXT("#N/A");
			}
		}
	}
	catch (const WMI::Exception& /*e*/)
	{
		formattedValue = TXT("#ERR");
	}

	return formattedValue;
}
Exemplo n.º 17
0
//---------------------------------------------------------------
void ColorScaleGraph::paintEvent (QPaintEvent *)
{
	int W=width(), H=height();		
    QPainter pnt(this);
	QColor bgcolor, fgcolor;
	int dh = 16;
	pnt.fillRect (0,0,W,dh, QColor(210,210,255));
	bgcolor = Util::getSetting("landColor", QColor(200,200,120)).value<QColor>();
	pnt.fillRect (0,dh,W,H-dh, bgcolor);
	int i;
	if (sc) {
		pnt.setPen (QColor(0,0,0));
		QFont font = Font::getFont(FONT_ColorScale);
		font.setBold (true);
		pnt.setFont (font);
		pnt.drawText (0, 0, W,dh, Qt::AlignHCenter|Qt::AlignVCenter, Util::getDataUnit (dtc));
		int nb = sc->colors.size();
		if (nb == 0)
				return;
		pnt.setFont (Font::getFont(FONT_ColorScale));
		int h1;
		int hc = (H-dh)/nb;
		QRgb rgb;
		for (i=0; i<nb; i++) {
			// Background
			double v = sc->colors[i]->vmax;
			rgb = datacolors->getDataCodeColor (dtc, v, true);
			bgcolor.setRgba (rgb);
			h1 = dh + (nb-i-1)*hc;
			pnt.fillRect (0, h1, W,hc, bgcolor);
			//DBG("i=%d H=%d dh=%d : h1=%d : (%d %d %d)", i,H,dh, h1, r,g,b);
			
			// Foreground (value)
			pnt.setPen (DataColors::getContrastedColor (bgcolor));
			QString sval = formatValue (v);
			//pnt.drawText (0, h1, W,hc, Qt::AlignHCenter|Qt::AlignTop, sval);
			pnt.drawText (0, h1, W,hc, Qt::AlignHCenter|Qt::AlignVCenter, sval);
		}
	}
}
Exemplo n.º 18
0
std::string DictionaryLuaFormatter::format(const Dictionary& dictionary,
                                           int indentationSteps) const
{
    if (dictionary.empty()) {
        return "{}";
    }

    std::string indent;
    if (_prettyPrint) {
        for (int i = 0; i < indentationSteps; i++) {
            indent += _indentation;
        }
    }

    std::string newLine = _prettyPrint ? "\n" : "";

    auto convert = [this, dictionary, indentationSteps]
        (const std::string& key)
    {
        return
            (_prettyPrint ? _indentation : "") + key +
            (_prettyPrint ? " " : "") + "=" + (_prettyPrint ? " " : "") +
            formatValue(dictionary, key, indentationSteps + 1);
    };

    std::vector<std::string> keys = dictionary.keys();

    std::string lua = std::accumulate(
        std::next(keys.begin()),
        keys.end(),
        convert(*keys.begin()),
        [convert, indent, this](std::string a, std::string key) {
            return a + "," + (_prettyPrint ? "\n" : "") + indent + convert(key);
        }
    );

    return std::string("{") + (_prettyPrint ? "\n" : "") +
        indent + lua + (_prettyPrint ? "\n" : "") +
        indent + "}";
}
Exemplo n.º 19
0
void JsonPrettify::serialize (web::json::value &val, utility::ostream_t &stream) {
	formatValue (val, stream) ;
}
Exemplo n.º 20
0
StringBuilder& FormatUtils::vformat(StringBuilder& sb, const char* fmt, va_list ap) noexcept {
  const char kFormatChar = '%';

  const char* p = fmt;
  const char* mark = fmt;

  for (;;) {
    uint32_t c = static_cast<unsigned char>(*p);
    if (c == '\0')
      break;
    p++;

    // Don't continue if the character is not a formatting mark. In most cases
    // this branch should be taken as most of the string should be just a text.
    if (c != kFormatChar)
      continue;

    // NULL terminator after a formatting mark. It's safe to just break here.
    // The trailing mark will be appended to the string as well. However, this
    // is basically handling of an invalid `fmt` string.
    c = static_cast<unsigned char>(*p);
    if (c == '\0')
      break;

    // Handle a double-escaped formatting mark "%%", which produces "%".
    bool isEscape = (c == kFormatChar);
    sb.appendString(mark, (size_t)(p - mark) - 1 + isEscape);

    // Guess a new mark position, which is exactly two characters after the
    // initial mark when simple or a double-escaped mark formatting has been
    // used. MPSL formatting extensions will adjust the mark again.
    mark = ++p;
    if (isEscape)
      continue;

    if (c == '{') {
      // ----------------------------------------------------------------------
      // [MPSL Formatting Extensions - '%{...}']
      // ----------------------------------------------------------------------

      do {
        c = static_cast<unsigned char>(*p);
        // Invalid formatting, bail out.
        if (c == '\0') {
          mark -= 2;
          goto _Done;
        }
        p++;
      } while (c != '}');

      StringRef ext(mark, (size_t)(p - mark) - 1);
      mark = p;

      // Handle '%{StringRef}' passed as 'const StringRef*'.
      if (ext.eq("StringRef", 9)) {
        const StringRef* value = va_arg(ap, StringRef*);

        sb.appendString(value->getData(), value->getLength());
        continue;
      }

      // Handle '%{Type}' passed as 'unsigned int'.
      if (ext.eq("Type", 4)) {
        unsigned int type = va_arg(ap, unsigned int);

        formatType(sb, type);
        continue;
      }

      // Handle '%{Value}' passed as 'unsigned int, const Value*'.
      if (ext.eq("Value", 5)) {
        unsigned int type = va_arg(ap, unsigned int);
        const Value* value = va_arg(ap, const Value*);

        formatValue(sb, type, value);
        continue;
      }

      // Handle '%{SymbolType}' passed as 'unsigned int'.
      if (ext.eq("SymbolType", 10)) {
        unsigned int value = va_arg(ap, unsigned int);

        sb.appendString(mpAstSymbolType[value].name);
        continue;
      }
Exemplo n.º 21
0
const char *MSIntMatrixView::formatOutput(MSString &buffer_,unsigned row_,unsigned column_) 
{
  if (MSView::model()!=0) formatValue(buffer_,matrix()(row_,column_));
  return buffer_.string();
}
Exemplo n.º 22
0
/*!
    Returns a SQL statement of type \a type for the table \a tableName
    with the values from \a rec. If \a preparedStatement is true, the
    string will contain placeholders instead of values.

    This method can be used to manipulate tables without having to worry
    about database-dependent SQL dialects. For non-prepared statements,
    the values will be properly escaped.
*/
QString QSqlDriver::sqlStatement(StatementType type, const QString &tableName,
                                 const QSqlRecord &rec, bool preparedStatement) const
{
    int i;
    QString s;
    s.reserve(128);
    switch (type) {
    case SelectStatement:
        for (i = 0; i < rec.count(); ++i) {
            if (rec.isGenerated(i))
                s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(QLatin1String(", "));
        }
        if (s.isEmpty())
            return s;
        s.chop(2);
        s.prepend(QLatin1String("SELECT ")).append(QLatin1String(" FROM ")).append(escapeIdentifier(tableName, TableName));
        break;
    case WhereStatement:
        if (preparedStatement) {
            for (int i = 0; i < rec.count(); ++i) {
                s.append(escapeIdentifier(rec.fieldName(i), FieldName));
                if (rec.isNull(i))
                    s.append(QLatin1String(" IS NULL"));
                else
                    s.append(QLatin1String(" = ?"));
                s.append(QLatin1String(" AND "));
            }
        } else {
            for (i = 0; i < rec.count(); ++i) {
                s.append(escapeIdentifier(rec.fieldName(i), FieldName));
                QString val = formatValue(rec.field(i));
                if (val == QLatin1String("NULL"))
                    s.append(QLatin1String(" IS NULL"));
                else
                    s.append(QLatin1String(" = ")).append(val);
                s.append(QLatin1String(" AND "));
            }
        }
        if (!s.isEmpty()) {
            s.prepend(QLatin1String("WHERE "));
            s.chop(5); // remove tailing AND
        }
        break;
    case UpdateStatement:
        s.append(QLatin1String("UPDATE ")).append(escapeIdentifier(tableName, TableName)).append(
                 QLatin1String(" SET "));
        for (i = 0; i < rec.count(); ++i) {
            if (!rec.isGenerated(i) || !rec.value(i).isValid())
                continue;
            s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(QLatin1Char('='));
            if (preparedStatement)
                s.append(QLatin1Char('?'));
            else
                s.append(formatValue(rec.field(i)));
            s.append(QLatin1String(", "));
        }
        if (s.endsWith(QLatin1String(", ")))
            s.chop(2);
        else
            s.clear();
        break;
    case DeleteStatement:
        s.append(QLatin1String("DELETE FROM ")).append(escapeIdentifier(tableName, TableName));
        break;
    case InsertStatement: {
        s.append(QLatin1String("INSERT INTO ")).append(escapeIdentifier(tableName, TableName)).append(QLatin1String(" ("));
        QString vals;
        for (i = 0; i < rec.count(); ++i) {
            if (!rec.isGenerated(i) || !rec.value(i).isValid())
                continue;
            s.append(escapeIdentifier(rec.fieldName(i), FieldName)).append(QLatin1String(", "));
            if (preparedStatement)
                vals.append(QLatin1String("?"));
            else
                vals.append(formatValue(rec.field(i)));
            vals.append(QLatin1String(", "));
        }
        if (vals.isEmpty()) {
            s.clear();
        } else {
            vals.chop(2); // remove trailing comma
            s[s.length() - 2] = QLatin1Char(')');
            s.append(QLatin1String("VALUES (")).append(vals).append(QLatin1String(")"));
        }
        break; }
    }
    return s;
}
Exemplo n.º 23
0
static const char *
getValue_numeric (const MenuItem *item) {
  return formatValue(item->menu, "%u", *item->setting);
}
Exemplo n.º 24
0
/*!
  Returns a string representation of the value \a val for the database
  \a database.
*/
QString TSqlQuery::formatValue(const QVariant &val, const QSqlDatabase &database)
{
    return formatValue(val, val.type(), database);
}
Exemplo n.º 25
0
/*****************************************************
**
**   BaseInputField   ---   OnKillFocus
**
******************************************************/
void BaseInputField::OnKillFocus( wxFocusEvent &event )
{
	if( Validate()) formatValue();
	else resetStoredValue();
}
Exemplo n.º 26
0
/*!
  Returns a string representation of the value \a val for the database
  \a databaseId.
*/
QString TSqlQuery::formatValue(const QVariant &val, QVariant::Type type, int databaseId)
{
    return formatValue(val, type, Tf::currentSqlDatabase(databaseId));
}
Exemplo n.º 27
0
String DateTimeNumericFieldElement::value() const
{
    return m_hasValue ? formatValue(m_value) : emptyString();
}
Exemplo n.º 28
0
void JsonPrettify::formatPair (utility::string_t &key, web::json::value &val, utility::ostream_t &stream) {
	indent (stream) ;
	format_string (key, stream) ;
	stream << U(": ") ;
	formatValue (val, stream) ;
}
Exemplo n.º 29
0
String DateTimeNumericFieldElement::visibleValue() const
{
    if (m_typeAheadBuffer.length())
        return formatValue(typeAheadValue());
    return m_hasValue ? value() : m_placeholder;
}
Exemplo n.º 30
0
PUBLIC void espTable(HttpConn *conn, EdiGrid *grid, cchar *optionString)
{
    MprHash     *options, *colOptions, *rowOptions, *thisCol;
    MprList     *cols;
    EdiRec      *rec;
    EdiField    *fp;
    cchar       *title, *width, *o, *header, *value, *sortColumn;
    char        index[8];
    int         c, r, ncols, sortOrder;
   
    assert(grid);
    if (grid == 0) {
        return;
    }
    options = httpGetOptions(optionString);
    if (grid->nrecords == 0) {
        espRender(conn, "<p>No Data</p>\r\n");
        return;
    }
    if (grid->flags & EDI_GRID_READ_ONLY) {
        grid = ediCloneGrid(grid);
    }
    if ((sortColumn = httpGetOption(options, "sort", 0)) != 0) {
        sortOrder = httpOption(options, "sortOrder", "ascending", 1);
        ediSortGrid(grid, sortColumn, sortOrder);
    }
    colOptions = httpGetOptionHash(options, "columns");

    filterCols(grid, options, colOptions);

    if (httpOption(options, "pivot", "true", 0) != 0) {
        pivotTable(conn, ediPivotGrid(grid, 1), options);
        return;
    }
    cols = ediGetGridColumns(grid);
    ncols = mprGetListLength(cols);
    rowOptions = mprCreateHash(0, MPR_HASH_STABLE);

    httpSetOption(rowOptions, EDATA("click"), httpGetOption(options, EDATA("click"), 0));
    httpRemoveOption(options, EDATA("click"));
    httpSetOption(rowOptions, EDATA("remote"), httpGetOption(options, EDATA("remote"), 0));
    httpSetOption(rowOptions, EDATA("key"), httpGetOption(options, EDATA("key"), 0));
    httpSetOption(rowOptions, EDATA("params"), httpGetOption(options, EDATA("params"), 0));
    httpSetOption(rowOptions, EDATA("edit"), httpGetOption(options, EDATA("edit"), 0));

    httpInsertOption(options, "class", ESTYLE("table"));
    httpInsertOption(options, "class", ESTYLE("stripe"));
    espRender(conn, "<table%s>\r\n", map(conn, options));

    /*
        Table header
     */
    if (httpOption(options, "showHeader", "true", 1)) {
        espRender(conn, "    <thead>\r\n");
        if ((title = httpGetOption(options, "title", 0)) != 0) {
            espRender(conn, "        <tr class='" ESTYLE("table-title") "'><td colspan='%s'>%s</td></tr>\r\n", 
                mprGetListLength(cols), title);
        }
        espRender(conn, "        <tr class='" ESTYLE("table-header") "'>\r\n");
        rec = grid->records[0];
        for (c = 0; c < ncols; c++) {
            assert(c <= rec->nfields);
            fp = &rec->fields[c];
            width = ((o = httpGetOption(options, "width", 0)) != 0) ? sfmt(" width='%s'", o) : "";
            thisCol = mprLookupKey(colOptions, itosbuf(index, sizeof(index), c, 10));
            header = httpGetOption(thisCol, "header", spascal(fp->name));
            espRender(conn, "            <th%s>%s</th>\r\n", width, header);
        }
        espRender(conn, "        </tr>\r\n    </thead>\r\n");
    }
    espRender(conn, "    <tbody>\r\n");

    /*
        Table body data
     */
    for (r = 0; r < grid->nrecords; r++) {
        rec = grid->records[r];
        httpSetOption(rowOptions, "id", rec->id);
        espRender(conn, "        <tr%s>\r\n", map(conn, rowOptions));
        for (c = 0; c < ncols; c++) {
            fp = &rec->fields[c];
            thisCol = mprLookupKey(colOptions, itosbuf(index, sizeof(index), c, 10));

            if (httpGetOption(thisCol, "align", 0) == 0) {
                if (fp->type == EDI_TYPE_INT || fp->type == EDI_TYPE_FLOAT) {
                    if (!thisCol) {
                        thisCol = mprCreateHash(0, MPR_HASH_STABLE);
                    }
                    httpInsertOption(thisCol, "align", "right");
                }
            }
            value = formatValue(fp, thisCol);
            espRender(conn, "            <td%s>%s</td>\r\n", map(conn, thisCol), value);
        }
        espRender(conn, "        </tr>\r\n");
    }
    espRender(conn, "    </tbody>\r\n</table>\r\n");
}