mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed a few more bugs in post version UI
This commit is contained in:
parent
8deeec61c5
commit
5bf8376dd1
@ -45,12 +45,13 @@
|
||||
#define CREATEGXSFORUMMSG_FORUMINFO 1
|
||||
#define CREATEGXSFORUMMSG_PARENTMSG 2
|
||||
#define CREATEGXSFORUMMSG_CIRCLENFO 3
|
||||
#define CREATEGXSFORUMMSG_ORIGMSG 4
|
||||
|
||||
//#define ENABLE_GENERATE
|
||||
|
||||
/** Constructor */
|
||||
CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId,const RsGxsMessageId& mOId)
|
||||
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId), mOrigMsgId(mOId)
|
||||
CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId,const RsGxsMessageId& mOId,const RsGxsId& posterId)
|
||||
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId), mOrigMsgId(mOId),mPosterId(posterId)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -75,6 +76,13 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
|
||||
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui.forumSubject);
|
||||
mStateHelper->addClear(CREATEGXSFORUMMSG_PARENTMSG, ui.forumName);
|
||||
|
||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui.buttonBox->button(QDialogButtonBox::Ok));
|
||||
mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui.innerFrame);
|
||||
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui.forumName);
|
||||
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui.forumSubject);
|
||||
mStateHelper->addClear(CREATEGXSFORUMMSG_ORIGMSG, ui.forumName);
|
||||
|
||||
|
||||
QString text = mOId.isNull()?(pId.isNull() ? tr("Start New Thread") : tr("Post Forum Message")):tr("Edit Message");
|
||||
setWindowTitle(text);
|
||||
|
||||
@ -129,13 +137,24 @@ void CreateGxsForumMsg::newMsg()
|
||||
|
||||
//std::cerr << "Initing ID chooser. Sign flags = " << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
|
||||
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
||||
if(!mPosterId.isNull())
|
||||
{
|
||||
std::set<RsGxsId> id_set ;
|
||||
id_set.insert(mPosterId) ;
|
||||
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NO_CREATE, mPosterId);
|
||||
ui.idChooser->setIdConstraintSet(id_set);
|
||||
}
|
||||
else
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, mPosterId);
|
||||
|
||||
if (mForumId.isNull()) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
mStateHelper->clear(CREATEGXSFORUMMSG_FORUMINFO);
|
||||
mStateHelper->clear(CREATEGXSFORUMMSG_PARENTMSG);
|
||||
mStateHelper->clear(CREATEGXSFORUMMSG_ORIGMSG);
|
||||
ui.forumName->setText(tr("No Forum"));
|
||||
return;
|
||||
}//if ( mForumId.isNull())
|
||||
@ -174,11 +193,53 @@ void CreateGxsForumMsg::newMsg()
|
||||
uint32_t token;
|
||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||
}//if (mParentId.isNull())
|
||||
|
||||
if (mOrigMsgId.isNull()) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||
mOrigMsgLoaded = true;
|
||||
} else {
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
std::vector<RsGxsMessageId> &vect = msgIds[mForumId];
|
||||
vect.push_back(mOrigMsgId);
|
||||
|
||||
//std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_ORIGMSG);
|
||||
}//if (mParentId.isNull())
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadFormInformation()
|
||||
{
|
||||
if (!mParentId.isNull()) {
|
||||
if (!mOrigMsgId.isNull())
|
||||
{
|
||||
if (mOrigMsgLoaded) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
} else {
|
||||
//std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
}
|
||||
|
||||
|
||||
if (!mParentId.isNull())
|
||||
{
|
||||
if (mParentMsgLoaded) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
@ -190,7 +251,9 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, true);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||
}
|
||||
@ -212,17 +275,22 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
|
||||
//std::cerr << "CreateGxsForumMsg::loadMsgInformation() using signFlags=" << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
|
||||
|
||||
uint32_t fl = IDCHOOSER_ID_REQUIRED ;
|
||||
|
||||
if( (mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) || (mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN))
|
||||
ui.idChooser->setFlags(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NON_ANONYMOUS) ;
|
||||
else
|
||||
ui.idChooser->setFlags(IDCHOOSER_ID_REQUIRED) ;
|
||||
fl |= IDCHOOSER_NON_ANONYMOUS ;
|
||||
|
||||
if(!mPosterId.isNull())
|
||||
fl |= IDCHOOSER_NO_CREATE;
|
||||
|
||||
ui.idChooser->setFlags(fl) ;
|
||||
|
||||
QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str());
|
||||
QString subj;
|
||||
|
||||
if(!mOrigMsgId.isNull())
|
||||
{
|
||||
subj = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str());
|
||||
subj = QString::fromUtf8(mOrigMsg.mMeta.mMsgName.c_str());
|
||||
}
|
||||
else if (!mParentId.isNull())
|
||||
{
|
||||
@ -240,6 +308,7 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
|
||||
ui.forumName->setText(misc::removeNewLine(name));
|
||||
ui.forumSubject->setText(misc::removeNewLine(subj));
|
||||
ui.forumSubject->setReadOnly(!mOrigMsgId.isNull());
|
||||
|
||||
if (ui.forumSubject->text().isEmpty())
|
||||
{
|
||||
@ -380,7 +449,7 @@ void CreateGxsForumMsg::reject()
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("Cancel Forum Message"),
|
||||
tr("Forum Message has not been sent yet!\n"
|
||||
"Please confirm that you want to discard this message?"),
|
||||
"Do you want to discard this message?"),
|
||||
QMessageBox::Yes | QMessageBox::No);
|
||||
switch (ret) {
|
||||
case QMessageBox::Yes:
|
||||
@ -522,6 +591,35 @@ void CreateGxsForumMsg::loadForumCircleInfo(const uint32_t& token)
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadOrigMsg(const uint32_t &token)
|
||||
{
|
||||
//std::cerr << "CreateGxsForumMsg::loadParentMsg()";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
// Only grab one.... ignore more (shouldn't be any).
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
if (rsGxsForums->getMsgData(token, msgs))
|
||||
{
|
||||
if (msgs.size() != 1)
|
||||
{
|
||||
/* error */
|
||||
std::cerr << "CreateGxsForumMsg::loadOrigMsg() ERROR wrong number of msgs";
|
||||
std::cerr << std::endl;
|
||||
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
mOrigMsg = msgs[0];
|
||||
mOrigMsgLoaded = true;
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
||||
{
|
||||
//std::cerr << "CreateGxsForumMsg::loadParentMsg()";
|
||||
@ -563,6 +661,9 @@ void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest
|
||||
case CREATEGXSFORUMMSG_FORUMINFO:
|
||||
loadForumInfo(req.mToken);
|
||||
break;
|
||||
case CREATEGXSFORUMMSG_ORIGMSG:
|
||||
loadOrigMsg(req.mToken);
|
||||
break;
|
||||
case CREATEGXSFORUMMSG_PARENTMSG:
|
||||
loadParentMsg(req.mToken);
|
||||
break;
|
||||
|
@ -36,7 +36,7 @@ class CreateGxsForumMsg : public QDialog, public TokenResponse
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId &moId);
|
||||
CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessageId &pId, const RsGxsMessageId &moId, const RsGxsId &posterId = RsGxsId());
|
||||
~CreateGxsForumMsg();
|
||||
|
||||
void newMsg(); /* cleanup */
|
||||
@ -61,18 +61,22 @@ private:
|
||||
|
||||
void loadForumInfo(const uint32_t &token);
|
||||
void loadParentMsg(const uint32_t &token);
|
||||
void loadOrigMsg(const uint32_t &token);
|
||||
void loadForumCircleInfo(const uint32_t &token);
|
||||
|
||||
RsGxsGroupId mForumId;
|
||||
RsGxsCircleId mCircleId ;
|
||||
RsGxsMessageId mParentId;
|
||||
RsGxsMessageId mOrigMsgId;
|
||||
RsGxsId mPosterId;
|
||||
|
||||
bool mParentMsgLoaded;
|
||||
bool mOrigMsgLoaded;
|
||||
bool mForumMetaLoaded;
|
||||
bool mForumCircleLoaded ;
|
||||
|
||||
RsGxsForumMsg mParentMsg;
|
||||
RsGxsForumMsg mOrigMsg;
|
||||
RsGroupMetaData mForumMeta;
|
||||
RsGxsCircleGroup mForumCircleData ;
|
||||
|
||||
|
@ -200,7 +200,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget
|
||||
|
||||
ui->threadTreeWidget->setItemDelegateForColumn(COLUMN_THREAD_DISTRIBUTION,new DistributionItemDelegate()) ;
|
||||
|
||||
connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedThread()));
|
||||
connect(ui->versions_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changedVersion()));
|
||||
connect(ui->threadTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(threadListCustomPopupMenu(QPoint)));
|
||||
connect(ui->postText, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTextBrowser(QPoint)));
|
||||
|
||||
@ -690,6 +690,17 @@ void GxsForumThreadWidget::togglethreadview_internal()
|
||||
}
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::changedVersion()
|
||||
{
|
||||
mThreadId = RsGxsMessageId(ui->versions_CB->itemData(ui->versions_CB->currentIndex()).toString().toStdString()) ;
|
||||
|
||||
if (mFillThread) {
|
||||
return;
|
||||
}
|
||||
ui->postText->resetImagesStatus(Settings->getForumLoadEmbeddedImages()) ;
|
||||
insertMessage();
|
||||
}
|
||||
|
||||
void GxsForumThreadWidget::changedThread()
|
||||
{
|
||||
/* just grab the ids of the current item */
|
||||
@ -697,20 +708,10 @@ void GxsForumThreadWidget::changedThread()
|
||||
|
||||
if (!item || !item->isSelected()) {
|
||||
mThreadId.clear();
|
||||
mOrigThreadId.clear();
|
||||
} else {
|
||||
mThreadId.clear();
|
||||
|
||||
if(ui->versions_CB->count() > 0)
|
||||
{
|
||||
mThreadId = RsGxsMessageId(ui->versions_CB->itemData(ui->versions_CB->currentIndex()).toString().toStdString()) ;
|
||||
mOrigThreadId = RsGxsMessageId(ui->versions_CB->itemData(0).toString().toStdString()) ;
|
||||
}
|
||||
|
||||
if(mThreadId.isNull())
|
||||
{
|
||||
mThreadId = RsGxsMessageId(item->data(COLUMN_THREAD_MSGID, Qt::DisplayRole).toString().toStdString());
|
||||
mOrigThreadId = mThreadId ;
|
||||
}
|
||||
mThreadId = mOrigThreadId = RsGxsMessageId(item->data(COLUMN_THREAD_MSGID, Qt::DisplayRole).toString().toStdString());
|
||||
}
|
||||
|
||||
if (mFillThread) {
|
||||
@ -1603,7 +1604,7 @@ void GxsForumThreadWidget::insertMessage()
|
||||
|
||||
for(uint32_t i=0;i<(*it).size();++i)
|
||||
{
|
||||
ui->versions_CB->insertItem(i,DateTime::formatLongDateTime( (*it)[i].first));
|
||||
ui->versions_CB->insertItem(i, ((i==0)?tr("(Latest) "):tr("(Old) "))+" "+DateTime::formatLongDateTime( (*it)[i].first));
|
||||
ui->versions_CB->setItemData(i,QString::fromStdString((*it)[i].second.toStdString()));
|
||||
|
||||
std::cerr << " added new post version " << (*it)[i].first << " " << (*it)[i].second << std::endl;
|
||||
@ -2176,7 +2177,7 @@ void GxsForumThreadWidget::editForumMessageData(const RsGxsForumMsg& msg)
|
||||
|
||||
if (!msg.mMeta.mAuthorId.isNull())
|
||||
{
|
||||
CreateGxsForumMsg *cfm = new CreateGxsForumMsg(groupId(), msg.mMeta.mParentId, msg.mMeta.mMsgId);
|
||||
CreateGxsForumMsg *cfm = new CreateGxsForumMsg(groupId(), msg.mMeta.mParentId, msg.mMeta.mMsgId, msg.mMeta.mAuthorId);
|
||||
|
||||
cfm->insertPastedText(QString::fromUtf8(msg.mMsg.c_str())) ;
|
||||
cfm->show();
|
||||
|
@ -75,6 +75,7 @@ private slots:
|
||||
void contextMenuTextBrowser(QPoint point);
|
||||
|
||||
void changedThread();
|
||||
void changedVersion();
|
||||
void clickedThread (QTreeWidgetItem *item, int column);
|
||||
|
||||
void reply_with_private_message();
|
||||
|
@ -210,7 +210,9 @@ void GxsForumsFillThread::run()
|
||||
{
|
||||
// Ensuring that the post exists allows to only collect the existing data.
|
||||
|
||||
mPostVersions[msgIt->second.mMeta.mOrigMsgId].push_back(QPair<time_t,RsGxsMessageId>(msgIt2->second.mMeta.mPublishTs,msgIt2->second.mMeta.mMsgId)) ;
|
||||
if(mPostVersions[msgIt->second.mMeta.mOrigMsgId].empty())
|
||||
mPostVersions[msgIt->second.mMeta.mOrigMsgId].push_back(QPair<time_t,RsGxsMessageId>(msgIt2->second.mMeta.mPublishTs,msgIt2->second.mMeta.mMsgId)) ;
|
||||
|
||||
mPostVersions[msgIt->second.mMeta.mOrigMsgId].push_back(QPair<time_t,RsGxsMessageId>(msgIt->second.mMeta.mPublishTs,msgIt->second.mMeta.mMsgId)) ;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user