当前位置: 首页>>代码示例>>C++>>正文


C++ QLocale::negativeSign方法代码示例

本文整理汇总了C++中QLocale::negativeSign方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocale::negativeSign方法的具体用法?C++ QLocale::negativeSign怎么用?C++ QLocale::negativeSign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QLocale的用法示例。


在下文中一共展示了QLocale::negativeSign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sSave


//.........这里部分代码省略.........
  QLocale sampleLocale = generateLocale();

  if (_mode == cNew)
  {
    q.prepare( "INSERT INTO locale "
               "( locale_id, locale_code, locale_descrip,"
               "  locale_lang_id, locale_country_id, "
               "  locale_dateformat, locale_timeformat, locale_timestampformat,"
	       "  locale_intervalformat, locale_qtyformat,"
               "  locale_curr_scale,"
               "  locale_salesprice_scale, locale_purchprice_scale,"
               "  locale_extprice_scale, locale_cost_scale,"
               "  locale_qty_scale, locale_qtyper_scale,"
               "  locale_uomratio_scale, locale_percent_scale, "
               "  locale_comments, "
               "  locale_error_color, locale_warning_color,"
               "  locale_emphasis_color, locale_altemphasis_color,"
               "  locale_expired_color, locale_future_color) "
               "VALUES "
               "( :locale_id, :locale_code, :locale_descrip,"
               "  :locale_lang_id, :locale_country_id,"
               "  :locale_dateformat, :locale_timeformat, :locale_timestampformat,"
	       "  :locale_intervalformat, :locale_qtyformat,"
               "  :locale_curr_scale,"
               "  :locale_salesprice_scale, :locale_purchprice_scale,"
               "  :locale_extprice_scale, :locale_cost_scale,"
               "  :locale_qty_scale, :locale_qtyper_scale,"
               "  :locale_uomratio_scale, :local_percent_scale, "
               "  :locale_comments,"
               "  :locale_error_color, :locale_warning_color,"
               "  :locale_emphasis_color, :locale_altemphasis_color,"
               "  :locale_expired_color, :locale_future_color);" );
  }
  else if ( (_mode == cEdit) || (_mode == cCopy) )
    q.prepare( "UPDATE locale "
                "SET locale_code=:locale_code,"
                "    locale_descrip=:locale_descrip,"
                "    locale_lang_id=:locale_lang_id,"
                "    locale_country_id=:locale_country_id,"
                "    locale_dateformat=:locale_dateformat,"
                "    locale_timeformat=:locale_timeformat,"
                "    locale_timestampformat=:locale_timestampformat,"
                "    locale_intervalformat=:locale_intervalformat,"
                "    locale_qtyformat=:locale_qtyformat,"
		"    locale_curr_scale=:locale_curr_scale,"
                "    locale_salesprice_scale=:locale_salesprice_scale,"
                "    locale_purchprice_scale=:locale_purchprice_scale,"
                "    locale_extprice_scale=:locale_extprice_scale,"
                "    locale_cost_scale=:locale_cost_scale,"
                "    locale_qty_scale=:locale_qty_scale,"
                "    locale_qtyper_scale=:locale_qtyper_scale,"
                "    locale_uomratio_scale=:locale_uomratio_scale,"
                "    locale_percent_scale=:locale_percent_scale,"
                "    locale_comments=:locale_comments,"
                "    locale_error_color=:locale_error_color,"
                "    locale_warning_color=:locale_warning_color,"
                "    locale_emphasis_color=:locale_emphasis_color,"
                "    locale_altemphasis_color=:locale_altemphasis_color,"
                "    locale_expired_color=:locale_expired_color,"
                "    locale_future_color=:locale_future_color "
                "WHERE (locale_id=:locale_id);" );

  q.bindValue(":locale_id",                _localeid);
  q.bindValue(":locale_code",              _code->text());
  q.bindValue(":locale_descrip",           _description->text());
  q.bindValue(":locale_lang_id",           _language->id());
  q.bindValue(":locale_country_id",        _country->id());
  q.bindValue(":locale_curr_scale",        _currencyScale->text());
  q.bindValue(":locale_salesprice_scale",  _salesPriceScale->text());
  q.bindValue(":locale_purchprice_scale",  _purchPriceScale->text());
  q.bindValue(":locale_extprice_scale",    _extPriceScale->text());
  q.bindValue(":locale_cost_scale",        _costScale->text());
  q.bindValue(":locale_qty_scale",         _qtyScale->text());
  q.bindValue(":locale_qtyper_scale",      _qtyPerScale->text());
  q.bindValue(":locale_uomratio_scale",    _uomRatioScale->text());
  q.bindValue(":locale_percent_scale",     _percentScale->text());
  q.bindValue(":locale_comments",          _comments->toPlainText());
  q.bindValue(":locale_error_color",       _error->text());
  q.bindValue(":locale_warning_color",     _warning->text());
  q.bindValue(":locale_emphasis_color",    _emphasis->text());
  q.bindValue(":locale_altemphasis_color", _alternate->text());
  q.bindValue(":locale_expired_color",     _expired->text());
  q.bindValue(":locale_future_color",      _future->text());
  q.bindValue(":locale_dateformat",     convert(sampleLocale.dateFormat(QLocale::ShortFormat)));
  q.bindValue(":locale_timeformat",     convert(sampleLocale.timeFormat(QLocale::ShortFormat)));
  q.bindValue(":locale_timestampformat",convert(sampleLocale.dateFormat(QLocale::ShortFormat)) +
                                  " " + convert(sampleLocale.timeFormat(QLocale::ShortFormat)));
  q.bindValue(":locale_intervalformat", convert(sampleLocale.timeFormat(QLocale::ShortFormat).remove("ap", Qt::CaseInsensitive)));
  q.bindValue(":locale_qtyformat",      QString(sampleLocale.decimalPoint()) +
                                        QString(sampleLocale.negativeSign()) +
                                        QString(sampleLocale.groupSeparator()));
  q.exec();
  if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }

  done(_localeid);
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: stringToValue

	/// \brief Converts string containing value and (prefix+)unit to double (Counterpart to Helper::valueToString).
	/// \param text The text containing the value and its unit.
	/// \param unit The base unit of the value.
	/// \param ok Pointer to a success-flag, true on success, false on error.
	/// \return Decoded value.
	double stringToValue(const QString &text, Unit unit, bool *ok) {
		// Check if the text is empty
		int totalSize = text.size();
		if(!totalSize){
			if(ok)
				*ok = false;
			return 0.0;
		}
		
		// Split value and unit apart
		int valueSize = 0;
		QLocale locale;
		bool decimalFound = false;
		bool exponentFound = false;
		if(text[valueSize] == locale.negativeSign())
			++valueSize;
		for(; valueSize < text.size(); ++valueSize) {
			QChar character = text[valueSize];
			
			if(character.isDigit()) {
			}
			else if(character == locale.decimalPoint() && decimalFound == false && exponentFound == false) {
				decimalFound = true;
			}
			else if(character == locale.exponential() && exponentFound == false) {
				exponentFound = true;
				if(text[valueSize + 1] == locale.negativeSign())
					++valueSize;
			}
			else {
				break;
			}
		}
		QString valueString = text.left(valueSize);
		bool valueOk = false;
		double value = valueString.toDouble(&valueOk);
		if(!valueOk) {
			if(ok)
				*ok = false;
			return value;
		}
		QString unitString = text.right(text.size() - valueSize).trimmed();
		
		if(ok)
			*ok = true;
		switch(unit) {
			case UNIT_VOLTS: {
				// Voltage string decoding
				if(unitString.startsWith('\265'))
					return value * 1e-6;
				else if(unitString.startsWith('m'))
					return value * 1e-3;
				else
					return value;
			}
			case UNIT_DECIBEL:
				// Power level string decoding
				return value;
			
			case UNIT_SECONDS:
				// Time string decoding
				if(unitString.startsWith('p'))
					return value * 1e-12;
				else if(unitString.startsWith('n'))
					return value * 1e-9;
				else if(unitString.startsWith('\265'))
					return value * 1e-6;
				else if(unitString.startsWith("min"))
					return value * 60;
				else if(unitString.startsWith('m'))
					return value * 1e-3;
				else if(unitString.startsWith('h'))
					return value * 3600;
				else
					return value;
			
			case UNIT_HERTZ:
				// Frequency string decoding
				if(unitString.startsWith('k'))
					return value * 1e3;
				else if(unitString.startsWith('M'))
					return value * 1e6;
				else if(unitString.startsWith('G'))
					return value * 1e9;
				else
					return value;
			
			case UNIT_SAMPLES:
				// Sample count string decoding
				if(unitString.startsWith('k'))
					return value * 1e3;
				else if(unitString.startsWith('M'))
					return value * 1e6;
				else if(unitString.startsWith('G'))
					return value * 1e9;
//.........这里部分代码省略.........
开发者ID:Sparkq,项目名称:OpnHntkDroid,代码行数:101,代码来源:helper.cpp


注:本文中的QLocale::negativeSign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。