コード例 #1
0
ファイル: newsfeedmodel.cpp プロジェクト: magist3r/vkit
void NewsFeedModel::onAddLike(const QVariant &response)
{
    auto reply = vk::sender_cast<vk::Reply*>(sender());
    auto url = reply->networkReply()->url();

    int postId = url.queryItemValue("post_id").toInt();
    int retweet = url.queryItemValue("repost").toInt();
    auto map = response.toMap();
    int likes = map.value("likes").toInt();
    int reposts = map.value("reposts").toInt();

    int index = findNews(postId);
    if (index != -1) {
        auto news = m_newsList.at(index);

        map = news.likes();
        map.insert("count", likes);
        map.insert("user_likes", true);
        news.setLikes(map);

        map = news.reposts();
        map.insert("count", reposts);
        map.insert("user_reposted", retweet);
        news.setReposts(map);

        replaceNews(index, news);
    }
}
コード例 #2
0
void NetworkComm::finishedSlot(QNetworkReply * reply){
    QByteArray bytes = reply->readAll();  //.readAll();  // bytes
    QString string(bytes); // string
    qDebug()<<"reply: "<<string<<".................";
    emit networkReply(string);
    delete(multiPart);
    multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);

}
コード例 #3
0
QNetworkReply *filterNetworkAccessModule::Get()
{
    QUrl url(this->requestURL);
    QNetworkRequest req(url);

    this->reply = netManager->get(req);

    connect(reply, SIGNAL(finished()), this, SLOT(networkReply()));
    connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));

    {
        QEventLoop loop;
        loop.connect(this, SIGNAL(dataProcessed()), SLOT(quit()));
//        std::cout << "...in event loop..." << std::endl;
        loop.exec();

//        std::cout << "EVENT LOOP HAS EXITED" << std::endl;
    }
    return this->reply;
}