added sorting of channels to push to, and auto-fill of channel subject

This commit is contained in:
csoler 2017-10-27 22:03:42 +02:00
parent 2e9f5202e0
commit 0c97d5bc3c
4 changed files with 29 additions and 1 deletions

View File

@ -963,6 +963,15 @@ void SharedFilesDialog::postModDirectories(bool local)
QCoreApplication::flush();
}
class ChannelCompare
{
public:
bool operator()(const std::pair<std::string,RsGxsGroupId>& id1,const std::pair<std::string,RsGxsGroupId>& 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<RsGroupMetaData> grp_metas ;
channelDialog->getGroupList(grp_metas) ;
std::vector<std::pair<std::string,RsGxsGroupId> > 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

View File

@ -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) ;

View File

@ -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);

View File

@ -87,6 +87,12 @@ void GxsChannelDialog::shareOnChannel(const RsGxsGroupId& channel_id,const QList
for(QList<RetroShareLink>::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();
}