Added photo slide show

added time stamps on comments
photo items now store real image 
fixed bug in rsdataservice due to stack overflow (large photo!)


git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5672 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-10-13 21:10:42 +00:00
parent 87856b2c9e
commit b166fe0c99
8 changed files with 90 additions and 76 deletions

View File

@ -468,10 +468,11 @@ int RsDataService::storeMessage(std::map<RsNxsMsg *, RsGxsMsgMetaData *> &msg)
cv.put(KEY_CHILD_TS, (int32_t)msgMetaPtr->mChildTs); cv.put(KEY_CHILD_TS, (int32_t)msgMetaPtr->mChildTs);
offset = 0; offset = 0;
char msgData[msgPtr->msg.TlvSize()]; char* msgData = new char[msgPtr->msg.TlvSize()];
msgPtr->msg.SetTlv(msgData, msgPtr->msg.TlvSize(), &offset); msgPtr->msg.SetTlv(msgData, msgPtr->msg.TlvSize(), &offset);
ostrm.write(msgData, msgPtr->msg.TlvSize()); ostrm.write(msgData, msgPtr->msg.TlvSize());
ostrm.close(); ostrm.close();
delete[] msgData;
mDb->sqlInsert(MSG_TABLE_NAME, "", cv); mDb->sqlInsert(MSG_TABLE_NAME, "", cv);
} }

View File

@ -1,6 +1,9 @@
#include <QDateTime>
#include "PhotoCommentItem.h" #include "PhotoCommentItem.h"
#include "ui_PhotoCommentItem.h" #include "ui_PhotoCommentItem.h"
PhotoCommentItem::PhotoCommentItem(const RsPhotoComment& comment, QWidget *parent): PhotoCommentItem::PhotoCommentItem(const RsPhotoComment& comment, QWidget *parent):
QWidget(parent), QWidget(parent),
ui(new Ui::PhotoCommentItem), mComment(comment) ui(new Ui::PhotoCommentItem), mComment(comment)
@ -22,4 +25,8 @@ const RsPhotoComment& PhotoCommentItem::getComment()
void PhotoCommentItem::setUp() void PhotoCommentItem::setUp()
{ {
ui->labelComment->setText(QString::fromStdString(mComment.mComment)); ui->labelComment->setText(QString::fromStdString(mComment.mComment));
QDateTime qtime;
qtime.setTime_t(mComment.mMeta.mPublishTs);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
ui->datetimelabel->setText(timestamp);
} }

View File

@ -43,7 +43,42 @@ border-radius: 10px;}</string>
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="datetimelabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:600; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; color:#666666;&quot;&gt;DateTime&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="QWidget" name="commentWidget" native="true"> <widget class="QWidget" name="commentWidget" native="true">
<property name="styleSheet"> <property name="styleSheet">

View File

@ -10,8 +10,14 @@
<height>566</height> <height>566</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>PhotoShare</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
@ -56,6 +62,12 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>327</width>
<height>0</height>
</size>
</property>
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>

View File

@ -32,10 +32,8 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget
{ {
ui->setupUi(this); ui->setupUi(this);
int width = 250;
int height = 250;
QPixmap qtn = QPixmap(path).scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); QPixmap qtn = QPixmap(path);
mThumbNail = qtn; mThumbNail = qtn;
ui->label_Thumbnail->setPixmap(mThumbNail.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation)); ui->label_Thumbnail->setPixmap(mThumbNail.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation));
setSelected(false); setSelected(false);
@ -133,7 +131,7 @@ void PhotoItem::updateImage(const RsPhotoThumbnail &thumbnail)
{ {
QPixmap qtn; QPixmap qtn;
qtn.loadFromData(thumbnail.data, thumbnail.size, thumbnail.type.c_str()); qtn.loadFromData(thumbnail.data, thumbnail.size, thumbnail.type.c_str());
ui->label_Thumbnail->setPixmap(qtn); ui->label_Thumbnail->setPixmap(qtn.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation));
mThumbNail = qtn; mThumbNail = qtn;
} }
} }

View File

@ -210,18 +210,15 @@ void PhotoShare::OpenSlideShow()
return; return;
} }
std::string albumId = mAlbumSelected->getAlbum().mMeta.mGroupId;
if (mSlideShow) if (mSlideShow)
{ {
mSlideShow->show(); mSlideShow->show();
} }
else else
{ {
mSlideShow = new PhotoSlideShow(NULL); mSlideShow = new PhotoSlideShow(mAlbumSelected->getAlbum(), NULL);
mSlideShow->show(); mSlideShow->show();
} }
mSlideShow->loadAlbum(albumId);
} }

View File

@ -27,8 +27,8 @@
#include <iostream> #include <iostream>
/** Constructor */ /** Constructor */
PhotoSlideShow::PhotoSlideShow(QWidget *parent) PhotoSlideShow::PhotoSlideShow(const RsPhotoAlbum& album, QWidget *parent)
: QWidget(parent) : QWidget(parent), mAlbum(album)
{ {
ui.setupUi(this); ui.setupUi(this);
@ -45,12 +45,19 @@ PhotoSlideShow::PhotoSlideShow(QWidget *parent)
mImageIdx = 0; mImageIdx = 0;
//loadImage(); requestPhotos();
loadImage();
//QTimer::singleShot(5000, this, SLOT(timerEvent())); //QTimer::singleShot(5000, this, SLOT(timerEvent()));
} }
PhotoSlideShow::~PhotoSlideShow(){ PhotoSlideShow::~PhotoSlideShow(){
std::map<std::string, RsPhotoPhoto *>::iterator mit = mPhotos.begin();
for(; mit != mPhotos.end(); mit++)
{
delete mit->second;
}
} }
void PhotoSlideShow::showPhotoDetails() void PhotoSlideShow::showPhotoDetails()
@ -174,9 +181,7 @@ void PhotoSlideShow::loadImage()
qtn.loadFromData(tn.data, tn.size, tn.type.c_str()); qtn.loadFromData(tn.data, tn.size, tn.type.c_str());
tn.data = 0; tn.data = 0;
//ui.imgLabel->setPixmap(qtn); QPixmap sqtn = qtn.scaled(800, 600, Qt::KeepAspectRatio, Qt::SmoothTransformation);
QPixmap sqtn = qtn.scaled(ui.albumLabel->width(), ui.imgLabel->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui.imgLabel->setPixmap(sqtn); ui.imgLabel->setPixmap(sqtn);
} }
@ -238,24 +243,16 @@ void PhotoSlideShow::clearDialog()
#endif #endif
} }
void PhotoSlideShow::requestPhotos()
void PhotoSlideShow::loadAlbum(const std::string &albumId)
{ {
/* much like main load fns */ RsTokReqOptionsV2 opts;
clearDialog(); opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
uint32_t token;
RsTokReqOptionsV2 opts; std::list<RsGxsGroupId> grpIds;
uint32_t token; grpIds.push_back(mAlbum.mMeta.mGroupId);
std::list<std::string> albumIds; mPhotoQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, 0);
albumIds.push_back(albumId);
// We need both Album and Photo Data.
mPhotoQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, albumIds, 0);
} }
bool PhotoSlideShow::loadPhotoData(const uint32_t &token) bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
{ {
std::cerr << "PhotoSlideShow::loadPhotoData()"; std::cerr << "PhotoSlideShow::loadPhotoData()";
@ -270,7 +267,7 @@ bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
{ {
std::vector<RsPhotoPhoto>& photoV = mit->second; std::vector<RsPhotoPhoto>& photoV = mit->second;
std::vector<RsPhotoPhoto>::iterator vit = photoV.begin(); std::vector<RsPhotoPhoto>::iterator vit = photoV.begin();
int i = 0;
for(; vit != photoV.end(); vit++) for(; vit != photoV.end(); vit++)
{ {
RsPhotoPhoto& photo = *vit; RsPhotoPhoto& photo = *vit;
@ -278,7 +275,7 @@ bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
*ptr = photo; *ptr = photo;
ptr->mThumbnail.data = 0; ptr->mThumbnail.data = 0;
ptr->mThumbnail.copyFrom(photo.mThumbnail); ptr->mThumbnail.copyFrom(photo.mThumbnail);
ptr->mOrder = i++;
mPhotos[photo.mMeta.mMsgId] = ptr; mPhotos[photo.mMeta.mMsgId] = ptr;
mPhotoOrder[ptr->mOrder] = photo.mMeta.mMsgId; mPhotoOrder[ptr->mOrder] = photo.mMeta.mMsgId;
@ -297,38 +294,6 @@ bool PhotoSlideShow::loadPhotoData(const uint32_t &token)
return true; return true;
} }
bool PhotoSlideShow::loadAlbumData(const uint32_t &token)
{
std::cerr << "PhotoSlideShow::loadAlbumData()";
std::cerr << std::endl;
std::vector<RsPhotoAlbum> albums;
rsPhotoV2->getAlbum(token, albums);
std::vector<RsPhotoAlbum>::iterator vit = albums.begin();
GxsMsgReq req;
for(; vit != albums.end(); vit++)
{
RsPhotoAlbum& album = *vit;
std::cerr << " PhotoSlideShow::loadAlbumData() AlbumId: " << album.mMeta.mGroupId << std::endl;
//updateAlbumDetails(album);
uint32_t token;
std::list<std::string> albumIds;
albumIds.push_back(album.mMeta.mGroupId);
req[album.mMeta.mGroupId] = std::vector<RsGxsMessageId>();
}
RsTokReqOptionsV2 opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t t;
mPhotoQueue->requestMsgInfo(t, RS_TOKREQ_ANSTYPE_DATA, opts, req, 0);
return true;
}
void PhotoSlideShow::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req) void PhotoSlideShow::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req)
{ {
std::cerr << "PhotoSlideShow::loadRequest()"; std::cerr << "PhotoSlideShow::loadRequest()";
@ -339,14 +304,11 @@ void PhotoSlideShow::loadRequest(const TokenQueueV2 *queue, const TokenRequestV2
/* now switch on req */ /* now switch on req */
switch(req.mType) switch(req.mType)
{ {
case TOKENREQ_GROUPINFO:
loadAlbumData(req.mToken);
break;
case TOKENREQ_MSGINFO: case TOKENREQ_MSGINFO:
loadPhotoData(req.mToken); loadPhotoData(req.mToken);
break; break;
default: default:
std::cerr << "PhotoSlideShow::loadRequest() ERROR: GROUP: INVALID ANS TYPE"; std::cerr << "PhotoSlideShow::loadRequest() ERROR: REQ: INVALID REQ TYPE";
std::cerr << std::endl; std::cerr << std::endl;
break; break;
} }

View File

@ -28,17 +28,17 @@
#include <retroshare/rsphotoV2.h> #include <retroshare/rsphotoV2.h>
#include "util/TokenQueueV2.h" #include "util/TokenQueueV2.h"
#include "AlbumItem.h"
class PhotoSlideShow : public QWidget, public TokenResponseV2 class PhotoSlideShow : public QWidget, public TokenResponseV2
{ {
Q_OBJECT Q_OBJECT
public: public:
PhotoSlideShow(QWidget *parent = 0); PhotoSlideShow(const RsPhotoAlbum& mAlbum, QWidget *parent = 0);
virtual ~PhotoSlideShow(); virtual ~PhotoSlideShow();
void loadAlbum(const std::string &albumId); void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req);
virtual void loadRequest(const TokenQueueV2 *queue, const TokenRequestV2 &req);
void clearDialog(); void clearDialog();
@ -53,13 +53,13 @@ private slots:
private: private:
void requestPhotos();
void loadImage(); void loadImage();
void updateMoveButtons(uint32_t status); void updateMoveButtons(uint32_t status);
bool loadPhotoData(const uint32_t &token); bool loadPhotoData(const uint32_t &token);
bool loadAlbumData(const uint32_t &token);
//protected: private:
std::map<std::string, RsPhotoPhoto *> mPhotos; std::map<std::string, RsPhotoPhoto *> mPhotos;
std::map<int, std::string> mPhotoOrder; std::map<int, std::string> mPhotoOrder;
@ -68,6 +68,8 @@ private:
int mImageIdx; int mImageIdx;
bool mShotActive; bool mShotActive;
RsPhotoAlbum mAlbum;
TokenQueueV2 *mPhotoQueue; TokenQueueV2 *mPhotoQueue;
Ui::PhotoSlideShow ui; Ui::PhotoSlideShow ui;