From e97b80536541b8dc4b3a5f2b870a694f76365efd Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 15 Nov 2009 08:40:26 +0000 Subject: [PATCH] Peer lis column width are now restored on startup --- src/peerlistwidget.cpp | 23 +++++++++++++++++++++++ src/peerlistwidget.h | 4 ++++ src/propertieswidget.cpp | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/peerlistwidget.cpp b/src/peerlistwidget.cpp index aea0ae8c2..0db32b0c5 100644 --- a/src/peerlistwidget.cpp +++ b/src/peerlistwidget.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include PeerListWidget::PeerListWidget() { @@ -60,6 +61,8 @@ PeerListWidget::PeerListWidget() { setItemDelegate(listDelegate); // Enable sorting setSortingEnabled(true); + // Load settings + loadSettings(); // IP to Hostname resolver resolver = new ReverseResolution(this); connect(resolver, SIGNAL(ip_resolved(QString,QString)), this, SLOT(handleResolved(QString,QString))); @@ -67,12 +70,32 @@ PeerListWidget::PeerListWidget() { } PeerListWidget::~PeerListWidget() { + saveSettings(); delete proxyModel; delete listModel; delete listDelegate; delete resolver; } +void PeerListWidget::loadSettings() { + QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); + QVariantList contentColsWidths = settings.value(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), QVariantList()).toList(); + if(!contentColsWidths.empty()) { + for(int i=0; icolumnCount(); ++i) { + contentColsWidths.append(columnWidth(i)); + } + settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths); +} + void PeerListWidget::loadPeers(QTorrentHandle &h) { std::vector peers; h.get_peer_info(peers); diff --git a/src/peerlistwidget.h b/src/peerlistwidget.h index c6f3732da..f89b99532 100644 --- a/src/peerlistwidget.h +++ b/src/peerlistwidget.h @@ -61,6 +61,10 @@ public slots: QStandardItem* addPeer(QString ip, peer_info peer); void updatePeer(QString ip, peer_info peer); void handleResolved(QString ip, QString hostname); + +protected slots: + void loadSettings(); + void saveSettings() const; }; #endif // PEERLISTWIDGET_H diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 068f5f492..067a0497d 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -242,6 +242,8 @@ void PropertiesWidget::saveSettings() { for(int i=0; icolumnCount(); ++i) { contentColsWidths.append(filesList->columnWidth(i)); } + settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths); + // Splitter sizes QSplitter *hSplitter = static_cast(parentWidget()); QList sizes; if(state == VISIBLE) @@ -254,7 +256,6 @@ void PropertiesWidget::saveSettings() { if(sizes.size() == 2) { settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString::number(sizes.first())+','+QString::number(sizes.last())); } - settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths); } void PropertiesWidget::loadPeers() {