mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
- Added popup menu for file priorities in torrent addition dialog too
This commit is contained in:
parent
0bdb10cdbe
commit
8fdd614673
4 changed files with 67 additions and 5 deletions
|
@ -105,6 +105,9 @@
|
|||
<property name="editTriggers" >
|
||||
<set>QAbstractItemView::AllEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode" >
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -71,6 +71,11 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||
PropDelegate = new PropListDelegate();
|
||||
torrentContentList->setItemDelegate(PropDelegate);
|
||||
connect(torrentContentList, SIGNAL(clicked(const QModelIndex&)), torrentContentList, SLOT(edit(const QModelIndex&)));
|
||||
connect(torrentContentList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
|
||||
connect(actionIgnored, SIGNAL(triggered()), this, SLOT(ignoreSelection()));
|
||||
connect(actionNormal, SIGNAL(triggered()), this, SLOT(normalSelection()));
|
||||
connect(actionHigh, SIGNAL(triggered()), this, SLOT(highSelection()));
|
||||
connect(actionMaximum, SIGNAL(triggered()), this, SLOT(maximumSelection()));
|
||||
torrentContentList->header()->resizeSection(0, 200);
|
||||
QString home = QDir::homePath();
|
||||
if(home[home.length()-1] != QDir::separator()){
|
||||
|
@ -173,6 +178,61 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||
}
|
||||
}
|
||||
|
||||
void displayFilesListMenu(const QPoint& pos){
|
||||
QMenu myFilesLlistMenu(this);
|
||||
QModelIndex index;
|
||||
// Enable/disable pause/start action given the DL state
|
||||
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
|
||||
myFilesLlistMenu.setTitle(tr("Priority"));
|
||||
myFilesLlistMenu.addAction(actionIgnored);
|
||||
myFilesLlistMenu.addAction(actionNormal);
|
||||
myFilesLlistMenu.addAction(actionHigh);
|
||||
myFilesLlistMenu.addAction(actionMaximum);
|
||||
// Call menu
|
||||
// XXX: why mapToGlobal() is not enough?
|
||||
myFilesLlistMenu.exec(mapToGlobal(pos)+QPoint(22,95));
|
||||
}
|
||||
|
||||
void ignoreSelection(){
|
||||
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
|
||||
QModelIndex index;
|
||||
foreach(index, selectedIndexes){
|
||||
if(index.column() == PRIORITY){
|
||||
PropListModel->setData(index, QVariant(IGNORED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void normalSelection(){
|
||||
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
|
||||
QModelIndex index;
|
||||
foreach(index, selectedIndexes){
|
||||
if(index.column() == PRIORITY){
|
||||
PropListModel->setData(index, QVariant(NORMAL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void highSelection(){
|
||||
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
|
||||
QModelIndex index;
|
||||
foreach(index, selectedIndexes){
|
||||
if(index.column() == PRIORITY){
|
||||
PropListModel->setData(index, QVariant(HIGH));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void maximumSelection(){
|
||||
QModelIndexList selectedIndexes = torrentContentList->selectionModel()->selectedIndexes();
|
||||
QModelIndex index;
|
||||
foreach(index, selectedIndexes){
|
||||
if(index.column() == PRIORITY){
|
||||
PropListModel->setData(index, QVariant(MAXIMUM));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void savePiecesPriorities(){
|
||||
qDebug("Saving pieces priorities");
|
||||
QFile pieces_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+fileHash+".priorities");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue