void QTweetUserStream::parseFriendsList(const QVariantMap& streamObject) { QList<qint64> friends; QVariantList friendsVarList = streamObject["friends"].toList(); foreach (const QVariant& idVar, friendsVarList) friends.append(idVar.toLongLong()); emit friendsList(friends); }
void MainWindow::createDeclarativeView() { m_tweetListModel = new TweetQmlListModel(m_oauthTwitter); //connect user stream to tweet home timeline connect(m_userStream, SIGNAL(statusesStream(QTweetStatus)), m_tweetListModel, SLOT(onStatusesStream(QTweetStatus))); connect(m_userStream, SIGNAL(deleteStatusStream(qint64,qint64)), m_tweetListModel, SLOT(onDeleteStatusStream(qint64,qint64))); // ### TODO: Test for syncing problems connect(m_userStream, SIGNAL(reconnected()), m_tweetListModel, SLOT(fetchLastTweets())); //try using REST API when streams fails connect(m_userStream, SIGNAL(failureConnect()), m_tweetListModel, SLOT(fetchLastTweets())); m_mentionsListModel = new MentionsQmlListModel(m_oauthTwitter); connect(m_userStream, SIGNAL(statusesStream(QTweetStatus)), m_mentionsListModel, SLOT(onStatusesStream(QTweetStatus))); connect(m_userStream, SIGNAL(deleteStatusStream(qint64,qint64)), m_mentionsListModel, SLOT(onDeleteStatusStream(qint64,qint64))); connect(m_userStream, SIGNAL(reconnected()), m_mentionsListModel, SLOT(fetchLastTweets())); m_directMessagesListModel = new DirectMessagesQmlListModel(m_oauthTwitter); connect(m_userStream, SIGNAL(directMessageStream(QTweetDMStatus)), m_directMessagesListModel, SLOT(onDirectMessageStream(QTweetDMStatus))); m_searchListModel = new SearchQmlListModel(m_oauthTwitter); m_userInfo = new UserInfo; m_userInfo->setOAuthTwitter(m_oauthTwitter); connect(m_userStream, SIGNAL(friendsList(QList<qint64>)), m_userInfo, SLOT(onUserStreamFriendsList(QList<qint64>))); m_userTimelineListModel = new UserTimelineListModel(m_oauthTwitter); m_conversationListModel = new ConversationListModel(m_oauthTwitter); rootContext()->setContextProperty("hometimelineListModel", m_tweetListModel); rootContext()->setContextProperty("mentionsListModel", m_mentionsListModel); rootContext()->setContextProperty("directMessagesListModel", m_directMessagesListModel); rootContext()->setContextProperty("searchListModel", m_searchListModel); rootContext()->setContextProperty("userInfo", m_userInfo); rootContext()->setContextProperty("userTimelineListModel", m_userTimelineListModel); rootContext()->setContextProperty("conversationListModel", m_conversationListModel); rootContext()->setContextProperty("rootWindow", this); //setSource(QUrl::fromLocalFile("qml/QTwitdget/Main.qml")); setMainQmlFile(QLatin1String("qml/QTwitdget/Main.qml")); }