diff --git a/TODO b/TODO index 446a1fef7..0fff1f54f 100644 --- a/TODO +++ b/TODO @@ -45,7 +45,6 @@ - Add checking icon to documentation * beta3 - Translations update (IN PROGRESS) - - Check that there is no problem with right click menu in torrent content (all files filtered for example) - Wait for some bug fixes in libtorrent : - upload/download limit per torrent (Ticket #83) - double free or corruption on exit (Ticket #84) diff --git a/src/PropListDelegate.h b/src/PropListDelegate.h index b1344f2d9..e9c1cf076 100644 --- a/src/PropListDelegate.h +++ b/src/PropListDelegate.h @@ -165,7 +165,7 @@ class PropListDelegate: public QItemDelegate { bool onlyOneItem(const QModelIndex& index) const { const QAbstractItemModel *model = index.model(); unsigned int nbRows = model->rowCount(); - if(nbRows == (unsigned int)1) return true; + if(nbRows == 1) return true; for(unsigned int i=0; idata(model->index(i, PRIORITY)).toInt()) return false; diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index eccc946d7..6cebf5cfb 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -205,13 +205,39 @@ void properties::loadPiecesPriorities(){ } } +bool properties::onlyOneItem() 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; idata(PropListModel->index(i, PRIORITY)).toInt() != IGNORED){ + ++nb_unfiltered; + } + } + if(nb_unfiltered-to_be_filtered == 0) + return true; + return false; +} + void properties::displayFilesListMenu(const QPoint& pos){ + unsigned int nbRows = PropListModel->rowCount(); + if(nbRows == 1) return; QMenu myFilesLlistMenu(this); QModelIndex index; // Enable/disable pause/start action given the DL state QModelIndexList selectedIndexes = filesList->selectionModel()->selectedIndexes(); myFilesLlistMenu.setTitle(tr("Priority")); - myFilesLlistMenu.addAction(actionIgnored); + if(!onlyOneItem()) + myFilesLlistMenu.addAction(actionIgnored); myFilesLlistMenu.addAction(actionNormal); myFilesLlistMenu.addAction(actionHigh); myFilesLlistMenu.addAction(actionMaximum); diff --git a/src/properties_imp.h b/src/properties_imp.h index bbdf6a1f4..7e8ab498b 100644 --- a/src/properties_imp.h +++ b/src/properties_imp.h @@ -79,6 +79,7 @@ class properties : public QDialog, private Ui::properties{ // Constructor properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h); ~properties(); + bool onlyOneItem() const; }; #endif diff --git a/src/torrentAddition.h b/src/torrentAddition.h index 692cffb03..66b401366 100644 --- a/src/torrentAddition.h +++ b/src/torrentAddition.h @@ -178,18 +178,44 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ } } + bool onlyOneItem() 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; idata(PropListModel->index(i, PRIORITY)).toInt() != IGNORED){ + ++nb_unfiltered; + } + } + if(nb_unfiltered-to_be_filtered == 0) + return true; + return false; + } + void displayFilesListMenu(const QPoint& pos){ + unsigned int nbRows = PropListModel->rowCount(); + if(nbRows == 1) return; QMenu myFilesLlistMenu(this); QModelIndex index; - // Enable/disable pause/start action given the DL state + // Enable/disable pause/start action given the DL state QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes(); myFilesLlistMenu.setTitle(tr("Priority")); - myFilesLlistMenu.addAction(actionIgnored); + if(!onlyOneItem()) + myFilesLlistMenu.addAction(actionIgnored); myFilesLlistMenu.addAction(actionNormal); myFilesLlistMenu.addAction(actionHigh); myFilesLlistMenu.addAction(actionMaximum); - // Call menu - // XXX: why mapToGlobal() is not enough? + // Call menu + // XXX: why mapToGlobal() is not enough? myFilesLlistMenu.exec(mapToGlobal(pos)+QPoint(10,145)); }