From 0c97d5bc3c01d06ff365595f62d0577718be925c Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 27 Oct 2017 22:03:42 +0200 Subject: [PATCH] added sorting of channels to push to, and auto-fill of channel subject --- .../src/gui/FileTransfer/SharedFilesDialog.cpp | 18 +++++++++++++++++- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 5 +++++ .../src/gui/gxschannels/CreateGxsChannelMsg.h | 1 + .../src/gui/gxschannels/GxsChannelDialog.cpp | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index 6035d37d2..704708e30 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -963,6 +963,15 @@ void SharedFilesDialog::postModDirectories(bool local) QCoreApplication::flush(); } +class ChannelCompare +{ +public: + bool operator()(const std::pair& id1,const std::pair& id2) const + { + return id1.first < id2.first ; + } +}; + void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) { if (!rsPeers) return; /* not ready yet! */ @@ -1026,9 +1035,16 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point ) std::list grp_metas ; channelDialog->getGroupList(grp_metas) ; + std::vector > chnls ; // I dont use a std::map because two or more channels may have the same name. + for(auto it(grp_metas.begin());it!=grp_metas.end();++it) if(IS_GROUP_PUBLISHER((*it).mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).mSubscribeFlags)) - shareChannelMenu.addAction(QString::fromUtf8((*it).mGroupName.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).mGroupId.toStdString())) ; + chnls.push_back(std::make_pair((*it).mGroupName, (*it).mGroupId)); + + std::sort(chnls.begin(),chnls.end(),ChannelCompare()) ; + + for(auto it(chnls.begin());it!=chnls.end();++it) + shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ; contextMnu.addMenu(&shareChannelMenu) ; contextMnu.exec(QCursor::pos()) ; // added here because the shareChannelMenu QMenu object is deleted afterwards diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 8c4f2c524..e8b15ed8e 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -412,6 +412,11 @@ void CreateGxsChannelMsg::addExtraFile() } } +void CreateGxsChannelMsg::addSubject(const QString& text) +{ + subjectEdit->setText(text) ; +} + void CreateGxsChannelMsg::addHtmlText(const QString& text) { msgEdit->setHtml(text) ; diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index 5168c6226..3e9f6ccc6 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -44,6 +44,7 @@ public: ~CreateGxsChannelMsg(); void addHtmlText(const QString& text) ; + void addSubject(const QString& text) ; void addAttachment(const std::string &path); void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId,bool assume_file_ready = false); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp index c011621a8..4bff7528b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.cpp @@ -87,6 +87,12 @@ void GxsChannelDialog::shareOnChannel(const RsGxsGroupId& channel_id,const QList for(QList::const_iterator it(file_links.begin());it!=file_links.end();++it) txt += (*it).toHtml() + "\n" ; + if(!file_links.empty()) + { + QString subject = (*file_links.begin()).name() ; + msgDialog->addSubject(subject); + } + msgDialog->addHtmlText(txt); msgDialog->show(); }