connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
m_mapEngine, SIGNAL(friendsLocationsReady(QList<User*>&)));
+ connect(this, SIGNAL(friendImageReady(User*)),
+ m_ui, SIGNAL(friendImageReady(User*)));
+
+ connect(this, SIGNAL(friendImageReady(User*)),
+ m_mapEngine, SIGNAL(friendImageReady(User*)));
+
m_automaticUpdateIntervalTimer = new QTimer(this);
connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
this, SLOT(startAutomaticUpdate()));
m_ui->setUsername(m_facebookAuthenticator->loadUsername());
}
+void SituareEngine::imageReady(User *user)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(user->type())
+ emit userLocationReady(user);
+ else
+ emit friendImageReady(user);
+}
+
void SituareEngine::initializeGpsAndAutocentering()
{
qDebug() << __PRETTY_FUNCTION__;
connect(m_situareService, SIGNAL(error(int, int)),
this, SLOT(error(int, int)));
+ connect(m_situareService, SIGNAL(imageReady(User*)),
+ this, SLOT(imageReady(User*)));
+
connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
m_ui, SIGNAL(reverseGeoReady(QString)));
*/
void enableAutomaticLocationUpdate(bool enabled, int updateIntervalMsecs = 0);
+ void imageReady(User *user);
+
/**
* @brief Requests automatic update.
*
*/
void friendsLocationsReady(QList<User *> &friendList);
+ void friendImageReady(User *user);
+
/**
* @brief Signals when new user data is ready
*
}
}
+void FriendItemsHandler::friendImageReady(User *user)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ foreach (FriendLocationItem *friendItem, m_friendItems) {
+ if (user->userId() == friendItem->userId()) {
+ friendItem->setProfileImage(user->profileImage(), user->profileImageUrl());
+ break;
+ }
+ }
+}
+
void FriendItemsHandler::friendListUpdated(QList<User *> &friendsList)
{
qDebug() << __PRETTY_FUNCTION__;
void updateFriendLocationsAndImages(const QList<User *> &friendsList);
private slots:
+
+ void friendImageReady(User *user);
/**
* @brief Slot for upgrading friend items and groups
*
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
m_friendItemsHandler, SLOT(friendListUpdated(QList<User*>&)));
+ connect(this, SIGNAL(friendImageReady(User*)),
+ m_friendItemsHandler, SLOT(friendImageReady(User*)));
+
connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
this, SLOT(friendsPositionsUpdated()));
*/
void fetchImage(int zoomLevel, int x, int y);
+ void friendImageReady(User *user);
+
/**
* @brief Signal when friend list locations are fetched
*
{
qDebug() << __PRETTY_FUNCTION__;
- m_visited = 0;
- m_nbrOfImages = 0;
m_defaultImage = false;
QJson::Parser parser;
m_friendsList.append(user);
}
+ emit userDataChanged(m_user, m_friendsList);
addProfileImages();
} else {
QVariant address = result.value("address");
if(url == QUrl(SILHOUETTE_URL)) {
if(m_user->profileImageUrl().isEmpty()) {
m_user->setProfileImage(AvatarImage::create(image, AvatarImage::Large));
+ emit imageReady(m_user);
}
for(int i=0;i < m_friendsList.count();i++) {
if(m_friendsList.at(i)->profileImageUrl().isEmpty()) {
m_friendsList.at(i)->setProfileImage(AvatarImage::create(image,
AvatarImage::Small));
+ emit imageReady(m_friendsList.at(i));
}
}
}
if (m_user->profileImageUrl() == url) {
m_user->setProfileImage(AvatarImage::create(image, AvatarImage::Large));
+ emit imageReady(m_user);
}
for(int i=0;i<m_friendsList.count();i++) {
if(m_friendsList.at(i)->profileImageUrl() == url) {
m_friendsList.at(i)->setProfileImage(AvatarImage::create(image, AvatarImage::Small));
- m_nbrOfImages++; // indicates how many friend profile images has been downloaded
+ emit imageReady(m_friendsList.at(i));
}
}
-
- if(m_nbrOfImages == m_visited) {
- qDebug() << "m_nbrOfImages: " << m_nbrOfImages << " m_visited: " << m_visited;
- qDebug() << "emit userDataChanged";
- emit userDataChanged(m_user, m_friendsList);
- }
}
void SituareService::addProfileImages()
for(int i=0;i<m_friendsList.count();i++) {
if(!m_friendsList.at(i)->profileImageUrl().isEmpty() &&
m_friendsList.at(i)->profileImageUrl().isValid()) {
- m_visited++; // indicates how many friends that have profile image
- emit fetchImage(m_friendsList.at(i)->profileImageUrl());
+ emit fetchImage(m_friendsList.at(i)->profileImageUrl());
}
}
}
*/
void fetchImage(const QUrl &url);
+ void imageReady(User *user);
+
/**
* @brief Signals when address data is retrieved
*
private:
- int m_nbrOfImages; ///< Indicates number of friends whose images has been downloaded
- int m_visited; ///< Indicates number of friends with images
-
bool m_defaultImage; ///< Indicates if some of the friends/user doesn't have a image
QList<QNetworkReply *> m_currentRequests; ///< List of current http requests
FacebookCredentials m_credentials; ///< handle for FacebookCredentials
ImageFetcher *m_imageFetcher; ///< Instance of the image fetcher
User *m_user; ///< Pointer to User
-
-
-
};
#endif // SITUARESERVICE_H
}
}
+void FriendListItem::setAvatarImage(const QPixmap &image)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(!image.isNull())
+ m_findButton->setButtonIcon(image);
+}
+
void FriendListItem::setDistanceIcon(double value, const QString &unit)
{
QPixmap distanceImage;
*/
void setData(User *user);
+ void setAvatarImage(const QPixmap &image);
+
private:
/**
* @brief Set distance icon.
this, SLOT(clearFriendListFilter()));
}
+void FriendListPanel::friendImageReady(User *user)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ FriendListItem *item = m_friendListView->widget(user->userId());
+ item->setAvatarImage(user->profileImage());
+}
+
void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
{
qDebug() << __PRETTY_FUNCTION__;
*/
void friendInfoReceived(QList<User *> &friendList);
+ void friendImageReady(User *user);
+
private slots:
/**
* @brief Slot to clear friend list filter.
connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
this, SIGNAL(findFriend(QPointF)));
+
+ connect(this, SIGNAL(friendImageReady(User*)),
+ m_friendsListPanel, SLOT(friendImageReady(User*)));
}
void MainWindow::buildInformationBox(const QString &message, bool modal)
*/
void findUser(const QPointF &coordinates);
+ void friendImageReady(User *user);
+
/**
* @brief GPS setting changed
*
connect(this, SIGNAL(clearUpdateLocationDialogData()),
m_userInfo, SLOT(clearUpdateLocationDialogData()));
- connect (m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
+ connect(m_userInfo, SIGNAL(notificateUpdateFailing(QString, bool)),
this, SIGNAL(notificateUpdateFailing(QString, bool)));
}