Browse Source

resize column to contents only when they're visible

refactor updatePeerCountryResolutionState
deprecate m_resolveCountries var
adaptive-webui-19844
thalieht 9 years ago
parent
commit
4baa6dde52
  1. 13
      src/gui/properties/peerlistwidget.cpp
  2. 1
      src/gui/properties/peerlistwidget.h

13
src/gui/properties/peerlistwidget.cpp

@ -57,7 +57,6 @@
PeerListWidget::PeerListWidget(PropertiesWidget *parent) PeerListWidget::PeerListWidget(PropertiesWidget *parent)
: QTreeView(parent) : QTreeView(parent)
, m_properties(parent) , m_properties(parent)
, m_resolveCountries(false)
{ {
// Load settings // Load settings
loadSettings(); loadSettings();
@ -91,9 +90,9 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
setModel(m_proxyModel); setModel(m_proxyModel);
hideColumn(PeerListDelegate::IP_HIDDEN); hideColumn(PeerListDelegate::IP_HIDDEN);
hideColumn(PeerListDelegate::COL_COUNT); hideColumn(PeerListDelegate::COL_COUNT);
if (!Preferences::instance()->resolvePeerCountries()) m_resolveCountries = Preferences::instance()->resolvePeerCountries();
if (!m_resolveCountries)
hideColumn(PeerListDelegate::COUNTRY); hideColumn(PeerListDelegate::COUNTRY);
m_wasCountryColHidden = isColumnHidden(PeerListDelegate::COUNTRY);
//Ensure that at least one column is visible at all times //Ensure that at least one column is visible at all times
bool atLeastOne = false; bool atLeastOne = false;
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++) { 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 //its size is 0, because explicitly 'showing' the column isn't enough
//in the above scenario. //in the above scenario.
for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++) for (unsigned int i = 0; i < PeerListDelegate::IP_HIDDEN; i++)
if (!columnWidth(i)) if ((columnWidth(i) <= 0) && !isColumnHidden(i))
resizeColumnToContents(i); resizeColumnToContents(i);
// Context menu // Context menu
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
@ -208,14 +207,12 @@ void PeerListWidget::updatePeerCountryResolutionState()
m_resolveCountries = !m_resolveCountries; m_resolveCountries = !m_resolveCountries;
if (m_resolveCountries) { if (m_resolveCountries) {
loadPeers(m_properties->getCurrentTorrent()); loadPeers(m_properties->getCurrentTorrent());
if (!m_wasCountryColHidden) { showColumn(PeerListDelegate::COUNTRY);
showColumn(PeerListDelegate::COUNTRY); if (columnWidth(PeerListDelegate::COUNTRY) <= 0)
resizeColumnToContents(PeerListDelegate::COUNTRY); resizeColumnToContents(PeerListDelegate::COUNTRY);
}
} }
else { else {
hideColumn(PeerListDelegate::COUNTRY); 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:
QPointer<Net::ReverseResolution> m_resolver; QPointer<Net::ReverseResolution> m_resolver;
PropertiesWidget *m_properties; PropertiesWidget *m_properties;
bool m_resolveCountries; bool m_resolveCountries;
bool m_wasCountryColHidden;
QShortcut *m_copyHotkey; QShortcut *m_copyHotkey;
}; };

Loading…
Cancel
Save