1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-10 14:57:52 +00:00

- Fixed selected states of files when .pieces file doesn't exist

This commit is contained in:
Christophe Dumez 2006-10-10 21:44:59 +00:00
parent 94eb12e6a1
commit d16d30a350
2 changed files with 17 additions and 0 deletions

View File

@ -154,8 +154,11 @@ void properties::loadFilteredFiles(){
QString fileName = QString(torrentInfo.name().c_str());
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileName+".pieces");
has_filtered_files = false;
qDebug("Loading filtered state of files");
// Read saved file
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){
qDebug("Could not find pieces file");
setAllPiecesState(true);
selectionBitmask.assign(torrentInfo.num_files(), 0);
return;
}
@ -164,6 +167,7 @@ void properties::loadFilteredFiles(){
QList<QByteArray> pieces_selection_list = pieces_selection.split('\n');
if(pieces_selection_list.size() != torrentInfo.num_files()+1){
std::cout << "Error: Corrupted pieces file\n";
setAllPiecesState(true);
selectionBitmask.assign(torrentInfo.num_files(), 0);
return;
}
@ -200,6 +204,18 @@ void properties::setRowColor(int row, QString color){
}
}
void properties::setAllPiecesState(bool selected){
torrent_info torrentInfo = h.get_torrent_info();
for(int i=0; i<torrentInfo.num_files(); ++i){
if(selected){
setRowColor(i, "green");
}else{
setRowColor(i, "red");
}
PropListModel->setData(PropListModel->index(i, SELECTED), QVariant(selected));
}
}
// Toggle the selected state of a file within the torrent when we
// double click on it.
void properties::toggleSelectedState(const QModelIndex& index){

View File

@ -51,6 +51,7 @@ class properties : public QDialog, private Ui::properties{
void saveFilteredFiles();
void updateProgress();
void loadFilteredFiles();
void setAllPiecesState(bool selected);
signals:
void changedFilteredFiles(torrent_handle h, bool compact_mode);