mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 19:26:59 +03:00
- 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:
parent
913f93ba82
commit
54516ac231
4 changed files with 25 additions and 60 deletions
1
TODO
1
TODO
|
@ -109,6 +109,7 @@ beta6->beta7 changelog:
|
|||
- FEATURE: Allow to drag'n drop plugin to list for install/update
|
||||
- FEATURE: Added some search plugins to http://plugins.qbittorrent.org
|
||||
- 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: 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
|
||||
|
|
|
@ -187,27 +187,13 @@ void properties::loadPiecesPriorities(){
|
|||
}
|
||||
}
|
||||
|
||||
bool properties::onlyOneItem() const {
|
||||
bool properties::allFiltered() const {
|
||||
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){
|
||||
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED){
|
||||
++nb_unfiltered;
|
||||
}
|
||||
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED)
|
||||
return false;
|
||||
}
|
||||
if(nb_unfiltered-to_be_filtered == 0)
|
||||
return true;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
||||
QModelIndexList selectedIndexes = filesList->selectionModel()->selectedIndexes();
|
||||
myFilesLlistMenu.setTitle(tr("Priority"));
|
||||
if(!onlyOneItem())
|
||||
myFilesLlistMenu.addAction(actionIgnored);
|
||||
myFilesLlistMenu.addAction(actionIgnored);
|
||||
myFilesLlistMenu.addAction(actionNormal);
|
||||
myFilesLlistMenu.addAction(actionHigh);
|
||||
myFilesLlistMenu.addAction(actionMaximum);
|
||||
|
@ -525,8 +510,8 @@ void properties::on_incrementalDownload_stateChanged(int){
|
|||
}
|
||||
|
||||
void properties::on_okButton_clicked(){
|
||||
savePiecesPriorities();
|
||||
close();
|
||||
if(savePiecesPriorities())
|
||||
close();
|
||||
}
|
||||
|
||||
void properties::loadWebSeedsFromFile(){
|
||||
|
@ -566,8 +551,12 @@ void properties::saveWebSeeds(){
|
|||
qDebug("url seeds were saved");
|
||||
}
|
||||
|
||||
void properties::savePiecesPriorities(){
|
||||
if(!changedFilteredfiles) return;
|
||||
bool properties::savePiecesPriorities() {
|
||||
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");
|
||||
bool hasFilteredFiles = false;
|
||||
QString fileName = h.name();
|
||||
|
@ -577,7 +566,7 @@ void properties::savePiecesPriorities(){
|
|||
// Write new files
|
||||
if(!pieces_file.open(QIODevice::WriteOnly | QIODevice::Text)){
|
||||
std::cerr << "Error: Could not save pieces priorities\n";
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
unsigned int nbRows = PropListModel->rowCount();
|
||||
for(unsigned int i=0; i<nbRows; ++i){
|
||||
|
@ -597,4 +586,5 @@ void properties::savePiecesPriorities(){
|
|||
}
|
||||
emit filteredFilesChanged(hash);
|
||||
has_filtered_files = hasFilteredFiles;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ class properties : public QDialog, private Ui::properties{
|
|||
void on_okButton_clicked();
|
||||
void on_incrementalDownload_stateChanged(int);
|
||||
void setRowColor(int row, QString color);
|
||||
void savePiecesPriorities();
|
||||
void updateInfos();
|
||||
void loadPiecesPriorities();
|
||||
void setAllPiecesState(unsigned short priority);
|
||||
|
@ -78,7 +77,8 @@ class properties : public QDialog, private Ui::properties{
|
|||
// Constructor
|
||||
properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h);
|
||||
~properties();
|
||||
bool onlyOneItem() const;
|
||||
bool allFiltered() const;
|
||||
bool savePiecesPriorities();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -178,27 +178,14 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||
}
|
||||
}
|
||||
|
||||
bool onlyOneItem() const {
|
||||
bool allFiltered() const {
|
||||
unsigned int nbRows = PropListModel->rowCount();
|
||||
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){
|
||||
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED){
|
||||
++nb_unfiltered;
|
||||
}
|
||||
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED)
|
||||
return false;
|
||||
}
|
||||
if(nb_unfiltered-to_be_filtered == 0)
|
||||
return true;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
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
|
||||
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
|
||||
myFilesLlistMenu.setTitle(tr("Priority"));
|
||||
if(!onlyOneItem())
|
||||
myFilesLlistMenu.addAction(actionIgnored);
|
||||
myFilesLlistMenu.addAction(actionIgnored);
|
||||
myFilesLlistMenu.addAction(actionNormal);
|
||||
myFilesLlistMenu.addAction(actionHigh);
|
||||
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"));
|
||||
}
|
||||
// Check if there is at least one selected file
|
||||
if(!hasSelectedFiles()){
|
||||
QMessageBox::critical(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
|
||||
if(allFiltered()){
|
||||
QMessageBox::warning(0, tr("Invalid file selection"), tr("You must select at least one file in the torrent"));
|
||||
return;
|
||||
}
|
||||
// save filtered files
|
||||
|
@ -338,18 +324,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||
emit torrentAddition(filePath, fromScanDir, from_url);
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue