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


C++ QVariantList::takeFirst方法代码示例

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


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

示例1: read_from

/* ========================================================================== */
QVariant LispPlugin::read_from(QVariantList& tokenz) {
    if (tokenz.isEmpty())
        throw runtime_error("unexpected EOF while reading");

    QByteArray token = tokenz.takeFirst().toByteArray();
    if (token == "(") {
        //auto L = QVariant(QVariant::List);
        QVariantList L;
        while (tokenz[0] != ")")
            L.append(read_from(tokenz));
        tokenz.takeFirst(); // pop off )
        return L;
    } else if (token == ")") {
        throw std::runtime_error("enexcepted )");
    } else {
        bool successCast;

        auto i = token.toInt(&successCast);
        if (successCast) return i;

        auto d = token.toDouble(&successCast);
        if (successCast) return d;

        return QString(token);
    }
}
开发者ID:SQReder,项目名称:SimplePluginCore,代码行数:27,代码来源:LispPlugin.cpp

示例2: testDMSToRad

void TestConversions::testDMSToRad()
{
	QVariantList data;

	data << 0 << 0 << 0 << 0.;
	data << 30 << 0 << 0 << M_PI/6;
	data << 45 << 0 << 0 << M_PI/4;
	data << 60 << 0 << 0 << M_PI/3;
	data << 90 << 0 << 0 << M_PI/2;
	data << 120 << 0 << 0 << 2*M_PI/3;
	data << 180 << 0 << 0 << M_PI;
	data << 270 << 0 << 0 << 3*M_PI/2;
	data << 360 << 0 << 0 << 2*M_PI;
	data << 0 << 30 << 0 << M_PI/360;
	data << 0 << 45 << 0 << M_PI/240;
	data << 30 << 30 << 0 << 61*M_PI/360;
	data << 0 << 0 << 1 << M_PI/648000;
	data << 90 << 58 << 30 << 1213*M_PI/2400;
	data << 10 << 59 << 59 << 39599*M_PI/648000;

	while (data.count() >= 4)
	{
		int deg, min, sec;
		double rad;
		deg = data.takeFirst().toInt();
		min = data.takeFirst().toInt();
		sec = data.takeFirst().toInt();
		rad = data.takeFirst().toDouble();
		QVERIFY2(std::abs(StelUtils::dmsToRad(deg, min, sec)-rad)<=ERROR_LIMIT, qPrintable(QString("%1d%2m%3s=%4").arg(deg).arg(min).arg(sec).arg(rad)));
	}
}
开发者ID:incadoi,项目名称:stellarium-1,代码行数:31,代码来源:testConversions.cpp

示例3: testHMSToRad

void TestConversions::testHMSToRad()
{
	QVariantList data;

	data << 0 << 0 << 0 << 0.;
	data << 1 << 0 << 0 << M_PI/12;
	data << 6 << 0 << 0 << M_PI/2;
	data << 12 << 0 << 0 << M_PI;
	data << 15 << 0 << 0 << 5*M_PI/4;
	data << 0 << 15 << 0 << M_PI/720;
	data << 0 << 0 << 15 << M_PI/43200;
	data << 2 << 15 << 45 << 269*M_PI/1600;
	data << 20 << 0 << 0 << 5*M_PI/3;
	data << 24 << 0 << 0 << 2*M_PI;
	data << 0 << 59 << 0 << 59*M_PI/10800;
	data << 0 << 0 << 59 << 59*M_PI/648000;
	data << 0 << 59 << 59 << 3599*M_PI/648000;
	data << 3 << 59 << 59 << 165599*M_PI/648000;

	while (data.count() >= 4)
	{
		int h, m, s;
		double rad;
		h = data.takeFirst().toInt();
		m = data.takeFirst().toInt();
		s = data.takeFirst().toInt();
		rad = data.takeFirst().toDouble();		
		QVERIFY2(std::abs(StelUtils::hmsToRad(h, m, s)-rad)<=ERROR_LIMIT, qPrintable(QString("%1h%2m%3s=%4").arg(h).arg(m).arg(s).arg(rad)));
	}
}
开发者ID:incadoi,项目名称:stellarium-1,代码行数:30,代码来源:testConversions.cpp

示例4: checkChanges

bool ChangeLog::checkChanges(const QString &previousVersion, const QString &currentVersion)
{
    QVersionNumber previous = QVersionNumber::fromString(previousVersion);
    QVersionNumber current = QVersionNumber::fromString(currentVersion);
    if (current <= previous) {
        qCInfo(CHANGELOG_CATEGORY) << "Current version isn't newer, than previous"
                                   << previousVersion << currentVersion;
        return false;
    }

    QFileSelector fileSelector;
    fileSelector.setExtraSelectors(QStringList() << QLocale::system().uiLanguages().constFirst().split('-').constFirst());
    const QString path = fileSelector.select(":/changelogs/changelog.json");

    QFile file(path);
    if (!file.open(QIODevice::ReadOnly)) {
        qCCritical(CHANGELOG_CATEGORY) << "Fail to open changelog file" << path << file.errorString();
        return false;
    }
    QByteArray data = file.readAll();

    QJsonParseError parseError;
    QJsonDocument document = QJsonDocument::fromJson(data, &parseError);
    if (parseError.error != QJsonParseError::NoError) {
        qCritical(CHANGELOG_CATEGORY) << "Fail to parse changelog data JSON:"
                                      << data << "error at offset"
                                      << parseError.offset
                                      << parseError.errorString() << parseError.error;
        return false;
    }
    QVariantList content = document.array().toVariantList();

    while (!content.isEmpty()) {
        if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > current) {
            content.takeFirst();
        } else {
            break;
        }
    }
    QVariantList result;
    while (!content.isEmpty()) {
        if (QVersionNumber::fromString(content.constFirst().toMap().value("version").toString()) > previous) {
            result.append(content.takeFirst());
        } else {
            break;
        }
    }

    if (result.isEmpty()) {
        qCWarning(CHANGELOG_CATEGORY) << "Empty changelog" << previousVersion << currentVersion;
        return false;
    }

    emit changesAvailable(result);

    return true;
}
开发者ID:g-timetracker,项目名称:g-timetracker,代码行数:57,代码来源:ChangeLog.cpp

示例5: set

void QJnextMainLoop::set(QObject *object, QVariantList& args,
		QByteArray* retval) {
	QByteArray property = args.takeFirst().toByteArray();

	const QMetaObject * meta = object->metaObject();
	int propertyIndex = meta->indexOfProperty(property);
	if (propertyIndex < 0) {
		retval->append("No such property " + property);
		return;
	}

	QMetaProperty metaprop = meta->property(propertyIndex);
	if (!metaprop.isWritable()) {
		retval->append("Property " + property + " is not writable");
		return;
	}
	QVariant vValue = args.takeFirst();

	/* handle enum inputs as text */
	if (metaprop.isEnumType()) {
		int id;
		const QMetaEnum &enumerator = metaprop.enumerator();
		QByteArray keys;
		for (int i = 0; i < enumerator.keyCount(); ++i)
			keys += enumerator.key(i) + QByteArray(" ");
#ifdef DEBUG_QJnextMainLoop
		qDebug() << "[QJnextMainLoop]\tEnumerator" << enumerator.isFlag() << enumerator.scope() << enumerator.name() <<
		keys;
#endif

		if (enumerator.isFlag())
			id = enumerator.keyToValue(vValue.toByteArray().constData());
		else
			id = enumerator.keysToValue(vValue.toByteArray().constData());

		if (id != -1)
			vValue = QVariant(id);
	}
#ifdef DEBUG_QJnextMainLoop
	qDebug() << "[QJnextMainLoop]\tSET" << meta->className() << property << vValue
	<< vValue.canConvert(metaprop.type());
#endif

	if (!vValue.convert(metaprop.type())) {
		retval->append(
				"Unable to convert \"" + vValue.toByteArray() + "\" to "
						+ metaprop.typeName());
		return;
	}

	if (!metaprop.write(object, vValue))
		retval->append(
				QByteArray("Unable to set property ") + meta->className() + "."
						+ property + " to " + vValue.toByteArray());
	else
		*retval = QByteArray();
}
开发者ID:Balgam,项目名称:WebWorks-Community-APIs,代码行数:57,代码来源:QJnextMainLoop.cpp

示例6: QString

void TestDeltaT::testDeltaTByMorrisonStephenson1982WideDates()
{
	// test data from Mathematical Astronomical Morsels, p. 8. [ISBN 0-943396-51-4]
	QVariantList data;
	data <<    0 << 177; 
	data <<  100 << 158; 
	data <<  200 << 140;
	data <<  300 << 123;
	data <<  400 << 107;
	data <<  500 <<  93;
	data <<  600 <<  79;
	data <<  700 <<  66;
	data <<  800 <<  55;
	data <<  900 <<  45;
	data << 1000 <<  35;
	data << 1100 <<  27;
	data << 1200 <<  20;
	data << 1300 <<  14;
	data << 1400 <<   9;
	data << 1500 <<   5;
	data << 1600 <<   2;
	data << 1700 <<   0;
	data << 1800 <<   0;
	data << 1980 <<   1;
	data << 2075 <<   4;
	data << 2200 <<   8;
	data << 2300 <<  13;
	data << 2400 <<  19;
	data << 2500 <<  26;
	data << 2600 <<  34;
	data << 2700 <<  43;
	data << 2800 <<  53;
	data << 2900 <<  64;
	data << 3000 <<  76;

	while(data.count() >= 2)
	{
		// 30 seconds accuracy
		int year = data.takeFirst().toInt();
		int yout, mout, dout;
		double JD;
		double expectedResult = data.takeFirst().toDouble();
		StelUtils::getJDFromDate(&JD, year, 1, 1, 0, 0, 0);
		double result = StelUtils::getDeltaTByMorrisonStephenson1982(JD)/60.0;
		StelUtils::getDateFromJulianDay(JD, &yout, &mout, &dout);
		QVERIFY2(qRound(result) <= expectedResult, QString("date=%2 year=%3 result=%4 expected=%5")
							.arg(QString("%1-%2-%3 00:00:00").arg(yout).arg(mout).arg(dout))
							.arg(year)
							.arg(result)
							.arg(expectedResult)
							.toUtf8());
	}
}
开发者ID:NGCyang,项目名称:stellarium,代码行数:53,代码来源:testDeltaT.cpp

示例7: testRadToDMS

void TestConversions::testRadToDMS()
{
	QVariantList data;

	data << 0. << 0 << 0 << 0.;
	data << M_PI/6 << 30 << 0 << 0.;
	data << M_PI/4 << 45 << 0 << 0.;
	data << M_PI/3 << 60 << 0 << 0.;
	data << M_PI/2 << 90 << 0 << 0.;
	data << 2*M_PI/3 << 120 << 0 << 0.;
	data << M_PI << 180 << 0 << 0.;
	data << 3*M_PI/2 << 270 << 0 << 0.;
	data << M_PI/360 << 0 << 30 << 0.;
	data << M_PI/240 << 0 << 45 << 0.;
	data << 61*M_PI/360 << 30 << 30 << 0.;
	data << M_PI/648000 << 0 << 0 << 1.;
	data << 1213*M_PI/2400 << 90 << 58 << 30.;
	data << 39599*M_PI/648000 << 10 << 59 << 59.;
	data << -M_PI/36 << -5 << 0 << 0.;
	data << -7*M_PI/8 << -157 << 30 << 0.;
	data << -2*M_PI/5 << -72 << 0 << 0.;
	data << -M_PI << -180 << 0 << 0.;
	data << -10*M_PI/648 << -2 << 46 << 40.0;

	while (data.count()>=4)
	{
		double rad, sec, seco, angle1, angle2;
		int deg, min;
		unsigned int dego, mino;
		bool sign;
		QString s;
		rad = data.takeFirst().toDouble();
		deg = data.takeFirst().toInt();
		min = data.takeFirst().toInt();
		sec = data.takeFirst().toDouble();
		if (deg>=0)
			angle1 = sec+min*60+deg*3600;
		else
			angle1 = -1*(sec+min*60+std::abs(deg)*3600);
		StelUtils::radToDms(rad, sign, dego, mino, seco);
		angle2 = seco+mino*60+dego*3600;
		if (!sign)
		{
			angle2 = -1*angle2;
			s = "-";
		}
		else
			s = "+";
		QVERIFY2(std::abs(angle1-angle2)<=ERROR_LIMIT, qPrintable(QString("%1rad=%2%3d%4m%5s").arg(rad).arg(s).arg(dego).arg(mino).arg(seco)));
	}
}
开发者ID:incadoi,项目名称:stellarium-1,代码行数:51,代码来源:testConversions.cpp

示例8: connect

void QJnextMainLoop::connect(QObject *object, uint id, QVariantList& args,
		QByteArray *retval) {
	QByteArray methodName = args.takeFirst().toByteArray();
	QByteArray sid = args.takeFirst().toByteArray();
	int argCount = -1;

	const QMetaObject* meta = object->metaObject();
	QMetaMethod method;
	for (int i = 0; i < meta->methodCount(); ++i) {
		method = meta->method(i);
		if (QByteArray(method.signature()).startsWith(methodName + "(")) {
			QList<QByteArray> types = method.parameterTypes();
			if (types.size() > argCount) {
				// TODO : always pick enum types
				argCount = method.parameterTypes().size();
				break;
			}
		}
	}
	if (argCount == -1) {
		*retval = "No signal named " + methodName + " found";
		return;
	}
#ifdef DEBUG_QJnextMainLoop
	qDebug() << "[QJnextMainLoop]\tSIGNAL.connect" << methodName << id << sid;
#endif

	QJnextUserData * jnextData = dynamic_cast<QJnextUserData*>(object->userData(
			QJnextMainLoop::userDataId));
	if (jnextData == NULL) {
		*retval = "Unable to retrieve jnextData from object "
				+ QByteArray::number(id);
		return;
	}

	SignalHandler *& handler = jnextData->signalHandlers[sid];
	if (handler != NULL) {
#ifdef DEBUG_QJnextMainLoop
		qDebug() << "[QJnextMainLoop]\tCONNECTED (chained)";
#endif
		return;
	}
	handler = new SignalHandler(this, object, id, "com.blackberry.qt" + sid, meta, method);
	if (!handler->isValid()) {
		*retval = "QMetaObject::connect returned false. Unable to connect";
		return;
	}
#ifdef DEBUG_QJnextMainLoop
	qDebug() << "[QJnextMainLoop]\tCONNECTED";
#endif
}
开发者ID:Balgam,项目名称:WebWorks-Community-APIs,代码行数:51,代码来源:QJnextMainLoop.cpp

示例9: listNamespace

void QJnextMainLoop::listNamespace(QVariantList& args, QByteArray* retval) {
	QByteArray param = args.takeFirst().toByteArray();
	QByteArray ns(param);
	QByteArray ver = QtBridge::takeLastParam(ns, "@");
	if (ver.size() == 0)
		ver = "1.0";

	QDeclarativeComponent component(declarativeEngine, this);

	component.setData(
			"import " + ns + " " + ver + "; import QtQuick 1.0; QtObject {}",
			QUrl());
	if (component.isError() || !component.isReady()) {
		qWarning() << "COMPONENT ERROR" << component.errorString();
	}

	QList<QDeclarativeType*> types = QDeclarativeMetaType::qmlTypes();
	QSet<QString> typeNames;
	foreach(QDeclarativeType* type, types)
	{
#ifdef DEBUG_QJnextMainLoop
		qDebug() << "[QJnextMainLoop]\t" << type->qmlTypeName() << type->majorVersion()
				<< type->minorVersion();
#endif

		if (ns == type->module() && type->isCreatable()) {
			QString qmlType = QString::fromLatin1(type->qmlTypeName());
			typeNames << qmlType.split("/").takeLast();
		}
	}
开发者ID:Balgam,项目名称:WebWorks-Community-APIs,代码行数:30,代码来源:QJnextMainLoop.cpp

示例10: exec

/* ========================================================================== */
QVariant LispPlugin::exec(QVariant procName, QVariant _exps) {
    QVariant result;
    assert(isa(_exps, "StringList"));
    QVariantList exps = _exps.toList();
    if ("*" == procName) {
        auto a = exps[0].toDouble();
        auto b = exps[1].toDouble();
        return a * b;
    } else if ("+" == procName) {
        auto a = exps[0].toDouble();
        auto b = exps[1].toDouble();
        return a + b;
    }  else if ("-" == procName) {
        auto a = exps[0].toDouble();
        auto b = exps[1].toDouble();
        return a - b;
    } else if ("<=" == procName) {
        auto a = exps[0].toDouble();
        auto b = exps[1].toDouble();
        return a <= b;
    } else {
        if (exps.size() == 1)
            _exps = exps.takeFirst();
        return CallExternal(procName.toByteArray(), _exps);
    }


    throw runtime_error(
                QString("Unable to resolve symbol: %1 in this context")
                .arg(procName.toString()).toStdString());
}
开发者ID:SQReder,项目名称:SimplePluginCore,代码行数:32,代码来源:LispPlugin.cpp

示例11: get

void QJnextMainLoop::get(QObject *object, QVariantList& args,
		QByteArray* retval) {
	QByteArray property = args.takeFirst().toByteArray();

	const QMetaObject * meta = object->metaObject();
	int propertyIndex = meta->indexOfProperty(property);
	if (propertyIndex < 0) {
		retval->append("No such property " + property);
		return;
	}

	QMetaProperty metaprop = meta->property(propertyIndex);
	if (!metaprop.isReadable()) {
		retval->append("Property " + property + " is not readable");
		return;
	}

	QVariant value = metaprop.read(object);
	if (value.isNull()) {
		qWarning() << "[QJnextMainLoop]\tNULL value ignored" << object->property(property);
	}
#ifdef DEBUG_QJnextMainLoop
	qDebug() << "[QJnextMainLoop]\tVALUE" << value << object->property(property) << metaprop.isEnumType();
#endif

    if (metaprop.isEnumType()) {
        bool ok;
        int enumValue = value.toInt(&ok);
        if (!ok) {
            int status = -1;
            void *argv[] = { 0, &value, &status };
            QMetaObject::metacall(const_cast<QObject*>(object), QMetaObject::ReadProperty,
                    propertyIndex + meta->propertyOffset(), argv);
            const int * enumRaw = static_cast<const int *>(argv[0]);

            if (status == -1 && enumRaw != 0) {
                const QMetaEnum & iEnum = metaprop.enumerator();
                if (iEnum.isFlag())
                    value = iEnum.valueToKeys(*enumRaw);
                else
                    value = iEnum.valueToKey(*enumRaw);
            } else {
                // someone is evil and didn't register enumerations properly
                qDebug() << "[QJnextMainLoop]\t" << "!!!!!!!" << argv[0] << value;
            }
        } else if (metaprop.enumerator().isFlag()) {
            *retval = metaprop.enumerator().valueToKeys(enumValue);
            return;
        } else {
            *retval = metaprop.enumerator().valueToKey(enumValue);
            return;
        }
    }
	*retval = value.toByteArray();
}
开发者ID:Balgam,项目名称:WebWorks-Community-APIs,代码行数:55,代码来源:QJnextMainLoop.cpp

示例12: setWriteIns

void Decision::setWriteIns(QVariantList newWriteIns)
{
    if (newWriteIns == writeIns())
        return;

    auto writeInList = m_decision.initWriteIns(newWriteIns.size());
    for (::UnsignedContest::Contestant::Builder writeInBuilder : writeInList) {
        auto writeIn = newWriteIns.takeFirst().toMap();
        writeInBuilder.setName(writeIn["name"].toString().toStdString());
        writeInBuilder.setDescription(writeIn["description"].toString().toStdString());
    }

    emit writeInsChanged();
}
开发者ID:votesapp,项目名称:StakeWeightedVoting,代码行数:14,代码来源:Decision.cpp

示例13: testRadToHMS

void TestConversions::testRadToHMS()
{
	QVariantList data;

	data << 0. << 0 << 0 << 0.;
	data << M_PI/36 << 0 << 19 << 59.9;
	data << 7*M_PI/8 << 10 << 30 << 0.;
	data << 2*M_PI/5 << 4 << 48 << 0.;

	while (data.count()>=4)
	{
		double rad, s, so, t1, t2;
		int h, m;
		unsigned int ho, mo;
		rad = data.takeFirst().toDouble();
		h = data.takeFirst().toInt();
		m = data.takeFirst().toInt();
		s = data.takeFirst().toDouble();
		t1 = s+m*60+h*3600;
		StelUtils::radToHms(rad, ho, mo, so);
		t2 = so+mo*60+ho*3600;
		QVERIFY2(std::abs(t1-t2)<=0.1, qPrintable(QString("%1rad=%2h%3m%4s").arg(rad).arg(ho).arg(mo).arg(so)));
	}
}
开发者ID:incadoi,项目名称:stellarium-1,代码行数:24,代码来源:testConversions.cpp

示例14: init

bool ApplicationsMenuApplet::init(QWidget* parent)
{
  if(m_settings.type() == QVariant::List)
  {
    QVariantList list = m_settings.value<QVariantList>();

    while(!list.isEmpty())
    {
      const char** names = reinterpret_cast<const char**>(list.takeFirst().value<void*>());

      QMenu* menu = m_menu->addMenu(g_menu_names.value(names[0]));
      menu->setIcon(QIcon::fromTheme(names[1]).pixmap(menu->height(),menu->height()));
      m_menus.insert(g_menu_names.value(names[0]), menu);
    }

    QStringList categories;
    for(QList<DesktopEntryObject*>::iterator pos = m_entries.begin(); pos != m_entries.end(); ++pos)
    {
      if(m_menus.contains((*pos)->Category()))
        m_menus[(*pos)->Category()]->addAction((*pos)->Action());
      else
        m_menus["Other"]->addAction((*pos)->Action());
/*
      categories = (*pos)->Categories();
      for(QStringList::iterator pos2 = categories.begin(); pos2 != categories.end(); ++pos2)
        if(m_menus.contains(*pos2))
          m_menus[*pos2]->addAction((*pos)->Action());
*/
    }
  }

  m_menu->addSeparator();
  m_menu->addAction(QIcon::fromTheme("application-exit"), "Quit", qApp, SLOT(quit()));

/*
  connect(DesktopApplications::instance(), SIGNAL(applicationUpdated(const DesktopApplication&)), this, SLOT(onApplicationUpdated(const DesktopApplication&)));
  connect(DesktopApplications::instance(), SIGNAL(applicationRemoved(const QString&)), this, SLOT(onApplicationRemoved(const QString&)));

  QList<DesktopApplication> apps = DesktopApplications::instance()->applications();
  foreach(const DesktopApplication& app, apps)
    onApplicationUpdated(app);
*/

  return true;
}
开发者ID:GravisZro,项目名称:qtpanel,代码行数:45,代码来源:applicationsmenuapplet.cpp

示例15: PQuery

QSqlQuery DatabaseConnection::PQuery(QString queryStr, QVariantList args)
{
    if(!m_db.isOpen())
        throw std::runtime_error("Database : Tentative de requete sur une connexion non ouverte : " + queryStr.toStdString()
                                 + " : "  + m_db.lastError().text().toLatin1().constData());

    QSqlQuery query(m_db);
    query.prepare(queryStr);

    while (!args.isEmpty())
        query.addBindValue(args.takeFirst());

    if(!query.exec())
        throw std::runtime_error("Database : Erreur lors de l'execution de \"" + queryStr.toStdString() + "\" : "
                                 + query.lastError().text().toLatin1().data());

    return query;
}
开发者ID:Nicky31,项目名称:Dofus-Arena-Server,代码行数:18,代码来源:DatabaseConnection.cpp


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