mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-22 14:10:54 -04:00
first part of channel post editing
This commit is contained in:
parent
af18e4c314
commit
5406da92fa
5 changed files with 91 additions and 7 deletions
|
@ -39,10 +39,12 @@
|
||||||
//#define ENABLE_GENERATE
|
//#define ENABLE_GENERATE
|
||||||
|
|
||||||
#define CREATEMSG_CHANNELINFO 0x002
|
#define CREATEMSG_CHANNELINFO 0x002
|
||||||
|
#define CREATEMSG_CHANNEL_POST_INFO 0x003
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId)
|
CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId existing_post)
|
||||||
: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false)
|
: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
|
||||||
|
mChannelId(cId) , mOrigPostId(existing_post),mCheckAttachment(true), mAutoMediaThumbNail(false)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
@ -555,6 +557,15 @@ void CreateGxsChannelMsg::newChannelMsg()
|
||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEMSG_CHANNELINFO);
|
mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEMSG_CHANNELINFO);
|
||||||
|
|
||||||
|
if(!mOrigPostId.isNull())
|
||||||
|
{
|
||||||
|
GxsMsgReq message_ids;
|
||||||
|
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
message_ids[mChannelId].push_back(mOrigPostId);
|
||||||
|
mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, message_ids, CREATEMSG_CHANNEL_POST_INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,6 +697,39 @@ void CreateGxsChannelMsg::addThumbnail()
|
||||||
thumbnail_label->setPixmap(picture);
|
thumbnail_label->setPixmap(picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token)
|
||||||
|
{
|
||||||
|
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
std::vector<RsGxsChannelPost> posts;
|
||||||
|
rsGxsChannels->getPostData(token, posts);
|
||||||
|
|
||||||
|
if (posts.size() != 1)
|
||||||
|
{
|
||||||
|
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo() ERROR INVALID Number of posts in request" << std::endl;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now populate the widget with the channel post data.
|
||||||
|
const RsGxsChannelPost& post = posts[0];
|
||||||
|
|
||||||
|
if(post.mMeta.mGroupId != mChannelId || post.mMeta.mMsgId != mOrigPostId)
|
||||||
|
{
|
||||||
|
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo() ERROR INVALID post ID or channel ID" << std::endl;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
subjectEdit->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())) ;
|
||||||
|
msgEdit->setText(QString::fromUtf8(post.mMsg.c_str())) ;
|
||||||
|
|
||||||
|
for(std::list<RsGxsFile>::const_iterator it(post.mFiles.begin());it!=post.mFiles.end();++it)
|
||||||
|
addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId());
|
||||||
|
|
||||||
|
picture.loadFromData(post.mThumbnail.mData,post.mThumbnail.mSize,"PNG");
|
||||||
|
thumbnail_label->setPixmap(picture);
|
||||||
|
}
|
||||||
|
|
||||||
void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token)
|
void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token)
|
||||||
{
|
{
|
||||||
std::cerr << "CreateGxsChannelMsg::loadChannelInfo()";
|
std::cerr << "CreateGxsChannelMsg::loadChannelInfo()";
|
||||||
|
@ -719,6 +763,9 @@ void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenReques
|
||||||
case CREATEMSG_CHANNELINFO:
|
case CREATEMSG_CHANNELINFO:
|
||||||
loadChannelInfo(req.mToken);
|
loadChannelInfo(req.mToken);
|
||||||
break;
|
break;
|
||||||
|
case CREATEMSG_CHANNEL_POST_INFO:
|
||||||
|
loadChannelPostInfo(req.mToken);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
std::cerr << "CreateGxsChannelMsg::loadRequest() UNKNOWN UserType ";
|
std::cerr << "CreateGxsChannelMsg::loadRequest() UNKNOWN UserType ";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CreateGxsChannelMsg : public QDialog, public TokenResponse, private Ui::Cr
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
CreateGxsChannelMsg(const RsGxsGroupId& cId);
|
CreateGxsChannelMsg(const RsGxsGroupId& cId, RsGxsMessageId existing_post = RsGxsMessageId());
|
||||||
|
|
||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
~CreateGxsChannelMsg();
|
~CreateGxsChannelMsg();
|
||||||
|
@ -71,6 +71,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadChannelInfo(const uint32_t &token);
|
void loadChannelInfo(const uint32_t &token);
|
||||||
|
void loadChannelPostInfo(const uint32_t &token);
|
||||||
void saveChannelInfo(const RsGroupMetaData &group);
|
void saveChannelInfo(const RsGroupMetaData &group);
|
||||||
|
|
||||||
void parseRsFileListAttachments(const std::string &attachList);
|
void parseRsFileListAttachments(const std::string &attachList);
|
||||||
|
@ -78,7 +79,9 @@ private:
|
||||||
bool setThumbNail(const std::string& path, int frame);
|
bool setThumbNail(const std::string& path, int frame);
|
||||||
|
|
||||||
RsGxsGroupId mChannelId;
|
RsGxsGroupId mChannelId;
|
||||||
|
RsGxsMessageId mOrigPostId;
|
||||||
RsGroupMetaData mChannelMeta;
|
RsGroupMetaData mChannelMeta;
|
||||||
|
RsMsgMetaData mOrigMeta;
|
||||||
bool mChannelMetaLoaded;
|
bool mChannelMetaLoaded;
|
||||||
|
|
||||||
std::list<SubFileItem *> mAttachments;
|
std::list<SubFileItem *> mAttachments;
|
||||||
|
|
|
@ -67,11 +67,14 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
||||||
mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
|
mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
|
||||||
|
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton);
|
mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton);
|
||||||
|
mStateHelper->addWidget(mTokenTypeGroupData, ui->editButton);
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
|
mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
|
||||||
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
|
||||||
|
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
||||||
|
connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editMsg()));
|
||||||
|
|
||||||
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
|
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
||||||
|
|
||||||
|
@ -211,7 +214,21 @@ void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &
|
||||||
{
|
{
|
||||||
emit loadComment(groupId, msgId, title);
|
emit loadComment(groupId, msgId, title);
|
||||||
}
|
}
|
||||||
|
void GxsChannelPostsWidget::editMsg()
|
||||||
|
{
|
||||||
|
if (groupId().isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IS_GROUP_SUBSCRIBED(subscribeFlags())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(groupId(),mCurrentMessageId);
|
||||||
|
msgDialog->show();
|
||||||
|
|
||||||
|
/* window will destroy itself! */
|
||||||
|
}
|
||||||
void GxsChannelPostsWidget::createMsg()
|
void GxsChannelPostsWidget::createMsg()
|
||||||
{
|
{
|
||||||
if (groupId().isNull()) {
|
if (groupId().isNull()) {
|
||||||
|
@ -244,10 +261,12 @@ void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
|
||||||
if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
|
if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
|
||||||
{
|
{
|
||||||
mStateHelper->setWidgetEnabled(ui->postButton, true);
|
mStateHelper->setWidgetEnabled(ui->postButton, true);
|
||||||
|
mStateHelper->setWidgetEnabled(ui->editButton, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mStateHelper->setWidgetEnabled(ui->postButton, false);
|
mStateHelper->setWidgetEnabled(ui->postButton, false);
|
||||||
|
mStateHelper->setWidgetEnabled(ui->editButton, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
|
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
|
||||||
|
|
|
@ -79,6 +79,7 @@ protected:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void createMsg();
|
void createMsg();
|
||||||
|
void editMsg();
|
||||||
void toggleAutoDownload();
|
void toggleAutoDownload();
|
||||||
void subscribeGroup(bool subscribe);
|
void subscribeGroup(bool subscribe);
|
||||||
void filterChanged(int filter);
|
void filterChanged(int filter);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>793</width>
|
<width>828</width>
|
||||||
<height>465</height>
|
<height>557</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
@ -184,6 +184,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="editButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Edit current post</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../images.qrc">
|
||||||
|
<normaloff>:/images/edit_24.png</normaloff>:/images/edit_24.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -454,7 +468,7 @@
|
||||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html></string>
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textInteractionFlags">
|
<property name="textInteractionFlags">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue