#include "userimageprovider.h"
#include "../user/friendmodel.h"
+#include "../user/profile.h"
-UserImageProvider::UserImageProvider(FriendModel* friendModel) :
+UserImageProvider::UserImageProvider(FriendModel* friendModel, Profile *profile) :
QDeclarativeImageProvider(QDeclarativeImageProvider::Image),
- friendModel(friendModel)
+ friendModel(friendModel),
+ profile(profile)
{
}
QImage UserImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
- Q_UNUSED(size);
- Q_UNUSED(requestedSize);
Q_ASSERT(friendModel);
+ Q_ASSERT(profile);
for (int i=0; i<friendModel->rowCount(); ++i) {
const QModelIndex index = friendModel->index(i);
const QPixmap pixmap = friendModel->data(index, FriendModel::ImageRole).value<QPixmap>();
if (!pixmap.isNull()) {
QImage image = pixmap.toImage();
+ size->setHeight(image.height());
+ size->setWidth(image.width());
if (requestedSize.isValid())
image = image.scaled(requestedSize);
return image;
break;
}
}
+ if ((profile->userId() == id) && !profile->pixmap().isNull()) {
+ QImage image = profile->pixmap().toImage();
+ size->setHeight(image.height());
+ size->setWidth(image.width());
+ if (requestedSize.isValid())
+ image = image.scaled(requestedSize);
+ return image;
+ }
+
return QImage();
}