Optimized some small things in TransferDialog and SearchDialog.

Changed the parameter of the constructor of ftFileCreator and ftFileProvider and some methods of ftTransferModule from "std::string" to "const std::string&"

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4045 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-02-20 00:59:47 +00:00
parent 61b57ede65
commit db19db7e60
8 changed files with 40 additions and 33 deletions

View file

@ -334,16 +334,17 @@ void SearchDialog::download()
std::cerr << std::endl;
std::list<std::string> srcIds;
getSourceFriendsForHash((item->text(SR_HASH_COL)).toStdString(),srcIds) ;
std::string hash = item->text(SR_HASH_COL).toStdString();
getSourceFriendsForHash(hash,srcIds) ;
if(!rsFiles -> FileRequest((item->text(SR_NAME_COL)).toStdString(),
(item->text(SR_HASH_COL)).toStdString(),
hash,
(item->text(SR_SIZE_COL)).toULongLong(),
"", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
attemptDownloadLocal = true ;
else
{
std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << (item->text(SR_HASH_COL)).toStdString() << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ;
std::cout << "isuing file request from search dialog: -" << (item->text(SR_NAME_COL)).toStdString() << "-" << hash << "-" << (item->text(SR_SIZE_COL)).toULongLong() << "-ids=" ;
for(std::list<std::string>::const_iterator it(srcIds.begin());it!=srcIds.end();++it)
std::cout << *it << "-" << std::endl ;
}
@ -365,17 +366,19 @@ void SearchDialog::downloadDirectory(const QTreeWidgetItem *item, const QString
+ "/" + base + "/";
QString cleanPath = QDir::cleanPath(path);
getSourceFriendsForHash((item->text(SR_HASH_COL)).toStdString(),srcIds) ;
std::string hash = item->text(SR_HASH_COL).toStdString();
getSourceFriendsForHash(hash,srcIds) ;
rsFiles->FileRequest(item->text(SR_NAME_COL).toStdString(),
item->text(SR_HASH_COL).toStdString(),
hash,
item->text(SR_SIZE_COL).toULongLong(),
cleanPath.toStdString(),RS_FILE_HINTS_NETWORK_WIDE, srcIds);
std::cout << "SearchDialog::downloadDirectory(): "\
"issuing file request from search dialog: -"
<< (item->text(SR_NAME_COL)).toStdString()
<< "-" << (item->text(SR_HASH_COL)).toStdString()
<< "-" << hash
<< "-" << (item->text(SR_SIZE_COL)).toULongLong()
<< "-ids=" ;
for(std::list<std::string>::const_iterator it(srcIds.begin());

View file

@ -923,13 +923,15 @@ void TransfersDialog::insertTransfers()
//first clean the model in case some files are not download anymore
//remove items that are not fiends anymore
int removeIndex = 0;
while (removeIndex < DLListModel->rowCount())
int rowCount = DLListModel->rowCount();
while (removeIndex < rowCount)
{
std::string hash = DLListModel->item(removeIndex, ID)->data(Qt::DisplayRole).toString().toStdString();
if(used_hashes.find(hash) == used_hashes.end())
if(used_hashes.find(hash) == used_hashes.end()) {
QListDelete (DLListModel->takeRow(removeIndex));
else
rowCount = DLListModel->rowCount();
} else
removeIndex++;
}
@ -1017,14 +1019,16 @@ void TransfersDialog::insertTransfers()
//first clean the model in case some files are not download anymore
//remove items that are not fiends anymore
removeIndex = 0;
while (removeIndex < ULListModel->rowCount())
rowCount = ULListModel->rowCount();
while (removeIndex < rowCount)
{
std::string hash = ULListModel->item(removeIndex, UHASH)->data(Qt::EditRole).toString().toStdString();
std::string peer = ULListModel->item(removeIndex, UUSERID)->data(Qt::EditRole).toString().toStdString();
if(used_hashes.find(hash + peer) == used_hashes.end())
if(used_hashes.find(hash + peer) == used_hashes.end()) {
QListDelete (ULListModel->takeRow(removeIndex));
else
rowCount = ULListModel->rowCount();
} else
removeIndex++;
}