mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #1107 from csoler/v0.6-Links2
fixed bug causing RsCollection to fail on remote files. Now using RsC…
This commit is contained in:
commit
45c8e9ea96
@ -445,10 +445,10 @@ void SearchDialog::collCreate()
|
|||||||
details.type = DIR_TYPE_FILE;
|
details.type = DIR_TYPE_FILE;
|
||||||
|
|
||||||
dirVec.push_back(details);
|
dirVec.push_back(details);
|
||||||
}//if (!item->text(SR_HASH_COL).isEmpty())
|
}
|
||||||
}//for (int i = 0; i < numdls; ++i)
|
}
|
||||||
|
|
||||||
RsCollection(dirVec).openNewColl(this);
|
RsCollection(dirVec,RS_FILE_HINTS_LOCAL).openNewColl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchDialog::collModif()
|
void SearchDialog::collModif()
|
||||||
|
@ -509,9 +509,18 @@ void RemoteSharedFilesDialog::spawnCustomPopupMenu( QPoint point )
|
|||||||
collectionMenu.addAction(collCreateAct);
|
collectionMenu.addAction(collCreateAct);
|
||||||
collectionMenu.addAction(collOpenAct);
|
collectionMenu.addAction(collOpenAct);
|
||||||
|
|
||||||
|
if(type == DIR_TYPE_DIR)
|
||||||
|
{
|
||||||
|
QAction *downloadActI = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download..." ), &contextMnu ) ;
|
||||||
|
connect( downloadActI , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelectedInteractive() ) ) ;
|
||||||
|
contextMnu.addAction( downloadActI) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu ) ;
|
QAction *downloadAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Download" ), &contextMnu ) ;
|
||||||
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
connect( downloadAct , SIGNAL( triggered() ), this, SLOT( downloadRemoteSelected() ) ) ;
|
||||||
contextMnu.addAction( downloadAct) ;
|
contextMnu.addAction( downloadAct) ;
|
||||||
|
}
|
||||||
|
|
||||||
contextMnu.addSeparator() ;//------------------------------------
|
contextMnu.addSeparator() ;//------------------------------------
|
||||||
contextMnu.addAction( copylinkAct) ;
|
contextMnu.addAction( copylinkAct) ;
|
||||||
@ -545,7 +554,16 @@ void RemoteSharedFilesDialog::expanded(const QModelIndex& indx)
|
|||||||
|
|
||||||
model->updateRef(proxyModel->mapToSource(indx)) ;
|
model->updateRef(proxyModel->mapToSource(indx)) ;
|
||||||
}
|
}
|
||||||
|
void RemoteSharedFilesDialog::downloadRemoteSelectedInteractive()
|
||||||
|
{
|
||||||
|
/* call back to the model (which does all the interfacing? */
|
||||||
|
|
||||||
|
std::cerr << "Downloading Files" ;
|
||||||
|
std::cerr << std::endl ;
|
||||||
|
|
||||||
|
QModelIndexList lst = getSelected() ;
|
||||||
|
model -> downloadSelected(lst,true) ;
|
||||||
|
}
|
||||||
void RemoteSharedFilesDialog::downloadRemoteSelected()
|
void RemoteSharedFilesDialog::downloadRemoteSelected()
|
||||||
{
|
{
|
||||||
/* call back to the model (which does all the interfacing? */
|
/* call back to the model (which does all the interfacing? */
|
||||||
@ -554,7 +572,7 @@ void RemoteSharedFilesDialog::downloadRemoteSelected()
|
|||||||
std::cerr << std::endl ;
|
std::cerr << std::endl ;
|
||||||
|
|
||||||
QModelIndexList lst = getSelected() ;
|
QModelIndexList lst = getSelected() ;
|
||||||
model -> downloadSelected(lst) ;
|
model -> downloadSelected(lst,false) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList<RetroShareLink>& urls,bool& has_unhashed_files)
|
void SharedFilesDialog::copyLinks(const QModelIndexList& lst, bool remote,QList<RetroShareLink>& urls,bool& has_unhashed_files)
|
||||||
|
@ -187,6 +187,7 @@ class RemoteSharedFilesDialog : public SharedFilesDialog
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void downloadRemoteSelected();
|
void downloadRemoteSelected();
|
||||||
|
void downloadRemoteSelectedInteractive();
|
||||||
void expanded(const QModelIndex& indx);
|
void expanded(const QModelIndex& indx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2133,7 +2133,8 @@ void TransfersDialog::collCreate()
|
|||||||
std::set<RsFileHash>::iterator it ;
|
std::set<RsFileHash>::iterator it ;
|
||||||
getDLSelectedItems(&items, NULL);
|
getDLSelectedItems(&items, NULL);
|
||||||
|
|
||||||
for (it = items.begin(); it != items.end(); ++it) {
|
for (it = items.begin(); it != items.end(); ++it)
|
||||||
|
{
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
|
|
||||||
@ -2144,9 +2145,9 @@ void TransfersDialog::collCreate()
|
|||||||
details.type = DIR_TYPE_FILE;
|
details.type = DIR_TYPE_FILE;
|
||||||
|
|
||||||
dirVec.push_back(details);
|
dirVec.push_back(details);
|
||||||
}//for (it = items.begin();
|
}
|
||||||
|
|
||||||
RsCollection(dirVec).openNewColl(this);
|
RsCollection(dirVec,RS_FILE_HINTS_LOCAL).openNewColl(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::collModif()
|
void TransfersDialog::collModif()
|
||||||
|
@ -1027,12 +1027,12 @@ void MainWindow::addFriend()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** New RSCollection ShortCut */
|
/** New RSCollection ShortCut */
|
||||||
void MainWindow::newRsCollection()
|
// void MainWindow::newRsCollection()
|
||||||
{
|
// {
|
||||||
std::vector <DirDetails> dirVec;
|
// std::vector <DirDetails> dirVec;
|
||||||
|
//
|
||||||
RsCollection(dirVec).openNewColl(this);
|
// RsCollection(dirVec).openNewColl(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/** Shows Share Manager */
|
/** Shows Share Manager */
|
||||||
void MainWindow::openShareManager()
|
void MainWindow::openShareManager()
|
||||||
|
@ -223,7 +223,7 @@ private slots:
|
|||||||
|
|
||||||
/** Toolbar fns. */
|
/** Toolbar fns. */
|
||||||
void addFriend();
|
void addFriend();
|
||||||
void newRsCollection();
|
//void newRsCollection();
|
||||||
void showMessengerWindow();
|
void showMessengerWindow();
|
||||||
void showStatisticsWindow();
|
void showStatisticsWindow();
|
||||||
#ifdef ENABLE_WEBUI
|
#ifdef ENABLE_WEBUI
|
||||||
|
@ -1065,10 +1065,12 @@ void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndex
|
|||||||
std::vector <DirDetails> dirVec;
|
std::vector <DirDetails> dirVec;
|
||||||
getDirDetailsFromSelect(list, dirVec);
|
getDirDetailsFromSelect(list, dirVec);
|
||||||
|
|
||||||
RsCollection(dirVec).openNewColl(parent);
|
FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
||||||
|
|
||||||
|
RsCollection(dirVec,f).openNewColl(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
void RetroshareDirModel::downloadSelected(const QModelIndexList &list,bool interactive)
|
||||||
{
|
{
|
||||||
if (!RemoteMode)
|
if (!RemoteMode)
|
||||||
{
|
{
|
||||||
@ -1085,8 +1087,11 @@ void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
|||||||
std::vector <DirDetails> dirVec;
|
std::vector <DirDetails> dirVec;
|
||||||
|
|
||||||
getDirDetailsFromSelect(list, dirVec);
|
getDirDetailsFromSelect(list, dirVec);
|
||||||
|
FileSearchFlags f = RemoteMode?RS_FILE_HINTS_REMOTE:RS_FILE_HINTS_LOCAL ;
|
||||||
|
|
||||||
/* Fire off requests */
|
if(interactive)
|
||||||
|
RsCollection(dirVec,f).downloadFiles() ;
|
||||||
|
else /* Fire off requests */
|
||||||
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
for (int i = 0, n = dirVec.size(); i < n; ++i)
|
||||||
{
|
{
|
||||||
if (!RemoteMode)
|
if (!RemoteMode)
|
||||||
|
@ -63,7 +63,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||||||
bool visible() { return _visible ;}
|
bool visible() { return _visible ;}
|
||||||
|
|
||||||
/* Callback from GUI */
|
/* Callback from GUI */
|
||||||
void downloadSelected(const QModelIndexList &list);
|
void downloadSelected(const QModelIndexList &list, bool interactive);
|
||||||
void createCollectionFile(QWidget *parent, const QModelIndexList &list);
|
void createCollectionFile(QWidget *parent, const QModelIndexList &list);
|
||||||
|
|
||||||
void getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec);
|
void getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec);
|
||||||
|
@ -56,14 +56,20 @@ RsCollection::RsCollection(const FileTree& fr)
|
|||||||
recursAddElements(_xml_doc,fr,0,_root) ;
|
recursAddElements(_xml_doc,fr,0,_root) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsCollection::RsCollection(const std::vector<DirDetails>& file_infos, QObject *parent)
|
RsCollection::RsCollection(const std::vector<DirDetails>& file_infos,FileSearchFlags flags, QObject *parent)
|
||||||
: QObject(parent), _xml_doc("RsCollection")
|
: QObject(parent), _xml_doc("RsCollection")
|
||||||
{
|
{
|
||||||
_root = _xml_doc.createElement("RsCollection");
|
_root = _xml_doc.createElement("RsCollection");
|
||||||
_xml_doc.appendChild(_root);
|
_xml_doc.appendChild(_root);
|
||||||
|
|
||||||
|
if(! ( (flags & RS_FILE_HINTS_LOCAL) || (flags & RS_FILE_HINTS_REMOTE)))
|
||||||
|
{
|
||||||
|
std::cerr << "(EE) Wrong flags passed to RsCollection constructor. Please fix the code!" << std::endl;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
for(uint32_t i = 0;i<file_infos.size();++i)
|
for(uint32_t i = 0;i<file_infos.size();++i)
|
||||||
recursAddElements(_xml_doc,file_infos[i],_root) ;
|
recursAddElements(_xml_doc,file_infos[i],_root,flags) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsCollection::~RsCollection()
|
RsCollection::~RsCollection()
|
||||||
@ -170,7 +176,7 @@ void RsCollection::recursCollectColFileInfos(const QDomElement& e,std::vector<Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RsCollection::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e) const
|
void RsCollection::recursAddElements(QDomDocument& doc,const DirDetails& details,QDomElement& e,FileSearchFlags flags) const
|
||||||
{
|
{
|
||||||
if (details.type == DIR_TYPE_FILE)
|
if (details.type == DIR_TYPE_FILE)
|
||||||
{
|
{
|
||||||
@ -194,12 +200,11 @@ void RsCollection::recursAddElements(QDomDocument& doc,const DirDetails& details
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
DirDetails subDirDetails;
|
DirDetails subDirDetails;
|
||||||
FileSearchFlags flags = RS_FILE_HINTS_LOCAL;
|
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(details.children[i].ref, subDirDetails, flags))
|
if (!rsFiles->RequestDirDetails(details.children[i].ref, subDirDetails, flags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
recursAddElements(doc,subDirDetails,d) ;
|
recursAddElements(doc,subDirDetails,d,flags) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.appendChild(d) ;
|
e.appendChild(d) ;
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
|
|
||||||
RsCollection(QObject *parent = 0) ;
|
RsCollection(QObject *parent = 0) ;
|
||||||
// create from list of files and directories
|
// create from list of files and directories
|
||||||
RsCollection(const std::vector<DirDetails>& file_entries, QObject *parent = 0) ;
|
RsCollection(const std::vector<DirDetails>& file_entries, FileSearchFlags flags, QObject *parent = 0) ;
|
||||||
RsCollection(const FileTree& fr);
|
RsCollection(const FileTree& fr);
|
||||||
virtual ~RsCollection() ;
|
virtual ~RsCollection() ;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void recursAddElements(QDomDocument&,const DirDetails&,QDomElement&) const ;
|
void recursAddElements(QDomDocument&, const DirDetails&, QDomElement&, FileSearchFlags flags) const ;
|
||||||
void recursAddElements(QDomDocument&,const ColFileInfo&,QDomElement&) const;
|
void recursAddElements(QDomDocument&,const ColFileInfo&,QDomElement&) const;
|
||||||
void recursAddElements(QDomDocument& doc,const FileTree& ft,uint32_t index,QDomElement& e) const;
|
void recursAddElements(QDomDocument& doc,const FileTree& ft,uint32_t index,QDomElement& e) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user