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);
offset = 0;
char msgData[msgPtr->msg.TlvSize()];
char* msgData = new char[msgPtr->msg.TlvSize()];
msgPtr->msg.SetTlv(msgData, msgPtr->msg.TlvSize(), &offset);
ostrm.write(msgData, msgPtr->msg.TlvSize());
ostrm.close();
delete[] msgData;
mDb->sqlInsert(MSG_TABLE_NAME, "", cv);
}

View File

@ -1,6 +1,9 @@
#include <QDateTime>
#include "PhotoCommentItem.h"
#include "ui_PhotoCommentItem.h"
PhotoCommentItem::PhotoCommentItem(const RsPhotoComment& comment, QWidget *parent):
QWidget(parent),
ui(new Ui::PhotoCommentItem), mComment(comment)
@ -22,4 +25,8 @@ const RsPhotoComment& PhotoCommentItem::getComment()
void PhotoCommentItem::setUp()
{
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">
<enum>QFrame::Raised</enum>
</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>
<widget class="QWidget" name="commentWidget" native="true">
<property name="styleSheet">

View File

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

View File

@ -32,10 +32,8 @@ PhotoItem::PhotoItem(PhotoShareItemHolder *holder, const QString& path, QWidget
{
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;
ui->label_Thumbnail->setPixmap(mThumbNail.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation));
setSelected(false);
@ -133,7 +131,7 @@ void PhotoItem::updateImage(const RsPhotoThumbnail &thumbnail)
{
QPixmap qtn;
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;
}
}

View File

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

View File

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

View File

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