- Added popup menu for file priorities in torrent addition dialog too

This commit is contained in:
Christophe Dumez 2007-07-20 13:21:46 +00:00
commit 8fdd614673
4 changed files with 67 additions and 5 deletions

View file

@ -105,6 +105,9 @@
<property name="editTriggers" >
<set>QAbstractItemView::AllEditTriggers</set>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>

View file

@ -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");