mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Prevent users from filtering all the files in a torrent using right-click menu (combobox was ok)
This commit is contained in:
parent
58dc75fbcf
commit
57b4a7150a
5 changed files with 59 additions and 7 deletions
1
TODO
1
TODO
|
@ -45,7 +45,6 @@
|
||||||
- Add checking icon to documentation
|
- Add checking icon to documentation
|
||||||
* beta3
|
* beta3
|
||||||
- Translations update (IN PROGRESS)
|
- 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 :
|
- Wait for some bug fixes in libtorrent :
|
||||||
- upload/download limit per torrent (Ticket #83)
|
- upload/download limit per torrent (Ticket #83)
|
||||||
- double free or corruption on exit (Ticket #84)
|
- double free or corruption on exit (Ticket #84)
|
||||||
|
|
|
@ -165,7 +165,7 @@ class PropListDelegate: public QItemDelegate {
|
||||||
bool onlyOneItem(const QModelIndex& index) const {
|
bool onlyOneItem(const QModelIndex& index) const {
|
||||||
const QAbstractItemModel *model = index.model();
|
const QAbstractItemModel *model = index.model();
|
||||||
unsigned int nbRows = model->rowCount();
|
unsigned int nbRows = model->rowCount();
|
||||||
if(nbRows == (unsigned int)1) return true;
|
if(nbRows == 1) return true;
|
||||||
for(unsigned int i=0; i<nbRows; ++i){
|
for(unsigned int i=0; i<nbRows; ++i){
|
||||||
if((unsigned int)index.row() == i) continue;
|
if((unsigned int)index.row() == i) continue;
|
||||||
if(model->data(model->index(i, PRIORITY)).toInt()) return false;
|
if(model->data(model->index(i, PRIORITY)).toInt()) return false;
|
||||||
|
|
|
@ -205,12 +205,38 @@ 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; i<nbRows; ++i){
|
||||||
|
if(PropListModel->data(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){
|
void properties::displayFilesListMenu(const QPoint& pos){
|
||||||
|
unsigned int nbRows = PropListModel->rowCount();
|
||||||
|
if(nbRows == 1) return;
|
||||||
QMenu myFilesLlistMenu(this);
|
QMenu myFilesLlistMenu(this);
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
// 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);
|
||||||
|
|
|
@ -79,6 +79,7 @@ class properties : public QDialog, private Ui::properties{
|
||||||
// Constructor
|
// Constructor
|
||||||
properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h);
|
properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h);
|
||||||
~properties();
|
~properties();
|
||||||
|
bool onlyOneItem() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -178,12 +178,38 @@ 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; i<nbRows; ++i){
|
||||||
|
if(PropListModel->data(PropListModel->index(i, PRIORITY)).toInt() != IGNORED){
|
||||||
|
++nb_unfiltered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(nb_unfiltered-to_be_filtered == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void displayFilesListMenu(const QPoint& pos){
|
void displayFilesListMenu(const QPoint& pos){
|
||||||
|
unsigned int nbRows = PropListModel->rowCount();
|
||||||
|
if(nbRows == 1) return;
|
||||||
QMenu myFilesLlistMenu(this);
|
QMenu myFilesLlistMenu(this);
|
||||||
QModelIndex index;
|
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();
|
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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue