From cd70dcc3baa3d7bd234cc75ca0d6f2378fb6e06f Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 4 Apr 2007 12:52:50 +0000 Subject: [PATCH] - Allow the user to display torrent properties in finished list --- src/FinishedTorrents.cpp | 23 +++++++++++++++++++++++ src/FinishedTorrents.h | 6 ++++-- src/GUI.cpp | 5 +++++ src/GUI.h | 4 +++- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index cb7e919d7..a8471a1de 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -21,6 +21,7 @@ #include "FinishedTorrents.h" #include "misc.h" #include "GUI.h" +#include "properties_imp.h" #include FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){ @@ -147,3 +148,25 @@ QTreeView* FinishedTorrents::getFinishedList(){ QStandardItemModel* FinishedTorrents::getFinishedListModel(){ return finishedListModel; } + +// Show torrent properties dialog +void FinishedTorrents::showProperties(const QModelIndex &index){ + int row = index.row(); + QString fileHash = finishedListModel->data(finishedListModel->index(row, HASH)).toString(); + torrent_handle h = BTSession->getTorrentHandle(fileHash); + QStringList errors = ((GUI*)parent)->trackerErrors.value(fileHash, QStringList(tr("None", "i.e: No error message"))); + properties *prop = new properties(this, h, errors); + connect(prop, SIGNAL(changedFilteredFiles(torrent_handle, bool)), BTSession, SLOT(reloadTorrent(torrent_handle, bool))); + prop->show(); +} + +// display properties of selected items +void FinishedTorrents::propertiesSelection(){ + QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes(); + QModelIndex index; + foreach(index, selectedIndexes){ + if(index.column() == NAME){ + showProperties(index); + } + } +} diff --git a/src/FinishedTorrents.h b/src/FinishedTorrents.h index 24df9c225..1c114bb2c 100644 --- a/src/FinishedTorrents.h +++ b/src/FinishedTorrents.h @@ -42,13 +42,15 @@ class FinishedTorrents : public QWidget, public Ui::seeding{ ~FinishedTorrents(); // Methods QStringList getFinishedSHAs(); + QTreeView* getFinishedList(); + QStandardItemModel* getFinishedListModel(); public slots: void addFinishedSHA(QString sha); void updateFinishedList(); void deleteFromFinishedList(QString hash); - QTreeView* getFinishedList(); - QStandardItemModel* getFinishedListModel(); + void showProperties(const QModelIndex &index); + void propertiesSelection(); protected slots: void setRowColor(int row, const QString& color); diff --git a/src/GUI.cpp b/src/GUI.cpp index 8c473dbc7..6d4da84ba 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -1215,6 +1215,11 @@ void GUI::addUnauthenticatedTracker(QPair tracker){ // display properties of selected items void GUI::propertiesSelection(){ + if(tabs->currentIndex() > 1) return; + if(tabs->currentIndex() == 1){ + finishedTorrentTab->propertiesSelection(); + return; + } QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes(); QModelIndex index; foreach(index, selectedIndexes){ diff --git a/src/GUI.h b/src/GUI.h index fe0439adf..ef6e63555 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -59,11 +59,13 @@ namespace fs = boost::filesystem; class GUI : public QMainWindow, private Ui::MainWindow{ Q_OBJECT + public: + QHash trackerErrors; + private: // Bittorrent bittorrent BTSession; QTimer *checkConnect; - QHash trackerErrors; QList > unauthenticated_trackers; downloadFromURL *downloadFromURLDialog; // GUI related