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


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

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


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

示例1: _q_copyReadyRead

void QNetworkReplyImplPrivate::_q_copyReadyRead()
{
    Q_Q(QNetworkReplyImpl);
    if (state != Working)
        return;
    if (!copyDevice || !q->isOpen())
        return;

    // FIXME Optimize to use download buffer if it is a QBuffer.
    // Needs to be done where sendCacheContents() (?) of HTTP is emitting
    // metaDataChanged ?

    forever {
        qint64 bytesToRead = nextDownstreamBlockSize();
        if (bytesToRead == 0)
            // we'll be called again, eventually
            break;

        bytesToRead = qBound<qint64>(1, bytesToRead, copyDevice->bytesAvailable());
        QByteArray byteData;
        byteData.resize(bytesToRead);
        qint64 bytesActuallyRead = copyDevice->read(byteData.data(), byteData.size());
        if (bytesActuallyRead == -1) {
            byteData.clear();
            backendNotify(NotifyCopyFinished);
            break;
        }

        byteData.resize(bytesActuallyRead);
        readBuffer.append(byteData);

        if (!copyDevice->isSequential() && copyDevice->atEnd()) {
            backendNotify(NotifyCopyFinished);
            bytesDownloaded += bytesActuallyRead;
            break;
        }

        bytesDownloaded += bytesActuallyRead;
    }

    if (bytesDownloaded == lastBytesDownloaded) {
        // we didn't read anything
        return;
    }

    lastBytesDownloaded = bytesDownloaded;
    QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
    if (preMigrationDownloaded != Q_INT64_C(-1))
        totalSize = totalSize.toLongLong() + preMigrationDownloaded;
    pauseNotificationHandling();
    // emit readyRead before downloadProgress incase this will cause events to be
    // processed and we get into a recursive call (as in QProgressDialog).
    emit q->readyRead();
    if (downloadProgressSignalChoke.elapsed() >= progressSignalInterval) {
        downloadProgressSignalChoke.restart();
        emit q->downloadProgress(bytesDownloaded,
                             totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong());
    }
    resumeNotificationHandling();
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:60,代码来源:qnetworkreplyimpl.cpp

示例2: qgsVariantLessThan

bool qgsVariantLessThan( const QVariant& lhs, const QVariant& rhs )
{
  switch ( lhs.type() )
  {
    case QVariant::Int:
      return lhs.toInt() < rhs.toInt();
    case QVariant::UInt:
      return lhs.toUInt() < rhs.toUInt();
    case QVariant::LongLong:
      return lhs.toLongLong() < rhs.toLongLong();
    case QVariant::ULongLong:
      return lhs.toULongLong() < rhs.toULongLong();
    case QVariant::Double:
      return lhs.toDouble() < rhs.toDouble();
    case QVariant::Char:
      return lhs.toChar() < rhs.toChar();
    case QVariant::Date:
      return lhs.toDate() < rhs.toDate();
    case QVariant::Time:
      return lhs.toTime() < rhs.toTime();
    case QVariant::DateTime:
      return lhs.toDateTime() < rhs.toDateTime();
    default:
      return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
  }
}
开发者ID:dakcarto,项目名称:QGIS-Auth,代码行数:26,代码来源:qgis.cpp

示例3: switch

static void
writeValue(trace::Writer &writer, const QVariant &var, unsigned &id)
{
    int arrayType   = QMetaType::type("ApiArray");
    int bitmaskType = QMetaType::type("ApiBitmask");
    int structType  = QMetaType::type("ApiStruct");
    int pointerType = QMetaType::type("ApiPointer");
    int enumType    = QMetaType::type("ApiEnum");
    int type = var.userType();

    switch(type) {
    case QVariant::Bool:
        writer.writeBool(var.toBool());
        break;
    case QVariant::ByteArray: {
        QByteArray ba = var.toByteArray();
        writer.writeBlob((const void*)ba.constData(), ba.size());
    }
        break;
    case QVariant::Double:
        writer.writeDouble(var.toDouble());
        break;
    case QMetaType::Float:
        writer.writeFloat(var.toFloat());
        break;
    case QVariant::Int:
        writer.writeSInt(var.toInt());
        break;
    case QVariant::LongLong:
        writer.writeSInt(var.toLongLong());
        break;
    case QVariant::String: {
        QString str = var.toString();
        writer.writeString(str.toLocal8Bit().constData(), str.length());
    }
        break;
    case QVariant::UInt:
        writer.writeUInt(var.toInt());
        break;
    case QVariant::ULongLong:
        writer.writeUInt(var.toLongLong());
        break;
    default:
        if (type == arrayType) {
            ApiArray array = var.value<ApiArray>();
            QVector<QVariant> vals = array.values();
            writer.beginArray(vals.count());
            foreach(QVariant el, vals) {
                writer.beginElement();
                writeValue(writer, el, ++id);
                writer.endElement();
            }
            writer.endArray();
        } else if (type == bitmaskType) {
开发者ID:float-tw,项目名称:apitrace,代码行数:54,代码来源:saverthread.cpp

示例4: lessThan

bool ImageSortSettings::lessThan(const QVariant& left, const QVariant& right) const
{
    if (left.type() != right.type())
    {
        return false;
    }

    switch (left.type())
    {
        case QVariant::Int:
            return compareByOrder(left.toInt(), right.toInt(), currentSortOrder);
        case QVariant::UInt:
            return compareByOrder(left.toUInt(), right.toUInt(), currentSortOrder);
        case QVariant::LongLong:
            return compareByOrder(left.toLongLong(), right.toLongLong(), currentSortOrder);
        case QVariant::ULongLong:
            return compareByOrder(left.toULongLong(), right.toULongLong(), currentSortOrder);
        case QVariant::Double:
            return compareByOrder(left.toDouble(), right.toDouble(), currentSortOrder);
        case QVariant::Date:
            return compareByOrder(left.toDate(), right.toDate(), currentSortOrder);
        case QVariant::DateTime:
            return compareByOrder(left.toDateTime(), right.toDateTime(), currentSortOrder);
        case QVariant::Time:
            return compareByOrder(left.toTime(), right.toTime(), currentSortOrder);
        case QVariant::Rect:
        case QVariant::RectF:
        {
            QRectF rectLeft  = left.toRectF();
            QRectF rectRight = right.toRectF();
            int result;

            if ((result = compareByOrder(rectLeft.top(), rectRight.top(), currentSortOrder)) != 0)
            {
                return result < 0;
            }

            if ((result = compareByOrder(rectLeft.left(), rectRight.left(), currentSortOrder)) != 0)
            {
                return result < 0;
            }

            QSizeF sizeLeft = rectLeft.size(), sizeRight = rectRight.size();

            if ((result = compareByOrder(sizeLeft.width()*sizeLeft.height(), sizeRight.width()*sizeRight.height(), currentSortOrder)) != 0)
            {
                return result < 0;
            }
            // FIXME: fall through?? If not, add "break" here
        }
        default:
            return naturalCompare(left.toString(), right.toString(), currentSortOrder, sortCaseSensitivity);
    }
}
开发者ID:rickysarraf,项目名称:digikam,代码行数:54,代码来源:imagesortsettings.cpp

示例5: displayText

QString DateDelegate::displayText(const QVariant &value, const QLocale &locale) const {
    Q_UNUSED(locale); // suppress unused variable

    if (value.toLongLong() == 0)
        return "";
    QDateTime timestamp;
    timestamp.setTime_t(value.toLongLong()/1000);

    //    if (timestamp.date() == QDate::currentDate())
    //        return tr("Today") +" " + timestamp.time().toString(global.getTimeFormat());

    return timestamp.toString(global.getDateTimeFormat());
}
开发者ID:jeffkowalski,项目名称:Nixnote2,代码行数:13,代码来源:datedelegate.cpp

示例6: lessThan

bool QgsAttributeTableFilterModel::lessThan( const QModelIndex &left, const QModelIndex &right ) const
{
  if ( mSelectedOnTop )
  {
    bool leftSelected = layer()->selectedFeaturesIds().contains( masterModel()->rowToId( left.row() ) );
    bool rightSelected = layer()->selectedFeaturesIds().contains( masterModel()->rowToId( right.row() ) );

    if ( leftSelected && !rightSelected )
    {
      return true;
    }
    else if ( rightSelected && !leftSelected )
    {
      return false;
    }
  }


  QVariant leftData = left.data( QgsAttributeTableModel::SortRole );
  QVariant rightData = right.data( QgsAttributeTableModel::SortRole );

  if ( leftData.isNull() )
    return true;

  if ( rightData.isNull() )
    return false;

  switch ( leftData.type() )
  {
    case QVariant::Int:
    case QVariant::UInt:
    case QVariant::LongLong:
    case QVariant::ULongLong:
      return leftData.toLongLong() < rightData.toLongLong();

    case QVariant::Double:
      return leftData.toDouble() < rightData.toDouble();

    case QVariant::Date:
      return leftData.toDate() < rightData.toDate();

    case QVariant::DateTime:
      return leftData.toDateTime() < rightData.toDateTime();

    default:
      return leftData.toString().localeAwareCompare( rightData.toString() ) < 0;
  }

  // Avoid warning. Will never reach this
  return false;
}
开发者ID:vpicavet,项目名称:Quantum-GIS,代码行数:51,代码来源:qgsattributetablefiltermodel.cpp

示例7: compareCategories

int KCategorizedSortFilterProxyModel::compareCategories ( const QModelIndex &left, const QModelIndex &right ) const
{
	QVariant l = ( left.model() ? left.model()->data ( left, CategorySortRole ) : QVariant() );
	QVariant r = ( right.model() ? right.model()->data ( right, CategorySortRole ) : QVariant() );

	Q_ASSERT ( l.isValid() );
	Q_ASSERT ( r.isValid() );
	Q_ASSERT ( l.type() == r.type() );

	if ( l.type() == QVariant::String )
	{
		QString lstr = l.toString();
		QString rstr = r.toString();

		/*
		if ( d->sortCategoriesByNaturalComparison )
		{
			return KStringHandler::naturalCompare ( lstr, rstr );
		}
		else
		{
			*/
			if ( lstr < rstr )
			{
				return -1;
			}

			if ( lstr > rstr )
			{
				return 1;
			}

			return 0;
		//}
	}

	qlonglong lint = l.toLongLong();
	qlonglong rint = r.toLongLong();

	if ( lint < rint )
	{
		return -1;
	}

	if ( lint > rint )
	{
		return 1;
	}

	return 0;
}
开发者ID:ACGaming,项目名称:MultiMC5,代码行数:51,代码来源:categorizedsortfilterproxymodel.cpp

示例8: _q_copyReadyRead

void QNetworkReplyImplPrivate::_q_copyReadyRead()
{
    Q_Q(QNetworkReplyImpl);
    if (state != Working)
        return;
    if (!copyDevice || !q->isOpen())
        return;

    forever {
        qint64 bytesToRead = nextDownstreamBlockSize();
        if (bytesToRead == 0)
            // we'll be called again, eventually
            break;

        bytesToRead = qBound<qint64>(1, bytesToRead, copyDevice->bytesAvailable());
        QByteArray byteData;
        byteData.resize(bytesToRead);
        qint64 bytesActuallyRead = copyDevice->read(byteData.data(), byteData.size());
        if (bytesActuallyRead == -1) {
            byteData.clear();
            backendNotify(NotifyCopyFinished);
            break;
        }

        byteData.resize(bytesActuallyRead);
        readBuffer.append(byteData);

        if (!copyDevice->isSequential() && copyDevice->atEnd()) {
            backendNotify(NotifyCopyFinished);
            bytesDownloaded += bytesActuallyRead;
            break;
        }

        bytesDownloaded += bytesActuallyRead;
    }

    if (bytesDownloaded == lastBytesDownloaded) {
        // we didn't read anything
        return;
    }

    lastBytesDownloaded = bytesDownloaded;
    QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
    if (preMigrationDownloaded != Q_INT64_C(-1))
        totalSize = totalSize.toLongLong() + preMigrationDownloaded;
    pauseNotificationHandling();
    emit q->downloadProgress(bytesDownloaded,
                             totalSize.isNull() ? Q_INT64_C(-1) : totalSize.toLongLong());
    emit q->readyRead();
    resumeNotificationHandling();
}
开发者ID:,项目名称:,代码行数:51,代码来源:

示例9: displayText

QString DateDelegate::displayText(const QVariant &value, const QLocale &locale) const {
    Q_UNUSED(locale); // suppress unused variable

    if (value.toLongLong() == 0)
        return "";
    QDateTime timestamp;
    timestamp.setTime_t(value.toLongLong()/1000);

    //QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom));
    if (timestamp.date() == QDate::currentDate())
        return tr("Today") +" " + timestamp.time().toString(global.timeFormat);
    return timestamp.toString(global.dateFormat + QString(" ") +global.timeFormat);
//    return timestamp.toString(Qt::SystemLocaleShortDate);
}
开发者ID:AustinPowered,项目名称:Nixnote2,代码行数:14,代码来源:datedelegate.cpp

示例10: parseNetworkTimeInfoFromMap

NetworkTimeInfo NetworkTime::parseNetworkTimeInfoFromMap(QVariantMap map)
{
    QVariant tmp;
    QDateTime dateTime;
    int daylightAdjustment = -1; // -1 means "value not available"
    int offsetFromUtc = 0;
    qlonglong received = 0;
    QString mnc, mcc;
    bool ok;
    if (!map.isEmpty()) {
        tmp = map.value("UTC");
        if (tmp.isValid() && tmp.type() == QVariant::LongLong) {
            dateTime.setTimeSpec(Qt::UTC);
            qlonglong secs = tmp.toLongLong(&ok);
            if (ok) {
                dateTime.setMSecsSinceEpoch(secs*1000);
            } else {
                QDateTime tmp;
                dateTime = tmp;
            }
        }

        tmp = map.value("Received");
        if (tmp.isValid() && tmp.type() == QVariant::LongLong)
            received = tmp.toLongLong(&ok);

        tmp = map.value("Timezone");
        if (tmp.isValid() && tmp.type() == QVariant::Int)
            offsetFromUtc = tmp.toInt(&ok);

        tmp = map.value("DST");
        if (tmp.isValid() && tmp.type() == QVariant::UInt) {
            daylightAdjustment = tmp.toInt(&ok);
            if (!ok)
                daylightAdjustment = -1;
        }

        tmp = map.value("MobileCountryCode");
        if (tmp.isValid() && tmp.type() == QVariant::String)
            mcc = tmp.toString();

        tmp = map.value("MobileNetworkCode");
        if (tmp.isValid() && tmp.type() == QVariant::String)
            mnc = tmp.toString();
    }

    return NetworkTimeInfo(dateTime, daylightAdjustment, offsetFromUtc, received, 0, mnc, mcc);
}
开发者ID:spiiroin,项目名称:timed,代码行数:48,代码来源:networktime.cpp

示例11: bind

void SqliteStatement::bind(int index, const QVariant &value)
{
    checkBindingIndex(index);

    switch (value.type()) {
        case QVariant::Bool:
        case QVariant::Int:
            bind(index, value.toInt());
            break;
        case QVariant::UInt:
        case QVariant::LongLong:
        case QVariant::ULongLong:
            bind(index, value.toLongLong());
            break;
        case QVariant::Double:
            bind(index, value.toDouble());
            break;
        case QVariant::String:
            bind(index, value.toString());
            break;
        case QVariant::ByteArray:
            bind(index, value.toByteArray());
            break;
        default:
            sqlite3_bind_null(compiledStatement.get(), index);
    }
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:27,代码来源:sqlitestatement.cpp

示例12: fromVariant

/**
 * @brief QBsonValue::fromVariant converts a variant value to bsonvalue or
 * a default constructed QBsonValue if vaiant could not converted.
 * @param variant variant to convert
 * @return
 */
QBsonValue QBsonValue::fromVariant(QVariant variant)
{
    switch (variant.type()) {
    case QVariant::Bool:
        return QBsonValue(variant.toBool());
    case QVariant::ByteArray:
        return QBsonValue(variant.toByteArray());
    case QVariant::String:
        return QBsonValue(variant.toString());
    case QVariant::LongLong:
        return QBsonValue(variant.toLongLong());
    case QVariant::Int:
        return QBsonValue(variant.toInt());
    case QVariant::Double:
        return QBsonValue(variant.toDouble());
    case QVariant::DateTime:
        return QBsonValue(variant.toDateTime());
    }
    if (variant.canConvert<QBsonObject>()) {
        return QBsonValue(variant.value<QBsonObject>());
    }
    if (variant.canConvert<QBsonOid>()) {
        return QBsonValue(variant.value<QBsonOid>());
    }
    if (variant.canConvert<QBsonArray>()) {
        return QBsonValue(variant.value<QBsonArray>());
    }

    return QBsonValue();
}
开发者ID:gitter-badger,项目名称:qtejdb,代码行数:36,代码来源:qbsonvalue.cpp

示例13: toArgument

QString toArgument(const QVariant& v)
{
    switch (v.type()) {
    case QVariant::Bool:
        return v.toBool() ? "true" : "false";
    case QVariant::Int:
    case QVariant::UInt:
    case QVariant::LongLong:
    case QVariant::ULongLong:
        return QString("%1").arg(v.toLongLong());
    case QVariant::Double: {
        double f = v.toDouble();
        QString str;
        str.sprintf("%f", f);
        return str;
    }
    case QVariant::Date:
    case QVariant::Time:
    case QVariant::DateTime:
        return QString("new Date(%1)").arg(v.toDateTime().toTime_t() * 1000);
    case QVariant::String: {
            QString s = v.toString();
            s.replace("\\", "\\\\");
            s.replace("\r", "\\r");
            s.replace("\n", "\\n");
            s.replace("\t", "\\t");
            s.replace("\"", "\\\"");
            return "\"" + s + "\"";
        }
    default:
        qDebug() << "Unsupport type: " << v.type();
        return "undefined";
    }
}
开发者ID:WizTeam,项目名称:WizQTClient,代码行数:34,代码来源:WizWebEngineView.cpp

示例14: variantToValue

JValue JClass::variantToValue(QVariant& v)
{
	//JScope s;

	switch (v.type())
	{
	case QVariant::Int:
	case QVariant::UInt:
		return JValue(v.toInt());
	case QVariant::Double:
		return JValue(v.toDouble());
	case QVariant::LongLong:
		return JValue(v.toLongLong());
	case QVariant::Bool:
		return JValue(v.toBool());
	case QVariant::String:
		{
			JString str = JString(v.toString());
			return JValue(str);
		}
	default:
		if (v.canConvert<JObject>())
		{
			JObject obj = v.value<JObject>();
			return JValue(obj);
		}
		else if (v.canConvert<JArray>())
		{
			JArray arr = v.value<JArray>();
			return JValue(arr);
		}
		else
			throw RuntimeException(QObject::tr("Unknown data type"));
	}
}
开发者ID:ActionLuzifer,项目名称:fatrat,代码行数:35,代码来源:JClass.cpp

示例15:

/*!
	Returns the 64bit integer value associated to \a name in \a section or in the
	default section if the \a section name is empty.
	Sets \a ok to false if no such value could be found and \a ok is not null.
*/
qint64 XmlPreferences::getInt64(const QString& name, const QString& section, bool* ok)
{
	QVariant v = d->getData(name, section);
	if (ok != 0)
		*ok = v.isValid() && v.type() == QVariant::LongLong;
	return v.toLongLong();
}
开发者ID:hippydream,项目名称:osdab,代码行数:12,代码来源:xmlpreferences.cpp


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