From 719b32ba36fa7393beb950c555b114dcd9b77c3c Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 3 Jan 2010 18:51:24 +0000 Subject: [PATCH] - Fix bugs with torrent labeling (Problems when adding a torrent when a filter was selected) --- src/transferlistfilterswidget.h | 9 ++++++--- src/transferlistwidget.cpp | 6 +++++- src/transferlistwidget.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/transferlistfilterswidget.h b/src/transferlistfilterswidget.h index f76898952..1f4d8144b 100644 --- a/src/transferlistfilterswidget.h +++ b/src/transferlistfilterswidget.h @@ -40,6 +40,7 @@ #include #include #include +#include #include "transferlistdelegate.h" #include "transferlistwidget.h" @@ -178,6 +179,9 @@ public: // Load settings loadSettings(); + labelFilters->setCurrentRow(0); + //labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select); + // Label menu labelFilters->setContextMenuPolicy(Qt::CustomContextMenu); connect(labelFilters, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showLabelMenu(QPoint))); @@ -217,8 +221,7 @@ public: newLabel->setText(label + " (0)"); 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: @@ -331,7 +334,7 @@ protected slots: void torrentAdded(QModelIndex index) { if(!index.isValid()) return; //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()); if(!label.isEmpty()) { if(!customLabels.contains(label)) { diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 5e0080043..215cd9c6d 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -192,7 +192,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) { if(listModel->rowCount() == 1) selectionModel()->setCurrentIndex(proxyModel->index(row, TR_NAME), QItemSelectionModel::SelectCurrent|QItemSelectionModel::Rows); // Emit signal - emit torrentAdded(mapFromSource(listModel->index(row, 0))); + emit torrentAdded(listModel->index(row, 0)); // Refresh the list refreshList(); } 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) { unsigned int nbColumns = listModel->columnCount()-1; for(unsigned int i=0; i