mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-23 22:49:37 -05:00
make possible to download an entire found directory from search dialog
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1684 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d59e85efa5
commit
b715d07708
@ -230,7 +230,6 @@ void SearchDialog::searchtableWidgetCostumPopupMenu( QPoint point )
|
|||||||
contextMnu->exec( mevent->globalPos() );
|
contextMnu->exec( mevent->globalPos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SearchDialog::download()
|
void SearchDialog::download()
|
||||||
{
|
{
|
||||||
/* should also be able to handle multi-selection */
|
/* should also be able to handle multi-selection */
|
||||||
@ -244,6 +243,7 @@ void SearchDialog::download()
|
|||||||
// call the download
|
// call the download
|
||||||
if (item->text(SR_ID_COL) != "Local")
|
if (item->text(SR_ID_COL) != "Local")
|
||||||
{
|
{
|
||||||
|
if (!item->childCount()) {
|
||||||
std::cerr << "SearchDialog::download() Calling File Request";
|
std::cerr << "SearchDialog::download() Calling File Request";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
std::list<std::string> srcIds;
|
std::list<std::string> srcIds;
|
||||||
@ -257,6 +257,10 @@ void SearchDialog::download()
|
|||||||
std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << (item->text(SR_HASH_COL)).toStdString() << "-" << (item->text(SR_REALSIZE_COL)).toInt() << "-ids=" ;
|
std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << (item->text(SR_HASH_COL)).toStdString() << "-" << (item->text(SR_REALSIZE_COL)).toInt() << "-ids=" ;
|
||||||
for(std::list<std::string>::const_iterator it(srcIds.begin());it!=srcIds.end();++it)
|
for(std::list<std::string>::const_iterator it(srcIds.begin());it!=srcIds.end();++it)
|
||||||
std::cout << *it << "-" << std::endl ;
|
std::cout << *it << "-" << std::endl ;
|
||||||
|
} else {
|
||||||
|
// we have a folder
|
||||||
|
downloadDirectory(item, tr(""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -269,6 +273,53 @@ void SearchDialog::download()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString &base)
|
||||||
|
{
|
||||||
|
if (!item->childCount()) {
|
||||||
|
std::list<std::string> srcIds;
|
||||||
|
srcIds.push_back(item->text(SR_UID_COL).toStdString());
|
||||||
|
|
||||||
|
QString path = QString::fromStdString(rsFiles->getDownloadDirectory())
|
||||||
|
+ tr("/") + base + tr("/");
|
||||||
|
QString cleanPath = QDir::cleanPath(path);
|
||||||
|
|
||||||
|
rsFiles->FileRequest(item->text(SR_NAME_COL).toStdString(),
|
||||||
|
item->text(SR_HASH_COL).toStdString(),
|
||||||
|
item->text(SR_REALSIZE_COL).toInt(),
|
||||||
|
cleanPath.toStdString(), 0, srcIds);
|
||||||
|
|
||||||
|
std::cout << "SearchDialog::downloadDirectory(): "\
|
||||||
|
"issuing file request from search dialog: -"
|
||||||
|
<< (item->text(SR_NAME_COL)).toStdString()
|
||||||
|
<< "-" << (item->text(SR_HASH_COL)).toStdString()
|
||||||
|
<< "-" << (item->text(SR_REALSIZE_COL)).toInt()
|
||||||
|
<< "-ids=" ;
|
||||||
|
for(std::list<std::string>::const_iterator it(srcIds.begin());
|
||||||
|
it!=srcIds.end();++it)
|
||||||
|
std::cout << *it << "-" << std::endl ;
|
||||||
|
} else {
|
||||||
|
QDir dwlDir(QString::fromStdString(rsFiles->getDownloadDirectory()));
|
||||||
|
QString path;
|
||||||
|
if (base == tr(""))
|
||||||
|
path = item->text(SR_NAME_COL);
|
||||||
|
else
|
||||||
|
path = base + tr("/") + item->text(SR_NAME_COL);
|
||||||
|
QString cleanPath = QDir::cleanPath(path);
|
||||||
|
|
||||||
|
// create this folder in download path
|
||||||
|
if (!dwlDir.mkpath(cleanPath)) {
|
||||||
|
std::cerr << "SearchDialog::downloadDirectory() - can't create "
|
||||||
|
<< cleanPath.toStdString() << " directory" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// recursive call for every child - file or folder
|
||||||
|
for (int i = 0, cnt = item->childCount(); i < cnt; i++) {
|
||||||
|
QTreeWidgetItem *child = item->child(i);
|
||||||
|
downloadDirectory(child, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SearchDialog::broadcastonchannel()
|
void SearchDialog::broadcastonchannel()
|
||||||
{
|
{
|
||||||
|
@ -91,6 +91,7 @@ private:
|
|||||||
void insertFile(const std::string& txt,qulonglong searchId, const FileDetail& file) ;
|
void insertFile(const std::string& txt,qulonglong searchId, const FileDetail& file) ;
|
||||||
void insertDirectory(const std::string &txt, qulonglong searchId, const DirDetails &dir, QTreeWidgetItem *item);
|
void insertDirectory(const std::string &txt, qulonglong searchId, const DirDetails &dir, QTreeWidgetItem *item);
|
||||||
void setIconAndType(QTreeWidgetItem *item, QString &ext);
|
void setIconAndType(QTreeWidgetItem *item, QString &ext);
|
||||||
|
void downloadDirectory(const QTreeWidgetItem *item, const QString &base);
|
||||||
|
|
||||||
|
|
||||||
/** the advanced search dialog instance */
|
/** the advanced search dialog instance */
|
||||||
|
Loading…
Reference in New Issue
Block a user