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:
parent
6dbd1daa5c
commit
e97b805365
@ -34,6 +34,7 @@
|
|||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QSettings>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
PeerListWidget::PeerListWidget() {
|
PeerListWidget::PeerListWidget() {
|
||||||
@ -60,6 +61,8 @@ PeerListWidget::PeerListWidget() {
|
|||||||
setItemDelegate(listDelegate);
|
setItemDelegate(listDelegate);
|
||||||
// Enable sorting
|
// Enable sorting
|
||||||
setSortingEnabled(true);
|
setSortingEnabled(true);
|
||||||
|
// Load settings
|
||||||
|
loadSettings();
|
||||||
// IP to Hostname resolver
|
// IP to Hostname resolver
|
||||||
resolver = new ReverseResolution(this);
|
resolver = new ReverseResolution(this);
|
||||||
connect(resolver, SIGNAL(ip_resolved(QString,QString)), this, SLOT(handleResolved(QString,QString)));
|
connect(resolver, SIGNAL(ip_resolved(QString,QString)), this, SLOT(handleResolved(QString,QString)));
|
||||||
@ -67,12 +70,32 @@ PeerListWidget::PeerListWidget() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PeerListWidget::~PeerListWidget() {
|
PeerListWidget::~PeerListWidget() {
|
||||||
|
saveSettings();
|
||||||
delete proxyModel;
|
delete proxyModel;
|
||||||
delete listModel;
|
delete listModel;
|
||||||
delete listDelegate;
|
delete listDelegate;
|
||||||
delete resolver;
|
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) {
|
void PeerListWidget::loadPeers(QTorrentHandle &h) {
|
||||||
std::vector<peer_info> peers;
|
std::vector<peer_info> peers;
|
||||||
h.get_peer_info(peers);
|
h.get_peer_info(peers);
|
||||||
|
@ -61,6 +61,10 @@ public slots:
|
|||||||
QStandardItem* addPeer(QString ip, peer_info peer);
|
QStandardItem* addPeer(QString ip, peer_info peer);
|
||||||
void updatePeer(QString ip, peer_info peer);
|
void updatePeer(QString ip, peer_info peer);
|
||||||
void handleResolved(QString ip, QString hostname);
|
void handleResolved(QString ip, QString hostname);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void loadSettings();
|
||||||
|
void saveSettings() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PEERLISTWIDGET_H
|
#endif // PEERLISTWIDGET_H
|
||||||
|
@ -242,6 +242,8 @@ void PropertiesWidget::saveSettings() {
|
|||||||
for(int i=0; i<PropListModel->columnCount(); ++i) {
|
for(int i=0; i<PropListModel->columnCount(); ++i) {
|
||||||
contentColsWidths.append(filesList->columnWidth(i));
|
contentColsWidths.append(filesList->columnWidth(i));
|
||||||
}
|
}
|
||||||
|
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
||||||
|
// Splitter sizes
|
||||||
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
|
QSplitter *hSplitter = static_cast<QSplitter*>(parentWidget());
|
||||||
QList<int> sizes;
|
QList<int> sizes;
|
||||||
if(state == VISIBLE)
|
if(state == VISIBLE)
|
||||||
@ -254,7 +256,6 @@ void PropertiesWidget::saveSettings() {
|
|||||||
if(sizes.size() == 2) {
|
if(sizes.size() == 2) {
|
||||||
settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString::number(sizes.first())+','+QString::number(sizes.last()));
|
settings.setValue(QString::fromUtf8("TorrentProperties/SplitterSizes"), QString::number(sizes.first())+','+QString::number(sizes.last()));
|
||||||
}
|
}
|
||||||
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::loadPeers() {
|
void PropertiesWidget::loadPeers() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user