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


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

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


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

示例1: testResults

void TestControllerTest::testResults()
{
    ITestSuite* suite = new FakeTestSuite(TestSuiteName, m_project);
    m_testController->addTestSuite(suite);

    QSignalSpy spy(m_testController, SIGNAL(testRunFinished(KDevelop::ITestSuite*,KDevelop::TestResult)));
    QVERIFY(spy.isValid());

    QList<TestResult::TestCaseResult> results;
    results << TestResult::Passed << TestResult::Failed << TestResult::Error << TestResult::Skipped << TestResult::NotRun;

    foreach (TestResult::TestCaseResult result, results)
    {
        emitTestResult(suite, result);
        QCOMPARE(spy.size(), 1);

        QVariantList arguments = spy.takeFirst();
        QCOMPARE(arguments.size(), 2);

        QVERIFY(arguments.first().canConvert<ITestSuite*>());
        QCOMPARE(arguments.first().value<ITestSuite*>(), suite);

        QVERIFY(arguments.at(1).canConvert<TestResult>());
        QCOMPARE(arguments.at(1).value<TestResult>().suiteResult, result);

        foreach (const QString& testCase, suite->cases())
        {
            QCOMPARE(arguments.at(1).value<TestResult>().testCaseResults[testCase], result);
        }
    }
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:30,代码来源:testcontrollertest.cpp

示例2: internalDelTreeValue

QVariant QVariantTree::internalDelTreeValue(const QVariant& root,
                                    const QVariantList& address,
                                    bool* isValid) const
{
    QVariant result = root;
    bool trueValid = true;

    if (address.isEmpty())
        result.clear(); // if no address -> invalid
    else if (address.count() == 1) {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType == NULL)
            trueValid = false;
        else
            result = containerType->delItem(result, address.first());
    }
    else {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType && containerType->keys(result).contains(address.first())) {
            result = containerType->item(result, address.first());
            result = internalDelTreeValue(result, address.mid(1));
            result = containerType->setItem(root, address.first(), result);
        }
        else
            trueValid = false;
    }

    if (isValid)
        *isValid = trueValid;

    return result;
}
开发者ID:VaysseB,项目名称:QVariantEditor,代码行数:32,代码来源:qvarianttree.cpp

示例3: internalSetTreeValue

QVariant QVariantTree::internalSetTreeValue(const QVariant& root,
                                    const QVariantList& address,
                                    const QVariant& value,
                                    bool* isValid) const
{
    QVariant result = root;
    bool trueValid = true;

    if (address.isEmpty())
        result = value;
    else {
        QVariantTreeElementContainer* containerType = containerOf(result.type());
        if (containerType && containerType->keys(result).contains(address.first())) {
            result = containerType->item(result, address.first());
            result = internalSetTreeValue(result, address.mid(1), value);
            result = containerType->setItem(root, address.first(), result);
        }
        else
            trueValid = false;
    }

    if (isValid)
        *isValid = trueValid;

    return result;
}
开发者ID:VaysseB,项目名称:QVariantEditor,代码行数:26,代码来源:qvarianttree.cpp

示例4: QObject

ReadOnlyArchiveInterface::ReadOnlyArchiveInterface(QObject *parent, const QVariantList & args)
        : QObject(parent)
        , m_waitForFinishedSignal(false)
        , m_isHeaderEncryptionEnabled(false)
        , m_isCorrupt(false)
{
    qCDebug(ARK) << "Created read-only interface for" << args.first().toString();
    m_filename = args.first().toString();
}
开发者ID:gitter-badger,项目名称:ark-1,代码行数:9,代码来源:archiveinterface.cpp

示例5: deleteRecord

void QuotesApp::deleteRecord()
{
    QVariantList indexPath = mListView->selected();

    if (!indexPath.isEmpty()) {
        QVariantMap map = mDataModel->data(indexPath).toMap();

        // Delete the item from the database based on unique ID. If successful, remove it
        // from the data model (which will remove the data from the list).
        if (mQuotesDbHelper->deleteById(map["id"])) {

            // Delete is the only operation where the logics for updating which item
            // is selected is handled in code.
            // Before the item is removed, we store how many items there are in the
            // category that the item is removed from, we need this to select a new item.
            QVariantList categoryIndexPath;
            categoryIndexPath.append(indexPath.first());
            int childrenInCategory = mDataModel->childCount(categoryIndexPath);

            mDataModel->remove(map);

            // After removing the selected item, we want another quote to be shown.
            // So we select the next quote relative to the removed one in the list.
            if (childrenInCategory > 1) {
                // If the Category still has items, select within the category.
                int itemInCategory = indexPath.last().toInt();

                if (itemInCategory < childrenInCategory - 1) {
                    mListView->select(indexPath);
                } else {
                    // The last item in the category was removed, select the previous item relative to the removed item.
                    indexPath.replace(1, QVariant(itemInCategory - 1));
                    mListView->select(indexPath);
                }
            } else {
                // If no items left in the category, move to the next category. 
                // If there are no more categories below(next), select the previous category.
                // If no items left at all, navigate to the list.
                QVariantList lastIndexPath = mDataModel->last();

                if (!lastIndexPath.isEmpty()) {
                    if (indexPath.first().toInt() <= lastIndexPath.first().toInt()) {
                        mListView->select(indexPath);
                    } else {
                        mListView->select(mDataModel->last());
                    }
                }
            } // else statment
        } //if statement
    } // top if statement
} // deleteRecord()
开发者ID:ProLove365,项目名称:Cascades-Samples,代码行数:51,代码来源:quotesapp.cpp

示例6: state

/* Special version of the state() call which does not call event loop.
 * Needed in order to fix NB#175098 where Qt4.7 webkit crashes because event
 * loop is run when webkit does not expect it. This function is called from
 * bearer management API syncStateWithInterface() in QNetworkSession
 * constructor.
 */
uint IcdPrivate::state(QList<IcdStateResult>& state_results)
{
    QVariant reply;
    QVariantList vl;
    uint signals_left, total_signals;
    IcdStateResult result;
    time_t started;
    int timeout_secs = timeout / 1000;

    PDEBUG("%s\n", "state_results");

    clearState();
    reply = mDBus->call(ICD_DBUS_API_STATE_REQ);
    if (reply.type() != QVariant::List)
        return 0;
    vl = reply.toList();
    if (vl.isEmpty())
        return 0;
    reply = vl.first();
    signals_left = total_signals = reply.toUInt();
    if (!signals_left)
        return 0;

    started = time(0);
    state_results.clear();
    mError.clear();
    while (signals_left) {
        mInterface.clear();
	while ((time(0)<=(started+timeout_secs)) && mInterface.isEmpty()) {
	    mDBus->synchronousDispatch(1000);
        QCoreApplication::sendPostedEvents(icd, QEvent::MetaCall);
	}

        if (time(0)>(started+timeout_secs)) {
	    total_signals = 0;
	    break;
	}

	if (mSignal != ICD_DBUS_API_STATE_SIG) {
	    continue;
	}

	if (mError.isEmpty()) {
	    if (!mArgs.isEmpty()) {
	        if (mArgs.size()==2)
	            get_state_all_result2(mArgs, result);
		else
	            get_state_all_result(mArgs, result);
		state_results << result;
	    }
	    signals_left--;
	} else {
	    qWarning() << "Error:" << mError;
	    break;
	}
    }

    PDEBUG("total_signals=%d\n", total_signals);
    return total_signals;
}
开发者ID:RS102839,项目名称:qt,代码行数:66,代码来源:maemo_icd.cpp

示例7: _q_onRequestFinished

void ResourcesModelPrivate::_q_onRequestFinished() {
    if (!request) {
        return;
    }

    Q_Q(ResourcesModel);

    if (request->status() == ResourcesRequest::Ready) {
        const QVariantMap result = request->result().toMap();
    
        if (!result.isEmpty()) {
            next = result.value("next").toString();
            previous = result.value("previous").toString();
        
            const QVariantList list = result.value("items").toList();
        
            if (!list.isEmpty()) {
                if (roles.isEmpty()) {
                    setRoleNames(list.first().toMap());
                }
                
                q->beginInsertRows(QModelIndex(), items.size(), items.size() + list.size() - 1);
                
                foreach (const QVariant &item, list) {
                    items << item.toMap();
                }
                
                q->endInsertRows();
                emit q->countChanged(q->rowCount());
            }
        }
    }
开发者ID:marxoft,项目名称:libcuteradio,代码行数:32,代码来源:resourcesmodel.cpp

示例8: get_addrinfo_all_result

static void get_addrinfo_all_result(QList<QVariant>& args,
				    IcdAddressInfoResult& ret)
{
    int i=0;

    if (args.isEmpty())
      return;

    ret.params.service_type = args[i++].toString();
    ret.params.service_attrs = args[i++].toUInt();
    ret.params.service_id = args[i++].toString();
    ret.params.network_type = args[i++].toString();
    ret.params.network_attrs = args[i++].toUInt();
    ret.params.network_id = args[i++].toByteArray();

    QVariantList vl = args[i].toList();
    QVariant reply = vl.first();
    QList<QVariant> lst = reply.toList();
    for (int k=0; k<lst.size()/6; k=k+6) {
        IcdIPInformation ip_info;
	ip_info.address = lst[k].toString();
	ip_info.netmask = lst[k++].toString();
	ip_info.default_gateway = lst[k++].toString();
	ip_info.dns1 = lst[k++].toString();
	ip_info.dns2 = lst[k++].toString();
	ip_info.dns3 = lst[k++].toString();

	ret.ip_info << ip_info;
    }
}
开发者ID:RS102839,项目名称:qt,代码行数:30,代码来源:maemo_icd.cpp

示例9: readOscMsg

void OSCRemote::readOscMsg(QString addr, QVariantList args)
{
    qWarning()<<"OSC|"<<addr<<args;
    if(!addr.startsWith(_oscAddress))
        return;
    qWarning()<<"1";
    if(args.size()!=2)
        return;
        qWarning()<<"2";
    bool ok = true;
    float intensity = (float)(args.at(1).toInt(&ok))/255.0f;
    if(!ok)
        return;
        qWarning()<<"3";
    
    QString led = args.first().toString();
    if(led == "LED1")
        ledChanged(1, intensity);
    else if(led == "LED2")
        ledChanged(2, intensity);
    else if(led == "LED3")
        ledChanged(3, intensity);
    else if(led == "LED"){
        ledChanged(1, intensity);
        ledChanged(2, intensity);
        ledChanged(3, intensity);
    }
    
}
开发者ID:ewolio,项目名称:VoxPopuli,代码行数:29,代码来源:oscremote.cpp

示例10: systemLogs

void TestLogging::systemLogs()
{
    // check the active system log at boot
    QVariantMap params;
    params.insert("loggingSources", QVariantList() << JsonTypes::loggingSourceToString(Logging::LoggingSourceSystem));
    params.insert("eventTypes", QVariantList() << JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeActiveChange));

    // there should be 2 logs, one for shutdown, one for startup (from server restart)
    QVariant response = injectAndWait("Logging.GetLogEntries", params);
    verifyLoggingError(response);
    QVariantList logEntries = response.toMap().value("params").toMap().value("logEntries").toList();
    QVERIFY(logEntries.count() == 2);

    QVariantMap logEntryShutdown = logEntries.first().toMap();

    QCOMPARE(logEntryShutdown.value("active").toBool(), false);
    QCOMPARE(logEntryShutdown.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeActiveChange));
    QCOMPARE(logEntryShutdown.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceSystem));
    QCOMPARE(logEntryShutdown.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));

    QVariantMap logEntryStartup = logEntries.last().toMap();

    QCOMPARE(logEntryStartup.value("active").toBool(), true);
    QCOMPARE(logEntryStartup.value("eventType").toString(), JsonTypes::loggingEventTypeToString(Logging::LoggingEventTypeActiveChange));
    QCOMPARE(logEntryStartup.value("source").toString(), JsonTypes::loggingSourceToString(Logging::LoggingSourceSystem));
    QCOMPARE(logEntryStartup.value("loggingLevel").toString(), JsonTypes::loggingLevelToString(Logging::LoggingLevelInfo));
}
开发者ID:tonnenpinguin,项目名称:guh,代码行数:27,代码来源:testlogging.cpp

示例11: info

void
RoviPlugin::albumLookupFinished()
{
    QNetworkReply* reply = qobject_cast<QNetworkReply*>( sender() );
    Q_ASSERT( reply );

    if ( reply->error() != QNetworkReply::NoError )
        return;

    Tomahawk::InfoSystem::InfoRequestData requestData = reply->property( "requestData" ).value< Tomahawk::InfoSystem::InfoRequestData >();

    QJson::Parser p;
    bool ok;
    QVariantMap response = p.parse( reply, &ok ).toMap();

    if ( !ok || response.isEmpty() || !response.contains( "searchResponse" ) )
    {
        tLog() << "Error parsing JSON from Rovi!" << p.errorString() << response;
        emit info( requestData, QVariant() );
        return;
    }

    QVariantList resultList = response[ "searchResponse" ].toMap().value( "results" ).toList();
    if ( resultList.size() == 0 )
    {
        emit info( requestData, QVariant() );
        return;
    }

    QVariantMap results = resultList.first().toMap();
    QVariantList tracks = results[ "album" ].toMap()[ "tracks" ].toList();

    if ( tracks.isEmpty() )
    {
        tLog() << "Error parsing JSON from Rovi!" << p.errorString() << response;
        emit info( requestData, QVariant() );
    }


    QStringList trackNameList;
    foreach ( const QVariant& track, tracks )
    {
        const QVariantMap trackData = track.toMap();
        if ( trackData.contains( "title" ) )
            trackNameList << trackData[ "title" ].toString();
    }

    QVariantMap returnedData;
    returnedData["tracks"] = trackNameList;

    emit info( requestData, returnedData );

    Tomahawk::InfoSystem::InfoStringHash criteria;
    criteria["artist"] = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>()["artist"];
    criteria["album"] = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash>()["album"];

    emit updateCache( criteria, 0, requestData.type, returnedData );
}
开发者ID:ChrisOHu,项目名称:tomahawk,代码行数:58,代码来源:RoviPlugin.cpp

示例12: lastOutboundId

int OpsSqlDataSource::lastOutboundId()
{
    int op_id = -1;
    QVariant result = _sda->execute("select max(out_op_id) from outbound_ops_queue");
    QVariantList list = result.value<QVariantList>();
    QVariant row = list.first();
    op_id = row.toMap().value("max(out_op_id)").toInt();
    return op_id;
}
开发者ID:DevJay22,项目名称:Cascades-Community-Samples,代码行数:9,代码来源:OpsSqlDataSource.cpp

示例13: handleMessage

bool DeclarativeDBusAdaptor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection)
{
    QVariant variants[10];
    QGenericArgument arguments[10];

    const QMetaObject * const meta = metaObject();
    const QVariantList dbusArguments = message.arguments();

    QString member = message.member();
    QString interface = message.interface();

    // Don't try to handle introspect call. It will be handled
    // internally for QDBusVirtualObject derived classes.
    if (interface == QLatin1String("org.freedesktop.DBus.Introspectable")) {
        return false;
    } else if (interface == QLatin1String("org.freedesktop.DBus.Properties")) {
        if (member == QLatin1String("Get")) {
            interface = dbusArguments.value(0).toString();
            member = dbusArguments.value(1).toString();

            const QMetaObject * const meta = metaObject();
            if (!member.isEmpty() && member.at(0).isUpper())
                member = "rc" + member;

            for (int propertyIndex = meta->propertyOffset();
                    propertyIndex < meta->propertyCount();
                    ++propertyIndex) {
                QMetaProperty property = meta->property(propertyIndex);

                if (QLatin1String(property.name()) != member)
                    continue;

                QVariant value = property.read(this);
                if (value.userType() == qMetaTypeId<QJSValue>())
                    value = value.value<QJSValue>().toVariant();

                if (value.userType() == QVariant::List) {
                    QVariantList variantList = value.toList();
                    if (variantList.count() > 0) {

                        QDBusArgument list;
                        list.beginArray(variantList.first().userType());
                        foreach (const QVariant &listValue, variantList) {
                            list << listValue;
                        }
                        list.endArray();
                        value = QVariant::fromValue(list);
                    }
                }

                QDBusMessage reply = message.createReply(QVariantList() << value);
                connection.call(reply, QDBus::NoBlock);

                return true;
            }
开发者ID:jlehtoranta,项目名称:nemo-qml-plugin-dbus,代码行数:55,代码来源:declarativedbusadaptor.cpp

示例14: statistics

uint IcdPrivate::statistics(QList<IcdStatisticsResult>& stats_results)
{
    QTimer timer;
    QVariant reply;
    QVariantList vl;
    uint signals_left, total_signals;
    IcdStatisticsResult result;

    clearState();
    reply = mDBus->call(ICD_DBUS_API_STATISTICS_REQ);
    if (reply.type() != QVariant::List)
        return 0;
    vl = reply.toList();
    if (vl.isEmpty())
        return 0;
    reply = vl.first();
    if (reply.type() != QVariant::UInt)
        return 0;
    signals_left = total_signals = reply.toUInt();

    if (!signals_left)
        return 0;

    timer.setSingleShot(true);
    timer.start(timeout);
    stats_results.clear();
    while (signals_left) {
	mInterface.clear();
	while (timer.isActive() && mInterface.isEmpty()) {
	    QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
	}

	if (!timer.isActive()) {
	    total_signals = 0;
	    break;
	}

	if (mSignal != ICD_DBUS_API_STATISTICS_SIG) {
	    continue;
	}

	if (mError.isEmpty()) {
  	    get_statistics_all_result(mArgs, result);
	    stats_results << result;
	    signals_left--;
	} else {
	    qWarning() << "Error:" << mError;
	    break;
	}
    }
    timer.stop();

    return total_signals;
}
开发者ID:RS102839,项目名称:qt,代码行数:54,代码来源:maemo_icd.cpp

示例15: acceptAction

void ActionManager::acceptAction()
{
    ActionType action = m_deferredAction.first;
    if (action == None)
        return;

    QVariantList data = m_deferredAction.second;

    switch(action)
    {
        case DeleteFunctions:
        {
            m_functionManager->deleteFunctions(data);
        }
        break;
        case DeleteShowItems:
        {
            m_showManager->deleteShowItems(data);
        }
        break;
        case DeleteVCPage:
        {
            m_virtualConsole->deletePage(data.first().toInt());
        }
        break;
        case DeleteVCWidgets:
        {
            m_virtualConsole->deleteVCWidgets(data);
        }
        break;
        case VCPagePINRequest:
        {
            m_virtualConsole->setSelectedPage(data.first().toInt());
        }
        break;
        default: break;
    }

    // invalidate the action just processed
    m_deferredAction = QPair<ActionType, QVariantList> (None, QVariantList());
}
开发者ID:boxy321,项目名称:qlcplus,代码行数:41,代码来源:actionmanager.cpp


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