sort ap list by signal

Change-Id: I6c4ba4fe24c166d0fa70d906fd111b77c4a9ded1
This commit is contained in:
石博文 2016-07-27 10:18:46 +08:00 committed by Hualet Wang
parent 69ed8cf322
commit d6861fdfb2
4 changed files with 11 additions and 9 deletions

View File

@ -23,9 +23,9 @@ bool AccessPoint::operator==(const AccessPoint &ap) const
return m_ssid == ap.m_ssid;
}
bool AccessPoint::operator<(const AccessPoint &ap) const
bool AccessPoint::operator>(const AccessPoint &ap) const
{
return m_strength < ap.m_strength;
return m_strength > ap.m_strength;
}
AccessPoint &AccessPoint::operator=(const AccessPoint &ap)

View File

@ -12,7 +12,7 @@ public:
explicit AccessPoint(const QJsonObject &apInfo);
AccessPoint(const AccessPoint &ap);
bool operator==(const AccessPoint &ap) const;
bool operator<(const AccessPoint &ap) const;
bool operator>(const AccessPoint &ap) const;
AccessPoint &operator=(const AccessPoint &ap);
const QString ssid() const;

View File

@ -112,10 +112,11 @@ void WirelessApplet::APPropertiesChanged(const QString &devPath, const QString &
if (it == m_apList.end())
return;
if (*it < ap)
return;
*it = ap;
m_updateAPTimer->start();
if (*it > ap)
{
*it = ap;
m_updateAPTimer->start();
}
}
void WirelessApplet::updateAPList()
@ -129,6 +130,9 @@ void WirelessApplet::updateAPList()
delete item;
}
// sort ap list by strength
std::sort(m_apList.begin(), m_apList.end(), std::greater<AccessPoint>());
for (auto ap : m_apList)
{
AccessPointWidget *apw = new AccessPointWidget(ap);

View File

@ -69,6 +69,4 @@ void WirelessItem::init()
m_applet = new WirelessApplet(devPath, this);
m_applet->setVisible(false);
// connect(m_networkManager, &NetworkManager::APPropertiesChanged, this, &WirelessItem::APPropertiesChanegd);
}