Browse Source

Peer lis column width are now restored on startup

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
e97b805365
  1. 23
      src/peerlistwidget.cpp
  2. 4
      src/peerlistwidget.h
  3. 3
      src/propertieswidget.cpp

23
src/peerlistwidget.cpp

@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QSet>
#include <QSettings>
#include <vector>
PeerListWidget::PeerListWidget() {
@ -60,6 +61,8 @@ 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() { @@ -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);

4
src/peerlistwidget.h

@ -61,6 +61,10 @@ public slots: @@ -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

3
src/propertieswidget.cpp

@ -242,6 +242,8 @@ void PropertiesWidget::saveSettings() { @@ -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() { @@ -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() {

Loading…
Cancel
Save