Browse Source

- Fix bugs with torrent labeling (Problems when adding a torrent when a filter was selected)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
719b32ba36
  1. 9
      src/transferlistfilterswidget.h
  2. 6
      src/transferlistwidget.cpp
  3. 1
      src/transferlistwidget.h

9
src/transferlistfilterswidget.h

@ -40,6 +40,7 @@ @@ -40,6 +40,7 @@
#include <QMenu>
#include <QInputDialog>
#include <QDragMoveEvent>
#include <QStandardItemModel>
#include "transferlistdelegate.h"
#include "transferlistwidget.h"
@ -178,6 +179,9 @@ public: @@ -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: @@ -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: @@ -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)) {

6
src/transferlistwidget.cpp

@ -192,7 +192,7 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) { @@ -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) { @@ -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<nbColumns; ++i) {

1
src/transferlistwidget.h

@ -59,6 +59,7 @@ public: @@ -59,6 +59,7 @@ public:
TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent* BTSession);
~TransferListWidget();
int getNbTorrents() const;
QStandardItemModel* getSourceModel() const;
protected:
int getRowFromHash(QString hash) const;

Loading…
Cancel
Save