mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added Forum reply with plaintext quote (by anmo)
This commit is contained in:
parent
e3d12b8194
commit
5404cda302
@ -260,7 +260,7 @@ void CreateGxsForumMsg::loadFormInformation()
|
|||||||
ui.signBox->setEnabled(true);
|
ui.signBox->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.forumMessage->setText("");
|
//ui.forumMessage->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateGxsForumMsg::createMsg()
|
void CreateGxsForumMsg::createMsg()
|
||||||
@ -506,3 +506,8 @@ void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateGxsForumMsg::insertPastedText(QString msg)
|
||||||
|
{
|
||||||
|
ui.forumMessage->append(msg);
|
||||||
|
}
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
|
|
||||||
void newMsg(); /* cleanup */
|
void newMsg(); /* cleanup */
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
|
void insertPastedText(QString msg) ;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
||||||
|
@ -97,6 +97,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||||||
mTokenTypeInsertThreads = nextTokenType();
|
mTokenTypeInsertThreads = nextTokenType();
|
||||||
mTokenTypeMessageData = nextTokenType();
|
mTokenTypeMessageData = nextTokenType();
|
||||||
mTokenTypeReplyMessage = nextTokenType();
|
mTokenTypeReplyMessage = nextTokenType();
|
||||||
|
mTokenTypeReplyForumMessage = nextTokenType();
|
||||||
|
|
||||||
setUpdateWhenInvisible(true);
|
setUpdateWhenInvisible(true);
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
|||||||
|
|
||||||
ui->subscribeToolButton->hide() ;
|
ui->subscribeToolButton->hide() ;
|
||||||
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
|
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
|
||||||
connect(ui->newmessageButton, SIGNAL(clicked()), this, SLOT(createmessage()));
|
connect(ui->newmessageButton, SIGNAL(clicked()), this, SLOT(replytoforummessage()));
|
||||||
connect(ui->newthreadButton, SIGNAL(clicked()), this, SLOT(createthread()));
|
connect(ui->newthreadButton, SIGNAL(clicked()), this, SLOT(createthread()));
|
||||||
|
|
||||||
connect(ui->threadTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(changedThread()));
|
connect(ui->threadTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(changedThread()));
|
||||||
@ -404,7 +405,7 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
|
|||||||
QMenu contextMnu(this);
|
QMenu contextMnu(this);
|
||||||
|
|
||||||
QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply"), &contextMnu);
|
QAction *replyAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply"), &contextMnu);
|
||||||
connect(replyAct, SIGNAL(triggered()), this, SLOT(createmessage()));
|
connect(replyAct, SIGNAL(triggered()), this, SLOT(replytoforummessage()));
|
||||||
|
|
||||||
QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply with private message"), &contextMnu);
|
QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply with private message"), &contextMnu);
|
||||||
connect(replyauthorAct, SIGNAL(triggered()), this, SLOT(replytomessage()));
|
connect(replyauthorAct, SIGNAL(triggered()), this, SLOT(replytomessage()));
|
||||||
@ -1787,6 +1788,18 @@ void GxsForumThreadWidget::replytomessage()
|
|||||||
requestMsgData_ReplyMessage(postId);
|
requestMsgData_ReplyMessage(postId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsForumThreadWidget::replytoforummessage()
|
||||||
|
{
|
||||||
|
if (groupId().isNull() || mThreadId.isNull()) {
|
||||||
|
QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to a non-existant Message"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Message ... then complete replyMessageData().
|
||||||
|
RsGxsGrpMsgIdPair postId = std::make_pair(groupId(), mThreadId);
|
||||||
|
requestMsgData_ReplyForumMessage(postId);
|
||||||
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::replyMessageData(const RsGxsForumMsg &msg)
|
void GxsForumThreadWidget::replyMessageData(const RsGxsForumMsg &msg)
|
||||||
{
|
{
|
||||||
if ((msg.mMeta.mGroupId != groupId()) || (msg.mMeta.mMsgId != mThreadId))
|
if ((msg.mMeta.mGroupId != groupId()) || (msg.mMeta.mMsgId != mThreadId))
|
||||||
@ -1815,6 +1828,34 @@ void GxsForumThreadWidget::replyMessageData(const RsGxsForumMsg &msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsForumThreadWidget::replyForumMessageData(const RsGxsForumMsg &msg)
|
||||||
|
{
|
||||||
|
if ((msg.mMeta.mGroupId != groupId()) || (msg.mMeta.mMsgId != mThreadId))
|
||||||
|
{
|
||||||
|
std::cerr << "GxsForumThreadWidget::replyMessageData() ERROR Message Ids have changed!";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.mMeta.mAuthorId.isNull())
|
||||||
|
{
|
||||||
|
CreateGxsForumMsg *cfm = new CreateGxsForumMsg(groupId(), mThreadId);
|
||||||
|
QTextDocument doc ;
|
||||||
|
// doc.setHtml(QString::fromUtf8(msg.mMsg.c_str()) );
|
||||||
|
// std::string cited_text(doc.toPlainText().toStdString()) ;
|
||||||
|
RsHtml::makeQuotedText(ui->postText);
|
||||||
|
|
||||||
|
cfm->insertPastedText(RsHtml::makeQuotedText(ui->postText)) ;
|
||||||
|
cfm->show();
|
||||||
|
|
||||||
|
/* window will destroy itself! */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to an Anonymous Author"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::changedViewBox()
|
void GxsForumThreadWidget::changedViewBox()
|
||||||
{
|
{
|
||||||
if (mInProcessSettings) {
|
if (mInProcessSettings) {
|
||||||
@ -2031,6 +2072,24 @@ void GxsForumThreadWidget::requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &
|
|||||||
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeReplyMessage);
|
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeReplyMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsForumThreadWidget::requestMsgData_ReplyForumMessage(const RsGxsGrpMsgIdPair &msgId)
|
||||||
|
{
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumThreadWidget::requestMsgData_ReplyMessage(" << msgId.first << "," << msgId.second << ")";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GxsMsgReq msgIds;
|
||||||
|
std::vector<RsGxsMessageId> &vect = msgIds[msgId.first];
|
||||||
|
vect.push_back(msgId.second);
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeReplyForumMessage);
|
||||||
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::loadMsgData_ReplyMessage(const uint32_t &token)
|
void GxsForumThreadWidget::loadMsgData_ReplyMessage(const uint32_t &token)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
@ -2047,7 +2106,6 @@ void GxsForumThreadWidget::loadMsgData_ReplyMessage(const uint32_t &token)
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
replyMessageData(msgs[0]);
|
replyMessageData(msgs[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2057,6 +2115,32 @@ void GxsForumThreadWidget::loadMsgData_ReplyMessage(const uint32_t &token)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsForumThreadWidget::loadMsgData_ReplyForumMessage(const uint32_t &token)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_FORUMS
|
||||||
|
std::cerr << "GxsForumThreadWidget::loadMsgData_ReplyMessage()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::vector<RsGxsForumMsg> msgs;
|
||||||
|
if (rsGxsForums->getMsgData(token, msgs))
|
||||||
|
{
|
||||||
|
if (msgs.size() != 1)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsForumThreadWidget::loadMsgData_ReplyMessage() ERROR Wrong number of answers";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
replyForumMessageData(msgs[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "GxsForumThreadWidget::loadMsgData_ReplyMessage() ERROR Missing Message Data...";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GxsForumThreadWidget::loadMsgData_BanAuthor(const uint32_t &token)
|
void GxsForumThreadWidget::loadMsgData_BanAuthor(const uint32_t &token)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef DEBUG_FORUMS
|
||||||
@ -2115,6 +2199,11 @@ void GxsForumThreadWidget::loadRequest(const TokenQueue *queue, const TokenReque
|
|||||||
loadMsgData_ReplyMessage(req.mToken);
|
loadMsgData_ReplyMessage(req.mToken);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.mUserType == mTokenTypeReplyForumMessage) {
|
||||||
|
loadMsgData_ReplyForumMessage(req.mToken);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (req.mUserType == mTokenTypeBanAuthor) {
|
if (req.mUserType == mTokenTypeBanAuthor) {
|
||||||
loadMsgData_BanAuthor(req.mToken);
|
loadMsgData_BanAuthor(req.mToken);
|
||||||
|
@ -75,7 +75,13 @@ private slots:
|
|||||||
void clickedThread (QTreeWidgetItem *item, int column);
|
void clickedThread (QTreeWidgetItem *item, int column);
|
||||||
|
|
||||||
void replytomessage();
|
void replytomessage();
|
||||||
|
void replytoforummessage();
|
||||||
|
|
||||||
void replyMessageData(const RsGxsForumMsg &msg);
|
void replyMessageData(const RsGxsForumMsg &msg);
|
||||||
|
void replyForumMessageData(const RsGxsForumMsg &msg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//void print();
|
//void print();
|
||||||
//void printpreview();
|
//void printpreview();
|
||||||
@ -141,7 +147,10 @@ private:
|
|||||||
void loadMessageData(const uint32_t &token);
|
void loadMessageData(const uint32_t &token);
|
||||||
void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId);
|
void requestMsgData_ReplyMessage(const RsGxsGrpMsgIdPair &msgId);
|
||||||
void loadMsgData_ReplyMessage(const uint32_t &token);
|
void loadMsgData_ReplyMessage(const uint32_t &token);
|
||||||
void loadMsgData_BanAuthor(const uint32_t &token);
|
|
||||||
|
void requestMsgData_ReplyForumMessage(const RsGxsGrpMsgIdPair &msgId);
|
||||||
|
void loadMsgData_ReplyForumMessage(const uint32_t &token);
|
||||||
|
void loadMsgData_BanAuthor(const uint32_t &token);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RsGxsGroupId mLastForumID;
|
RsGxsGroupId mLastForumID;
|
||||||
@ -162,6 +171,7 @@ private:
|
|||||||
uint32_t mTokenTypeInsertThreads;
|
uint32_t mTokenTypeInsertThreads;
|
||||||
uint32_t mTokenTypeMessageData;
|
uint32_t mTokenTypeMessageData;
|
||||||
uint32_t mTokenTypeReplyMessage;
|
uint32_t mTokenTypeReplyMessage;
|
||||||
|
uint32_t mTokenTypeReplyForumMessage;
|
||||||
uint32_t mTokenTypeBanAuthor;
|
uint32_t mTokenTypeBanAuthor;
|
||||||
|
|
||||||
/* Color definitions (for standard see qss.default) */
|
/* Color definitions (for standard see qss.default) */
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QTextDocumentFragment>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
#include "HandleRichText.h"
|
#include "HandleRichText.h"
|
||||||
@ -997,3 +998,15 @@ QString RsHtml::plainText(const std::string &text)
|
|||||||
return Qt::escape(QString::fromUtf8(text.c_str()));
|
return Qt::escape(QString::fromUtf8(text.c_str()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RsHtml::makeQuotedText(RSTextBrowser *browser)
|
||||||
|
{
|
||||||
|
QString text = browser->textCursor().selection().toPlainText();
|
||||||
|
if(text.length() == 0)
|
||||||
|
{
|
||||||
|
text = browser->toPlainText();
|
||||||
|
}
|
||||||
|
QStringList sl = text.split(QRegExp("[\r\n]"),QString::SkipEmptyParts);
|
||||||
|
text = sl.join("\n>");
|
||||||
|
return QString(">") + text;
|
||||||
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
#include <gui/common/RSTextBrowser.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file provides helper functions and functors for translating data from/to
|
* This file provides helper functions and functors for translating data from/to
|
||||||
* rich text format and HTML. Its main goal is to facilitate decoding of chat
|
* rich text format and HTML. Its main goal is to facilitate decoding of chat
|
||||||
@ -72,6 +74,8 @@ public:
|
|||||||
static QString plainText(const QString &text);
|
static QString plainText(const QString &text);
|
||||||
static QString plainText(const std::string &text);
|
static QString plainText(const std::string &text);
|
||||||
|
|
||||||
|
static QString makeQuotedText(RSTextBrowser* browser);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void embedHtml(QTextDocument *textDocument, QDomDocument &doc, QDomElement ¤tElement, EmbedInHtml& embedInfos, ulong flag);
|
void embedHtml(QTextDocument *textDocument, QDomDocument &doc, QDomElement ¤tElement, EmbedInHtml& embedInfos, ulong flag);
|
||||||
void replaceAnchorWithImg(QDomDocument& doc, QDomElement &element, QTextDocument *textDocument, const RetroShareLink &link);
|
void replaceAnchorWithImg(QDomDocument& doc, QDomElement &element, QTextDocument *textDocument, const RetroShareLink &link);
|
||||||
|
Loading…
Reference in New Issue
Block a user