Browse Source

Merge pull request #5245 from thalieht/resolveCountries

Minor refactor in PeerListWidget
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
fc0746eb71
  1. 11
      src/gui/properties/peerlistwidget.cpp
  2. 1
      src/gui/properties/peerlistwidget.h

11
src/gui/properties/peerlistwidget.cpp

@ -57,7 +57,6 @@ @@ -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) @@ -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) @@ -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() @@ -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
}
}
}

1
src/gui/properties/peerlistwidget.h

@ -94,7 +94,6 @@ private: @@ -94,7 +94,6 @@ private:
QPointer<Net::ReverseResolution> m_resolver;
PropertiesWidget *m_properties;
bool m_resolveCountries;
bool m_wasCountryColHidden;
QShortcut *m_copyHotkey;
};

Loading…
Cancel
Save