Posted Links:

- cleaned source code
- added auto refresh
Updated english translation

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6506 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-07-15 18:39:39 +00:00
parent 11d2701edc
commit 4edcec6fe9
16 changed files with 406 additions and 596 deletions

View File

@ -24,19 +24,29 @@
#include <QMessageBox>
#include "PostedCreatePostDialog.h"
#include "ui_PostedCreatePostDialog.h"
#include "PostedUserTypes.h"
#include "util/TokenQueue.h"
#include <iostream>
PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *posted, const RsGxsGroupId& grpId, QWidget *parent):
QDialog(parent), mTokenQueue(tokenQ), mPosted(posted), mGrpId(grpId),
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
mTokenQueue(tokenQ), mPosted(posted), mGrpId(grpId),
ui(new Ui::PostedCreatePostDialog)
{
ui->setupUi(this);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(createPost()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
/* fill in the available OwnIds for signing */
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
}
PostedCreatePostDialog::~PostedCreatePostDialog()
{
delete ui;
}
void PostedCreatePostDialog::createPost()
@ -47,13 +57,11 @@ void PostedCreatePostDialog::createPost()
std::cerr << "PostedCreatePostDialog::createPost() ERROR GETTING AuthorId!, Post Failed";
std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id first"),
QMessageBox::Ok, QMessageBox::Ok);
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id first"), QMessageBox::Ok, QMessageBox::Ok);
return;
}
RsPostedPost post;
post.mMeta.mGroupId = mGrpId;
post.mLink = std::string(ui->linkEdit->text().toUtf8());
@ -64,10 +72,6 @@ void PostedCreatePostDialog::createPost()
uint32_t token;
mPosted->createPost(token, post);
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_POST);
accept();
}
PostedCreatePostDialog::~PostedCreatePostDialog()
{
delete ui;
}

View File

@ -26,9 +26,8 @@
#include <QDialog>
#include "retroshare/rsposted.h"
#include "PostedUserTypes.h"
#include "util/TokenQueue.h"
class TokenQueue;
namespace Ui {
class PostedCreatePostDialog;
@ -39,7 +38,6 @@ class PostedCreatePostDialog : public QDialog
Q_OBJECT
public:
/*!
* @param tokenQ parent callee token
* @param posted
@ -48,17 +46,16 @@ public:
~PostedCreatePostDialog();
private slots:
void createPost();
private:
Ui::PostedCreatePostDialog *ui;
QString mLink;
QString mNotes;
TokenQueue* mTokenQueue;
RsPosted* mPosted;
RsGxsGroupId mGrpId;
TokenQueue* mTokenQueue;
Ui::PostedCreatePostDialog *ui;
};
#endif // POSTEDCREATEPOSTDIALOG_H

View File

@ -15,9 +15,12 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="titleEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="titleLabel">
<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;
@ -27,15 +30,8 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="titleEdit"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<item row="1" column="0">
<widget class="QLabel" name="linkLabel">
<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;
@ -45,7 +41,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QLineEdit" name="linkEdit"/>
</item>
</layout>
@ -81,9 +77,9 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="notesLayout">
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="notesLabel">
<property name="text">
<string>Notes</string>
</property>
@ -113,9 +109,7 @@ p, li { white-space: pre-wrap; }
<header>gui/gxs/GxsIdChooser.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>
</resources>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>

View File

@ -28,6 +28,7 @@
#include "gui/gxs/GxsCommentContainer.h"
#include "gui/Posted/PostedListDialog.h"
#include "gui/Posted/PostedItem.h"
class PostedDialog : public GxsCommentContainer
{
@ -44,7 +45,7 @@ public:
virtual QString getServiceName()
{
return tr("Posted");
return tr("Posted Links");
}
virtual RsTokenService *getTokenService()
@ -62,7 +63,10 @@ public:
return new PostedItem(NULL, 0, grpId, msgId, true);
}
virtual QPixmap getServicePixmap()
{
return QPixmap(":/images/posted_24.png");
}
};
#endif

View File

@ -52,19 +52,14 @@ uint32_t PostedCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
PostedGroupDialog::PostedGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(tokenQueue, PostedCreateEnabledFlags, PostedCreateDefaultsFlags, parent)
{
}
PostedGroupDialog::PostedGroupDialog(const RsPostedGroup &group, QWidget *parent)
:GxsGroupDialog(group.mMeta, MODE_SHOW, parent)
{
}
void PostedGroupDialog::initUi()

View File

@ -21,7 +21,6 @@
*
*/
#ifndef _POSTED_GROUP_DIALOG_H
#define _POSTED_GROUP_DIALOG_H
@ -42,10 +41,7 @@ protected:
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
private:
RsPostedGroup mTopic;
};
#endif

View File

@ -21,21 +21,15 @@
*
*/
#include <QDateTime>
#include <QMessageBox>
#include <QMouseEvent>
#include <QBuffer>
#include <time.h>
#include "PostedItem.h"
#include "gui/feeds/FeedHolder.h"
#include <retroshare/rsposted.h>
#include <algorithm>
#include <iostream>
/** Constructor */
PostedItem::PostedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome)
@ -53,7 +47,6 @@ PostedItem::PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedPost &
setContent(mPost);
}
void PostedItem::setup()
{
setupUi(this);
@ -62,11 +55,8 @@ void PostedItem::setup()
connect(commentButton, SIGNAL( clicked()), this, SLOT(loadComments()));
connect(voteUpButton, SIGNAL(clicked()), this, SLOT(makeUpVote()));
connect(voteDownButton, SIGNAL(clicked()), this, SLOT( makeDownVote()));
return;
}
void PostedItem::loadMessage(const uint32_t &token)
{
std::vector<RsPostedPost> posts;
@ -86,15 +76,12 @@ void PostedItem::loadMessage(const uint32_t &token)
mPost = posts[0];
setContent(mPost);
return;
}
void PostedItem::setContent(const RsPostedPost &post)
{
mPost = post;
QDateTime qtime;
qtime.setTime_t(mPost.mMeta.mPublishTs);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
@ -169,10 +156,14 @@ void PostedItem::setContent(const RsPostedPost &post)
+ QString::number(nComments) + "</span></p>");
}
#endif
}
RsPostedPost PostedItem::getPost() const
const RsPostedPost &PostedItem::getPost() const
{
return mPost;
}
RsPostedPost &PostedItem::post()
{
return mPost;
}
@ -185,6 +176,7 @@ void PostedItem::makeDownVote()
voteUpButton->setEnabled(false);
voteDownButton->setEnabled(false);
emit vote(msgId, false);
}
@ -210,6 +202,3 @@ void PostedItem::loadComments()
mParent->openComments(0, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, title);
}
}

View File

@ -27,9 +27,9 @@
#include "ui_PostedItem.h"
#include <retroshare/rsposted.h>
#include "gui/feeds/FeedHolder.h"
#include "gui/gxs/GxsFeedItem.h"
class RsPostedPost;
class PostedItem : public GxsFeedItem, private Ui::PostedItem
{
@ -39,12 +39,10 @@ public:
PostedItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome);
PostedItem(FeedHolder *parent, uint32_t feedId, const RsPostedPost &post, bool isHome);
RsPostedPost getPost() const;
const RsPostedPost &getPost() const;
RsPostedPost &post();
void setContent(const RsPostedPost& post);
// Make this public so we can sort based on it.
RsPostedPost mPost;
private slots:
void loadComments();
void makeUpVote();
@ -61,10 +59,7 @@ private:
uint32_t mType;
bool mSelected;
RsPostedPost mPost;
};
#endif

View File

@ -23,45 +23,28 @@
#include "PostedListDialog.h"
#include "gui/Posted/PostedGroupDialog.h"
#include "gui/Posted/PostedCreatePostDialog.h"
#include "gui/Posted/PostedDialog.h"
#include <retroshare/rsposted.h>
#include <retroshare/rsgxsflags.h>
#include "PostedGroupDialog.h"
#include "PostedCreatePostDialog.h"
#include "PostedDialog.h"
#include "PostedItem.h"
#include "PostedUserTypes.h"
#include <iostream>
#include <sstream>
#include <algorithm>
#include <QTimer>
#include <QMenu>
#include <QMessageBox>
/****************************************************************
*/
//#define DEBUG_FORUMS
/* Images for context menu icons */
#define IMAGE_MESSAGE ":/images/folder-draft.png"
#define IMAGE_MESSAGEREPLY ":/images/mail_reply.png"
#define IMAGE_MESSAGEREMOVE ":/images/mail_delete.png"
#define IMAGE_DOWNLOAD ":/images/start.png"
#define IMAGE_DOWNLOADALL ":/images/startall.png"
/* Images for TreeWidget */
#define IMAGE_FOLDER ":/images/folder16.png"
#define IMAGE_FOLDERGREEN ":/images/folder_green.png"
#define IMAGE_FOLDERRED ":/images/folder_red.png"
#define IMAGE_FOLDERYELLOW ":/images/folder_yellow.png"
#define IMAGE_FORUM ":/images/konversation16.png"
#define IMAGE_SUBSCRIBE ":/images/edit_add24.png"
#define IMAGE_UNSUBSCRIBE ":/images/cancel.png"
#define IMAGE_INFO ":/images/info16.png"
#define IMAGE_NEWFORUM ":/images/new_forum16.png"
#define IMAGE_FORUMAUTHD ":/images/konv_message2.png"
#define IMAGE_COPYLINK ":/images/copyrslink.png"
// token types to deal with
@ -70,7 +53,7 @@
/** Constructor */
PostedListDialog::PostedListDialog(QWidget *parent)
: RsAutoUpdatePage(1000,parent), GxsServiceDialog(dynamic_cast<GxsCommentContainer *>(parent))
: RsGxsUpdateBroadcastPage(rsPosted, parent), GxsServiceDialog(dynamic_cast<GxsCommentContainer *>(parent))
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -79,7 +62,6 @@ PostedListDialog::PostedListDialog(QWidget *parent)
mPostedQueue = new TokenQueue(rsPosted->getTokenService(), this);
connect( ui.groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupListCustomPopupMenu(QPoint)));
connect( ui.groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedTopic(QString)));
connect(ui.hotSortButton, SIGNAL(clicked()), this, SLOT(getRankings()));
@ -103,13 +85,9 @@ PostedListDialog::PostedListDialog(QWidget *parent)
ui.hotSortButton->setChecked(true);
connect(ui.newTopicButton, SIGNAL(clicked()), this, SLOT(newTopic()));
connect(ui.refreshButton, SIGNAL(clicked()), this, SLOT(refreshTopics()));
connect(ui.submitPostButton, SIGNAL(clicked()), this, SLOT(newPost()));
refreshTopics();
}
void PostedListDialog::showNext()
{
mPostIndex += mPostShow;
@ -119,7 +97,6 @@ void PostedListDialog::showNext()
updateShowText();
}
void PostedListDialog::showPrev()
{
mPostIndex -= mPostShow;
@ -129,7 +106,6 @@ void PostedListDialog::showPrev()
updateShowText();
}
void PostedListDialog::updateShowText()
{
QString showText = tr("Showing");
@ -140,8 +116,6 @@ void PostedListDialog::updateShowText()
ui.showLabel->setText(showText);
}
void PostedListDialog::getRankings()
{
if(mCurrTopicId.empty())
@ -180,24 +154,6 @@ void PostedListDialog::getRankings()
applyRanking();
}
void PostedListDialog::refreshTopics()
{
std::cerr << "PostedListDialog::requestGroupSummary()";
std::cerr << std::endl;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token;
mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC);
/* refresh Id Chooser Too */
RsGxsId currentId = "";
ui.idChooser->getChosenId(currentId);
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, currentId);
}
void PostedListDialog::groupListCustomPopupMenu(QPoint /*point*/)
{
if (mCurrTopicId.empty())
@ -238,7 +194,6 @@ void PostedListDialog::newPost()
}
}
void PostedListDialog::unsubscribeTopic()
{
std::cerr << "PostedListDialog::unsubscribeTopic()";
@ -252,7 +207,6 @@ void PostedListDialog::unsubscribeTopic()
mPostedQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_SUBSCRIBE_CHANGE);
}
void PostedListDialog::subscribeTopic()
{
std::cerr << "PostedListDialog::subscribeTopic()";
@ -266,7 +220,6 @@ void PostedListDialog::subscribeTopic()
mPostedQueue->queueRequest(token, 0, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_SUBSCRIBE_CHANGE);
}
void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
{
/* must grab AuthorId from Layout */
@ -276,8 +229,7 @@ void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
std::cerr << "PostedListDialog::createPost() ERROR GETTING AuthorId!, Vote Failed";
std::cerr << std::endl;
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id before Voting"),
QMessageBox::Ok, QMessageBox::Ok);
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id before Voting"), QMessageBox::Ok, QMessageBox::Ok);
return;
}
@ -311,7 +263,6 @@ void PostedListDialog::submitVote(const RsGxsGrpMsgIdPair &msgId, bool up)
mPostedQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_VOTE);
}
/*****************************************************************************************/
// Overloaded from FeedHolder.
QScrollArea *PostedListDialog::getScrollArea()
@ -319,74 +270,41 @@ QScrollArea *PostedListDialog::getScrollArea()
return ui.scrollArea;
}
void PostedListDialog::deleteFeedItem(QWidget *item, uint32_t type)
void PostedListDialog::deleteFeedItem(QWidget */*item*/, uint32_t /*type*/)
{
std::cerr << "PostedListDialog::deleteFeedItem() Nah";
std::cerr << std::endl;
return;
}
void PostedListDialog::openChat(std::string peerId)
void PostedListDialog::openChat(std::string /*peerId*/)
{
std::cerr << "PostedListDialog::openChat() Nah";
std::cerr << std::endl;
return;
}
void PostedListDialog::openComments(uint32_t feed_type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title)
void PostedListDialog::openComments(uint32_t /*feed_type*/, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title)
{
commentLoad(groupId, msgId, title);
}
/*****************************************************************************************/
void PostedListDialog::updateDisplay()
void PostedListDialog::updateDisplay(bool /*initialFill*/)
{
if (!rsPosted)
return;
std::list<std::string> groupIds;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgs;
if (rsPosted->updated(true, true))
{
std::cerr << "rsPosted->updated() returned true";
std::cerr << "rsPosted->updateDisplay()";
std::cerr << std::endl;
/* update Forums List */
rsPosted->groupsChanged(groupIds);
if(!groupIds.empty())
{
std::cerr << "rsPosted->groupsChanged():";
std::cerr << std::endl;
std::list<std::string>::iterator it;
for(it = groupIds.begin(); it != groupIds.end(); it++)
{
std::cerr << "\t" << *it;
std::cerr << std::endl;
}
it = std::find(groupIds.begin(), groupIds.end(), mCurrTopicId);
if(it != groupIds.end())
{
std::cerr << "current Group -> requesting Group Summary";
std::cerr << std::endl;
requestGroupSummary();
return;
}
}
rsPosted->msgsChanged(msgs);
/* update List */
insertGroups();
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgs = getMsgIds();
if(!msgs.empty())
{
std::cerr << "rsPosted->msgsChanged():";
std::cerr << std::endl;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
mit = msgs.find(mCurrTopicId);
if(mit != msgs.end())
@ -398,18 +316,13 @@ void PostedListDialog::updateDisplay()
}
}
}
void PostedListDialog::updateDisplayedItems(const std::vector<RsGxsMessageId> &msgIds)
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
GxsMsgReq msgs;
msgs[mCurrTopicId] = msgIds;
@ -425,18 +338,14 @@ void PostedListDialog::updateDisplayedItems(const std::vector<RsGxsMessageId> &m
uint32_t token;
mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgs, TOKEN_USER_TYPE_POST_MOD);
}
void PostedListDialog::changedTopic(const QString &id)
{
mCurrTopicId = id.toStdString();
insertThreads();
}
/*********************** **** **** **** ***********************/
/** New / Edit Groups ********************************/
/*********************** **** **** **** ***********************/
@ -458,7 +367,6 @@ void PostedListDialog::showGroupDetails()
cf.exec ();
}
void PostedListDialog::insertGroups()
{
requestGroupSummary();
@ -473,6 +381,11 @@ void PostedListDialog::requestGroupSummary()
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t token;
mPostedQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_USER_TYPE_TOPIC);
/* refresh Id Chooser Too */
RsGxsId currentId = "";
ui.idChooser->getChosenId(currentId);
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, currentId);
}
void PostedListDialog::acknowledgeGroup(const uint32_t &token)
@ -482,7 +395,6 @@ void PostedListDialog::acknowledgeGroup(const uint32_t &token)
if(!grpId.empty())
{
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
uint32_t reqToken;
@ -529,7 +441,7 @@ void PostedListDialog::acknowledgeVoteMsg(const uint32_t &token)
rsPosted->acknowledgeVote(token, msgId);
}
void PostedListDialog::loadVoteData(const uint32_t &token)
void PostedListDialog::loadVoteData(const uint32_t &/*token*/)
{
return;
}
@ -537,8 +449,6 @@ void PostedListDialog::loadVoteData(const uint32_t &token)
/*********************** **** **** **** ***********************/
/*********************** **** **** **** ***********************/
void PostedListDialog::requestGroupSummary_CurrentForum(const std::string &forumId)
{
RsTokReqOptions opts;
@ -578,7 +488,6 @@ void PostedListDialog::loadGroupSummary_CurrentForum(const uint32_t &token)
/*********************** **** **** **** ***********************/
/*********************** **** **** **** ***********************/
void PostedListDialog::insertThreads()
{
loadCurrentTopicThreads(mCurrTopicId);
@ -586,7 +495,6 @@ void PostedListDialog::insertThreads()
void PostedListDialog::loadCurrentTopicThreads(const std::string &topicId)
{
std::cerr << "PostedListDialog::loadCurrentForumThreads(" << topicId << ")";
std::cerr << std::endl;
@ -603,8 +511,6 @@ void PostedListDialog::loadCurrentTopicThreads(const std::string &topicId)
requestGroupThreadData_InsertThreads(topicId);
}
void PostedListDialog::requestGroupThreadData_InsertThreads(const std::string &groupId)
{
RsTokReqOptions opts;
@ -622,7 +528,6 @@ void PostedListDialog::requestGroupThreadData_InsertThreads(const std::string &g
mPostedQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, grpIds, TOKEN_USER_TYPE_POST);
}
void PostedListDialog::loadGroupThreadData_InsertThreads(const uint32_t &token)
{
std::cerr << "PostedListDialog::loadGroupThreadData_InsertThreads()";
@ -641,7 +546,6 @@ void PostedListDialog::loadGroupThreadData_InsertThreads(const uint32_t &token)
}
applyRanking();
}
void PostedListDialog::loadPost(const RsPostedPost &post)
@ -654,33 +558,37 @@ void PostedListDialog::loadPost(const RsPostedPost &post)
mPostList.push_back(item);
}
bool CmpPIHot(const PostedItem *a, const PostedItem *b)
{
if (a->mPost.mHotScore == b->mPost.mHotScore)
const RsPostedPost &postA = a->getPost();
const RsPostedPost &postB = b->getPost();
if (postA.mHotScore == postB.mHotScore)
{
(a->mPost.mNewScore > b->mPost.mNewScore);
return (postA.mNewScore > postB.mNewScore);
}
return (a->mPost.mHotScore > b->mPost.mHotScore);
return (postA.mHotScore > postB.mHotScore);
}
bool CmpPITop(const PostedItem *a, const PostedItem *b)
{
if (a->mPost.mTopScore == b->mPost.mTopScore)
const RsPostedPost &postA = a->getPost();
const RsPostedPost &postB = b->getPost();
if (postA.mTopScore == postB.mTopScore)
{
(a->mPost.mNewScore > b->mPost.mNewScore);
return (postA.mNewScore > postB.mNewScore);
}
return (a->mPost.mTopScore > b->mPost.mTopScore);
return (postA.mTopScore > postB.mTopScore);
}
bool CmpPINew(const PostedItem *a, const PostedItem *b)
{
return (a->mPost.mNewScore > b->mPost.mNewScore);
return (a->getPost().mNewScore > b->getPost().mNewScore);
}
void PostedListDialog::applyRanking()
{
/* uses current settings to sort posts, then add to layout */
@ -725,7 +633,7 @@ void PostedListDialog::applyRanking()
std::cerr << "PostedListDialog::applyRanking() Item: " << item;
std::cerr << std::endl;
if (item->mPost.mMeta.mPublishTs < min_ts)
if (item->getPost().mMeta.mPublishTs < min_ts)
{
std::cerr << "\t Skipping OLD";
std::cerr << std::endl;
@ -733,7 +641,6 @@ void PostedListDialog::applyRanking()
continue;
}
if (counter >= mPostIndex + mPostShow)
{
std::cerr << "\t END - Counter too high";
@ -745,8 +652,8 @@ void PostedListDialog::applyRanking()
std::cerr << "\t Adding to Layout";
std::cerr << std::endl;
/* add it in! */
item->show();
alayout->addWidget(item);
item->show();
}
else
{
@ -764,7 +671,6 @@ void PostedListDialog::applyRanking()
ui.scrollAreaWidgetContents->update();
}
void PostedListDialog::clearPosts()
{
std::cerr << "PostedListDialog::clearPosts()" << std::endl;
@ -849,7 +755,6 @@ void PostedListDialog::shallowClearPosts()
PostedItem *item = *pit;
alayout->removeWidget(item);
}
}
void PostedListDialog::updateCurrentDisplayComplete(const uint32_t &token)
@ -863,7 +768,6 @@ void PostedListDialog::updateCurrentDisplayComplete(const uint32_t &token)
std::vector<RsPostedPost>::iterator vit;
for(vit = posts.begin(); vit != posts.end(); vit++)
{
RsPostedPost& p = *vit;
// modify post content
@ -887,13 +791,12 @@ void PostedListDialog::updateCurrentDisplayComplete(const uint32_t &token)
QMap<RsGxsMessageId, PostedItem*>::iterator pit;
for(pit = mPosts.begin(); pit != mPosts.end(); pit++)
{
(*pit)->mPost.calculateScores(now);
(*pit)->post().calculateScores(now);
}
applyRanking();
}
void PostedListDialog::acknowledgeSubscribeChange(const uint32_t &token)
{
std::cerr << "PostedListDialog::acknowledgeSubscribeChange()";
@ -903,7 +806,7 @@ void PostedListDialog::acknowledgeSubscribeChange(const uint32_t &token)
RsGxsGroupId groupId;
rsPosted->acknowledgeGrp(token, groupId);
refreshTopics();
insertGroups();
}
/*********************** **** **** **** ***********************/
@ -920,7 +823,6 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
/* now switch on req */
switch(req.mUserType)
{
case TOKEN_USER_TYPE_TOPIC:
switch(req.mAnsType)
{
@ -1002,14 +904,11 @@ void PostedListDialog::loadRequest(const TokenQueue *queue, const TokenRequest &
}
}
/**************************************************************************************/
/**************************************************************************************/
/**************************************************************************************/
/**************************** Groups **********************/
void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo)
{
groupItemInfo.id = QString::fromStdString(groupInfo.mGroupId);
@ -1018,13 +917,10 @@ void PostedListDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo
groupItemInfo.popularity = groupInfo.mPop;
groupItemInfo.lastpost = QDateTime::fromTime_t(groupInfo.mLastPost);
groupItemInfo.subscribeFlags = groupInfo.mSubscribeFlags;
}
void PostedListDialog::insertGroupData(const std::list<RsGroupMetaData> &groupList)
{
std::list<RsGroupMetaData>::const_iterator it;
QList<GroupItemInfo> adminList;
@ -1091,5 +987,3 @@ void PostedListDialog::insertGroupData(const std::list<RsGroupMetaData> &groupLi
/**************************************************************************************/
/**************************************************************************************/
/**************************************************************************************/

View File

@ -24,23 +24,18 @@
#ifndef MRK_POSTED_LIST_DIALOG_H
#define MRK_POSTED_LIST_DIALOG_H
#include "retroshare-gui/mainpage.h"
#include "ui_PostedListDialog.h"
#include <retroshare/rsposted.h>
#include <map>
#include "gui/Posted/PostedItem.h"
#include "gui/common/GroupTreeWidget.h"
#include "util/TokenQueue.h"
#include "retroshare-gui/RsAutoUpdatePage.h"
#include "PostedUserTypes.h"
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
#include "gui/gxs/GxsCommentContainer.h"
#include "gui/feeds/FeedHolder.h"
class PostedItem;
/*********************** **** **** **** ***********************/
/** Request / Response of Data ********************************/
@ -53,7 +48,7 @@
#define POSTEDDIALOG_INSERT_POST 5
#define POSTEDDIALOG_REPLY_MESSAGE 6
class PostedListDialog : public RsAutoUpdatePage, public FeedHolder, public TokenResponse, public GxsServiceDialog
class PostedListDialog : public RsGxsUpdateBroadcastPage, public FeedHolder, public TokenResponse, public GxsServiceDialog
{
Q_OBJECT
@ -67,14 +62,12 @@ public:
virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title);
private slots:
void groupListCustomPopupMenu( QPoint /*point*/ );
void groupListCustomPopupMenu(QPoint point);
void changedTopic(const QString &id);
void newTopic();
void showGroupDetails();
void newPost();
void refreshTopics();
void submitVote(const RsGxsGrpMsgIdPair& msgId, bool up);
@ -83,12 +76,13 @@ private slots:
void subscribeTopic();
void unsubscribeTopic();
void showNext();
void showPrev();
private:
protected:
virtual void updateDisplay(bool initialFill);
private:
void updateShowText();
void clearPosts();
@ -98,7 +92,6 @@ private:
*/
void shallowClearPosts();
void updateDisplay();
void loadPost(const RsPostedPost &post);
void insertGroups();
@ -109,7 +102,6 @@ private:
void requestGroupSummary_CurrentForum(const std::string &forumId);
void loadGroupSummary_CurrentForum(const uint32_t &token);
// subscribe/unsubscribe ack.
void acknowledgeSubscribeChange(const uint32_t &token);
@ -122,19 +114,15 @@ private:
void loadGroupThreadData_InsertThreads(const uint32_t &token);
// votes
void acknowledgeVoteMsg(const uint32_t& token);
void loadVoteData(const uint32_t &token);
// ranking
//void loadRankings(const uint32_t& token);
//void applyRanking(const PostedRanking& ranks);
void applyRanking();
// update displayed item
void updateDisplayedItems(const std::vector<RsGxsMessageId>& msgIds);
void updateCurrentDisplayComplete(const uint32_t& token);
@ -144,7 +132,6 @@ private:
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
private:
QTreeWidgetItem *yourTopics;
QTreeWidgetItem *subscribedTopics;
QTreeWidgetItem *popularTopics;
@ -162,14 +149,12 @@ private:
QMap<RsGxsMessageId, PostedItem*> mPosts;
std::list<PostedItem *> mPostList;
TokenQueue *mPostedQueue;
//CommentHolder* mCommentHolder;
/* UI - from Designer */
Ui::PostedListDialog ui;
};
#endif

View File

@ -73,13 +73,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="refreshButton">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -224,7 +217,7 @@
<x>0</x>
<y>0</y>
<width>443</width>
<height>162</height>
<height>166</height>
</rect>
</property>
<property name="sizePolicy">

View File

@ -25,18 +25,11 @@
#include "gui/gxs/GxsCommentDialog.h"
#include <iostream>
#include <sstream>
#include <QTimer>
#include <QMessageBox>
/******
* #define PHOTO_DEBUG 1
*****/
#define MAX_COMMENT_TITLE 32
/****************************************************************
* Posted Dialog
* GxsCommentContainer
*
*/
@ -46,23 +39,21 @@ GxsCommentContainer::GxsCommentContainer(QWidget *parent)
ui.setupUi(this);
connect(ui.tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabCloseRequested(int)));
}
void GxsCommentContainer::setup()
{
mServiceDialog = createServiceDialog();
QString name = getServiceName();
ui.titleBarLabel->setText(name);
ui.titleBarPixmap->setPixmap(getServicePixmap());
QString list(name);
QWidget *widget = dynamic_cast<QWidget *>(mServiceDialog);
ui.tabWidget->addTab(widget, name);
int index = ui.tabWidget->addTab(widget, name);
ui.tabWidget->hideCloseButton(index);
}
#define MAX_COMMENT_TITLE 32
void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId, const QString &title)
{
QString comments = title;
@ -82,12 +73,11 @@ void GxsCommentContainer::commentLoad(const RsGxsGroupId &grpId, const RsGxsMess
ui.tabWidget->addTab(commentDialog, comments);
}
void GxsCommentContainer::tabCloseRequested(int index)
{
std::cerr << "GxsCommentContainer::tabCloseRequested(" << index << ")";
std::cerr << std::endl;
if (index != 0)
{
QWidget *comments = ui.tabWidget->widget(index);
@ -100,21 +90,3 @@ void GxsCommentContainer::tabCloseRequested(int index)
std::cerr << std::endl;
}
}

View File

@ -30,8 +30,6 @@
#include <retroshare/rsgxscommon.h>
#include <retroshare/rstokenservice.h>
#include <map>
class GxsServiceDialog;
class GxsCommentContainer : public MainPage
@ -49,24 +47,20 @@ public:
virtual RsTokenService *getTokenService() = 0;
virtual RsGxsCommentService *getCommentService() = 0;
virtual QWidget *createHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId) = 0;
virtual QPixmap getServicePixmap() = 0;
private slots:
void tabCloseRequested(int index);
private:
GxsServiceDialog *mServiceDialog;
/* UI - from Designer */
Ui::GxsCommentContainer ui;
};
class GxsServiceDialog
{
public:
GxsServiceDialog(GxsCommentContainer *container)
:mContainer(container) { return; }
@ -77,12 +71,9 @@ virtual ~GxsServiceDialog() { return; }
{
mContainer->commentLoad(grpId, msgId, title);
}
private:
GxsCommentContainer *mContainer;
};
#endif

View File

@ -17,33 +17,30 @@
<item>
<widget class="QFrame" name="titleBarFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="titleBarPixmap">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>:/images/posted_24.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="titleBarLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
@ -73,7 +70,7 @@
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<widget class="RSTabWidget" name="tabWidget">
<property name="currentIndex">
<number>-1</number>
</property>
@ -84,8 +81,14 @@
</item>
</layout>
</widget>
<resources>
<include location="Posted_images.qrc"/>
</resources>
<customwidgets>
<customwidget>
<class>RSTabWidget</class>
<extends>QTabWidget</extends>
<header>gui/common/RSTabWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -24,17 +24,15 @@
#ifndef MRK_CHANNEL_DIALOG_H
#define MRK_CHANNEL_DIALOG_H
#include <retroshare/rsgxschannels.h>
#include "gui/gxs/GxsCommentContainer.h"
#include "gui/gxschannels/GxsChannelDialog.h"
#include "gui/feeds/GxsChannelPostItem.h"
class ChannelDialog : public GxsCommentContainer
{
//Q_OBJECT
Q_OBJECT
public:
ChannelDialog(QWidget *parent = 0)
@ -64,7 +62,11 @@ public:
{
return new GxsChannelPostItem(NULL, 0, grpId, msgId, true);
}
virtual QPixmap getServicePixmap()
{
return QPixmap(":/images/channels24.png");
}
};
#endif

View File

@ -9962,7 +9962,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>PostedDialog</name>
<message>
<source>Posted</source>
<source>Posted Links</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -10050,10 +10050,6 @@ p, li { white-space: pre-wrap; }
<source>Top</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Refresh</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Today</source>
<translation type="unfinished"></translation>