mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-01 19:06:20 -05:00
download of whole directory from gui
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1387 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8a1ae827b9
commit
48df36f6d0
@ -765,11 +765,46 @@ void RemoteDirModel::downloadSelected(QModelIndexList list)
|
||||
/* if it is a dir, copy all files included*/
|
||||
else if (details.type == DIR_TYPE_DIR)
|
||||
{
|
||||
|
||||
size_t prefixLen = details.path.rfind(details.name);
|
||||
if (prefixLen < 0) continue;
|
||||
downloadDirectory(details, prefixLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* recursively download a directory */
|
||||
void RemoteDirModel::downloadDirectory(const DirDetails & dirDetails, int prefixLen)
|
||||
{
|
||||
if (dirDetails.type & DIR_TYPE_FILE)
|
||||
{
|
||||
std::list<std::string> srcIds;
|
||||
QString cleanPath = QDir::cleanPath((rsFiles->getDownloadDirectory() + "/" + dirDetails.path.substr(prefixLen)).c_str());
|
||||
|
||||
srcIds.push_back(dirDetails.id);
|
||||
rsFiles->FileRequest(dirDetails.name, dirDetails.hash, dirDetails.count, cleanPath.toStdString(), 0, srcIds);
|
||||
}
|
||||
else if (dirDetails.type & DIR_TYPE_DIR)
|
||||
{
|
||||
std::list<DirStub>::const_iterator it;
|
||||
QDir dwlDir(rsFiles->getDownloadDirectory().c_str());
|
||||
QString cleanPath = QDir::cleanPath(QString(dirDetails.path.c_str()).right(dirDetails.path.length() - prefixLen));
|
||||
|
||||
if (!dwlDir.mkpath(cleanPath)) return;
|
||||
|
||||
for (it = dirDetails.children.begin(); it != dirDetails.children.end(); it++)
|
||||
{
|
||||
if (!it->ref) continue;
|
||||
|
||||
DirDetails subDirDetails;
|
||||
uint32_t flags = DIR_FLAGS_CHILDREN | DIR_FLAGS_REMOTE;
|
||||
|
||||
if (!rsFiles->RequestDirDetails(it->ref, subDirDetails, flags)) continue;
|
||||
|
||||
downloadDirectory(subDirDetails, prefixLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteDirModel::getDirDetailsFromSelect (QModelIndexList list, std::vector <DirDetails>& dirVec)
|
||||
{
|
||||
dirVec.clear();
|
||||
|
@ -69,6 +69,7 @@ virtual QStringList mimeTypes () const;
|
||||
private:
|
||||
void update (const QModelIndex &index );
|
||||
void treeStyle();
|
||||
void downloadDirectory(const DirDetails & details, int prefixLen);
|
||||
|
||||
QIcon categoryIcon;
|
||||
QIcon peerIcon;
|
||||
|
Loading…
Reference in New Issue
Block a user