Esempio n. 1
0
void UserStream::statusStream(const QTweetStatus &tweet)
{
    ui->infoTextBrowser->append("New tweet");
    ui->infoTextBrowser->append("id: " + QString::number(tweet.id()));
    ui->infoTextBrowser->append("text: " + tweet.text());
    ui->infoTextBrowser->append("name: " + tweet.user().name());
}
Esempio n. 2
0
void
TwitterConfigWidget::postGotTomahawkStatusUpdateReply( const QTweetStatus& status )
{
    if ( status.id() == 0 )
        QMessageBox::critical( 0, QString("Tweetin' Error"), QString("There was an error posting your status -- sorry!") );
    else
        QMessageBox::information( 0, QString("Tweeted!"), QString("Your tweet has been posted!") );
}
void
TwitterInfoPlugin::postLovedStatusUpdateReply( const QTweetStatus& status )
{
    if ( status.id() == 0 )
        tDebug() << Q_FUNC_INFO << "Failed to post loved status";
    else
        tDebug() << Q_FUNC_INFO << "Successfully posted loved status";
}
Esempio n. 4
0
void MainWindow::statusUpdateFinished(const QTweetStatus &status)
{
    QTweetStatusUpdate *statusUpdate = qobject_cast<QTweetStatusUpdate*>(sender());
    if (statusUpdate) {
        qDebug() << "Sended status with id: " << status.id();

        statusUpdate->deleteLater();
    }
}
/**
 *  This slot is called when fetching mentions is finished (see fetchLastTweets())
 */
void MentionsQmlListModel::finishedFetchTweets(const QList<QTweetStatus> &statuses)
{
    QTweetMentions *mentions = qobject_cast<QTweetMentions*>(sender());

    if (mentions) {
        if (!statuses.isEmpty()) {
            qDebug() << "Fetch mentions: " << statuses.count();

            QSqlQuery query;

            query.exec("BEGIN;");
            query.prepare("INSERT OR REPLACE INTO status "
                          "(id, text, screenName, profileImageUrl, userId, mention, created, replyToStatusId) "
                          "VALUES "
                          "(:id, :text, :screenName, :profileImageUrl, :userId, :mention, :created, :replyToStatusId);");

            QListIterator<QTweetStatus> i(statuses);
            i.toBack();
            while (i.hasPrevious()) {
                QString text;
                QTweetStatus s = i.previous();
                query.bindValue(":id", s.id());
                query.bindValue(":replyToStatusId", s.inReplyToStatusId());
                query.bindValue(":userId", s.user().id());
                query.bindValue(":screenName", s.user().screenName());
                query.bindValue(":profileImageUrl", s.user().profileImageUrl());
                query.bindValue(":mention", 1);
                query.bindValue(":created", s.createdAt());

                if (s.isRetweet()) {
                    QString retweetedText = s.retweetedStatus().text();
                    text = "RT @" + s.retweetedStatus().user().screenName() + ": " + retweetedText;
                } else {
                    text = s.text();
                }

                query.bindValue(":text", text);

                query.exec();

                m_newStatuses.prepend(s);
            }
            query.exec("COMMIT;");

            m_numNewTweets = m_newStatuses.count();
            emit numNewTweetsChanged();
        }
        mentions->deleteLater();
    }
}
/**
 * This slot is connected to user stream object.
 * Called when new tweet arrives in the user stream
 */
void MentionsQmlListModel::onStatusesStream(const QTweetStatus &status)
{
    QList<QTweetEntityUserMentions> entityUserMentions = status.userMentionsEntities();

    for (int i = 0; i < entityUserMentions.count(); ++i) {
        if (entityUserMentions.at(i).userid() == userID()) {    //check if is mention
            QSqlQuery query;
            QString text;

            query.prepare("INSERT OR REPLACE INTO status "
                          "(id, text, screenName, profileImageUrl, userId, mention, created, replyToStatusId) "
                          "VALUES "
                          "(:id, :text, :screenName, :profileImageUrl, :userId, :mention, :created, :replyToStatusId);");
            query.bindValue(":id", status.id());
            query.bindValue(":userId", status.user().id());
            query.bindValue(":screenName", status.user().screenName());
            query.bindValue(":profileImageUrl", status.user().profileImageUrl());
            query.bindValue(":mention", 1);
            query.bindValue(":created", status.createdAt());
            query.bindValue(":replyToStatusId", status.inReplyToStatusId());

            if (status.isRetweet()) {
                QString retweetedText = status.retweetedStatus().text();
                text = "RT @" + status.retweetedStatus().user().screenName() + ": " + retweetedText;
            } else {
                text = status.text();
            }

             query.bindValue(":text", text);

            query.exec();

            m_newStatuses.prepend(status);

            m_numNewTweets = m_newStatuses.count();
            emit numNewTweetsChanged();
            break;
        }
    }
}