Fixed posted item serialisation (wrong way round)

cleaned up comments gui and added loading framework
correctly initialisaed posted items


git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5876 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2012-11-22 22:40:31 +00:00
parent 4e63561473
commit ebbe967402
14 changed files with 456 additions and 290 deletions

View File

@ -194,9 +194,8 @@ bool RsGxsPostedSerialiser::serialiseGxsPostedPostItem(RsGxsPostedPostItem* item
/* GxsPhotoAlbumItem */
ok &= SetTlvString(data, tlvsize, &offset, 1, item->mPost.mNotes);
ok &= SetTlvString(data, tlvsize, &offset, 1, item->mPost.mLink);
ok &= SetTlvString(data, tlvsize, &offset, 1, item->mPost.mNotes);
if(offset != tlvsize)
{

View File

@ -61,16 +61,13 @@
PostedComments::PostedComments(QWidget *parent)
:QWidget(parent)
{
ui.setupUi(this);
/* setup TokenQueue */
//mPhotoQueue = new TokenQueue(rsPhoto, this);
ui.treeWidget->setup(rsPosted->getTokenService());
ui.setupUi(this);
ui.postFrame->setVisible(false);
ui.treeWidget->setup(rsPosted->getTokenService());
}
void PostedComments::loadComments( std::string threadId )
void PostedComments::loadComments(const RsGxsMessageId& threadId )
{
std::cerr << "PostedComments::loadComments(" << threadId << ")";
std::cerr << std::endl;

View File

@ -31,12 +31,9 @@
#include <map>
//#include "gui/Posted/PostedItem.h"
//#include "gui/PhotoShare/PhotoAddDialog.h"
//#include "gui/PhotoShare/PhotoSlideShow.h"
#include "util/TokenQueueVEG.h"
#include "util/TokenQueue.h"
class PostedComments: public QWidget, public TokenResponseVEG
class PostedComments: public QWidget, public TokenResponse
{
Q_OBJECT
@ -44,75 +41,13 @@ public:
PostedComments(QWidget *parent = 0);
public slots:
void loadComments( std::string );
void loadComments(const RsGxsMessageId& );
private:
void loadRequest(const TokenQueueVEG *queue, const TokenRequestVEG &req) { return; }
void loadRequest(const TokenQueue *queue, const TokenRequest &req) { return; }
#if 0
virtual void deletePhotoItem(PhotoItem *, uint32_t type);
virtual void notifySelection(PhotoItem *item, int ptype);
void notifyAlbumSelection(PhotoItem *item);
void notifyPhotoSelection(PhotoItem *item);
private slots:
void checkUpdate();
void OpenOrShowPhotoAddDialog();
void OpenPhotoEditDialog();
void OpenSlideShow();
private:
/* Request Response Functions for loading data */
void requestAlbumList();
void requestAlbumData(const std::list<std::string> &ids);
void requestPhotoList(const std::string &albumId);
void requestPhotoData(const std::list<std::string> &photoIds);
void loadAlbumList(const uint32_t &token);
bool loadAlbumData(const uint32_t &token);
void loadPhotoList(const uint32_t &token);
void loadPhotoData(const uint32_t &token);
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
/* TODO: These functions must be filled in for proper filtering to work
* and tied to the GUI input
*/
bool matchesAlbumFilter(const RsPhotoAlbum &album);
double AlbumScore(const RsPhotoAlbum &album);
bool matchesPhotoFilter(const RsPhotoPhoto &photo);
double PhotoScore(const RsPhotoPhoto &photo);
/* Grunt work of setting up the GUI */
//bool FilterNSortAlbums(const std::list<std::string> &albumIds, std::list<std::string> &filteredAlbumIds, int count);
//bool FilterNSortPhotos(const std::list<std::string> &photoIds, std::list<std::string> &filteredPhotoIds, int count);
//void insertAlbums();
//void insertPhotosForAlbum(const std::list<std::string> &albumIds);
void insertPhotosForSelectedAlbum();
void addAlbum(const RsPhotoAlbum &album);
void addPhoto(const RsPhotoPhoto &photo);
void clearAlbums();
void clearPhotos();
PhotoAddDialog *mAddDialog;
PhotoSlideShow *mSlideShow;
PhotoItem *mAlbumSelected;
PhotoItem *mPhotoSelected;
#endif
TokenQueueVEG *mPhotoQueue;
TokenQueue *mPhotoQueue;
/* UI - from Designer */
Ui::PostedComments ui;

View File

@ -13,28 +13,294 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QFrame" name="postFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{border: 2px solid #CCCCCC;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #EEEEEE, stop: 1 #CCCCCC);
border-radius: 10px}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1">
<item>
<widget class="QLabel" name="scoreLabel">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="voteUpButton">
<property name="text">
<string>/\</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>score</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="voteDownButton">
<property name="text">
<string>\/</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Title this is a very very very very loooooooooooooooonnnnnnnnnnnnnnnnng title dont you think? yes it is and should wrap around I hope</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="_4">
<item>
<widget class="QLabel" name="dateBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Date</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dateLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">You eyes only</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_3">
<item>
<widget class="QLabel" name="fromBoldLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fromLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="_5">
<item>
<widget class="QLabel" name="fromBoldLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Site</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="siteLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string notr="true">Signed by</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>Hot</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>Top</string>
<widget class="QGroupBox" name="sortGroup">
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="hotSortButton">
<property name="text">
<string>Hot</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newSortButton">
<property name="text">
<string>New</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="topSortButton">
<property name="text">
<string>Top</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
@ -59,46 +325,21 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item>
<widget class="GxsCommentTreeWidget" name="treeWidget">
<column>
<property name="text">
<string>Stuff</string>
<string>Comment</string>
</property>
</column>
<column>
<property name="text">
<string>New Column</string>
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Yes More</string>
</property>
</column>
<column>
<property name="text">
<string>more, more, more</string>
</property>
</column>
<column>
<property name="text">
<string>More Stuff</string>
</property>
</column>
<column>
<property name="text">
<string>Less Stuff</string>
</property>
</column>
<column>
<property name="text">
<string>More</string>
</property>
</column>
<column>
<property name="text">
<string>asdf</string>
<string>Points</string>
</property>
</column>
</widget>

View File

@ -15,6 +15,7 @@ void PostedCreatePostDialog::createPost()
post.mMeta.mGroupId = mGrpId;
post.mLink = ui->linkEdit->text().toStdString();
post.mNotes = ui->notesTextEdit->toPlainText().toStdString();
post.mMeta.mMsgName = ui->titleEdit->text().toStdString();
uint32_t token;
mPosted->submitPost(token, post);

View File

@ -7,13 +7,31 @@
<x>0</x>
<y>0</y>
<width>406</width>
<height>168</height>
<height>195</height>
</rect>
</property>
<property name="windowTitle">
<string>Create Post</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&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:400; 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:12pt; font-weight:600;&quot;&gt;Title&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="titleEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>

View File

@ -47,17 +47,22 @@
PostedDialog::PostedDialog(QWidget *parent)
: MainPage(parent)
{
ui.setupUi(this);
ui.setupUi(this);
mPostedList = new PostedListDialog(NULL);
mPostedComments = new PostedComments(NULL);
mPostedList = new PostedListDialog(NULL);
mPostedComments = new PostedComments(NULL);
QString list("List");
ui.tabWidget->addTab(mPostedList, list);
QString comments("Comments");
ui.tabWidget->addTab(mPostedComments, comments);
QString list("List");
ui.tabWidget->addTab(mPostedList, list);
QString comments("Comments");
ui.tabWidget->addTab(mPostedComments, comments);
connect(mPostedList, SIGNAL(loadComments( std::string ) ), mPostedComments, SLOT(loadComments( std::string ) ) );
connect(mPostedList, SIGNAL(loadComments( std::string ) ), mPostedComments, SLOT(loadComments( std::string ) ) );
}
void PostedDialog::commentLoad(const RsGxsMessageId &msgId)
{
mPostedComments->loadComments(msgId);
}

View File

@ -31,28 +31,27 @@
#include <map>
//#include "gui/Posted/PostedList.h"
//#include "gui/Posted/PostedComments.h"
class CommentHolder
{
public:
//#include "gui/PhotoShare/PhotoAddDialog.h"
//#include "gui/PhotoShare/PhotoSlideShow.h"
//#include "util/TokenQueue.h"
/*!
* This should be used for loading comments of a message on a main comment viewing page
* @param msgId the message id for which comments will be requested
*/
virtual void commentLoad(const RsGxsMessageId& msgId) = 0;
};
class PostedListDialog;
class PostedComments;
class PostedDialog : public MainPage
class PostedDialog : public MainPage, public CommentHolder
{
Q_OBJECT
public:
PostedDialog(QWidget *parent = 0);
//virtual void addTab(std::string item);
private slots:
//void OpenSlideShow();
void commentLoad(const RsGxsMessageId &msgId);
private:

View File

@ -35,55 +35,41 @@
#include <algorithm>
#include <iostream>
/****
* #define DEBUG_ITEM 1
****/
/** Constructor */
PostedItem::PostedItem(PostedHolder *parent, const RsPostedPost &post)
:QWidget(NULL)
PostedItem::PostedItem(PostedHolder *postHolder, const RsPostedPost &post)
:QWidget(NULL), mPostHolder(postHolder)
{
setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
titleLabel->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
//dateLabel->setText(QString("Whenever"));
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
dateLabel->setText(timestamp);
fromLabel->setText(QString::fromUtf8(post.mMeta.mAuthorId.c_str()));
//siteLabel->setText(QString::fromUtf8(post.mMeta.mAuthorId.c_str()));
//scoreLabel->setText(QString("1140"));
titleLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
QString::fromStdString(post.mMeta.mMsgName) + "</span></a>");
siteLabel->setText("<a href=" + QString::fromStdString(post.mLink) +
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
QString::fromStdString(post.mLink) + "</span></a>");
// exposed for testing...
float score = 0;
time_t now = time(NULL);
QString fromLabelTxt = QString(" Age: ") + QString::number(now - post.mMeta.mPublishTs);
fromLabelTxt += QString(" Score: ") + QString::number(score);
fromLabel->setText(fromLabelTxt);
uint32_t votes = 0;
uint32_t comments = 0;
//rsPosted->extractPostedCache(post.mMeta.mServiceString, votes, comments);
scoreLabel->setText(QString::number(votes));
QString commentLabel = QString("Comments: ") + QString::number(comments);
commentLabel += QString(" Votes: ") + QString::number(votes);
siteLabel->setText(commentLabel);
QDateTime ts;
ts.setTime_t(post.mMeta.mPublishTs);
dateLabel->setText(ts.toString(QString("yyyy/MM/dd hh:mm:ss")));
mThreadId = post.mMeta.mThreadId;
mParent = parent;
scoreLabel->setText(QString("1"));
connect( commentButton, SIGNAL( clicked() ), this, SLOT( loadComments() ) );
return;
}
RsPostedPost PostedItem::getPost() const
{
return mPost;
}
void PostedItem::loadComments()
{
std::cerr << "PostedItem::loadComments() Requesting for " << mThreadId;
std::cerr << std::endl;
mParent->requestComments(mThreadId);
mPostHolder->showComments(mPost.mMeta.mMsgId);
}

View File

@ -34,10 +34,8 @@ class PostedItem;
class PostedHolder
{
public:
virtual void deletePostedItem(PostedItem *, uint32_t ptype) = 0;
virtual void notifySelection(PostedItem *item, int ptype) = 0;
virtual void requestComments(std::string threadId) = 0;
virtual void showComments(const RsGxsMessageId& threadId) = 0;
};
@ -48,15 +46,7 @@ class PostedItem : public QWidget, private Ui::PostedItem
public:
PostedItem(PostedHolder *parent, const RsPostedPost &item);
//void setDummyText();
//void updateParent(PhotoHolder *parent); // for external construction.
//void removeItem();
//void setSelected(bool on);
//bool isSelected();
protected:
//void mousePressEvent(QMouseEvent *event);
RsPostedPost getPost() const;
private slots:
void loadComments();
@ -66,7 +56,8 @@ private:
bool mSelected;
std::string mThreadId;
PostedHolder *mParent;
PostedHolder *mPostHolder;
RsPostedPost mPost;
};

View File

@ -60,7 +60,7 @@ border-radius: 10px}</string>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="toolButton_2">
<widget class="QToolButton" name="voteUpButton">
<property name="text">
<string>/\</string>
</property>
@ -74,7 +74,7 @@ border-radius: 10px}</string>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<widget class="QToolButton" name="voteDownButton">
<property name="text">
<string>\/</string>
</property>
@ -278,8 +278,6 @@ border-radius: 10px}</string>
</item>
</layout>
</widget>
<resources>
<include location="../../retroshare-gui/src/gui/images.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@ -25,6 +25,7 @@
#include "gui/Posted/PostedGroupDialog.h"
#include "gui/Posted/PostedCreatePostDialog.h"
#include "gui/Posted/PostedDialog.h"
#include <retroshare/rsposted.h>
#include <gxs/rsgxsflags.h>
@ -63,8 +64,8 @@
#define IMAGE_COPYLINK ":/images/copyrslink.png"
/** Constructor */
PostedListDialog::PostedListDialog(QWidget *parent)
: RsAutoUpdatePage(1000,parent)
PostedListDialog::PostedListDialog(CommentHolder *commentHolder, QWidget *parent)
: RsAutoUpdatePage(1000,parent), mCommentHolder(commentHolder)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -93,7 +94,7 @@ void PostedListDialog::groupListCustomPopupMenu( QPoint /*point*/ )
{
QMenu contextMnu( this );
QAction *action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Create Topic"), this, SLOT(newPost()));
QAction *action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Post"), this, SLOT(newPost()));
action->setDisabled (mCurrTopicId.empty());
contextMnu.exec(QCursor::pos());
@ -105,6 +106,11 @@ void PostedListDialog::newPost()
cp.exec();
}
void PostedListDialog::showComments(const RsGxsMessageId &threadId)
{
mCommentHolder->commentLoad(threadId);
}
void PostedListDialog::updateDisplay()
{
std::list<std::string> groupIds;
@ -121,16 +127,6 @@ void PostedListDialog::updateDisplay()
}
void PostedListDialog::requestComments(std::string threadId)
{
/* call a signal */
std::cerr << "PostedListDialog::requestComments(" << threadId << ")";
std::cerr << std::endl;
loadComments(threadId);
}
void PostedListDialog::changedTopic(const QString &id)
{

View File

@ -35,9 +35,11 @@
#include "gui/common/GroupTreeWidget.h"
#include "util/TokenQueue.h"
#include "retroshare-gui/RsAutoUpdatePage.h"
class CommentHolder;
/*********************** **** **** **** ***********************/
/** Request / Response of Data ********************************/
/*********************** **** **** **** ***********************/
@ -54,14 +56,9 @@ class PostedListDialog : public RsAutoUpdatePage, public PostedHolder, public To
Q_OBJECT
public:
PostedListDialog(QWidget *parent = 0);
PostedListDialog(CommentHolder* commentHolder, QWidget *parent = 0);
virtual void deletePostedItem(PostedItem *, uint32_t ptype) { return; }
virtual void notifySelection(PostedItem *item, int ptype) { return; }
virtual void requestComments(std::string threadId);
signals:
void loadComments( std::string );
void showComments(const RsGxsMessageId &threadId);
private slots:
@ -117,6 +114,8 @@ private:
QMap<RsGxsGroupId, RsPostedGroup> mGroups;
TokenQueue *mPostedQueue;
CommentHolder* mCommentHolder;
/* UI - from Designer */
Ui::PostedListDialog ui;

View File

@ -43,7 +43,8 @@ GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent)
:QTreeWidget(parent), mRsService(NULL), mTokenQueue(NULL)
{
return;
return;
}
void GxsCommentTreeWidget::setup(RsTokenService *service)