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


C++ QVariant::toDate方法代码示例

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


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

示例1: set

enum SetResponse transferOrderItem::set(const ParameterList &pParams)
{
  XDialog::set(pParams);
  QVariant  param;
  bool      valid;

  _prev->setEnabled(true);
  _next->setEnabled(true);
  _next->setText(tr("Next"));

  param = pParams.value("tohead_id", &valid);
  if (valid)
    _toheadid = param.toInt();

  param = pParams.value("srcwarehouse_id", &valid);
  if (valid)
    _warehouse->setId(param.toInt());

  param = pParams.value("taxzone_id", &valid);
  if (valid)
    _taxzoneid = param.toInt();

  param = pParams.value("orderNumber", &valid);
  if (valid)
    _orderNumber->setText(param.toString());

  param = pParams.value("curr_id", &valid);
  if (valid)
    _freight->setId(param.toInt());

  param = pParams.value("orderDate", &valid);
  if (valid)
    _freight->setEffective(param.toDate());

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      _save->setEnabled(FALSE);
      _next->setText(tr("New"));
      _comments->setEnabled(FALSE);
      _item->setReadOnly(false);
      _item->setFocus();

      _item->addExtraClause(QString("(item_id IN ("
				    "  SELECT itemsite_item_id"
				    "  FROM itemsite"
				    "  WHERE itemsite_warehous_id=%1))")
				    .arg(_warehouse->id()) );

      prepare();

      param = pParams.value("captive", &valid);
      if (valid)
        _captive = TRUE;

      param = pParams.value("item_id", &valid);
      if (valid)
        _item->setId(param.toInt());

      param = pParams.value("dueDate", &valid);
      if (valid)
        _scheduledDate->setDate(param.toDate());

      param = pParams.value("qty", &valid);
      if (valid)
        _qtyOrdered->setDouble(param.toDouble());

      q.prepare("SELECT count(*) AS cnt"
                "  FROM toitem"
                " WHERE (toitem_tohead_id=:tohead_id);");
      q.bindValue(":tohead_id", _toheadid);
      q.exec();
      if(!q.first() || q.value("cnt").toInt() == 0)
        _prev->setEnabled(false);
      if (q.lastError().type() != QSqlError::NoError)
      {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return UndefinedError;
      }
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
      _item->setReadOnly(true);
      _save->setFocus();
    }
    else if (param.toString() == "view")
    {
      _mode = cView;
    }
  }

  if(cView == _mode)
  {
    _item->setReadOnly(true);
    _qtyOrdered->setEnabled(false);
//.........这里部分代码省略.........
开发者ID:Wushaowei001,项目名称:xtuple-1,代码行数:101,代码来源:transferOrderItem.cpp

示例2: set

enum SetResponse creditMemoItem::set(const ParameterList &pParams)
{
  QVariant param;
  bool     valid;
  bool     vrestrict = FALSE;

  param = pParams.value("cmhead_id", &valid);
  if (valid)
  {
    _cmheadid = param.toInt();
    q.prepare("SELECT cmhead_taxzone_id, cmhead_curr_id "
	            "FROM cmhead "
	            "WHERE (cmhead_id=:cmhead_id);");
    q.bindValue(":cmhead_id", _cmheadid);
    q.exec();
    if (q.first())
    {
      _taxzoneid = q.value("cmhead_taxzone_id").toInt();
      _tax->setId(q.value("cmhead_curr_id").toInt());
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return UndefinedError;
    }
  }

  param = pParams.value("rsncode_id", &valid);
  if (valid)
    _rsnCode->setId(param.toInt());

  param = pParams.value("cust_id", &valid);
  if (valid)
    _custid = param.toInt();

  param = pParams.value("shipto_id", &valid);
  if (valid)
    _shiptoid = param.toInt();

  param = pParams.value("invoiceNumber", &valid);
  if (valid)
  {
    if ( (param.toInt() == 0) || (param.toInt() == -1) )
      _invoiceNumber = -1;
    else
    {
      _invoiceNumber = param.toInt();

      if (_metrics->boolean("RestrictCreditMemos"))
        vrestrict = TRUE;
    }
  }

  param = pParams.value("creditMemoNumber", &valid);
  if (valid)
    _orderNumber->setText(param.toString());

  param = pParams.value("curr_id", &valid);
  if (valid)
    _netUnitPrice->setId(param.toInt());

  param = pParams.value("effective", &valid);
  if (valid)
    _netUnitPrice->setEffective(param.toDate());

  param = pParams.value("cmitem_id", &valid);
  if (valid)
  {
    _cmitemid = param.toInt();
    populate();
  }

  param = pParams.value("mode", &valid);
  if (valid)
  {
    if (param.toString() == "new")
    {
      _mode = cNew;

      q.prepare( "SELECT (COALESCE(MAX(cmitem_linenumber), 0) + 1) AS n_linenumber "
                 "FROM cmitem "
                 "WHERE (cmitem_cmhead_id=:cmhead_id);" );
      q.bindValue(":cmhead_id", _cmheadid);
      q.exec();
      if (q.first())
        _lineNumber->setText(q.value("n_linenumber").toString());
      else if (q.lastError().type() == QSqlError::NoError)
      {
	      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	      return UndefinedError;
      }

      connect(_discountFromSale, SIGNAL(lostFocus()), this, SLOT(sCalculateFromDiscount()));
      connect(_item, SIGNAL(valid(bool)), _listPrices, SLOT(setEnabled(bool)));

      _item->setFocus();
    }
    else if (param.toString() == "edit")
    {
      _mode = cEdit;
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例3: variantToTextValue

static QString variantToTextValue(const QVariant& value, const QString& typeNs, const QString& type)
{
    switch (value.userType())
    {
    case QVariant::Char:
        // fall-through
    case QVariant::String:
        return value.toString();
    case QVariant::Url:
        // xmlpatterns/data/qatomicvalue.cpp says to do this:
        return value.toUrl().toString();
    case QVariant::ByteArray:
    {
        const QByteArray data = value.toByteArray();
        if (typeNs == KDSoapNamespaceManager::xmlSchema1999() || typeNs == KDSoapNamespaceManager::xmlSchema2001()) {
            if (type == QLatin1String("hexBinary")) {
                const QByteArray hb = data.toHex();
                return QString::fromLatin1(hb.constData(), hb.size());
            }
        }
        // default to base64Binary, like variantToXMLType() does.
        const QByteArray b64 = value.toByteArray().toBase64();
        return QString::fromLatin1(b64.constData(), b64.size());
    }
    case QVariant::Int:
        // fall-through
    case QVariant::LongLong:
        // fall-through
    case QVariant::UInt:
        return QString::number(value.toLongLong());
    case QVariant::ULongLong:
        return QString::number(value.toULongLong());
    case QVariant::Bool:
    case QMetaType::Float:
    case QVariant::Double:
        return value.toString();
    case QVariant::Time:
    {
        const QTime time = value.toTime();
        if (time.msec()) {
            // include milli-seconds
            return time.toString(QLatin1String("hh:mm:ss.zzz"));
        } else {
            return time.toString(Qt::ISODate);
        }
    }
    case QVariant::Date:
        return value.toDate().toString(Qt::ISODate);
    case QVariant::DateTime: // http://www.w3.org/TR/xmlschema-2/#dateTime
        return KDDateTime(value.toDateTime()).toDateString();
    case QVariant::Invalid:
        qDebug() << "ERROR: Got invalid QVariant in a KDSoapValue";
        return QString();
    default:
        if (value.canConvert<KDDateTime>()) {
            return value.value<KDDateTime>().toDateString();
        }

        if (value.userType() == qMetaTypeId<float>())
            return QString::number(value.value<float>());

        qDebug() << QString::fromLatin1("QVariants of type %1 are not supported in "
                                        "KDSoap, see the documentation").arg(QLatin1String(value.typeName()));
        return value.toString();
    }
}
开发者ID:andreasgrv,项目名称:NewSumInterface,代码行数:66,代码来源:KDSoapValue.cpp

示例4: parseAgent

DATA::Agent LiliHelper::parseAgent(const QString aPath, const QStringList aAliases, const QString aSheet)
{
    QXlsx::Document aDocument (aPath);
    DATA::Agent aAgent;

    QStringList aStringList;
    if (aSheet.length() != 0)
    {
        aStringList.append(aSheet);
    }
    else
    {
        aStringList = aDocument.sheetNames();
    }

    for (auto aSheet : aStringList)
    {
        aDocument.selectSheet(aSheet);
        QXlsx::CellRange aSheetRange (aDocument.dimension());

        QHash<QString, QDate> aRefDateMap;
        QDate aCurrentDate;
        QString aNote;
        for (int nRow = aSheetRange.firstRow(); nRow <= aSheetRange.lastRow(); ++nRow)
        {
            QVariant aCell = aDocument.read(nRow, 2);
            const bool bFirst = aCell.type() == QVariant::String && s_aWeekDays.contains(aCell.toString());

            if (bFirst)
            {
                if (aDocument.read(nRow, 19).type() == QVariant::String)
                {
                    aNote = aDocument.read(nRow, 19).toString();
                }

                QString aCellRef = QXlsx::CellReference (nRow, 9).toString();
                QVariant aDateVariant = aDocument.read(aCellRef);

                // Looking for date without reference
                if (!aCurrentDate.isValid() && aDateVariant.type() == QVariant::Date)
                {
                    aCurrentDate = aDateVariant.toDate();
                    aRefDateMap.insert(aCellRef, aCurrentDate);
                }

                // Looking for date with reference
                else if (aCurrentDate.isValid() && aDateVariant.type() == QVariant::String)
                {
                    QRegularExpression aRx;
                    QRegularExpressionMatchIterator aRxIterator;
                    aRx.setPattern("=(\\w+\\d+)\\+(\\d+)");

                    aRxIterator = aRx.globalMatch(aDateVariant.toString());

                    if (aRxIterator.hasNext())
                    {
                        QRegularExpressionMatch aMatch = aRxIterator.next();
                        QString aReferencedCell = aMatch.captured(1);
                        if (aRefDateMap.contains(aReferencedCell))
                        {
                            aCurrentDate = aRefDateMap[aReferencedCell].addDays(aMatch.captured(2).toInt());
                            aRefDateMap.insert(aCellRef, aCurrentDate);
                        }
                    }
                }

            }
            else if (aCurrentDate.isValid())
            {
                QVariant aNameVariant = aDocument.read(nRow, 1);
                if (aNameVariant.type() == QVariant::String && aAliases.contains(aNameVariant.toString()))
                {
                    int nHourHead = 2;
                    while (nHourHead <= 54)
                    {
                        QVariant aVariant = aDocument.read(nRow, nHourHead);
                        int nTempHead = nHourHead + 1;

                        if (aVariant.type() == QVariant::Double && aVariant.toInt() == 1)
                        {
                            QTime aStartTime (7, 0);
                            if (nHourHead > 2)
                            {
                                aStartTime = aStartTime.addSecs(1800 + (nHourHead - 3) * 900);
                            }
                            QTime aEndTime = aStartTime.addSecs(15 * 60);
                            aVariant = aDocument.read(nRow, nTempHead);
                            while (nTempHead <= 54 && aVariant.type() == QVariant::Double && aVariant.toInt() == 1)
                            {
                                aEndTime = aEndTime.addSecs(15 * 60);
                                ++nTempHead;
                                aVariant = aDocument.read(nRow, nTempHead);
                            }
                            aAgent.getEvents().append(DATA::CalEvent (QDateTime (aCurrentDate, aStartTime),
                                                                      QDateTime (aCurrentDate, aEndTime),
                                                                      aNote));
                        }

                        nHourHead = nTempHead;
                    }
//.........这里部分代码省略.........
开发者ID:Neirbo888,项目名称:lilicalendar,代码行数:101,代码来源:LiliHelper.cpp

示例5: getLabels

bool PSV_Public::getLabels(QVariant &maxValue, QVariant &minValue, QPair<double, double> &range, QList<QPair<QVariant, QString> > &labelList)
{
    if(maxValue.type() != minValue.type())
    {
        return false;
    }
    QVariant::Type type = maxValue.type();
    switch(type)
    {
    case QVariant::Double:
    case QVariant::Int:
    case QVariant::UInt:
    {
        double max = maxValue.toDouble();
        double min = minValue.toDouble();
        int numTick = getNumTicks(max, min);
        if(numTick <= 0)
        {
            return false;
        }
        adjustRange(max, min);
        labelList.clear();
        for(int i = 0; i <= numTick; ++i)
        {
            double value = min + 1.0 * (max - min) * i / numTick;
            QString str = QObject::tr("%1").arg(value);
            labelList.append(QPair<QVariant, QString>(value, str));
        }
        maxValue = max;
        minValue = min;
        range = QPair<double,double>(min,max);
        return true;
    }
        break;
    case QVariant::Date:
    {
        QDate maxDate = maxValue.toDate();
        QDate minDate = minValue.toDate();
        bool isOk = getDateLabels(maxDate, minDate, labelList);
        maxValue = maxDate;
        minValue = minDate;
        range = QPair<double,double>(0.0, 1.0 * minDate.daysTo(maxDate));
        return isOk;
    }
        break;
    case QVariant::Time:
    {
        QTime maxTime = maxValue.toTime();
        QTime minTime = minValue.toTime();
        bool isOk = getTimeLabels(maxTime, minTime, labelList);
        maxValue = maxTime;
        minValue = minTime;
        range = QPair<double,double>(0.0, 86400.0/*1.0 * minTime.secsTo(maxTime)*/);
        return isOk;
    }
        break;
    case QVariant::DateTime:
    {
        QDateTime maxTime = maxValue.toDateTime();
        QDateTime minTime = minValue.toDateTime();
        //        PSV_Public::printMes(maxTime,"1maxTime");
        //        PSV_Public::printMes(minTime,"1minTime");
        bool isOk = getDateTimeLabels(maxTime, minTime, labelList);
        maxValue = maxTime;
        minValue = minTime;
        //        PSV_Public::printMes(maxTime,"2maxTime");
        //        PSV_Public::printMes(minTime,"2minTime");

        range = QPair<double,double>(PSV_BEGIN_DATETIME.secsTo(minValue.toDateTime()),PSV_BEGIN_DATETIME.secsTo(maxValue.toDateTime()));
        return isOk;
    }
        break;
    default:
        break;
    }
    return false;
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:77,代码来源:psv_public.cpp

示例6: editData

bool CaseInModel::editData(int i, int j, QVariant newValue)
{
	if (j == 1 || j == 8)
	{
		QString rowid = m_cache[0][i].toString();
		QString pole = (j==1)?"data_wejscia":"data_zabezpieczenia";
		QSqlQuery query( SqlConnectionController::qSqlDb() );
		query.exec("UPDATE sprawy_wejscie SET " + pole + " = '" + newValue.toString() + "' WHERE rowid = " + rowid );
		m_cache[j][i].setValue(newValue.toDate().toString("dd.MM.yyyy"));
		return true;
	}
	else if (j == 2)
	{
		if (newValue.toString() != "")
		{
			QString rowid = m_cache[0][i].toString();

			if (isHeUnique(newValue.toString()))
			{
				QSqlQuery query( SqlConnectionController::qSqlDb() );
				query.exec("UPDATE sprawy_wejscie SET nr_he = '"+newValue.toString()+"' WHERE rowid = " + rowid);
				m_cache[j][i].setValue(newValue);
			}
			return true;
		}
	}
	else if (j == 6)
	{
		if (newValue.toString() != "0")
		{
			QString rowid = m_cache[0][i].toString();
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET id_przydzial = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(QVariant(StaffModel::nameSurnameByRowId(newValue.toString())));
			return true;
		}

	} else if (j == 3)
	{
		if (newValue.toString() != "0")
		{
			QString rowid = m_cache[0][i].toString();
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET id_jednostka = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(QVariant(PoliceStationModel::cityStationByRowId(newValue.toString())));
			return true;
		}
	}
	else if (j == 7)
	{
		QString v = newValue.toString();
		if ((QStringList() << "k" << "w" << "u" <<"uk" << "r").contains(v) )
		{
			QString rowid = m_cache[0][i].toString();
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET rodzaj = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(newValue);
			return true;
		}

	}
	else if (j == 4 || j == 5 || j == 9)
	{
		QString val = newValue.toString();
		if (val != "")
		{
			QString pole;
			QString rowid = m_cache[0][i].toString();
			switch (j)
			{
			case 4:
				pole = "nr_rsd";
				break;
			case 5:
				pole = "opis";
				break;
			case 9:
				pole = "uwagi";
				break;
			}
			QSqlQuery query( SqlConnectionController::qSqlDb() );
			query.exec("UPDATE sprawy_wejscie SET "+pole+" = '" + newValue.toString() + "' WHERE rowid = " + rowid );
			m_cache[j][i].setValue(newValue);
			return true;
		}

	}
	return false;
}
开发者ID:cykusz,项目名称:rejestr,代码行数:89,代码来源:CaseInModel.cpp

示例7: evaluation

    void evaluation()
    {
      QFETCH( QString, string );
      QFETCH( bool, evalError );
      QFETCH( QVariant, result );

      QgsExpression exp( string );
      QCOMPARE( exp.hasParserError(), false );
      if ( exp.hasParserError() )
        qDebug() << exp.parserErrorString();

      QVariant res = exp.evaluate();
      if ( exp.hasEvalError() )
        qDebug() << exp.evalErrorString();
      if ( res.type() != result.type() )
      {
        qDebug() << "got " << res.typeName() << " instead of " << result.typeName();
      }
      //qDebug() << res.type() << " " << result.type();
      //qDebug() << "type " << res.typeName();
      QCOMPARE( exp.hasEvalError(), evalError );

      QCOMPARE( res.type(), result.type() );
      switch ( res.type() )
      {
        case QVariant::Invalid:
          break; // nothing more to check
        case QVariant::Int:
          QCOMPARE( res.toInt(), result.toInt() );
          break;
        case QVariant::Double:
          QCOMPARE( res.toDouble(), result.toDouble() );
          break;
        case QVariant::String:
          QCOMPARE( res.toString(), result.toString() );
          break;
        case QVariant::Date:
          QCOMPARE( res.toDate(), result.toDate() );
          break;
        case QVariant::DateTime:
          QCOMPARE( res.toDateTime(), result.toDateTime() );
          break;
        case QVariant::Time:
          QCOMPARE( res.toTime(), result.toTime() );
          break;
        case QVariant::UserType:
        {
          if ( res.userType() == qMetaTypeId<QgsExpression::Interval>() )
          {
            QgsExpression::Interval inter = res.value<QgsExpression::Interval>();
            QgsExpression::Interval gotinter = result.value<QgsExpression::Interval>();
            QCOMPARE( inter.seconds(), gotinter.seconds() );
          }
          else
          {
            QFAIL( "unexpected user type" );
          }
          break;
        }
        default:
          Q_ASSERT( false ); // should never happen
      }
    }
开发者ID:MERIDIAN-CHARTWARE,项目名称:QGIS-1,代码行数:63,代码来源:testqgsexpression.cpp

示例8: set

enum SetResponse shipOrder::set(const ParameterList &pParams)
{
  XSqlQuery shipet;
  XSqlQuery siteq;
  XDialog::set(pParams);
  QString  returnValue;
  QVariant param;
  bool     valid;

  param = pParams.value("transdate", &valid);
  if (valid)
  {
    _transDate->setDate(param.toDate(), true);
  }
  
  param = pParams.value("shiphead_id", &valid);
  if (valid)
  {
    shipet.prepare( "SELECT shiphead_order_id, shiphead_order_type "
               "FROM shiphead "
               "WHERE (shiphead_id=:shiphead_id);" );
    shipet.bindValue(":shiphead_id", param.toInt());
    shipet.exec();
    if (shipet.first())
    {
      _captive = true;	// so order handling can reject if necessary
      if (shipet.value("shiphead_order_type").toString() == "SO")
      {
        siteq.prepare( "SELECT DISTINCT itemsite_warehous_id "
                       "FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)"
                       "              JOIN coitem ON (coitem_id=shipitem_orderitem_id)"
                       "              JOIN itemsite ON (itemsite_id=coitem_itemsite_id)"
                       "WHERE (shiphead_id=:shiphead_id);" );
        siteq.bindValue(":shiphead_id", param.toInt());
        siteq.exec();
        if (siteq.first())
        {
          _warehouse->setId(siteq.value("itemsite_warehous_id").toInt());
        }
        _order->setId(param.toInt(), "SO");
      }
      else if (shipet.value("shiphead_order_type").toString() == "TO")
      {
        siteq.prepare( "SELECT DISTINCT tohead_src_warehous_id "
                      "FROM shiphead JOIN shipitem ON (shipitem_shiphead_id=shiphead_id)"
                      "              JOIN toitem ON (toitem_id=shipitem_orderitem_id)"
                      "              JOIN tohead ON (tohead_id=toitem_tohead_id)"
                      "WHERE (shiphead_id=:shiphead_id);" );
        siteq.bindValue(":shiphead_id", param.toInt());
        siteq.exec();
        if (siteq.first())
        {
          _warehouse->setId(siteq.value("tohead_src_warehous_id").toInt());
        }
        _order->setId(param.toInt(), "TO");
      }
    }
    else if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Retrieving Shipping Information"),
                                  shipet, __FILE__, __LINE__))
    {
      return UndefinedError;
    }

    _shipment->setId(param.toInt());	// last because of signal cascade
  }

  if (_reject)
    return UndefinedError;

  return NoError;
}
开发者ID:dwatson78,项目名称:qt-client,代码行数:71,代码来源:shipOrder.cpp

示例9: displayText

QString DateTimeDelegate::displayText(const QVariant &value, const QLocale &locale) const
{
    if (m_IsDateOnly)
        return locale.toString(value.toDate(), tkTr(Trans::Constants::DATEFORMAT_FOR_EDITOR));
    return locale.toString(value.toDateTime(), tkTr(Trans::Constants::DATETIMEFORMAT_FOR_EDITOR));
}
开发者ID:eads77m,项目名称:freemedforms,代码行数:6,代码来源:datetimedelegate.cpp

示例10: query

QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
{
    QSystemLocalePrivate *d = systemLocalePrivate();
    switch(type) {
    case DecimalPoint:
        return d->decimalPoint();
    case GroupSeparator:
        return d->groupSeparator();
    case NegativeSign:
        return d->negativeSign();
    case PositiveSign:
        return d->positiveSign();
    case DateFormatLong:
        return d->dateFormat(QLocale::LongFormat);
    case DateFormatShort:
        return d->dateFormat(QLocale::ShortFormat);
    case TimeFormatLong:
        return d->timeFormat(QLocale::LongFormat);
    case TimeFormatShort:
        return d->timeFormat(QLocale::ShortFormat);
    case DateTimeFormatLong:
        return d->dateTimeFormat(QLocale::LongFormat);
    case DateTimeFormatShort:
        return d->dateTimeFormat(QLocale::ShortFormat);
    case DayNameLong:
        return d->dayName(in.toInt(), QLocale::LongFormat);
    case DayNameShort:
        return d->dayName(in.toInt(), QLocale::ShortFormat);
    case MonthNameLong:
        return d->monthName(in.toInt(), QLocale::LongFormat);
    case MonthNameShort:
        return d->monthName(in.toInt(), QLocale::ShortFormat);
    case DateToStringShort:
        return d->toString(in.toDate(), QLocale::ShortFormat);
    case DateToStringLong:
        return d->toString(in.toDate(), QLocale::LongFormat);
    case TimeToStringShort:
        return d->toString(in.toTime(), QLocale::ShortFormat);
    case TimeToStringLong:
        return d->toString(in.toTime(), QLocale::LongFormat);
    case DateTimeToStringShort:
        return d->toString(in.toDateTime(), QLocale::ShortFormat);
    case DateTimeToStringLong:
        return d->toString(in.toDateTime(), QLocale::LongFormat);
    case ZeroDigit:
        return d->zeroDigit();
    case LanguageId:
    case CountryId: {
        QString locale = QString::fromLatin1(getWinLocaleName());
        QLocale::Language lang;
        QLocale::Script script;
        QLocale::Country cntry;
        QLocalePrivate::getLangAndCountry(locale, lang, script, cntry);
        if (type == LanguageId)
            return lang;
        if (cntry == QLocale::AnyCountry)
            return fallbackLocale().country();
        return cntry;
    }
    case ScriptId:
        return QVariant(QLocale::AnyScript);
    case MeasurementSystem:
        return d->measurementSystem();
    case AMText:
        return d->amText();
    case PMText:
        return d->pmText();
    case FirstDayOfWeek:
        return d->firstDayOfWeek();
    case CurrencySymbol:
        return d->currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
    case CurrencyToString:
        return d->toCurrencyString(in.value<QSystemLocale::CurrencyToStringArgument>());
    case UILanguages:
        return d->uiLanguages();
    case LocaleChanged:
        d->update();
        break;
    case NativeLanguageName:
        return d->nativeLanguageName();
    case NativeCountryName:
        return d->nativeCountryName();
    default:
        break;
    }
    return QVariant();
}
开发者ID:Afreeca,项目名称:qt,代码行数:87,代码来源:qlocale_win.cpp

示例11: data

QVariant TableModel::data(const QModelIndex &index, int role) const
{
	QVariant ret;
	if(!index.isValid())
		return ret;
	if(role == RawValueRole) {
		ret = value(index.row(), index.column());
	}
	else if(role == ValueIsDirtyRole) {
		ret = isDirty(index.row(), index.column());
	}
	else if(role == SortRole) {
		int type = columnType(index.column());
		if(type == QVariant::Bool)
			ret = value(index.row(), index.column()).toBool();
		else
			ret = data(index, Qt::DisplayRole);
	}
	else if(role == Qt::DisplayRole) {
		ColumnDefinition cd = m_columns.value(index.column());
		if(cd.isNull()) {
			return QString("!%1").arg(index.column());
		}
		if(data(index, ValueIsNullRole).toBool()) {
			if(isNullReportedAsString())
				return QStringLiteral("null");
			return QVariant();
		}
		ret = data(index, Qt::EditRole);
		int type = columnType(index.column());
		if(type == QVariant::Invalid)
			type = ret.type(); /// pokud jsou sloupce virtualni (sloupce se pocitaji, nemusi byt pro ne definovan typ)
		if(type == QVariant::ByteArray) {
			const static QString blob_string = "{blob %1%2}";
			int size = ret.toByteArray().size();
			if(size < 1024) ret = blob_string.arg(size).arg(" B");
			else ret = blob_string.arg(size/1024).arg("kB");
		}
		else if(type == QVariant::Bool) {
			/// display check
			ret = QString();
		}
		QString format = cd.format();
		if(format.isEmpty()) {
			if(type == QVariant::Date) {
				format = m_defaultDateFormat;
			}
			else if(type == QVariant::Time) {
				format = m_defaultTimeFormat;
				//qfInfo() << "format" << format;
			}
			else if(type == QVariant::DateTime) {
				format = m_defaultDateTimeFormat;
				//qfInfo() << "format" << format;
			}
		}
		if(!format.isEmpty()) {
			if(type == QVariant::Time) {
				QTime t = ret.toTime();
				ret = t.toString(format);
			}
			else if(type == QVariant::Date) {
				QDate d = ret.toDate();
				ret = d.toString(format);
			}
			else if(type == QVariant::DateTime) {
				QDateTime dt = ret.toDateTime();
				ret = dt.toString(format);
			}
		}
	}
	else if(role == Qt::EditRole) {
		ret = data(index, RawValueRole);
		ret = rawValueToEdit(index.column(), ret);
	}
	else if (role == ValueIsNullRole) {
		ret = data(index, RawValueRole);
		return ret.isNull() && ret.isValid();
	}
	else if (role == Qt::TextAlignmentRole) {
		const ColumnDefinition cd = m_columns.value(index.column());
		Qt::Alignment al = cd.alignment();
		if(!!al)
			ret = (int)al;
		else {
			if(!data(index, ValueIsNullRole).toBool()) {
				ret = data(index, RawValueRole);
				if(ret.type() > QVariant::Bool && ret.type() <= QVariant::Double)
					ret = Qt::AlignRight;
				else
					ret = Qt::AlignLeft;
			}
		}
	}
	else if(role == Qt::TextColorRole) {
		int type = columnType(index.column());
		if(type == QVariant::ByteArray)
			return QColor(Qt::blue);
		if(data(index, ValueIsNullRole).toBool()) {
			return QColor(Qt::blue);
//.........这里部分代码省略.........
开发者ID:nitschk,项目名称:quickbox,代码行数:101,代码来源:tablemodel.cpp

示例12: set

enum SetResponse substituteList::set(const ParameterList &pParams)
{
  XSqlQuery substituteet;
  XDialog::set(pParams);
  QVariant param;
  bool     valid;

  param = pParams.value("womatl_id", &valid);
  if (valid)
  {
    substituteet.prepare( "SELECT womatl_itemsite_id,"
               "       bomitem_id, COALESCE(bomitem_subtype, 'I') AS subtype,"
               "       COALESCE(wo_id, 0) AS wo_id "
               "FROM womatl LEFT OUTER JOIN bomitem ON (bomitem_id=womatl_bomitem_id) "
               "            LEFT OUTER JOIN wo ON ( (wo_ordtype='W') AND"
               "                                    (wo_ordid=womatl_wo_id) AND"
               "                                    (wo_itemsite_id=womatl_itemsite_id) ) "
               "WHERE (womatl_id=:womatl_id);" );
    substituteet.bindValue(":womatl_id", param.toInt());
    substituteet.exec();
    if (substituteet.first())
    {
      if (substituteet.value("wo_id").toInt() > 0)
      {
        QMessageBox::warning(this, tr("Child Work Order"),
            tr("A child Work Order exists for this Material \n"
               "Requirement.  You should delete this \n"
               "child Work Order before substituting.") );
      }
      _item->setItemsiteid(substituteet.value("womatl_itemsite_id").toInt());
      _item->setReadOnly(TRUE);
      _warehouse->setEnabled(FALSE);
      
      _bomitemid = substituteet.value("bomitem_id").toInt();
      _itemsiteid = substituteet.value("womatl_itemsite_id").toInt();
      _source = substituteet.value("subtype").toString();

      sFillList();
    }
  }

  _byLeadTime->setChecked(pParams.inList("byLeadTime"));

  param = pParams.value("byDays", &valid);
  if (valid)
  {
   _byDays->setChecked(TRUE);
   _days->setValue(param.toInt());
  }

  param = pParams.value("byDate", &valid);
  if (valid)
  {
   _byDate->setChecked(TRUE);
   _date->setDate(param.toDate());
  }

  if (pParams.inList("run"))
  {
    sFillList();
    return NoError_Run;
  }

  return NoError;
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:65,代码来源:substituteList.cpp

示例13: data

QVariant LocaleModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid()
        || role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole
        || index.column() >= g_model_cols
        || index.row() >= g_locale_list_count + 2)
        return QVariant();

    QVariant data;
    if (index.column() < g_model_cols - 1)
        data = m_data_list.at(index.column());

    if (index.row() == 0) {
        if (role == Qt::ToolTipRole)
            return QVariant();
        switch (index.column()) {
            case 0:
                return data.toDouble();
            case 1:
                return data.toDate();
            case 2:
                return data.toDate();
            case 3:
                return data.toTime();
            case 4:
                return data.toTime();
            case 5:
                return QVariant();
            default:
                break;
        }
    } else {
        QLocale locale;
        if (index.row() == 1) {
            locale = QLocale::system();
        } else {
            LocaleListItem item = g_locale_list[index.row() - 2];
            locale = QLocale((QLocale::Language)item.language, (QLocale::Country)item.country);
        }

        switch (index.column()) {
            case 0:
                if (role == Qt::ToolTipRole)
                    return QVariant();
                return locale.toString(data.toDouble());
            case 1:
                if (role == Qt::ToolTipRole)
                    return locale.dateFormat(QLocale::LongFormat);
                return locale.toString(data.toDate(), QLocale::LongFormat);
            case 2:
                if (role == Qt::ToolTipRole)
                    return locale.dateFormat(QLocale::ShortFormat);
                return locale.toString(data.toDate(), QLocale::ShortFormat);
            case 3:
                if (role == Qt::ToolTipRole)
                    return locale.timeFormat(QLocale::LongFormat);
                return locale.toString(data.toTime(), QLocale::LongFormat);
            case 4:
                if (role == Qt::ToolTipRole)
                    return locale.timeFormat(QLocale::ShortFormat);
                return locale.toString(data.toTime(), QLocale::ShortFormat);
            case 5:
                if (role == Qt::ToolTipRole)
                    return QVariant();
                return locale.name();
            default:
                break;
        }
    }

    return QVariant();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:72,代码来源:localemodel.cpp

示例14: writeEntry

void KConfigBase::writeEntry(const char *pKey, const QVariant &prop, bool bPersistent, bool bGlobal, bool bNLS)
{
    switch(prop.type())
    {
        case QVariant::Invalid:
            writeEntry(pKey, "", bPersistent, bGlobal, bNLS);
            return;
        case QVariant::String:
            writeEntry(pKey, prop.toString(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::StringList:
            writeEntry(pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS);
            return;
        case QVariant::List:
        {
            QValueList< QVariant > list = prop.toList();
            QValueList< QVariant >::ConstIterator it = list.begin();
            QValueList< QVariant >::ConstIterator end = list.end();
            QStringList strList;

            for(; it != end; ++it)
                strList.append((*it).toString());

            writeEntry(pKey, strList, ',', bPersistent, bGlobal, bNLS);

            return;
        }
        case QVariant::Font:
            writeEntry(pKey, prop.toFont(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Point:
            writeEntry(pKey, prop.toPoint(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Rect:
            writeEntry(pKey, prop.toRect(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Size:
            writeEntry(pKey, prop.toSize(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Color:
            writeEntry(pKey, prop.toColor(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Int:
            writeEntry(pKey, prop.toInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::UInt:
            writeEntry(pKey, prop.toUInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::LongLong:
            writeEntry(pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::ULongLong:
            writeEntry(pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Bool:
            writeEntry(pKey, prop.toBool(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Double:
            writeEntry(pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS);
            return;
        case QVariant::DateTime:
            writeEntry(pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Date:
            writeEntry(pKey, QDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
            return;

        case QVariant::Pixmap:
        case QVariant::Image:
        case QVariant::Brush:
        case QVariant::Palette:
        case QVariant::ColorGroup:
        case QVariant::Map:
        case QVariant::IconSet:
        case QVariant::CString:
        case QVariant::PointArray:
        case QVariant::Region:
        case QVariant::Bitmap:
        case QVariant::Cursor:
        case QVariant::SizePolicy:
        case QVariant::Time:
        case QVariant::ByteArray:
        case QVariant::BitArray:
        case QVariant::KeySequence:
        case QVariant::Pen:
            break;
    }

    Q_ASSERT(0);
}
开发者ID:serghei,项目名称:kde3-kdelibs,代码行数:90,代码来源:kconfigbase.cpp

示例15: printMes

void PSV_Public::printMes(const QVariant &mes, const QString &frefix)
{    
    QString message;
    int type = mes.type();
    switch(type)
    {
    case QVariant::Bool :
        message = mes.toBool() ? "true":"false";
        break;
    case QVariant::Color :
    {
        QColor color = mes.value<QColor>();
        message = QObject::tr("colorname:%1,r=%2,g=%3,b=%4")
                .arg(color.name())
                .arg(color.red())
                .arg(color.green())
                .arg(color.blue());
    }
        break;
    case QVariant::Date:
        message = mes.toDate().toString("yyyy-MM-dd");
        break;
    case QVariant::DateTime:
        message = mes.toDateTime().toString("yyyy-MM-dd hh:mm:ss");
        break;
    case QVariant::Double:
        message = QString::number(mes.toDouble());
        break;
    case QVariant::UInt:
    case QVariant::Int:
        message = QString::number(mes.toInt());
        break;
    case QVariant::ULongLong:
    case QVariant::LongLong:
        message = QString::number(mes.toLongLong());
        break;
    case QVariant::Line:
    {
        QLine line = mes.toLine();
        message = QObject::tr("Line x1=%1,y1=%2,x2=%3,y2=%4")
                .arg(line.x1()).arg(line.y1()).arg(line.x2()).arg(line.y2());
    }
        break;
    case QVariant::LineF:
    {
        QLineF lineF = mes.toLineF();
        message = QObject::tr("LineF x1=%1,y1=%2,x2=%3,y2=%4")
                .arg(lineF.x1()).arg(lineF.y1()).arg(lineF.x2()).arg(lineF.y2());
    }
        break;
    case QVariant::Point:
    {
        QPoint point = mes.toPoint();
        message = QObject::tr("point x=%1,y=%2")
                .arg(point.x()).arg(point.y());
    }
        break;
    case QVariant::PointF:
    {
        QPointF pointF = mes.toPointF();
        message = QObject::tr("pointF x=%1,y=%2")
                .arg(pointF.x()).arg(pointF.y());
    }
        break;
    case QVariant::Rect:
    {
        QRect rect = mes.toRect();
        message = QObject::tr("rect x=%1,y=%2,width=%3,height=%4")
                .arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
    }
        break;
    case QVariant::RectF:
    {
        QRectF rectF = mes.toRect();
        message = QObject::tr("rectF x=%1,y=%2,width=%3,height=%4")
                .arg(rectF.x()).arg(rectF.y()).arg(rectF.width()).arg(rectF.height());
    }
        break;

    default:
        message = QObject::tr("type = %1,<%2>").arg(type).arg(mes.toString());
        break;
    }
    QString outMes = QObject::tr("%1 %2").arg(frefix).arg(message);

    qDebug()<<QObject::tr("PSV_LIB:<%1>%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")).arg(outMes);
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:87,代码来源:psv_public.cpp


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