Merge pull request #822 from csoler/v0.6-EditPosts

V0.6 edit posts
This commit is contained in:
csoler 2017-05-15 22:17:26 +02:00 committed by GitHub
commit b9d19c2a60
5 changed files with 55 additions and 17 deletions

View file

@ -186,7 +186,7 @@ void SubFileItem::updateItemStatic()
} }
/* get full path for local file */ /* get full path for local file */
if ((mMode == SFI_STATE_LOCAL) || (mMode == SFI_STATE_UPLOAD)) if (((mMode == SFI_STATE_LOCAL) || (mMode == SFI_STATE_UPLOAD)))
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "SubFileItem::updateItemStatic() STATE=Local/Upload checking path"; std::cerr << "SubFileItem::updateItemStatic() STATE=Local/Upload checking path";
@ -200,6 +200,9 @@ void SubFileItem::updateItemStatic()
/* look up path */ /* look up path */
if (!rsFiles->FileDetails(mFileHash, hintflags, fi)) if (!rsFiles->FileDetails(mFileHash, hintflags, fi))
{ {
if(mFlag & SFI_FLAG_ASSUME_FILE_READY)
mMode = SFI_STATE_REMOTE;
else
mMode = SFI_STATE_ERROR; mMode = SFI_STATE_ERROR;
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "SubFileItem::updateItemStatic() STATE=>Error No Details"; std::cerr << "SubFileItem::updateItemStatic() STATE=>Error No Details";
@ -251,6 +254,7 @@ void SubFileItem::updateItemStatic()
case SFI_STATE_REMOTE: case SFI_STATE_REMOTE:
playButton->setEnabled(false); playButton->setEnabled(false);
downloadButton->setEnabled(true); downloadButton->setEnabled(true);
downloadButton->setVisible(true);
cancelButton->setEnabled(false); cancelButton->setEnabled(false);
progressBar->setValue(0); progressBar->setValue(0);

View file

@ -42,7 +42,7 @@ const uint32_t SFI_TYPE_ATTACH = 0x0020;
const uint32_t SFI_FLAG_CREATE = 0x1000; const uint32_t SFI_FLAG_CREATE = 0x1000;
const uint32_t SFI_FLAG_ALLOW_DELETE = 0x2000; const uint32_t SFI_FLAG_ALLOW_DELETE = 0x2000;
const uint32_t SFI_FLAG_NO_DOWNLOAD = 0x4000; const uint32_t SFI_FLAG_ASSUME_FILE_READY = 0x4000;
//! This create a gui widget that allows users to access files shared by user //! This create a gui widget that allows users to access files shared by user

View file

@ -41,6 +41,8 @@
#define CREATEMSG_CHANNELINFO 0x002 #define CREATEMSG_CHANNELINFO 0x002
#define CREATEMSG_CHANNEL_POST_INFO 0x003 #define CREATEMSG_CHANNEL_POST_INFO 0x003
// #define DEBUG_CREATE_GXS_MSG
/** Constructor */ /** Constructor */
CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId existing_post) CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId existing_post)
: QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), : QDialog (NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint),
@ -343,23 +345,25 @@ void CreateGxsChannelMsg::parseRsFileListAttachments(const std::string &attachLi
} }
void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId) void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId, bool assume_file_ready)
{ {
/* add a SubFileItem to the attachment section */ /* add a SubFileItem to the attachment section */
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::addAttachment()"; std::cerr << "CreateGxsChannelMsg::addAttachment()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
/* add widget in for new destination */ /* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL | SFI_FLAG_ALLOW_DELETE ; uint32_t flags = SFI_TYPE_CHANNEL | SFI_FLAG_ALLOW_DELETE ;
if(assume_file_ready)
flags |= SFI_FLAG_ASSUME_FILE_READY;
if (local) if (local)
{
flags |= SFI_STATE_LOCAL; flags |= SFI_STATE_LOCAL;
}
else else
{
flags |= SFI_STATE_REMOTE; flags |= SFI_STATE_REMOTE;
}
SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed
@ -370,11 +374,7 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin
layout->addWidget(file); layout->addWidget(file);
if (mCheckAttachment) if (mCheckAttachment)
{
checkAttachmentReady(); checkAttachmentReady();
}
return;
} }
void CreateGxsChannelMsg::deleteAttachment() void CreateGxsChannelMsg::deleteAttachment()
@ -398,8 +398,10 @@ void CreateGxsChannelMsg::deleteAttachment()
void CreateGxsChannelMsg::addExtraFile() void CreateGxsChannelMsg::addExtraFile()
{ {
/* add a SubFileItem to the attachment section */ /* add a SubFileItem to the attachment section */
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::addExtraFile() opening file dialog"; std::cerr << "CreateGxsChannelMsg::addExtraFile() opening file dialog";
std::cerr << std::endl; std::cerr << std::endl;
#endif
QStringList files; QStringList files;
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) { if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
@ -412,8 +414,10 @@ void CreateGxsChannelMsg::addExtraFile()
void CreateGxsChannelMsg::addAttachment(const std::string &path) void CreateGxsChannelMsg::addAttachment(const std::string &path)
{ {
/* add a SubFileItem to the attachment section */ /* add a SubFileItem to the attachment section */
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::addAttachment()"; std::cerr << "CreateGxsChannelMsg::addAttachment()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
if(mAutoMediaThumbNail) if(mAutoMediaThumbNail)
setThumbNail(path, 2000); setThumbNail(path, 2000);
@ -548,8 +552,10 @@ void CreateGxsChannelMsg::checkAttachmentReady()
void CreateGxsChannelMsg::cancelMsg() void CreateGxsChannelMsg::cancelMsg()
{ {
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::cancelMsg() :" std::cerr << "CreateGxsChannelMsg::cancelMsg() :"
<< "Deleting EXTRA attachments" << std::endl; << "Deleting EXTRA attachments" << std::endl;
#endif
std::cerr << std::endl; std::cerr << std::endl;
@ -604,8 +610,10 @@ void CreateGxsChannelMsg::saveChannelInfo(const RsGroupMetaData &meta)
void CreateGxsChannelMsg::sendMsg() void CreateGxsChannelMsg::sendMsg()
{ {
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::sendMsg()"; std::cerr << "CreateGxsChannelMsg::sendMsg()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
/* construct message bits */ /* construct message bits */
std::string subject = std::string(misc::removeNewLine(subjectEdit->text()).toUtf8()); std::string subject = std::string(misc::removeNewLine(subjectEdit->text()).toUtf8());
@ -724,8 +732,10 @@ void CreateGxsChannelMsg::addThumbnail()
void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token) void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token)
{ {
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo()"; std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
std::vector<RsGxsChannelPost> posts; std::vector<RsGxsChannelPost> posts;
rsGxsChannels->getPostData(token, posts); rsGxsChannels->getPostData(token, posts);
@ -749,7 +759,7 @@ void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token)
msgEdit->setText(QString::fromUtf8(post.mMsg.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) for(std::list<RsGxsFile>::const_iterator it(post.mFiles.begin());it!=post.mFiles.end();++it)
addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId()); addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId(),true);
picture.loadFromData(post.mThumbnail.mData,post.mThumbnail.mSize,"PNG"); picture.loadFromData(post.mThumbnail.mData,post.mThumbnail.mSize,"PNG");
thumbnail_label->setPixmap(picture); thumbnail_label->setPixmap(picture);
@ -757,8 +767,10 @@ void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token)
void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token) void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token)
{ {
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::loadChannelInfo()"; std::cerr << "CreateGxsChannelMsg::loadChannelInfo()";
std::cerr << std::endl; std::cerr << std::endl;
#endif
std::list<RsGroupMetaData> groupInfo; std::list<RsGroupMetaData> groupInfo;
rsGxsChannels->getGroupSummary(token, groupInfo); rsGxsChannels->getGroupSummary(token, groupInfo);
@ -777,8 +789,10 @@ void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token)
void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req) void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{ {
#ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::loadRequest() UserType: " << req.mUserType; std::cerr << "CreateGxsChannelMsg::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl; std::cerr << std::endl;
#endif
if (queue == mChannelQueue) if (queue == mChannelQueue)
{ {

View file

@ -44,7 +44,7 @@ public:
~CreateGxsChannelMsg(); ~CreateGxsChannelMsg();
void addAttachment(const std::string &path); void addAttachment(const std::string &path);
void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId); void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId,bool assume_file_ready = false);
void newChannelMsg(); void newChannelMsg();

View file

@ -398,7 +398,27 @@ void GxsChannelPostsWidget::filterChanged(int filter)
void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool related) void GxsChannelPostsWidget::createPostItem(const RsGxsChannelPost &post, bool related)
{ {
GxsChannelPostItem *item = NULL; GxsChannelPostItem *item = NULL;
if (related) {
if(!post.mMeta.mOrigMsgId.isNull())
{
FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(post.mMeta.mGroupId, post.mMeta.mOrigMsgId);
item = dynamic_cast<GxsChannelPostItem*>(feedItem);
if(item)
{
ui->feedWidget->removeFeedItem(item) ;
RsGxsChannelGroup dummyGroup;
dummyGroup.mMeta.mGroupId = groupId();
dummyGroup.mMeta.mSubscribeFlags = 0xffffffff;
GxsChannelPostItem *item = new GxsChannelPostItem(this, 0, dummyGroup, post, true, false);
ui->feedWidget->addFeedItem(item, ROLE_PUBLISH, QDateTime::fromTime_t(post.mMeta.mPublishTs));
return ;
}
}
if (related)
{
FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(post.mMeta.mGroupId, post.mMeta.mMsgId); FeedItem *feedItem = ui->feedWidget->findGxsFeedItem(post.mMeta.mGroupId, post.mMeta.mMsgId);
item = dynamic_cast<GxsChannelPostItem*>(feedItem); item = dynamic_cast<GxsChannelPostItem*>(feedItem);
} }