Merge pull request #2618 from csoler/v0.6-BugFixing_19

fixed copy RS link in search dialog when clicking on a file with multiple names
This commit is contained in:
csoler 2022-05-11 20:42:45 +02:00 committed by GitHub
commit 83b7c21f5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1455,32 +1455,39 @@ void SearchDialog::copyResultLink()
{
/* should also be able to handle multi-selection */
QList<QTreeWidgetItem*> itemsForCopy = ui.searchResultWidget->selectedItems();
int numdls = itemsForCopy.size();
QTreeWidgetItem * item;
QList<RetroShareLink> urls ;
std::map<RsFileHash,RetroShareLink> url_map;
for (int i = 0; i < numdls; ++i)
for (auto item:itemsForCopy)
{
item = itemsForCopy.at(i);
// call copy
if (!item->childCount())
QString fhash = item->text(SR_HASH_COL);
RsFileHash hash(fhash.toStdString());
if(!hash.isNull())
{
std::cerr << "SearchDialog::copyResultLink() Calling set retroshare link";
std::cerr << std::endl;
QString fhash = item->text(SR_HASH_COL);
qulonglong fsize = item->text(SR_SIZE_COL).toULongLong();
QString fname = item->text(SR_NAME_COL);
RetroShareLink link = RetroShareLink::createFile(fname, fsize, fhash);
if (link.valid()) {
std::cerr << "new link added to clipboard: " << link.toString().toStdString() << std::endl ;
urls.push_back(link) ;
if (link.valid())
url_map[hash] = link;
}
}
QList<RetroShareLink> urls ;
for(auto link:url_map)
{
std::cerr << "new link added to clipboard: " << link.second.toString().toStdString() << std::endl ;
urls.push_back(link.second);
}
RSLinkClipboard::copyLinks(urls) ;
}