From 7dc1bd145f0db7967199e93a97be543aba4649cf Mon Sep 17 00:00:00 2001 From: chenxuechao Date: Fri, 22 Jul 2022 17:48:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86=E6=9C=BA?= =?UTF-8?q?=E5=9E=8BWiFi=E6=96=AD=E5=BC=80=E5=90=8E=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BB=8D=E7=84=B6=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mobilehotspot/blacklistpage.cpp | 22 ++++++++------ plugins/mobilehotspot/blacklistpage.h | 1 + plugins/mobilehotspot/connectdevpage.cpp | 38 ++++++++++++++---------- plugins/mobilehotspot/connectdevpage.h | 1 + 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/plugins/mobilehotspot/blacklistpage.cpp b/plugins/mobilehotspot/blacklistpage.cpp index a13a929f..4e3adca3 100644 --- a/plugins/mobilehotspot/blacklistpage.cpp +++ b/plugins/mobilehotspot/blacklistpage.cpp @@ -130,7 +130,6 @@ void BlacklistPage::addBlacklistDevFrame(QString staMac, QString staName) void BlacklistPage::clearBlacklistLayout() { - m_blacklistMap.clear(); if (m_blacklistLayout->layout() != NULL) { QLayoutItem* layoutItem; while ((layoutItem = m_blacklistLayout->layout()->takeAt(0)) != NULL) { @@ -157,12 +156,8 @@ bool BlacklistPage::removeStaFromBlacklist(QString staMac) return true; } -void BlacklistPage::refreshBlacklist() +void BlacklistPage::resetLayoutHight() { - clearBlacklistLayout(); - getBlacklistDevice(m_blacklistMap); - initBlacklistDev(); - int height = 0; for (int i = 0; i < m_blacklistLayout->count(); i ++) { QWidget *w = m_blacklistLayout->itemAt(i)->widget(); @@ -172,14 +167,23 @@ void BlacklistPage::refreshBlacklist() } this->setFixedHeight(height + m_titleLabel->height() + 8); - if (!m_blacklistMap.isEmpty()) { - this->show(); - } else { + if (m_blacklistMap.isEmpty()) { this->hide(); + } else { + this->show(); } this->update(); } +void BlacklistPage::refreshBlacklist() +{ + m_blacklistMap.clear(); + getBlacklistDevice(m_blacklistMap); + clearBlacklistLayout(); + initBlacklistDev(); + resetLayoutHight(); +} + void BlacklistPage::onRemoveFromBlacklistBtnClicked(QString staMac) { if (staMac.isNull() || staMac.isEmpty()) { diff --git a/plugins/mobilehotspot/blacklistpage.h b/plugins/mobilehotspot/blacklistpage.h index 8ea24a89..03f261c0 100644 --- a/plugins/mobilehotspot/blacklistpage.h +++ b/plugins/mobilehotspot/blacklistpage.h @@ -63,6 +63,7 @@ private: void initBlacklistDev(); void addBlacklistDevFrame(QString staMac, QString staName); void clearBlacklistLayout(); + void resetLayoutHight(); private slots: void onsetStaIntoBlacklist(QString staMac); diff --git a/plugins/mobilehotspot/connectdevpage.cpp b/plugins/mobilehotspot/connectdevpage.cpp index e4c0fde5..8e347bf7 100644 --- a/plugins/mobilehotspot/connectdevpage.cpp +++ b/plugins/mobilehotspot/connectdevpage.cpp @@ -116,7 +116,7 @@ void ConnectdevPage::addStaDevFrame(QString staMac, QString staName) void ConnectdevPage::clearStaListLayout() { - m_staMap.clear(); + if (m_staListLayout->layout() != NULL) { QLayoutItem* layoutItem; while ((layoutItem = m_staListLayout->layout()->takeAt(0)) != NULL) { @@ -128,30 +128,27 @@ void ConnectdevPage::clearStaListLayout() void ConnectdevPage::onStaDevAdded(bool istrue, QString staMac, QString staName) { - if (!m_staMap.keys().contains(staMac)) { - onStaDevChanged(istrue, staMac, staName); + if (!m_staMap.contains(staMac)) { + m_staMap.insert(staMac, staName); + clearStaListLayout(); + initStaDev(); + resetLayoutHight(); } } void ConnectdevPage::onStaDevRemoved(bool istrue, QString staMac, QString staName) { - if (m_staMap.keys().contains(staMac)) { - onStaDevChanged(istrue, staMac, staName); + if (m_staMap.contains(staMac)) { + if (m_staMap.remove(staMac)) { + clearStaListLayout(); + initStaDev(); + resetLayoutHight(); + } } } -void ConnectdevPage::onStaDevChanged(bool istrue, QString staMac, QString staName) +void ConnectdevPage::resetLayoutHight() { - if (istrue) { - refreshStalist(); - } -} - -void ConnectdevPage::refreshStalist() -{ - clearStaListLayout(); - getConnectStaDevice(m_staMap); - initStaDev(); int height = 0; for (int i = 0; i < m_staListLayout->count(); i ++) { QWidget *w = m_staListLayout->itemAt(i)->widget(); @@ -169,6 +166,15 @@ void ConnectdevPage::refreshStalist() this->update(); } +void ConnectdevPage::refreshStalist() +{ + m_staMap.clear(); + getConnectStaDevice(m_staMap); + clearStaListLayout(); + initStaDev(); + resetLayoutHight(); +} + void ConnectdevPage::onDropIntoBlacklistBtnClicked(QString staMac) { if (staMac.isNull() || staMac.isEmpty()) { diff --git a/plugins/mobilehotspot/connectdevpage.h b/plugins/mobilehotspot/connectdevpage.h index f4324ae2..cf94c2d5 100644 --- a/plugins/mobilehotspot/connectdevpage.h +++ b/plugins/mobilehotspot/connectdevpage.h @@ -65,6 +65,7 @@ private: void initNmDbus(QDBusInterface *interface); void onStaDevChanged(bool istrue, QString staMac, QString staName); + void resetLayoutHight(); signals: void setStaIntoBlacklist(QString staMac);