mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
GxsForums:
- Fixed expand new messages - Fixed creating of thread/post messages git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6065 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
84c910672e
commit
f12473f7f7
@ -41,11 +41,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#define CREATEGXSFORUMMSG_FORUMINFO 1
|
||||
#define CREATEGXSFORUMMSG_PARENTMSG 2
|
||||
|
||||
|
||||
/** Constructor */
|
||||
CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId)
|
||||
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId)
|
||||
@ -65,16 +63,16 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
|
||||
|
||||
Settings->loadWidgetInformation(this);
|
||||
|
||||
connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) );
|
||||
connect(ui.forumMessage, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT(forumMessageCostumPopupMenu(QPoint)));
|
||||
|
||||
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
|
||||
|
||||
// connect up the buttons.
|
||||
connect( ui.buttonBox, SIGNAL(accepted()), this, SLOT(createMsg()));
|
||||
connect( ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect( ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
|
||||
connect( ui.attachFileButton, SIGNAL(clicked() ), this , SLOT(addFile()));
|
||||
connect( ui.pastersButton, SIGNAL(clicked() ), this , SLOT(pasteLink()));
|
||||
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(createMsg()));
|
||||
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
|
||||
connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile()));
|
||||
connect(ui.pastersButton, SIGNAL(clicked()), this, SLOT(pasteLink()));
|
||||
|
||||
setAcceptDrops(true);
|
||||
ui.hashBox->setDropWidget(this);
|
||||
@ -86,12 +84,17 @@ CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &
|
||||
newMsg();
|
||||
}
|
||||
|
||||
/** context menu searchTablewidget2 **/
|
||||
CreateGxsForumMsg::~CreateGxsForumMsg()
|
||||
{
|
||||
delete(mForumQueue);
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::forumMessageCostumPopupMenu(QPoint point)
|
||||
{
|
||||
QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(point);
|
||||
|
||||
contextMnu->addSeparator();
|
||||
|
||||
QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
|
||||
QAction *pasteLinkFullAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste full RetroShare Link"), this, SLOT(pasteLinkFull()));
|
||||
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
|
||||
@ -114,9 +117,20 @@ void CreateGxsForumMsg::newMsg()
|
||||
/* fill in the available OwnIds for signing */
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
|
||||
|
||||
/* lock gui */
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
ui.innerFrame->setEnabled(false);
|
||||
|
||||
if (mForumId.empty()) {
|
||||
ui.forumName->setText(tr("No Forum"));
|
||||
return;
|
||||
}
|
||||
ui.forumName->setText(tr("Loading"));
|
||||
|
||||
/* request Data */
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
std::list<std::string> groupIds;
|
||||
groupIds.push_back(mForumId);
|
||||
@ -126,28 +140,29 @@ void CreateGxsForumMsg::newMsg()
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO);
|
||||
|
||||
}
|
||||
|
||||
if (mParentId != "")
|
||||
if (mParentId.empty())
|
||||
{
|
||||
mParentMsgLoaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
std::list<std::string> msgIds;
|
||||
msgIds.push_back(mParentId);
|
||||
GxsMsgReq msgIds;
|
||||
std::vector<RsGxsMessageId> &vect = msgIds[mForumId];
|
||||
vect.push_back(mParentId);
|
||||
|
||||
std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
uint32_t token;
|
||||
#ifdef TOGXS
|
||||
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||
#endif
|
||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateGxsForumMsg::saveForumInfo(const RsGroupMetaData &meta)
|
||||
{
|
||||
mForumMeta = meta;
|
||||
@ -166,7 +181,7 @@ void CreateGxsForumMsg::saveParentMsg(const RsGxsForumMsg &msg)
|
||||
|
||||
void CreateGxsForumMsg::loadFormInformation()
|
||||
{
|
||||
if ((!mParentMsgLoaded) && (mParentId != ""))
|
||||
if ((!mParentMsgLoaded) && (!mParentId.empty()))
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
|
||||
std::cerr << std::endl;
|
||||
@ -180,12 +195,15 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
return;
|
||||
}
|
||||
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
ui.innerFrame->setEnabled(true);
|
||||
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
|
||||
std::cerr << std::endl;
|
||||
|
||||
QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str());
|
||||
QString subj;
|
||||
if (mParentId != "")
|
||||
if (!mParentId.empty())
|
||||
{
|
||||
QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str());
|
||||
name += " " + tr("In Reply to") + ": ";
|
||||
@ -201,19 +219,18 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
{
|
||||
subj = "Re: " + title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ui.forumName->setText(misc::removeNewLine(name));
|
||||
ui.forumSubject->setText(misc::removeNewLine(subj));
|
||||
|
||||
if (!ui.forumSubject->text().isEmpty())
|
||||
if (ui.forumSubject->text().isEmpty())
|
||||
{
|
||||
ui.forumMessage->setFocus();
|
||||
ui.forumSubject->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.forumSubject->setFocus();
|
||||
ui.forumMessage->setFocus();
|
||||
}
|
||||
|
||||
#ifdef TOGXS
|
||||
@ -235,8 +252,6 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
ui.forumMessage->setText("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::createMsg()
|
||||
{
|
||||
QString name = misc::removeNewLine(ui.forumSubject->text());
|
||||
@ -294,37 +309,8 @@ void CreateGxsForumMsg::createMsg()
|
||||
uint32_t token;
|
||||
rsGxsForums->createMsg(token, msg);
|
||||
close();
|
||||
|
||||
|
||||
// Previous Info - for reference.
|
||||
|
||||
//ForumMsgInfo msgInfo;
|
||||
|
||||
//msgInfo.forumId = mForumId;
|
||||
//msgInfo.threadId = "";
|
||||
//msgInfo.parentId = mParentId;
|
||||
//msgInfo.msgId = "";
|
||||
|
||||
//msgInfo.title = name.toStdWString();
|
||||
//msgInfo.msg = desc.toStdWString();
|
||||
//msgInfo.msgflags = 0;
|
||||
|
||||
//if (ui.signBox->isChecked())
|
||||
//{
|
||||
// msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ;
|
||||
//}
|
||||
|
||||
//if ((msgInfo.msg == L"") && (msgInfo.title == L""))
|
||||
// return; /* do nothing */
|
||||
|
||||
//if (rsForumsV2->ForumMessageSend(msgInfo) == true) {
|
||||
// close();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::closeEvent (QCloseEvent * /*event*/)
|
||||
{
|
||||
Settings->saveWidgetInformation(this);
|
||||
@ -393,9 +379,6 @@ void CreateGxsForumMsg::pasteOwnCertificateLink()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadForumInfo()";
|
||||
@ -416,7 +399,6 @@ void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadParentMsg()";
|
||||
@ -431,15 +413,11 @@ void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
||||
/* error */
|
||||
std::cerr << "CreateGxsForumMsg::loadParentMsg() ERROR wrong number of msgs";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
}
|
||||
saveParentMsg(msgs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "CreateGxsForum::loadRequest() UserType: " << req.mUserType;
|
||||
@ -453,7 +431,6 @@ void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest
|
||||
case CREATEGXSFORUMMSG_FORUMINFO:
|
||||
loadForumInfo(req.mToken);
|
||||
break;
|
||||
|
||||
case CREATEGXSFORUMMSG_PARENTMSG:
|
||||
loadParentMsg(req.mToken);
|
||||
break;
|
||||
@ -464,4 +441,3 @@ void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#ifndef _CREATE_GXSFORUM_MSG_DIALOG_H
|
||||
#define _CREATE_GXSFORUM_MSG_DIALOG_H
|
||||
|
||||
@ -35,6 +34,7 @@ class CreateGxsForumMsg : public QDialog, public TokenResponse
|
||||
|
||||
public:
|
||||
CreateGxsForumMsg(const std::string &fId, const std::string &pId);
|
||||
~CreateGxsForumMsg();
|
||||
|
||||
void newMsg(); /* cleanup */
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
@ -80,4 +80,3 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -21,11 +21,22 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="HeaderFrame" name="headerFrame"/>
|
||||
<widget class="HeaderFrame" name="headerFrame">
|
||||
<zorder>buttonBox</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
@ -36,6 +47,21 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="innerFrame">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="subjectFrame">
|
||||
<property name="frameShape">
|
||||
@ -45,7 +71,16 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
@ -90,7 +125,16 @@
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -220,7 +264,7 @@
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html></string>
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -252,6 +296,9 @@ p, li { white-space: pre-wrap; }
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "GxsForumsFillThread.h"
|
||||
#include "GxsForumThreadWidget.h"
|
||||
|
||||
#include "gxs/rsgxsflags.h"
|
||||
#include <retroshare/rsgxsforums.h>
|
||||
|
||||
#include <iostream>
|
||||
@ -74,6 +75,18 @@ void GxsForumsFillThread::stop()
|
||||
wait();
|
||||
}
|
||||
|
||||
void GxsForumsFillThread::calculateExpand(const RsGxsForumMsg &msg, QTreeWidgetItem *item)
|
||||
{
|
||||
if (mFillComplete && mExpandNewMessages && IS_MSG_UNREAD(msg.mMeta.mMsgStatus)) {
|
||||
QTreeWidgetItem *parentItem = item;
|
||||
while ((parentItem = parentItem->parent()) != NULL) {
|
||||
if (std::find(mItemToExpand.begin(), mItemToExpand.end(), parentItem) == mItemToExpand.end()) {
|
||||
mItemToExpand.push_back(parentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumsFillThread::run()
|
||||
{
|
||||
RsTokenService *service = rsGxsForums->getTokenService();
|
||||
@ -162,6 +175,7 @@ void GxsForumsFillThread::run()
|
||||
|
||||
QTreeWidgetItem *item = mParent->convertMsgToThreadWidget(msg, mUseChildTS, mFilterColumn);
|
||||
threadList.push_back(QPair<std::string, QTreeWidgetItem*>(msg.mMeta.mMsgId, item));
|
||||
calculateExpand(msg, item);
|
||||
|
||||
mItems.append(item);
|
||||
emit progress(++pos, count);
|
||||
@ -202,6 +216,7 @@ void GxsForumsFillThread::run()
|
||||
threadPair.second->addChild(item);
|
||||
}
|
||||
|
||||
calculateExpand(msg, item);
|
||||
|
||||
/* add item to process list */
|
||||
threadList.push_back(QPair<std::string, QTreeWidgetItem*>(msg.mMeta.mMsgId, item));
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QThread>
|
||||
|
||||
class GxsForumThreadWidget;
|
||||
class RsGxsForumMsg;
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
class QTreeWidgetItem;
|
||||
|
||||
@ -39,6 +40,8 @@ public:
|
||||
QList<QTreeWidgetItem*> mItemToExpand;
|
||||
|
||||
private:
|
||||
void calculateExpand(const RsGxsForumMsg &msg, QTreeWidgetItem *item);
|
||||
|
||||
GxsForumThreadWidget *mParent;
|
||||
volatile bool mStopped;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user