mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
Merge pull request #1084 from csoler/v0.6-Links2
added sorting of channels to push to, and auto-fill of channel subject
This commit is contained in:
commit
b77e895691
@ -42,6 +42,7 @@
|
|||||||
#include "gui/msgs/MessageComposer.h"
|
#include "gui/msgs/MessageComposer.h"
|
||||||
#include "gui/settings/AddFileAssociationDialog.h"
|
#include "gui/settings/AddFileAssociationDialog.h"
|
||||||
#include "gui/gxschannels/GxsChannelDialog.h"
|
#include "gui/gxschannels/GxsChannelDialog.h"
|
||||||
|
#include "gui/gxsforums/GxsForumsDialog.h"
|
||||||
#include "gui/settings/rsharesettings.h"
|
#include "gui/settings/rsharesettings.h"
|
||||||
#include "util/QtVersion.h"
|
#include "util/QtVersion.h"
|
||||||
#include "util/RsAction.h"
|
#include "util/RsAction.h"
|
||||||
@ -64,6 +65,7 @@
|
|||||||
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
||||||
#define IMAGE_LIBRARY ":/images/library.png"
|
#define IMAGE_LIBRARY ":/images/library.png"
|
||||||
#define IMAGE_CHANNEL ":/images/channels32.png"
|
#define IMAGE_CHANNEL ":/images/channels32.png"
|
||||||
|
#define IMAGE_FORUMS ":/icons/png/forums.png"
|
||||||
#define IMAGE_COLLCREATE ":/images/library_add.png"
|
#define IMAGE_COLLCREATE ":/images/library_add.png"
|
||||||
#define IMAGE_COLLMODIF ":/images/library_edit.png"
|
#define IMAGE_COLLMODIF ":/images/library_edit.png"
|
||||||
#define IMAGE_COLLVIEW ":/images/library_view.png"
|
#define IMAGE_COLLVIEW ":/images/library_view.png"
|
||||||
@ -963,6 +965,15 @@ void SharedFilesDialog::postModDirectories(bool local)
|
|||||||
QCoreApplication::flush();
|
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 )
|
void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
||||||
{
|
{
|
||||||
if (!rsPeers) return; /* not ready yet! */
|
if (!rsPeers) return; /* not ready yet! */
|
||||||
@ -1017,26 +1028,55 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||||||
}
|
}
|
||||||
|
|
||||||
GxsChannelDialog *channelDialog = dynamic_cast<GxsChannelDialog*>(MainWindow::getPage(MainWindow::Channels));
|
GxsChannelDialog *channelDialog = dynamic_cast<GxsChannelDialog*>(MainWindow::getPage(MainWindow::Channels));
|
||||||
|
QMenu shareChannelMenu(tr("Share on channel...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
||||||
|
|
||||||
if(channelDialog != NULL)
|
if(channelDialog != NULL)
|
||||||
{
|
{
|
||||||
QMenu shareChannelMenu(tr("Share on channel...")) ;
|
|
||||||
shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL));
|
shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL));
|
||||||
|
|
||||||
std::list<RsGroupMetaData> grp_metas ;
|
std::list<RsGroupMetaData> grp_metas ;
|
||||||
channelDialog->getGroupList(grp_metas) ;
|
channelDialog->getGroupList(grp_metas) ;
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // 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)
|
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
|
||||||
if(IS_GROUP_PUBLISHER((*it).mSubscribeFlags) && IS_GROUP_SUBSCRIBED((*it).mSubscribeFlags))
|
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())) ;
|
grplist.push_back(std::make_pair((*it).mGroupName, (*it).mGroupId));
|
||||||
|
|
||||||
|
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;
|
||||||
|
|
||||||
|
for(auto it(grplist.begin());it!=grplist.end();++it)
|
||||||
|
shareChannelMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).second.toStdString())) ;
|
||||||
|
|
||||||
contextMnu.addMenu(&shareChannelMenu) ;
|
contextMnu.addMenu(&shareChannelMenu) ;
|
||||||
contextMnu.exec(QCursor::pos()) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
contextMnu.exec(QCursor::pos()) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
GxsForumsDialog *forumsDialog = dynamic_cast<GxsForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
||||||
|
QMenu shareForumMenu(tr("Share on forum...")) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
||||||
|
|
||||||
|
if(forumsDialog != NULL)
|
||||||
|
{
|
||||||
|
shareForumMenu.setIcon(QIcon(IMAGE_FORUMS));
|
||||||
|
|
||||||
|
std::list<RsGroupMetaData> grp_metas ;
|
||||||
|
forumsDialog->getGroupList(grp_metas) ;
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string,RsGxsGroupId> > grplist ; // 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_SUBSCRIBED((*it).mSubscribeFlags))
|
||||||
|
grplist.push_back(std::make_pair((*it).mGroupName, (*it).mGroupId));
|
||||||
|
|
||||||
|
std::sort(grplist.begin(),grplist.end(),ChannelCompare()) ;
|
||||||
|
|
||||||
|
for(auto it(grplist.begin());it!=grplist.end();++it)
|
||||||
|
shareForumMenu.addAction(QString::fromUtf8((*it).first.c_str()), this, SLOT(shareInForum()))->setData(QString::fromStdString((*it).second.toStdString())) ;
|
||||||
|
|
||||||
|
contextMnu.addMenu(&shareForumMenu) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMnu.exec(QCursor::pos()) ;
|
||||||
|
}
|
||||||
void LocalSharedFilesDialog::shareOnChannel()
|
void LocalSharedFilesDialog::shareOnChannel()
|
||||||
{
|
{
|
||||||
RsGxsGroupId groupId(qobject_cast<QAction*>(sender())->data().toString().toStdString());
|
RsGxsGroupId groupId(qobject_cast<QAction*>(sender())->data().toString().toStdString());
|
||||||
@ -1055,6 +1095,24 @@ void LocalSharedFilesDialog::shareOnChannel()
|
|||||||
|
|
||||||
channelDialog->shareOnChannel(groupId,file_links_list) ;
|
channelDialog->shareOnChannel(groupId,file_links_list) ;
|
||||||
}
|
}
|
||||||
|
void LocalSharedFilesDialog::shareInForum()
|
||||||
|
{
|
||||||
|
RsGxsGroupId groupId(qobject_cast<QAction*>(sender())->data().toString().toStdString());
|
||||||
|
|
||||||
|
GxsForumsDialog *forumsDialog = dynamic_cast<GxsForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
||||||
|
|
||||||
|
if(forumsDialog == NULL)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
std::list<DirDetails> files_info ;
|
||||||
|
|
||||||
|
QList<RetroShareLink> file_links_list ;
|
||||||
|
bool has_unhashed_files ;
|
||||||
|
|
||||||
|
copyLinks(getSelected(),false,file_links_list,has_unhashed_files) ;
|
||||||
|
|
||||||
|
forumsDialog->shareInMessage(groupId,file_links_list) ;
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
|
@ -160,6 +160,7 @@ class LocalSharedFilesDialog : public SharedFilesDialog
|
|||||||
void tryToAddNewAssotiation();
|
void tryToAddNewAssotiation();
|
||||||
void forceCheck();
|
void forceCheck();
|
||||||
void shareOnChannel();
|
void shareOnChannel();
|
||||||
|
void shareInForum();
|
||||||
|
|
||||||
QAction* fileAssotiationAction(const QString fileName);
|
QAction* fileAssotiationAction(const QString fileName);
|
||||||
|
|
||||||
|
@ -412,6 +412,11 @@ void CreateGxsChannelMsg::addExtraFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateGxsChannelMsg::addSubject(const QString& text)
|
||||||
|
{
|
||||||
|
subjectEdit->setText(text) ;
|
||||||
|
}
|
||||||
|
|
||||||
void CreateGxsChannelMsg::addHtmlText(const QString& text)
|
void CreateGxsChannelMsg::addHtmlText(const QString& text)
|
||||||
{
|
{
|
||||||
msgEdit->setHtml(text) ;
|
msgEdit->setHtml(text) ;
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
~CreateGxsChannelMsg();
|
~CreateGxsChannelMsg();
|
||||||
|
|
||||||
void addHtmlText(const QString& text) ;
|
void addHtmlText(const QString& text) ;
|
||||||
|
void addSubject(const QString& text) ;
|
||||||
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,bool assume_file_ready = false);
|
void addAttachment(const RsFileHash &hash, const std::string &fname, uint64_t size, bool local, const RsPeerId &srcId,bool assume_file_ready = false);
|
||||||
|
|
||||||
|
@ -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)
|
for(QList<RetroShareLink>::const_iterator it(file_links.begin());it!=file_links.end();++it)
|
||||||
txt += (*it).toHtml() + "\n" ;
|
txt += (*it).toHtml() + "\n" ;
|
||||||
|
|
||||||
|
if(!file_links.empty())
|
||||||
|
{
|
||||||
|
QString subject = (*file_links.begin()).name() ;
|
||||||
|
msgDialog->addSubject(subject);
|
||||||
|
}
|
||||||
|
|
||||||
msgDialog->addHtmlText(txt);
|
msgDialog->addHtmlText(txt);
|
||||||
msgDialog->show();
|
msgDialog->show();
|
||||||
}
|
}
|
||||||
|
@ -152,12 +152,13 @@ void CreateGxsForumMsg::newMsg()
|
|||||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||||
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_PARENTMSG, false);
|
||||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, false);
|
||||||
|
|
||||||
mStateHelper->clear(CREATEGXSFORUMMSG_FORUMINFO);
|
mStateHelper->clear(CREATEGXSFORUMMSG_FORUMINFO);
|
||||||
mStateHelper->clear(CREATEGXSFORUMMSG_PARENTMSG);
|
mStateHelper->clear(CREATEGXSFORUMMSG_PARENTMSG);
|
||||||
mStateHelper->clear(CREATEGXSFORUMMSG_ORIGMSG);
|
mStateHelper->clear(CREATEGXSFORUMMSG_ORIGMSG);
|
||||||
ui.forumName->setText(tr("No Forum"));
|
ui.forumName->setText(tr("No Forum"));
|
||||||
return;
|
return;
|
||||||
}//if ( mForumId.isNull())
|
}
|
||||||
|
|
||||||
{/* request Data */
|
{/* request Data */
|
||||||
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, true);
|
mStateHelper->setLoading(CREATEGXSFORUMMSG_FORUMINFO, true);
|
||||||
@ -192,7 +193,7 @@ void CreateGxsForumMsg::newMsg()
|
|||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||||
}//if (mParentId.isNull())
|
}
|
||||||
|
|
||||||
if (mOrigMsgId.isNull()) {
|
if (mOrigMsgId.isNull()) {
|
||||||
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, true);
|
mStateHelper->setActive(CREATEGXSFORUMMSG_ORIGMSG, true);
|
||||||
@ -212,7 +213,7 @@ void CreateGxsForumMsg::newMsg()
|
|||||||
|
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_ORIGMSG);
|
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_ORIGMSG);
|
||||||
}//if (mParentId.isNull())
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateGxsForumMsg::loadFormInformation()
|
void CreateGxsForumMsg::loadFormInformation()
|
||||||
@ -307,17 +308,14 @@ void CreateGxsForumMsg::loadFormInformation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.forumName->setText(misc::removeNewLine(name));
|
ui.forumName->setText(misc::removeNewLine(name));
|
||||||
ui.forumSubject->setText(misc::removeNewLine(subj));
|
|
||||||
//ui.forumSubject->setReadOnly(!mOrigMsgId.isNull());
|
if(!subj.isNull())
|
||||||
|
ui.forumSubject->setText(misc::removeNewLine(subj));
|
||||||
|
|
||||||
if (ui.forumSubject->text().isEmpty())
|
if (ui.forumSubject->text().isEmpty())
|
||||||
{
|
|
||||||
ui.forumSubject->setFocus();
|
ui.forumSubject->setFocus();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ui.forumMessage->setFocus();
|
ui.forumMessage->setFocus();
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TOGXS
|
#ifdef TOGXS
|
||||||
if (mForumMeta.mGroupFlags & RS_DISTRIB_AUTHEN_REQ)
|
if (mForumMeta.mGroupFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||||
@ -687,8 +685,12 @@ void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void CreateGxsForumMsg::setSubject(const QString& msg)
|
||||||
|
{
|
||||||
|
ui.forumSubject->setText(msg);
|
||||||
|
}
|
||||||
|
|
||||||
void CreateGxsForumMsg::insertPastedText(QString msg)
|
void CreateGxsForumMsg::insertPastedText(const QString& msg)
|
||||||
{
|
{
|
||||||
ui.forumMessage->append(msg);
|
ui.forumMessage->append(msg);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ public:
|
|||||||
|
|
||||||
void newMsg(); /* cleanup */
|
void newMsg(); /* cleanup */
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
void insertPastedText(QString msg) ;
|
void insertPastedText(const QString& msg) ;
|
||||||
|
void setSubject(const QString& msg);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "GxsForumsDialog.h"
|
#include "GxsForumsDialog.h"
|
||||||
#include "GxsForumGroupDialog.h"
|
#include "GxsForumGroupDialog.h"
|
||||||
#include "GxsForumThreadWidget.h"
|
#include "GxsForumThreadWidget.h"
|
||||||
|
#include "CreateGxsForumMsg.h"
|
||||||
#include "GxsForumUserNotify.h"
|
#include "GxsForumUserNotify.h"
|
||||||
#include "gui/notifyqt.h"
|
#include "gui/notifyqt.h"
|
||||||
#include "gui/gxs/GxsGroupShareKey.h"
|
#include "gui/gxs/GxsGroupShareKey.h"
|
||||||
@ -60,6 +61,24 @@ QString GxsForumsDialog::getHelpString() const
|
|||||||
return hlp_str ;
|
return hlp_str ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsForumsDialog::shareInMessage(const RsGxsGroupId& forum_id,const QList<RetroShareLink>& file_links)
|
||||||
|
{
|
||||||
|
CreateGxsForumMsg *msgDialog = new CreateGxsForumMsg(forum_id,RsGxsMessageId(),RsGxsMessageId(),RsGxsId()) ;
|
||||||
|
|
||||||
|
QString txt ;
|
||||||
|
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->setSubject(subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
msgDialog->insertPastedText(txt);
|
||||||
|
msgDialog->show();
|
||||||
|
}
|
||||||
|
|
||||||
UserNotify *GxsForumsDialog::getUserNotify(QObject *parent)
|
UserNotify *GxsForumsDialog::getUserNotify(QObject *parent)
|
||||||
{
|
{
|
||||||
return new GxsForumUserNotify(rsGxsForums, parent);
|
return new GxsForumUserNotify(rsGxsForums, parent);
|
||||||
|
@ -40,6 +40,8 @@ public:
|
|||||||
|
|
||||||
virtual UserNotify *getUserNotify(QObject *parent);
|
virtual UserNotify *getUserNotify(QObject *parent);
|
||||||
|
|
||||||
|
void shareInMessage(const RsGxsGroupId& forum_id, const QList<RetroShareLink>& file_link) ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString getHelpString() const ;
|
virtual QString getHelpString() const ;
|
||||||
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
|
||||||
|
Loading…
Reference in New Issue
Block a user