Ejemplo n.º 1
0
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);
    }
}
Ejemplo n.º 2
0
/*!
  Returns a method value as a query parameter named '_method'
  for REST API.
*/
Tf::HttpMethod THttpRequest::queryItemMethod() const
{
    QString queryMethod = queryItemValue("_method");
    return methodHash()->value(queryMethod, Tf::Invalid);
}