- In torrent content selection, check if all files are filtered before saving and display an error if it is the case. I removed this checking on right click menu in case people want to filter all torrents, then add one, then save.

This commit is contained in:
Christophe Dumez 2007-09-03 22:52:58 +00:00
parent 913f93ba82
commit 54516ac231
4 changed files with 25 additions and 60 deletions

1
TODO
View file

@ -109,6 +109,7 @@ beta6->beta7 changelog:
- FEATURE: Allow to drag'n drop plugin to list for install/update - FEATURE: Allow to drag'n drop plugin to list for install/update
- FEATURE: Added some search plugins to http://plugins.qbittorrent.org - FEATURE: Added some search plugins to http://plugins.qbittorrent.org
- FEATURE: Added zip support in search plugins manager (can put .py & .png inside) - FEATURE: Added zip support in search plugins manager (can put .py & .png inside)
- BUGFIX: In torrent content, it is now easier to filter all torrents using right click menu
- BUGFIX: Updated man page / README / INSTALL - BUGFIX: Updated man page / README / INSTALL
- BUGFIX: Paused torrents could be displayed as connected for a sec after checking - BUGFIX: Paused torrents could be displayed as connected for a sec after checking
- BUGFIX: 'Unknown' is now displayed in search results columns where value is -1 - BUGFIX: 'Unknown' is now displayed in search results columns where value is -1

View file

@ -187,27 +187,13 @@ void properties::loadPiecesPriorities(){
} }
} }
bool properties::onlyOneItem() const { bool properties::allFiltered() const {
unsigned int nbRows = PropListModel->rowCount(); unsigned int nbRows = PropListModel->rowCount();
if(nbRows == 1) return true;
unsigned int nb_unfiltered = 0;
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedIndexes();
QModelIndex index;
unsigned int to_be_filtered = 0;
foreach(index, selectedIndexes){
if(index.column() == PRIORITY){
if(index.data().toInt() != IGNORED)
++to_be_filtered;
}
}
for(unsigned int i=0; i<nbRows; ++i){ for(unsigned int i=0; i<nbRows; ++i){
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED){ if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED)
++nb_unfiltered; return false;
}
} }
if(nb_unfiltered-to_be_filtered == 0) return true;
return true;
return false;
} }
void properties::displayFilesListMenu(const QPoint& pos){ void properties::displayFilesListMenu(const QPoint& pos){
@ -218,8 +204,7 @@ void properties::displayFilesListMenu(const QPoint& pos){
// Enable/disable pause/start action given the DL state // Enable/disable pause/start action given the DL state
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = filesList->selectionModel()->selectedIndexes();
myFilesLlistMenu.setTitle(tr("Priority")); myFilesLlistMenu.setTitle(tr("Priority"));
if(!onlyOneItem()) myFilesLlistMenu.addAction(actionIgnored);
myFilesLlistMenu.addAction(actionIgnored);
myFilesLlistMenu.addAction(actionNormal); myFilesLlistMenu.addAction(actionNormal);
myFilesLlistMenu.addAction(actionHigh); myFilesLlistMenu.addAction(actionHigh);
myFilesLlistMenu.addAction(actionMaximum); myFilesLlistMenu.addAction(actionMaximum);
@ -525,8 +510,8 @@ void properties::on_incrementalDownload_stateChanged(int){
} }
void properties::on_okButton_clicked(){ void properties::on_okButton_clicked(){
savePiecesPriorities(); if(savePiecesPriorities())
close(); close();
} }
void properties::loadWebSeedsFromFile(){ void properties::loadWebSeedsFromFile(){
@ -566,8 +551,12 @@ void properties::saveWebSeeds(){
qDebug("url seeds were saved"); qDebug("url seeds were saved");
} }
void properties::savePiecesPriorities(){ bool properties::savePiecesPriorities() {
if(!changedFilteredfiles) return; if(!changedFilteredfiles) return true;
if(allFiltered()) {
QMessageBox::warning(0, tr("Priorities error"), tr("Error, you can't filter all the files in a torrent."));
return false;
}
qDebug("Saving pieces priorities"); qDebug("Saving pieces priorities");
bool hasFilteredFiles = false; bool hasFilteredFiles = false;
QString fileName = h.name(); QString fileName = h.name();
@ -577,7 +566,7 @@ void properties::savePiecesPriorities(){
// Write new files // Write new files
if(!pieces_file.open(QIODevice::WriteOnly | QIODevice::Text)){ if(!pieces_file.open(QIODevice::WriteOnly | QIODevice::Text)){
std::cerr << "Error: Could not save pieces priorities\n"; std::cerr << "Error: Could not save pieces priorities\n";
return; return true;
} }
unsigned int nbRows = PropListModel->rowCount(); unsigned int nbRows = PropListModel->rowCount();
for(unsigned int i=0; i<nbRows; ++i){ for(unsigned int i=0; i<nbRows; ++i){
@ -597,4 +586,5 @@ void properties::savePiecesPriorities(){
} }
emit filteredFilesChanged(hash); emit filteredFilesChanged(hash);
has_filtered_files = hasFilteredFiles; has_filtered_files = hasFilteredFiles;
return true;
} }

View file

@ -49,7 +49,6 @@ class properties : public QDialog, private Ui::properties{
void on_okButton_clicked(); void on_okButton_clicked();
void on_incrementalDownload_stateChanged(int); void on_incrementalDownload_stateChanged(int);
void setRowColor(int row, QString color); void setRowColor(int row, QString color);
void savePiecesPriorities();
void updateInfos(); void updateInfos();
void loadPiecesPriorities(); void loadPiecesPriorities();
void setAllPiecesState(unsigned short priority); void setAllPiecesState(unsigned short priority);
@ -78,7 +77,8 @@ class properties : public QDialog, private Ui::properties{
// Constructor // Constructor
properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h); properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h);
~properties(); ~properties();
bool onlyOneItem() const; bool allFiltered() const;
bool savePiecesPriorities();
}; };
#endif #endif

View file

@ -178,27 +178,14 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
} }
} }
bool onlyOneItem() const { bool allFiltered() const {
unsigned int nbRows = PropListModel->rowCount(); unsigned int nbRows = PropListModel->rowCount();
if(nbRows == 1) return true; if(nbRows == 1) return true;
unsigned int nb_unfiltered = 0;
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
QModelIndex index;
unsigned int to_be_filtered = 0;
foreach(index, selectedIndexes){
if(index.column() == PRIORITY){
if(index.data().toInt() != IGNORED)
++to_be_filtered;
}
}
for(unsigned int i=0; i<nbRows; ++i){ for(unsigned int i=0; i<nbRows; ++i){
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED){ if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED)
++nb_unfiltered; return false;
}
} }
if(nb_unfiltered-to_be_filtered == 0) return true;
return true;
return false;
} }
void displayFilesListMenu(const QPoint& pos){ void displayFilesListMenu(const QPoint& pos){
@ -209,8 +196,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
// Enable/disable pause/start action given the DL state // Enable/disable pause/start action given the DL state
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
myFilesLlistMenu.setTitle(tr("Priority")); myFilesLlistMenu.setTitle(tr("Priority"));
if(!onlyOneItem()) myFilesLlistMenu.addAction(actionIgnored);
myFilesLlistMenu.addAction(actionIgnored);
myFilesLlistMenu.addAction(actionNormal); myFilesLlistMenu.addAction(actionNormal);
myFilesLlistMenu.addAction(actionHigh); myFilesLlistMenu.addAction(actionHigh);
myFilesLlistMenu.addAction(actionMaximum); myFilesLlistMenu.addAction(actionMaximum);
@ -328,8 +314,8 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
QFile::remove(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused")); QFile::remove(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".paused"));
} }
// Check if there is at least one selected file // Check if there is at least one selected file
if(!hasSelectedFiles()){ if(allFiltered()){
QMessageBox::critical(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent")); QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
return; return;
} }
// save filtered files // save filtered files
@ -338,18 +324,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
emit torrentAddition(filePath, fromScanDir, from_url); emit torrentAddition(filePath, fromScanDir, from_url);
close(); close();
} }
bool hasSelectedFiles(){
unsigned int nbRows = PropListModel->rowCount();
for(unsigned int i=0; i<nbRows; ++i){
QStandardItem *item = PropListModel->item(i, PRIORITY);
unsigned short priority = item->text().toInt();
if(priority) {
return true;
}
}
return false;
}
}; };
#endif #endif