From 581efd0afdd19c6426a6d6d42bd708c2b62c7c27 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 22 Nov 2009 18:20:47 +0000 Subject: [PATCH] - Remember sorted column in peer list --- src/peerlistwidget.cpp | 21 +++++++++++++++++++++ src/transferlistwidget.cpp | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/peerlistwidget.cpp b/src/peerlistwidget.cpp index 93706bbbc..dfff3bbff 100644 --- a/src/peerlistwidget.cpp +++ b/src/peerlistwidget.cpp @@ -248,6 +248,18 @@ void PeerListWidget::loadSettings() { setColumnWidth(i, contentColsWidths.at(i).toInt()); } } + // Load sorted column + QString sortedCol = settings.value(QString::fromUtf8("TorrentProperties/Peers/PeerListSortedCol"), QString()).toString(); + if(!sortedCol.isEmpty()) { + Qt::SortOrder sortOrder; + if(sortedCol.endsWith(QString::fromUtf8("d"))) + sortOrder = Qt::DescendingOrder; + else + sortOrder = Qt::AscendingOrder; + sortedCol.chop(1); + int index = sortedCol.toInt(); + sortByColumn(index, sortOrder); + } } void PeerListWidget::saveSettings() const { @@ -257,6 +269,15 @@ void PeerListWidget::saveSettings() const { contentColsWidths.append(columnWidth(i)); } settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths); + // Save sorted column + Qt::SortOrder sortOrder = header()->sortIndicatorOrder(); + QString sortOrderLetter; + if(sortOrder == Qt::AscendingOrder) + sortOrderLetter = QString::fromUtf8("a"); + else + sortOrderLetter = QString::fromUtf8("d"); + int index = header()->sortIndicatorSection(); + settings.setValue(QString::fromUtf8("TorrentProperties/Peers/PeerListSortedCol"), misc::toQString(index)+sortOrderLetter); } void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_resolution) { diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 9e7a42558..9ba3e504e 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -1041,7 +1041,7 @@ void TransferListWidget::loadLastSortedColumn() { sortOrder = Qt::DescendingOrder; else sortOrder = Qt::AscendingOrder; - sortedCol = sortedCol.left(sortedCol.size()-1); + sortedCol.chop(1); int index = sortedCol.toInt(); sortByColumn(index, sortOrder); }