Browse Source

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

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
d16d30a350
  1. 16
      src/properties_imp.cpp
  2. 1
      src/properties_imp.h

16
src/properties_imp.cpp

@ -154,8 +154,11 @@ void properties::loadFilteredFiles(){ @@ -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(){ @@ -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){ @@ -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){

1
src/properties_imp.h

@ -51,6 +51,7 @@ class properties : public QDialog, private Ui::properties{ @@ -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);

Loading…
Cancel
Save