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


C++ QVariantMap::take方法代码示例

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


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

示例1: ContactRequest

PluginResult *ContactManager::find (QVariantMap &args, QString &clbId)
{
  QList<QVariant> values = args.values ();
  QVariantList fields = values [0].toList ();
  QVariantMap options = values [1].toMap ();

  QString filter = "";
  if (options.contains ("filter"))
  {
    filter = options.take ("filter").toString ();
  }

  bool multiple = false;
  if (options.contains ("multiple"))
  {
    multiple = options.take ("multiple").toBool ();
  }

  ContactRequest *request = new ContactRequest (clbId, filter, multiple, this);
  requests.insert (clbId, request);

  PluginResult *r;
  if (!request->start())
  {
    qDebug() << "Unable to request contacts!";
    r = new PluginResult (PGCommandStatus_ERROR, "Unable to request contacts!");
  } else
  {
    qDebug() << "Requested contacts; awaiting results...";
    r = new PluginResult (PGCommandStatus_OK, "Salut");
  }
  return r;
}
开发者ID:vinisketch,项目名称:phonegap-qt,代码行数:33,代码来源:ContactManager.cpp

示例2: NetworkEvent

MessageEvent::MessageEvent(EventManager::EventType type, QVariantMap &map, Network *network)
    : NetworkEvent(type, map, network)
{
    _msgType = static_cast<Message::Type>(map.take("messageType").toInt());
    _msgFlags = static_cast<Message::Flags>(map.take("messageFlags").toInt());
    _bufferType = static_cast<BufferInfo::Type>(map.take("bufferType").toInt());
    _text = map.take("text").toString();
    _sender = map.take("sender").toString();
    _target = map.take("target").toString();
}
开发者ID:2kah,项目名称:quassel,代码行数:10,代码来源:messageevent.cpp

示例3: qWarning

Event::Event(EventManager::EventType type, QVariantMap &map)
    : _type(type)
    , _valid(true)
{
    if (!map.contains("flags") || !map.contains("timestamp")) {
        qWarning() << "Received invalid serialized event:" << map;
        setValid(false);
        return;
    }

    setFlags(static_cast<EventManager::EventFlags>(map.take("flags").toInt())); // TODO sanity check?
    setTimestamp(QDateTime::fromTime_t(map.take("timestamp").toUInt()));
}
开发者ID:AGBrown,项目名称:quassel-ABContrib,代码行数:13,代码来源:event.cpp

示例4: foreach

void
WhatsHotWidget::setViewData( const QVariantMap& data )
{
    QStandardItem* rootItem = m_crumbModelLeft->invisibleRootItem();
    QVariantMap returnedData = data;

    // We need to take this from data
    QString defaultSource = returnedData.take( "defaultSource" ).toString();
    QVariantMap defaults = returnedData.take( "defaults" ).toMap();
    // Here, we dont want current sessions last view, but rather what was current on previus quit
    QString lastSeen = TomahawkSettings::instance()->lastChartIds().value( "lastseen" ).toString();

    if ( !lastSeen.isEmpty() )
        defaultSource = lastSeen;

    // Merge defaults with current defaults, split the value in to a list
    foreach ( const QString& key, m_currentVIds.keys() )
        defaults[ key ] = m_currentVIds.value( key ).toString().split( "/" );

    foreach ( const QString& label, returnedData.keys() )
    {
        QStandardItem* childItem = parseNode( rootItem, label, returnedData[ label ] );
        const QString id = label.toLower();

        if ( id == defaultSource.toLower() )
        {
            qDebug() << "Setting source as default" << id;
            childItem->setData( true, Breadcrumb::DefaultRole );
        }
        if ( defaults.contains( id ) )
        {
            QStringList defaultIndices = defaults[ id ].toStringList();
            QStandardItem* cur = childItem;

            foreach ( const QString& index, defaultIndices )
            {
                // Go through the children of the current item, marking the default one as default
                for ( int k = 0; k < cur->rowCount(); k++ )
                {
                    if ( cur->child( k, 0 )->text().toLower() == index.toLower() )
                    {
                        qDebug() << "Setting child as default" << index;
                        cur = cur->child( k, 0 ); // this is the default, drill down into the default to pick the next default
                        cur->setData( true, Breadcrumb::DefaultRole );
                        break;
                    }
                }
            }
        }
        rootItem->appendRow( childItem );
    }
开发者ID:rotzbouw,项目名称:tomahawk,代码行数:51,代码来源:WhatsHotWidget.cpp

示例5: it

void O2Gft::onTokenReplyFinished()
{
    qDebug() << "O2Gft::onTokenReplyFinished";

    QNetworkReply *tokenReply = qobject_cast<QNetworkReply *>(sender());
    if (tokenReply->error() == QNetworkReply::NoError) {
        QByteArray replyData = tokenReply->readAll();
        QScriptEngine engine;
        QScriptValueIterator it(engine.evaluate("(" + QString(replyData) + ")"));
        QVariantMap tokens;

        while (it.hasNext()) {
            it.next();
            tokens.insert(it.name(), it.value().toVariant());
        }

        // Check for mandatory tokens
        if (tokens.contains(O2_OAUTH2_ACCESS_TOKEN)) {
            setToken(tokens.take(O2_OAUTH2_ACCESS_TOKEN).toString());

            //
            setIdToken(tokens.take(O2_OAUTH2_ID_TOKEN).toString());

            //
            bool ok = false;
            int expiresIn = tokens.take(O2_OAUTH2_EXPIRES_IN).toInt(&ok);
            if (ok) {
                qDebug() << "Token expires in" << expiresIn << "seconds";
                setExpires(QDateTime::currentMSecsSinceEpoch() / 1000 + expiresIn);
            }
            setRefreshToken(tokens.take(O2_OAUTH2_REFRESH_TOKEN).toString());
            // Set extra tokens if any
            if (!tokens.isEmpty()) {
                setExtraTokens(tokens);
            }
            timedReplies_.remove(tokenReply);
            emit linkedChanged();
            emit tokenChanged();
            emit linkingSucceeded();
        } else {
            qWarning() << "O2::onTokenReplyFinished: oauth_token missing from response" << replyData;
            emit linkedChanged();
            emit tokenChanged();
            emit linkingFailed();
        }
    }
    tokenReply->deleteLater();
}
开发者ID:Sky,项目名称:o2,代码行数:48,代码来源:o2gft.cpp

示例6: AutoResizeMixin

	DeclarativeWindow::DeclarativeWindow (const QUrl& url, QVariantMap params,
			const QPoint& orig, ViewManager *viewMgr, ICoreProxy_ptr proxy, QWidget *parent)
	: QDeclarativeView (parent)
	{
		new Util::AutoResizeMixin (orig, [viewMgr] () { return viewMgr->GetFreeCoords (); }, this);

		if (!params.take ("keepOnFocusLeave").toBool ())
			new Util::UnhoverDeleteMixin (this, SLOT (beforeDelete ()));

		setStyleSheet ("background: transparent");
		setWindowFlags (Qt::Tool | Qt::FramelessWindowHint);
		setAttribute (Qt::WA_TranslucentBackground);

		for (const auto& cand : Util::GetPathCandidates (Util::SysPath::QML, ""))
			engine ()->addImportPath (cand);

		rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		for (const auto& key : params.keys ())
			rootContext ()->setContextProperty (key, params [key]);
		engine ()->addImageProvider ("ThemeIcons", new Util::ThemeImageProvider (proxy));
		setSource (url);

		connect (rootObject (),
				SIGNAL (closeRequested ()),
				this,
				SLOT (deleteLater ()));
	}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例7: getUserLimits

bool Storage::getUserLimits (const QString& user, QVariantMap& target)
{
    QString val;
    QFile file;
    QString filename = QString (CLEPSYDRA_WORKING_FOLDER).append(CLEPSYDRA_JSON_USERDATA_FILENAME);
    file.setFileName(filename);
    if ( !file.isReadable() ) {
        //
        return false;
    }
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)==true) {
        val = file.readAll();
        file.close();
    } else {
        qDebug () << filename << "json file not found";
        return false;
    }

    QJsonDocument d = QJsonDocument::fromJson(val.toUtf8());
    if (d.isEmpty()) {
        qDebug () << "Not valid document.";
        return false;
    }

    QJsonObject obj = d.object();
    QJsonValue mapArray = obj.value(user);
    if (mapArray.isUndefined()) {
        qDebug () << "User not found from limits.";
        return false;
    }

    QVariantMap dataC = mapArray.toObject().toVariantMap();
    target = dataC.take(user).toMap();
    return true;
}
开发者ID:timekpr,项目名称:clepsydra,代码行数:35,代码来源:storage.cpp

示例8: fromVariantMap

Event *EventManager::createEvent(const QVariantMap &map)
{
    QVariantMap m = map;

    Network *net = networkById(m.take("network").toInt());
    return Event::fromVariantMap(m, net);
}
开发者ID:2kah,项目名称:quassel,代码行数:7,代码来源:eventmanager.cpp

示例9: onMessage

void App::onMessage(QString type, QVariantMap data)
{
    if (type == "quit") {
        stopFullScreen();
        qApp->quit();
    }


    else if (type == "startFS")
        startFullScreen();


    else if (type == "stopFS")
        stopFullScreen();


    else if(type == "allowUserInput") {
        allowUserInput = data.value("value", false).toBool();

        if (lockWin)
            lockWin->allowUserInput(allowUserInput);
    }


    else if (type == "GMoption")
        graphic->setOption(data.take("option").toString(), data);


    else if (type == "shutdown")
        shutdown();
}
开发者ID:ParksProjets,项目名称:PProot,代码行数:31,代码来源:App.cpp

示例10: d

WallPost::WallPost(QVariantMap data, Client *client) :
    d(new WallPostData(client))
{
    d->id = data.take("id").toInt();
    d->body = data.take("text").toString();
    d->fromId = data.take("from_id").toInt();
    d->toId = data.take("to_id").toInt();
    d->date = QDateTime::fromTime_t(data.take("date").toUInt());
    d->likes = data.take("likes").toMap();
    d->reposts = data.take("reposts").toMap();
    setAttachments(Attachment::fromVariantList(data.take("attachments").toList()));
    d->data = data;
}
开发者ID:magist3r,项目名称:vkit,代码行数:13,代码来源:wallpost.cpp

示例11: IrcEvent

CtcpEvent::CtcpEvent(EventManager::EventType type, QVariantMap &map, Network *network)
    : IrcEvent(type, map, network)
{
    _ctcpType = static_cast<CtcpType>(map.take("ctcpType").toInt());
    _ctcpCmd = map.take("ctcpCmd").toString();
    _target = map.take("target").toString();
    _param = map.take("param").toString();
    _reply = map.take("repy").toString();
    _uuid = map.take("uuid").toString();
}
开发者ID:sandsmark,项目名称:quassel-proxy,代码行数:10,代码来源:ctcpevent.cpp

示例12: setOpinions

void Decision::setOpinions(QVariantMap newOpinions)
{
    canonicalizeOpinions(newOpinions);

    if (newOpinions == opinions())
        return;

    // Now we actually allocate space for and set the opinions
    auto opinionList = m_decision.initOpinions(newOpinions.size());
    unsigned currentIndex = 0;
    while (!newOpinions.empty()) {
        auto builder = opinionList[currentIndex++];
        auto key = newOpinions.firstKey();
        builder.setContestant(key.toInt());
        builder.setOpinion(newOpinions.take(key).toInt());
    }

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

示例13: readDefaultLimits

void Storage::readDefaultLimits()
{
    QString filename = QString(CLEPSYDRA_CONFIG_FOLDER).append(CLEPSYDRA_JSON_DEFAULTS_FILENAME);
    QFile file;
    QString data=NULL;
    file.setFileName(filename);
    if (file.open(QIODevice::ReadOnly | QIODevice::Text)==true) {
        data = file.readAll();
        file.close();
    } else {
        qDebug () << filename << "json file not found";
        return;
    }
    QJsonDocument d = QJsonDocument::fromJson(data.toUtf8());
    if (d.isEmpty()) {
        qDebug () << "Not valid document.";
        return;
    }
    QJsonObject obj = d.object();
    QVariantMap tempData = obj.toVariantMap();
    m_defaultLimits = tempData.take("default").toMap();
}
开发者ID:timekpr,项目名称:clepsydra,代码行数:22,代码来源:storage.cpp

示例14: readContents

bool DatabaseBackup::readContents(const QString &filename) {
    qDebug() << "Read contents from " + filename;
    QFile file(filename);
    QSqlQueryModel query;
    bool res = false;

    if (file.open(QIODevice::ReadOnly)) {
        QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
        if (doc.isObject()) {
            res = true;
            QJsonArray tables = doc.object().take("database").toObject().take("tables").toArray();
            QJsonArray::const_iterator i = tables.constBegin();
            while (i != tables.constEnd()) {
                QString tableName = (*i).toObject().take("name").toString();
                qDebug() << tableName;
                QJsonArray records = (*i).toObject().take("records").toArray();
                QJsonArray::const_iterator recordIterator = records.constBegin();
                while (recordIterator != records.constEnd()) {
                    QVariantMap record = (*recordIterator).toObject().toVariantMap();
                    QStringList fields = record.keys();
                    QStringList values;
                    QStringList::const_iterator fieldIterator = fields.constBegin();
                    while (fieldIterator != fields.constEnd()) {
                        values << record.take(*fieldIterator).toString();
                        ++fieldIterator;
                    }
                    qDebug() << "INSERT INTO " + tableName + " (" + fields.join(',') + ")" + " VALUES ('" + values.join("','") + "')";
                    query.setQuery( QSqlQuery("INSERT INTO " + tableName + " (" + fields.join(',') + ")" + " VALUES ('" + values.join("','") + "')") );
                    qDebug() << "Errors?" << query.lastError();
                    ++ recordIterator;
                }
                ++i;
            }
        }
        query.submit();
    }
    file.close();
    return res;
}
开发者ID:velerelectronic,项目名称:QML-Libraries,代码行数:39,代码来源:databasebackup.cpp

示例15: urlFor

QString DynamicRoute::urlFor(const QVariantMap & parameters) const
{
    QStringList list;
    QVariantMap params = parameters;

    for (const UrlPart & urlPart : m_urlParts)
    {
        if (urlPart.isVariable())
        {
            if (!params.contains(urlPart.getName()))
            {
                return "";
            }

            list << params.take(urlPart.getName()).toString();
        }
        else
        {
            list << urlPart.getName();
        }
    }

    return list.join("/") + urlParameters(params);
}
开发者ID:scheibel,项目名称:tasteful-framework,代码行数:24,代码来源:Route.cpp


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