mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-02 11:16:34 -04:00
added code to share a file/dir on channel
This commit is contained in:
parent
edffbc3670
commit
770add8b8a
6 changed files with 98 additions and 62 deletions
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "SharedFilesDialog.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/RemoteDirModel.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/ShareManager.h"
|
||||
|
@ -40,6 +41,7 @@
|
|||
#include "gui/common/RsCollection.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "gui/settings/AddFileAssociationDialog.h"
|
||||
#include "gui/gxschannels/GxsChannelDialog.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/RsAction.h"
|
||||
|
@ -61,6 +63,7 @@
|
|||
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
||||
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
||||
#define IMAGE_LIBRARY ":/images/library.png"
|
||||
#define IMAGE_CHANNEL ":/images/channels32.png"
|
||||
#define IMAGE_COLLCREATE ":/images/library_add.png"
|
||||
#define IMAGE_COLLMODIF ":/images/library_edit.png"
|
||||
#define IMAGE_COLLVIEW ":/images/library_view.png"
|
||||
|
@ -154,9 +157,6 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
|||
connect(notify, SIGNAL(filesPreModChanged(bool)), this, SLOT(preModDirectories(bool)));
|
||||
connect(notify, SIGNAL(filesPostModChanged(bool)), this, SLOT(postModDirectories(bool)));
|
||||
|
||||
//== connect(ui.localButton, SIGNAL(toggled(bool)), this, SLOT(showFrame(bool)));
|
||||
//== connect(ui.remoteButton, SIGNAL(toggled(bool)), this, SLOT(showFrameRemote(bool)));
|
||||
//== connect(ui.splittedButton, SIGNAL(toggled(bool)), this, SLOT(showFrameSplitted(bool)));
|
||||
connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int)));
|
||||
|
||||
connect( ui.dirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( spawnCustomPopupMenu( QPoint ) ) );
|
||||
|
@ -511,14 +511,12 @@ void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
||||
contextMnu.addAction( downloadAct) ;
|
||||
|
||||
//if ( type == DIR_TYPE_FILE )
|
||||
{
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction( copylinkAct) ;
|
||||
contextMnu.addAction( sendlinkAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
|
||||
}
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction( copylinkAct) ;
|
||||
contextMnu.addAction( sendlinkAct) ;
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addAction(QIcon(IMAGE_MSG), tr("Recommend in a message to..."), this, SLOT(recommendFilesToMsg())) ;
|
||||
|
||||
|
||||
contextMnu.addSeparator() ;//------------------------------------
|
||||
contextMnu.addMenu(&collectionMenu) ;
|
||||
|
@ -557,22 +555,20 @@ void RemoteSharedFilesDialog::downloadRemoteSelected()
|
|||
model -> downloadSelected(lst) ;
|
||||
}
|
||||
|
||||
void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
||||
void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList<RetroShareLink>& urls,bool& has_unhashed_files)
|
||||
{
|
||||
std::vector<DirDetails> dirVec;
|
||||
std::vector<DirDetails> dirVec;
|
||||
|
||||
model->getDirDetailsFromSelect(lst, dirVec);
|
||||
model->getDirDetailsFromSelect(lst, dirVec);
|
||||
|
||||
QList<RetroShareLink> urls ;
|
||||
has_unhashed_files = false;
|
||||
|
||||
bool has_unhashed_files = false;
|
||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||
{
|
||||
const DirDetails& details = dirVec[i];
|
||||
|
||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||
{
|
||||
const DirDetails& details = dirVec[i];
|
||||
|
||||
if (details.type == DIR_TYPE_DIR)
|
||||
{
|
||||
if (details.type == DIR_TYPE_DIR)
|
||||
{
|
||||
FileTree *ft = FileTree::create(details,remote) ;
|
||||
|
||||
std::cerr << "Created collection file tree:" << std::endl;
|
||||
|
@ -586,48 +582,32 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
|||
urls.push_back(link) ;
|
||||
|
||||
delete ft ;
|
||||
#ifdef TO_REMOVE
|
||||
for(uint32_t j=0;j<details.children.size();++j)
|
||||
{
|
||||
const DirStub& dirStub = details.children[j];
|
||||
|
||||
DirDetails details;
|
||||
FileSearchFlags flags = remote?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
||||
|
||||
// do not recursive copy sub dirs.
|
||||
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
|
||||
continue;
|
||||
|
||||
if(details.hash.isNull())
|
||||
{
|
||||
has_unhashed_files = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str());
|
||||
if (link.valid()) {
|
||||
urls.push_back(link) ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if(details.hash.isNull())
|
||||
}
|
||||
else
|
||||
{
|
||||
if(details.hash.isNull())
|
||||
{
|
||||
has_unhashed_files = true;
|
||||
continue;
|
||||
}
|
||||
RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str());
|
||||
if (link.valid()) {
|
||||
urls.push_back(link) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
RetroShareLink link = RetroShareLink::createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str());
|
||||
if (link.valid()) {
|
||||
urls.push_back(link) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
|
||||
{
|
||||
QList<RetroShareLink> urls ;
|
||||
bool has_unhashed_files = false;
|
||||
|
||||
copyLinks(lst,remote,urls,has_unhashed_files) ;
|
||||
RSLinkClipboard::copyLinks(urls) ;
|
||||
|
||||
if(has_unhashed_files)
|
||||
QMessageBox::warning(NULL,tr("Some files have been omitted"),tr("Some files have been omitted because their hash is not available yet.")) ;
|
||||
QMessageBox::warning(NULL,tr("Some files have been omitted"),tr("Some files have been omitted because they have not been indexed yet.")) ;
|
||||
}
|
||||
|
||||
void SharedFilesDialog::copyLink()
|
||||
|
@ -1036,7 +1016,44 @@ void LocalSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||
return ;
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
GxsChannelDialog *channelDialog = dynamic_cast<GxsChannelDialog*>(MainWindow::getPage(MainWindow::Channels));
|
||||
|
||||
if(channelDialog != NULL)
|
||||
{
|
||||
QMenu shareChannelMenu(tr("Share on channel...")) ;
|
||||
shareChannelMenu.setIcon(QIcon(IMAGE_CHANNEL));
|
||||
|
||||
std::list<RsGroupMetaData> grp_metas ;
|
||||
channelDialog->getGroupList(grp_metas) ;
|
||||
|
||||
for(auto it(grp_metas.begin());it!=grp_metas.end();++it)
|
||||
if(IS_GROUP_PUBLISHER((*it).mSubscribeFlags))
|
||||
shareChannelMenu.addAction(QString::fromUtf8((*it).mGroupName.c_str()), this, SLOT(shareOnChannel()))->setData(QString::fromStdString((*it).mGroupId.toStdString())) ;
|
||||
|
||||
contextMnu.addMenu(&shareChannelMenu) ;
|
||||
contextMnu.exec(QCursor::pos()) ; // added here because the shareChannelMenu QMenu object is deleted afterwards
|
||||
}
|
||||
else
|
||||
contextMnu.exec(QCursor::pos()) ;
|
||||
}
|
||||
|
||||
void LocalSharedFilesDialog::shareOnChannel()
|
||||
{
|
||||
RsGxsGroupId groupId(qobject_cast<QAction*>(sender())->data().toString().toStdString());
|
||||
|
||||
GxsChannelDialog *channelDialog = dynamic_cast<GxsChannelDialog*>(MainWindow::getPage(MainWindow::Channels));
|
||||
|
||||
if(channelDialog == 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) ;
|
||||
|
||||
channelDialog->shareOnChannel(groupId,file_links_list) ;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue