mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
- Fix bugs with torrent labeling (Problems when adding a torrent when a filter was selected)
This commit is contained in:
parent
af5c1096b5
commit
719b32ba36
@ -40,6 +40,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QDragMoveEvent>
|
#include <QDragMoveEvent>
|
||||||
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
#include "transferlistdelegate.h"
|
#include "transferlistdelegate.h"
|
||||||
#include "transferlistwidget.h"
|
#include "transferlistwidget.h"
|
||||||
@ -178,6 +179,9 @@ public:
|
|||||||
// Load settings
|
// Load settings
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
|
labelFilters->setCurrentRow(0);
|
||||||
|
//labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select);
|
||||||
|
|
||||||
// Label menu
|
// Label menu
|
||||||
labelFilters->setContextMenuPolicy(Qt::CustomContextMenu);
|
labelFilters->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint)));
|
connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint)));
|
||||||
@ -217,8 +221,7 @@ public:
|
|||||||
newLabel->setText(label + " (0)");
|
newLabel->setText(label + " (0)");
|
||||||
newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
|
newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
|
||||||
}
|
}
|
||||||
labelFilters->setCurrentRow(settings.value("selectedLabelIndex", 0).toInt());
|
|
||||||
//labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
@ -331,7 +334,7 @@ protected slots:
|
|||||||
void torrentAdded(QModelIndex index) {
|
void torrentAdded(QModelIndex index) {
|
||||||
if(!index.isValid()) return;
|
if(!index.isValid()) return;
|
||||||
//Q_ASSERT(index.isValid());
|
//Q_ASSERT(index.isValid());
|
||||||
QString label = transferList->model()->index(index.row(), TR_LABEL).data(Qt::DisplayRole).toString().trimmed();
|
QString label = transferList->getSourceModel()->index(index.row(), TR_LABEL).data(Qt::DisplayRole).toString().trimmed();
|
||||||
qDebug("New torrent was added with label: %s", label.toLocal8Bit().data());
|
qDebug("New torrent was added with label: %s", label.toLocal8Bit().data());
|
||||||
if(!label.isEmpty()) {
|
if(!label.isEmpty()) {
|
||||||
if(!customLabels.contains(label)) {
|
if(!customLabels.contains(label)) {
|
||||||
|
@ -192,7 +192,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) {
|
|||||||
if(listModel->rowCount() == 1)
|
if(listModel->rowCount() == 1)
|
||||||
selectionModel()->setCurrentIndex(proxyModel->index(row, TR_NAME), QItemSelectionModel::SelectCurrent|QItemSelectionModel::Rows);
|
selectionModel()->setCurrentIndex(proxyModel->index(row, TR_NAME), QItemSelectionModel::SelectCurrent|QItemSelectionModel::Rows);
|
||||||
// Emit signal
|
// Emit signal
|
||||||
emit torrentAdded(mapFromSource(listModel->index(row, 0)));
|
emit torrentAdded(listModel->index(row, 0));
|
||||||
// Refresh the list
|
// Refresh the list
|
||||||
refreshList();
|
refreshList();
|
||||||
} catch(invalid_handle e) {
|
} catch(invalid_handle e) {
|
||||||
@ -201,6 +201,10 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStandardItemModel* TransferListWidget::getSourceModel() const {
|
||||||
|
return listModel;
|
||||||
|
}
|
||||||
|
|
||||||
void TransferListWidget::setRowColor(int row, QColor color) {
|
void TransferListWidget::setRowColor(int row, QColor color) {
|
||||||
unsigned int nbColumns = listModel->columnCount()-1;
|
unsigned int nbColumns = listModel->columnCount()-1;
|
||||||
for(unsigned int i=0; i<nbColumns; ++i) {
|
for(unsigned int i=0; i<nbColumns; ++i) {
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent* BTSession);
|
TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent* BTSession);
|
||||||
~TransferListWidget();
|
~TransferListWidget();
|
||||||
int getNbTorrents() const;
|
int getNbTorrents() const;
|
||||||
|
QStandardItemModel* getSourceModel() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int getRowFromHash(QString hash) const;
|
int getRowFromHash(QString hash) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user