first part of channel post editing

This commit is contained in:
csoler 2017-05-11 23:21:13 +02:00
parent af18e4c314
commit 5406da92fa
5 changed files with 91 additions and 7 deletions

View File

@ -38,11 +38,13 @@
//#define ENABLE_GENERATE
#define CREATEMSG_CHANNELINFO 0x002
#define CREATEMSG_CHANNELINFO 0x002
#define CREATEMSG_CHANNEL_POST_INFO 0x003
/** Constructor */
CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId)
: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mChannelId(cId) ,mCheckAttachment(true), mAutoMediaThumbNail(false)
CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId existing_post)
: 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 */
setupUi(this);
@ -555,6 +557,15 @@ void CreateGxsChannelMsg::newChannelMsg()
uint32_t token;
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);
}
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)
{
std::cerr << "CreateGxsChannelMsg::loadChannelInfo()";
@ -719,6 +763,9 @@ void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenReques
case CREATEMSG_CHANNELINFO:
loadChannelInfo(req.mToken);
break;
case CREATEMSG_CHANNEL_POST_INFO:
loadChannelPostInfo(req.mToken);
break;
default:
std::cerr << "CreateGxsChannelMsg::loadRequest() UNKNOWN UserType ";
std::cerr << std::endl;

View File

@ -38,7 +38,7 @@ class CreateGxsChannelMsg : public QDialog, public TokenResponse, private Ui::Cr
public:
/** Default Constructor */
CreateGxsChannelMsg(const RsGxsGroupId& cId);
CreateGxsChannelMsg(const RsGxsGroupId& cId, RsGxsMessageId existing_post = RsGxsMessageId());
/** Default Destructor */
~CreateGxsChannelMsg();
@ -71,6 +71,7 @@ private slots:
private:
void loadChannelInfo(const uint32_t &token);
void loadChannelPostInfo(const uint32_t &token);
void saveChannelInfo(const RsGroupMetaData &group);
void parseRsFileListAttachments(const std::string &attachList);
@ -78,7 +79,9 @@ private:
bool setThumbNail(const std::string& path, int frame);
RsGxsGroupId mChannelId;
RsGxsMessageId mOrigPostId;
RsGroupMetaData mChannelMeta;
RsMsgMetaData mOrigMeta;
bool mChannelMetaLoaded;
std::list<SubFileItem *> mAttachments;

View File

@ -67,11 +67,14 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
mStateHelper->addLoadPlaceholder(mTokenTypeGroupData, ui->nameLabel);
mStateHelper->addWidget(mTokenTypeGroupData, ui->postButton);
mStateHelper->addWidget(mTokenTypeGroupData, ui->editButton);
mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
/* Connect signals */
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(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
@ -211,7 +214,21 @@ void GxsChannelPostsWidget::openComments(uint32_t /*type*/, const RsGxsGroupId &
{
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()
{
if (groupId().isNull()) {
@ -244,10 +261,12 @@ void GxsChannelPostsWidget::insertChannelDetails(const RsGxsChannelGroup &group)
if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH)
{
mStateHelper->setWidgetEnabled(ui->postButton, true);
mStateHelper->setWidgetEnabled(ui->editButton, true);
}
else
{
mStateHelper->setWidgetEnabled(ui->postButton, false);
mStateHelper->setWidgetEnabled(ui->editButton, false);
}
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));

View File

@ -79,6 +79,7 @@ protected:
private slots:
void createMsg();
void editMsg();
void toggleAutoDownload();
void subscribeGroup(bool subscribe);
void filterChanged(int filter);

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>793</width>
<height>465</height>
<width>828</width>
<height>557</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -184,6 +184,20 @@
</property>
</widget>
</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>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -454,7 +468,7 @@
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">