From cfe979c8ddac7c0d0b3d7be27a66d758f00a9ecc Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 11 Apr 2007 13:19:58 +0000 Subject: [PATCH] - Updated changelog - Made sorting work in the finished torrents list --- Changelog | 11 +++++- TODO | 3 +- src/FinishedTorrents.cpp | 73 ++++++++++++++++++++++++++++++++++++++++ src/FinishedTorrents.h | 3 ++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index bc981acc0..d061cc54d 100644 --- a/Changelog +++ b/Changelog @@ -1,19 +1,28 @@ * Unknown - Christophe Dumez - v0.10.0 - FEATURE: Added UPnP / NAT-PMP port forwarding support - FEATURE: Added RSS support - - FEATURE: Finished torrents are moved to another tab + - FEATURE: Finished torrents are now moved to another tab for seeding - FEATURE: Display more infos about the torrent in its properties - FEATURE: Allow the user to edit torrents' trackers - FEATURE: Allow user to change qBT's style (Plastique, Cleanlooks, Motif, CDE, MacOSX, WinXP) - FEATURE: Allow the user to disable system tray integration - FEATURE: Search engine is now using one thread per website for faster results - FEATURE: Improved a lot the torrent creation module + - FEATURE: Allow to set upload/download limit per torrent (right click) - FEATURE: Ask for exit confirmation only if download list is not empty - BUGFIX: Window can now stay maximized on exit - COSMETIC: Redesigned torrent properties a little - COSMETIC: Redesigned options a little - COSMETIC: Display more logs messages concerning features +* Tue Apr 10 2007 - Christophe Dumez - v0.9.2 + - BUGFIX: Window can now stay maximized on exit + - BUGFIX: Use PKGCONFIG again for configuring libtorrent + - BUGFIX: Allow to compile with libtorrent v0.11 + - BUGFIX: Disabled main window context menu (annoying) + - I18N: Added Japanese translation + - I18N: Updated Turkish translation + * Wed Apr 04 2007 - Christophe Dumez - v0.9.1 - BUGFIX: A lot of fixes in configure file diff --git a/TODO b/TODO index fcaae4eae..84952fa9b 100644 --- a/TODO +++ b/TODO @@ -47,4 +47,5 @@ - Improve ratio display / calculation / saving / per torrent... - Use buttonboxes when possible - Display the sum of the size of the selected files in the torrent instead of the whole torrent size in download list -- Support column sorting in finished list \ No newline at end of file +- Support column sorting in finished list +- Sorting in Download Status column should be smarter than just an alphabetical sort \ No newline at end of file diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index 0a4763fde..1f8129d6f 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -47,6 +47,10 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){ if(!loadColWidthFinishedList()){ finishedList->header()->resizeSection(0, 200); } + // Make download list header clickable for sorting + finishedList->header()->setClickable(true); + finishedList->header()->setSortIndicatorShown(true); + connect(finishedList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortFinishedList(int))); finishedListDelegate = new DLListDelegate(); finishedList->setItemDelegate(finishedListDelegate); connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&))); @@ -111,6 +115,75 @@ void FinishedTorrents::setRowColor(int row, const QString& color){ } } +void FinishedTorrents::sortFinishedList(int index){ + static Qt::SortOrder sortOrder = Qt::AscendingOrder; + if(finishedList->header()->sortIndicatorSection() == index){ + if(sortOrder == Qt::AscendingOrder){ + sortOrder = Qt::DescendingOrder; + }else{ + sortOrder = Qt::AscendingOrder; + } + } + finishedList->header()->setSortIndicator(index, sortOrder); + switch(index){ + case SIZE: + case ETA: + case UPSPEED: + case DLSPEED: + case PROGRESS: + sortFinishedListFloat(index, sortOrder); + break; + default: + sortFinishedListString(index, sortOrder); + } +} + +void FinishedTorrents::sortFinishedListFloat(int index, Qt::SortOrder sortOrder){ + QList > lines; + // insertion sorting + unsigned int nbRows = finishedListModel->rowCount(); + for(unsigned int i=0; i(i, finishedListModel->data(finishedListModel->index(i, index)).toDouble()), sortOrder); + } + // Insert items in new model, in correct order + unsigned int nbRows_old = lines.size(); + for(unsigned int row=0; rowinsertRow(finishedListModel->rowCount()); + unsigned int sourceRow = lines[row].first; + unsigned int nbColumns = finishedListModel->columnCount(); + for(unsigned int col=0; colsetData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col))); + finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole); + finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole); + } + } + // Remove old rows + finishedListModel->removeRows(0, nbRows_old); +} + +void FinishedTorrents::sortFinishedListString(int index, Qt::SortOrder sortOrder){ + QList > lines; + // Insertion sorting + unsigned int nbRows = finishedListModel->rowCount(); + for(unsigned int i=0; i(i, finishedListModel->data(finishedListModel->index(i, index)).toString()), sortOrder); + } + // Insert items in new model, in correct order + unsigned int nbRows_old = lines.size(); + for(unsigned int row=0; rowinsertRow(finishedListModel->rowCount()); + unsigned int sourceRow = lines[row].first; + unsigned int nbColumns = finishedListModel->columnCount(); + for(unsigned int col=0; colsetData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col))); + finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::DecorationRole), Qt::DecorationRole); + finishedListModel->setData(finishedListModel->index(nbRows_old+row, col), finishedListModel->data(finishedListModel->index(sourceRow, col), Qt::TextColorRole), Qt::TextColorRole); + } + } + // Remove old rows + finishedListModel->removeRows(0, nbRows_old); +} + // Load columns width in a file that were saved previously // (finished list) bool FinishedTorrents::loadColWidthFinishedList(){ diff --git a/src/FinishedTorrents.h b/src/FinishedTorrents.h index 1545e3472..93bbccf7c 100644 --- a/src/FinishedTorrents.h +++ b/src/FinishedTorrents.h @@ -55,6 +55,9 @@ class FinishedTorrents : public QWidget, public Ui::seeding{ void displayFinishedListMenu(const QPoint&); void setRowColor(int row, const QString& color); void saveColWidthFinishedList() const; + void sortFinishedList(int index); + void sortFinishedListFloat(int index, Qt::SortOrder sortOrder); + void sortFinishedListString(int index, Qt::SortOrder sortOrder); protected slots: void on_actionSet_upload_limit_triggered();