mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 11:49:01 +03:00
Merge pull request #5245 from thalieht/resolveCountries
Minor refactor in PeerListWidget
This commit is contained in:
commit
fc0746eb71
2 changed files with 5 additions and 9 deletions
|
@ -57,7 +57,6 @@
|
|||
PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
||||
: QTreeView(parent)
|
||||
, m_properties(parent)
|
||||
, m_resolveCountries(false)
|
||||
{
|
||||
// Load settings
|
||||
loadSettings();
|
||||
|
@ -91,9 +90,9 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
|||
setModel(m_proxyModel);
|
||||
hideColumn(PeerListDelegate::IP_HIDDEN);
|
||||
hideColumn(PeerListDelegate::COL_COUNT);
|
||||
if (!Preferences::instance()->resolvePeerCountries())
|
||||
m_resolveCountries = Preferences::instance()->resolvePeerCountries();
|
||||
if (!m_resolveCountries)
|
||||
hideColumn(PeerListDelegate::COUNTRY);
|
||||
m_wasCountryColHidden = isColumnHidden(PeerListDelegate::COUNTRY);
|
||||
//Ensure that at least one column is visible at all times
|
||||
bool atLeastOne = false;
|
||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++) {
|
||||
|
@ -108,7 +107,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
|||
//its size is 0, because explicitly 'showing' the column isn't enough
|
||||
//in the above scenario.
|
||||
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++)
|
||||
if (!columnWidth(i))
|
||||
if ((columnWidth(i) <= 0) && !isColumnHidden(i))
|
||||
resizeColumnToContents(i);
|
||||
// Context menu
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
@ -208,14 +207,12 @@ void PeerListWidget::updatePeerCountryResolutionState()
|
|||
m_resolveCountries = !m_resolveCountries;
|
||||
if (m_resolveCountries) {
|
||||
loadPeers(m_properties->getCurrentTorrent());
|
||||
if (!m_wasCountryColHidden) {
|
||||
showColumn(PeerListDelegate::COUNTRY);
|
||||
if (columnWidth(PeerListDelegate::COUNTRY) <= 0)
|
||||
resizeColumnToContents(PeerListDelegate::COUNTRY);
|
||||
}
|
||||
}
|
||||
else {
|
||||
hideColumn(PeerListDelegate::COUNTRY);
|
||||
m_wasCountryColHidden = false; // to forcefully enable that column if the user decides to resolve countries again
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,6 @@ private:
|
|||
QPointer<Net::ReverseResolution> m_resolver;
|
||||
PropertiesWidget *m_properties;
|
||||
bool m_resolveCountries;
|
||||
bool m_wasCountryColHidden;
|
||||
QShortcut *m_copyHotkey;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue