Merge pull request #1186 from csoler/v0.6-FT

V0.6 ft
This commit is contained in:
csoler 2018-02-20 21:08:09 +01:00 committed by GitHub
commit 4d7997b2ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,7 +139,7 @@ public:
if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size() || source_id > -1) if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size() || source_id > -1)
return false ; return false ;
return !mDownloads[entry].peers.empty(); // costly return !mDownloads[entry].peers.empty();
} }
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const
@ -242,12 +242,12 @@ public:
int source_id=0 ; int source_id=0 ;
if(!ref) if(!ref)
return false ; return QVariant() ;
if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size()) if(!convertRefPointerToTabEntry(ref,entry,source_id) || entry >= mDownloads.size())
{ {
std::cerr << "Bad pointer: " << (void*)ref << std::endl; std::cerr << "Bad pointer: " << (void*)ref << std::endl;
return false ; return QVariant() ;
} }
const FileInfo& finfo(mDownloads[entry]) ; const FileInfo& finfo(mDownloads[entry]) ;
@ -549,13 +549,13 @@ public:
if(old_size < mDownloads.size()) if(old_size < mDownloads.size())
{ {
beginInsertRows(QModelIndex(), old_size, mDownloads.size()); beginInsertRows(QModelIndex(), old_size, mDownloads.size()-1);
insertRows(old_size, mDownloads.size() - old_size); insertRows(old_size, mDownloads.size() - old_size);
endInsertRows(); endInsertRows();
} }
else if(mDownloads.size() < old_size) else if(mDownloads.size() < old_size)
{ {
beginRemoveRows(QModelIndex(), mDownloads.size(), old_size); beginRemoveRows(QModelIndex(), mDownloads.size(), old_size-1);
removeRows(old_size, old_size - mDownloads.size()); removeRows(old_size, old_size - mDownloads.size());
endRemoveRows(); endRemoveRows();
} }
@ -572,7 +572,7 @@ public:
// endResetModel(); // endResetModel();
QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(mDownloads.size(), COLUMN_COUNT-1); QModelIndex topLeft = createIndex(0,0), bottomRight = createIndex(mDownloads.size()-1, COLUMN_COUNT-1);
emit dataChanged(topLeft, bottomRight); emit dataChanged(topLeft, bottomRight);
//shit code follow (rewrite this please) //shit code follow (rewrite this please)