Browse Source

- 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.

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
54516ac231
  1. 1
      TODO
  2. 34
      src/properties_imp.cpp
  3. 4
      src/properties_imp.h
  4. 36
      src/torrentAddition.h

1
TODO

@ -109,6 +109,7 @@ beta6->beta7 changelog: @@ -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

34
src/properties_imp.cpp

@ -187,27 +187,13 @@ void properties::loadPiecesPriorities(){ @@ -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;
}
void properties::displayFilesListMenu(const QPoint& pos){
@ -218,7 +204,6 @@ void properties::displayFilesListMenu(const QPoint& pos){ @@ -218,7 +204,6 @@ 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(actionNormal);
myFilesLlistMenu.addAction(actionHigh);
@ -525,7 +510,7 @@ void properties::on_incrementalDownload_stateChanged(int){ @@ -525,7 +510,7 @@ void properties::on_incrementalDownload_stateChanged(int){
}
void properties::on_okButton_clicked(){
savePiecesPriorities();
if(savePiecesPriorities())
close();
}
@ -566,8 +551,12 @@ void properties::saveWebSeeds(){ @@ -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(){ @@ -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(){ @@ -597,4 +586,5 @@ void properties::savePiecesPriorities(){
}
emit filteredFilesChanged(hash);
has_filtered_files = hasFilteredFiles;
return true;
}

4
src/properties_imp.h

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

36
src/torrentAddition.h

@ -178,27 +178,14 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -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;
}
void displayFilesListMenu(const QPoint& pos){
@ -209,7 +196,6 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -209,7 +196,6 @@ 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(actionNormal);
myFilesLlistMenu.addAction(actionHigh);
@ -328,8 +314,8 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ @@ -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{ @@ -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…
Cancel
Save