1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-22 12:34:19 +00:00

Peer lis column width are now restored on startup

This commit is contained in:
Christophe Dumez 2009-11-15 08:40:26 +00:00
parent 6dbd1daa5c
commit e97b805365
3 changed files with 29 additions and 1 deletions

View File

@ -34,6 +34,7 @@
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QSet>
#include <QSettings>
#include <vector>
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; i<contentColsWidths.size(); ++i) {
setColumnWidth(i, contentColsWidths.at(i).toInt());
}
}
}
void PeerListWidget::saveSettings() const {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QVariantList contentColsWidths;
for(int i=0; i<listModel->columnCount(); ++i) {
contentColsWidths.append(columnWidth(i));
}
settings.setValue(QString::fromUtf8("TorrentProperties/Peers/peersColsWidth"), contentColsWidths);
}
void PeerListWidget::loadPeers(QTorrentHandle &h) {
std::vector<peer_info> peers;
h.get_peer_info(peers);

View File

@ -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

View File

@ -242,6 +242,8 @@ void PropertiesWidget::saveSettings() {
for(int i=0; i<PropListModel->columnCount(); ++i) {
contentColsWidths.append(filesList->columnWidth(i));
}
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
// Splitter sizes
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
QList<int> 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() {