Added fast reply feature to ForumsMsgItem

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3987 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2011-01-27 08:34:23 +00:00
parent 4fb593f1b9
commit 3f446d8f3c
3 changed files with 99 additions and 8 deletions

View File

@ -20,6 +20,7 @@
****************************************************************/
#include <QDateTime>
#include <QMessageBox>
#include "ForumMsgItem.h"
#include "FeedHolder.h"
@ -56,12 +57,17 @@ ForumMsgItem::ForumMsgItem(FeedHolder *parent, uint32_t feedId, const std::strin
/* specific ones */
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeForum ( void ) ) );
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyToPost ( void ) ) );
connect( sendButton, SIGNAL( clicked( ) ), this, SLOT( sendMsg() ) );
connect(NotifyQt::getInstance(), SIGNAL(peerHasNewAvatar(const QString&)), this, SLOT(updateAvatar(const QString&)));
small();
updateItemStatic();
updateItem();
textEdit->hide();
sendButton->hide();
signedcheckBox->hide();
}
@ -232,6 +238,9 @@ void ForumMsgItem::toggle()
if (prevFrame->isHidden())
{
prevFrame->show();
textEdit->show();
sendButton->show();
signedcheckBox->show();
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
expandButton->setToolTip("Hide");
if (!mIsTop)
@ -243,6 +252,9 @@ void ForumMsgItem::toggle()
{
prevFrame->hide();
nextFrame->hide();
textEdit->hide();
sendButton->hide();
signedcheckBox->hide();
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
expandButton->setToolTip("Expand");
}
@ -309,13 +321,49 @@ void ForumMsgItem::replyToPost()
#endif
if (mParent)
{
//mParent->openMsg(FEEDHOLDER_MSG_FORUM, mForumId, mPostId);
CreateForumMsg *cfm = new CreateForumMsg(mForumId, mPostId);
cfm->show();
}
}
void ForumMsgItem::sendMsg()
{
QString name = prevSubLabel->text();
QString desc = textEdit->toHtml();
if(textEdit->toPlainText().isEmpty())
{ /* error message */
QMessageBox::warning(this, tr("RetroShare"),tr("Please give a Text Message"),
QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty Message!!
}
ForumMsgInfo msgInfo;
msgInfo.forumId = mForumId;
msgInfo.threadId = "";
msgInfo.parentId = mPostId;
msgInfo.msgId = "";
msgInfo.title = name.toStdWString();
msgInfo.msg = desc.toStdWString();
msgInfo.msgflags = 0;
if (signedcheckBox->isChecked())
{
msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ;
}
if ((msgInfo.msg == L"") && (msgInfo.title == L""))
return; /* do nothing */
if (rsForums->ForumMessageSend(msgInfo) == true) {
textEdit->clear();
}
}
void ForumMsgItem::updateAvatar(const QString &peer_id)
{
if (mGpgIdPrev.empty() == false) {

View File

@ -49,6 +49,8 @@ private slots:
void unsubscribeForum();
void subscribeForum();
void replyToPost();
void sendMsg();
void updateItem();
void updateAvatar(const QString &peer_id);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>764</width>
<height>319</height>
<width>577</width>
<height>423</height>
</rect>
</property>
<property name="windowTitle">
@ -17,7 +17,7 @@
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<item row="2" column="0">
<widget class="QFrame" name="frame_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
@ -37,7 +37,7 @@ border-radius: 10px}</string>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
@ -487,14 +487,14 @@ border-radius: 10px}</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="2">
<widget class="QLabel" name="nextnamelabel">
<property name="text">
<string>Next Name</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_9">
@ -543,7 +543,7 @@ border-radius: 10px}</string>
</property>
</spacer>
</item>
<item row="2" column="1" rowspan="2">
<item row="2" column="2" rowspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="nextMsgLabel">
@ -569,6 +569,47 @@ border-radius: 10px}</string>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QTextEdit" name="textEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>2</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="sendButton">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="signedcheckBox">
<property name="text">
<string>Signed</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>