added a warning and skip files with missing hash in copy link

This commit is contained in:
csoler 2017-01-15 21:13:27 +01:00
parent f314e7d330
commit e7a119f22c
4 changed files with 18 additions and 36 deletions

View File

@ -1010,16 +1010,6 @@ void RetroshareDirModel::postMods()
beginResetModel();
#endif
// QModelIndexList piList = persistentIndexList();
// QModelIndexList empty;
// for (int i = 0; i < piList.size(); ++i) {
// empty.append(QModelIndex());
// }
// changePersistentIndexList(piList, empty);
/* Clear caches */
//mCache.clear();
#ifdef RDM_DEBUG
std::cerr << "RetroshareDirModel::postMods()" << std::endl;
#endif
@ -1059,30 +1049,6 @@ bool RetroshareDirModel::requestDirDetails(void *ref, bool remote,DirDetails& d)
return false ;
}
// const QMap<void*, DirDetailsVector>::const_iterator it = mCache.constFind(ref);
// if (it != mCache.constEnd()) {
// /* Details found in cache */
// return &it.value();
// }
//
//#warning this is terrible! A vector in a std::map will keep being copied and create a lot of CPU overload. Use a pointer instead.
// /* Get details from the lib */
//
// if (rsFiles->RequestDirDetails(ref, details, flags)) {
// /* Convert std::list to std::vector for fast access with index */
// std::list<DirStub>::const_iterator childIt;
// for (childIt = details.children.begin(); childIt != details.children.end(); ++childIt) {
// details.childrenVector.push_back(*childIt);
// }
//
// /* Add to cache, must cast to none const */
// const QMap<void*, DirDetailsVector>::iterator it1 = ((QMap<void*, DirDetailsVector>*) &mCache)->insert(ref, details);
// return &it1.value();
// }
//
// /* No details found */
// return NULL;
//}
void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndexList &list)
{

View File

@ -146,7 +146,6 @@ class RetroshareDirModel : public QAbstractItemModel
};
bool RemoteMode;
QMap<void*, DirDetailsVector> mCache;
mutable int nIndex;
mutable std::vector<RemoteIndex> indexSet;

View File

@ -27,6 +27,7 @@
#include <QMenu>
#include <QPainter>
#include <QProcess>
#include <QMessageBox>
#include <QSortFilterProxyModel>
#include <QStyledItemDelegate>
@ -583,6 +584,8 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
QList<RetroShareLink> urls ;
bool has_unhashed_files = false;
for (int i = 0, n = dirVec.size(); i < n; ++i)
{
const DirDetails& details = dirVec[i];
@ -600,6 +603,12 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
if (!rsFiles->RequestDirDetails(dirStub.ref, details, flags) || details.type != DIR_TYPE_FILE)
continue;
if(details.hash.isNull())
{
has_unhashed_files = true;
continue;
}
RetroShareLink link;
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
urls.push_back(link) ;
@ -608,6 +617,11 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
}
else
{
if(details.hash.isNull())
{
has_unhashed_files = true;
continue;
}
RetroShareLink link;
if (link.createFile(QString::fromUtf8(details.name.c_str()), details.count, details.hash.toStdString().c_str())) {
urls.push_back(link) ;
@ -615,6 +629,9 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
}
}
RSLinkClipboard::copyLinks(urls) ;
if(has_unhashed_files)
QMessageBox::warning(NULL,tr("Some files have been omitted"),tr("Some files have been ommitted because their hash is not available yet.")) ;
}
void SharedFilesDialog::copyLink()

View File

@ -277,7 +277,7 @@ void ChatLobbyDialog::voteParticipant()
return ;
}
RsReputations::Opinion op(act->data().toUInt()) ;
RsReputations::Opinion op = RsReputations::Opinion(act->data().toUInt()) ;
for (item = selectedItems.begin(); item != selectedItems.end(); ++item)
{