mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-21 04:44:25 -04:00
Added logic for rank calculation and interface methods
Disabled posting when no post is selected Added notes section when viewing post (tres basic) fix for comment item serialisation fix for subscription token option not in this commit ;) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5913 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5a55c1b5d6
commit
44d32626bc
9 changed files with 304 additions and 182 deletions
|
@ -63,14 +63,10 @@ PostedComments::PostedComments(QWidget *parent)
|
|||
ui.setupUi(this);
|
||||
ui.postFrame->setVisible(false);
|
||||
ui.treeWidget->setup(rsPosted->getTokenService());
|
||||
connect(ui.treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(test(QPoint)));
|
||||
}
|
||||
|
||||
void PostedComments::test(QPoint p)
|
||||
void PostedComments::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
int x = p.x();
|
||||
int y = p.y();
|
||||
int c= x+y;
|
||||
|
||||
}
|
||||
|
||||
|
@ -84,8 +80,8 @@ void PostedComments::loadComments(const RsPostedPost& post)
|
|||
|
||||
RsGxsGrpMsgIdPair threadId;
|
||||
|
||||
threadId.first = post.mMeta.mOrigMsgId;
|
||||
threadId.second = post.mMeta.mGroupId;
|
||||
threadId.first = post.mMeta.mGroupId;
|
||||
threadId.second = post.mMeta.mOrigMsgId;
|
||||
|
||||
ui.treeWidget->requestComments(threadId);
|
||||
}
|
||||
|
@ -107,7 +103,9 @@ void PostedComments::setUpPostFrame()
|
|||
"><span style=\" text-decoration: underline; color:#0000ff;\">" +
|
||||
QString::fromStdString(mCurrentPost.mLink) + "</span></a>");
|
||||
|
||||
ui.scoreLabel->setText(QString("1"));
|
||||
ui.scoreLabel->setText(QString("0"));
|
||||
|
||||
ui.notesBrowser->setPlainText(QString::fromStdString(mCurrentPost.mNotes));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,12 +44,8 @@ public slots:
|
|||
|
||||
void loadComments(const RsPostedPost& );
|
||||
|
||||
private slots:
|
||||
|
||||
void test(QPoint p);
|
||||
|
||||
private:
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req) { return; }
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
void setUpPostFrame();
|
||||
|
||||
RsPostedPost mCurrentPost;
|
||||
|
|
|
@ -23,10 +23,7 @@
|
|||
</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>
|
||||
<string notr="true">background-color: rgb(203, 203, 203);</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
|
@ -244,6 +241,13 @@ border-radius: 10px}</string>
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="notesBrowser">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(203, 203, 203);</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
@ -337,6 +341,11 @@ border-radius: 10px}</string>
|
|||
<string>Author</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Date</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Points</string>
|
||||
|
@ -344,43 +353,6 @@ border-radius: 10px}</string>
|
|||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<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="QPushButton" name="makeCommentButton">
|
||||
<property name="text">
|
||||
<string>Make Comment</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
|
@ -48,7 +48,7 @@ GxsCommentTreeWidget::GxsCommentTreeWidget(QWidget *parent)
|
|||
{
|
||||
// QTreeWidget* widget = this;
|
||||
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
// QFont font = QFont("ARIAL", 10);
|
||||
// font.setBold(true);
|
||||
|
||||
|
@ -73,34 +73,32 @@ void GxsCommentTreeWidget::setCurrentMsgId(QTreeWidgetItem *current, QTreeWidget
|
|||
if(current)
|
||||
{
|
||||
mCurrentMsgId = current->text(PCITEM_COLUMN_MSGID).toStdString();
|
||||
}else{
|
||||
mCurrentMsgId = "";
|
||||
}
|
||||
}
|
||||
|
||||
void GxsCommentTreeWidget::customPopUpMenu(const QPoint& point)
|
||||
{
|
||||
QMenu contextMnu( this );
|
||||
contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment()));
|
||||
QAction* action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Reply to Comment"), this, SLOT(replyToComment()));
|
||||
action->setDisabled(mCurrentMsgId.empty());
|
||||
action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment()));
|
||||
action->setDisabled(mThreadId.first.empty());
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void GxsCommentTreeWidget::makeComment()
|
||||
{
|
||||
PostedCreateCommentDialog pcc(mTokenQueue, mThreadId, mThreadId.second, this);
|
||||
pcc.exec();
|
||||
}
|
||||
|
||||
if(mCurrentMsgId.empty())
|
||||
{
|
||||
PostedCreateCommentDialog pcc(mTokenQueue, mThreadId, mThreadId.second, this);
|
||||
pcc.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
msgId.first = mThreadId.first;
|
||||
msgId.second = mCurrentMsgId;
|
||||
PostedCreateCommentDialog pcc(mTokenQueue, msgId, mThreadId.second, this);
|
||||
pcc.exec();
|
||||
}
|
||||
void GxsCommentTreeWidget::replyToComment()
|
||||
{
|
||||
RsGxsGrpMsgIdPair msgId;
|
||||
msgId.first = mThreadId.first;
|
||||
msgId.second = mCurrentMsgId;
|
||||
PostedCreateCommentDialog pcc(mTokenQueue, msgId, mThreadId.second, this);
|
||||
pcc.exec();
|
||||
}
|
||||
|
||||
void GxsCommentTreeWidget::setup(RsTokenService *service)
|
||||
|
@ -125,100 +123,100 @@ void GxsCommentTreeWidget::requestComments(const RsGxsGrpMsgIdPair& threadId)
|
|||
|
||||
void GxsCommentTreeWidget::service_requestComments(const RsGxsGrpMsgIdPair& threadId)
|
||||
{
|
||||
/* request comments */
|
||||
std::cerr << "GxsCommentTreeWidget::service_requestComments(" << threadId.second << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
|
||||
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||
msgIds.push_back(threadId);
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, GXSCOMMENTS_LOADTHREAD);
|
||||
/* request comments */
|
||||
std::cerr << "GxsCommentTreeWidget::service_requestComments(" << threadId.second << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||
opts.mOptions = RS_TOKREQOPT_MSG_THREAD | RS_TOKREQOPT_MSG_LATEST;
|
||||
|
||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||
msgIds.push_back(threadId);
|
||||
|
||||
uint32_t token;
|
||||
mTokenQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, GXSCOMMENTS_LOADTHREAD);
|
||||
}
|
||||
|
||||
|
||||
/* Generic Handling */
|
||||
void GxsCommentTreeWidget::clearItems()
|
||||
{
|
||||
mPendingInsertMap.clear();
|
||||
mLoadingMap.clear();
|
||||
mPendingInsertMap.clear();
|
||||
mLoadingMap.clear();
|
||||
}
|
||||
|
||||
|
||||
void GxsCommentTreeWidget::completeItems()
|
||||
{
|
||||
/* handle pending items */
|
||||
std::string parentId;
|
||||
QTreeWidgetItem *parent = NULL;
|
||||
QList<QTreeWidgetItem *> topLevelItems;
|
||||
/* handle pending items */
|
||||
std::string parentId;
|
||||
QTreeWidgetItem *parent = NULL;
|
||||
QList<QTreeWidgetItem *> topLevelItems;
|
||||
|
||||
std::map<std::string, QTreeWidgetItem *>::iterator lit;
|
||||
std::multimap<std::string, QTreeWidgetItem *>::iterator pit;
|
||||
std::map<std::string, QTreeWidgetItem *>::iterator lit;
|
||||
std::multimap<std::string, QTreeWidgetItem *>::iterator pit;
|
||||
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() " << mPendingInsertMap.size();
|
||||
std::cerr << " PendingItems";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() " << mPendingInsertMap.size();
|
||||
std::cerr << " PendingItems";
|
||||
std::cerr << std::endl;
|
||||
|
||||
for(pit = mPendingInsertMap.begin(); pit != mPendingInsertMap.end(); pit++)
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() item->parent: " << pit->first;
|
||||
std::cerr << std::endl;
|
||||
for(pit = mPendingInsertMap.begin(); pit != mPendingInsertMap.end(); pit++)
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() item->parent: " << pit->first;
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (pit->first != parentId)
|
||||
{
|
||||
/* find parent */
|
||||
parentId = pit->first;
|
||||
lit = mLoadingMap.find(pit->first);
|
||||
if (lit != mLoadingMap.end())
|
||||
{
|
||||
parent = lit->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = NULL;
|
||||
}
|
||||
}
|
||||
if (pit->first != parentId)
|
||||
{
|
||||
/* find parent */
|
||||
parentId = pit->first;
|
||||
lit = mLoadingMap.find(pit->first);
|
||||
if (lit != mLoadingMap.end())
|
||||
{
|
||||
parent = lit->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
parent = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (parent)
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() Added to Parent";
|
||||
std::cerr << std::endl;
|
||||
if (parent)
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() Added to Parent";
|
||||
std::cerr << std::endl;
|
||||
|
||||
parent->addChild(pit->second);
|
||||
}
|
||||
else if (parentId == mThreadId.second)
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() Added to topLevelItems";
|
||||
std::cerr << std::endl;
|
||||
parent->addChild(pit->second);
|
||||
}
|
||||
else if (parentId == mThreadId.second)
|
||||
{
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() Added to topLevelItems";
|
||||
std::cerr << std::endl;
|
||||
|
||||
topLevelItems.append(pit->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
topLevelItems.append(pit->second);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* missing parent -> insert At Top Level */
|
||||
QTreeWidgetItem *missingItem = service_createMissingItem(pit->first);
|
||||
/* missing parent -> insert At Top Level */
|
||||
QTreeWidgetItem *missingItem = service_createMissingItem(pit->first);
|
||||
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() Added MissingItem";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "GxsCommentTreeWidget::completeItems() Added MissingItem";
|
||||
std::cerr << std::endl;
|
||||
|
||||
parent = missingItem;
|
||||
parent->addChild(pit->second);
|
||||
topLevelItems.append(parent);
|
||||
}
|
||||
}
|
||||
parent = missingItem;
|
||||
parent->addChild(pit->second);
|
||||
topLevelItems.append(parent);
|
||||
}
|
||||
}
|
||||
|
||||
/* now push final tree into Tree */
|
||||
clear();
|
||||
insertTopLevelItems(0, topLevelItems);
|
||||
/* now push final tree into Tree */
|
||||
clear();
|
||||
insertTopLevelItems(0, topLevelItems);
|
||||
|
||||
/* cleanup temp stuff */
|
||||
mLoadingMap.clear();
|
||||
mPendingInsertMap.clear();
|
||||
/* cleanup temp stuff */
|
||||
mLoadingMap.clear();
|
||||
mPendingInsertMap.clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -316,7 +314,8 @@ void GxsCommentTreeWidget::service_loadThread(const uint32_t &token)
|
|||
text = QString::fromUtf8(comment.mMeta.mParentId.c_str());
|
||||
item->setText(PCITEM_COLUMN_PARENTID, text);
|
||||
|
||||
text = QString::fromUtf8(comment.mMeta.mServiceString.c_str());
|
||||
text = QString::fromUtf8("0");
|
||||
//text = QString::fromUtf8(comment.mMeta.mServiceString.c_str());
|
||||
item->setText(PCITEM_COLUMN_SERVSTRING, text);
|
||||
|
||||
addItem(comment.mMeta.mMsgId, comment.mMeta.mParentId, item);
|
||||
|
|
|
@ -26,19 +26,6 @@
|
|||
|
||||
#include "util/TokenQueue.h"
|
||||
|
||||
/* indicies for search results item columns SR_ = Search Result */
|
||||
#define SR_NAME_COL 0
|
||||
#define SR_SIZE_COL 1
|
||||
#define SR_ID_COL 2
|
||||
#define SR_TYPE_COL 3
|
||||
#define SR_AGE_COL 4
|
||||
#define SR_HASH_COL 5
|
||||
#define SR_SEARCH_ID_COL 6
|
||||
#define SR_UID_COL 7
|
||||
#define SR_DATA_COL SR_NAME_COL
|
||||
|
||||
#define SR_ROLE_LOCAL Qt::UserRole
|
||||
|
||||
class GxsCommentTreeWidget : public QTreeWidget, public TokenResponse
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -49,7 +36,7 @@ public:
|
|||
|
||||
void requestComments(const RsGxsGrpMsgIdPair& threadId);
|
||||
void getCurrentMsgId(RsGxsMessageId& parentId);
|
||||
void setCurrentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||
void applyRankings(std::map<RsGxsMessageId, uint32_t>& positions);
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
|
@ -70,10 +57,11 @@ protected:
|
|||
|
||||
public slots:
|
||||
void customPopUpMenu(const QPoint& point);
|
||||
private slots:
|
||||
void setCurrentMsgId(QTreeWidgetItem* current, QTreeWidgetItem* previous);
|
||||
|
||||
|
||||
void makeComment();
|
||||
void replyToComment();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue