diff --git a/src/ui/form/stat/pages/connectionspage.cpp b/src/ui/form/stat/pages/connectionspage.cpp index f9fbabd4..ab4468db 100644 --- a/src/ui/form/stat/pages/connectionspage.cpp +++ b/src/ui/form/stat/pages/connectionspage.cpp @@ -135,7 +135,7 @@ QLayout *ConnectionsPage::setupHeader() } }); connect(m_actClearAll, &QAction::triggered, this, [&] { - windowManager()->showConfirmBox([&] { connBlockListModel()->clear(); }, + windowManager()->showConfirmBox([&] { ctrl()->deleteBlockedConn(); }, tr("Are you sure to remove all connections?")); }); @@ -288,7 +288,7 @@ void ConnectionsPage::deleteConn(int row) if (connRow.isNull()) return; - connBlockListModel()->deleteConn(connRow.connId); + ctrl()->deleteBlockedConn(connRow.connId); } int ConnectionsPage::connListCurrentIndex() const diff --git a/src/ui/form/stat/statisticscontroller.cpp b/src/ui/form/stat/statisticscontroller.cpp index d0f69249..2f5ab34b 100644 --- a/src/ui/form/stat/statisticscontroller.cpp +++ b/src/ui/form/stat/statisticscontroller.cpp @@ -1,3 +1,16 @@ #include "statisticscontroller.h" +#include +#include + StatisticsController::StatisticsController(QObject *parent) : BaseController(parent) { } + +StatBlockManager *StatisticsController::statBlockManager() const +{ + return IoC(); +} + +void StatisticsController::deleteBlockedConn(qint64 connIdTo) +{ + statBlockManager()->deleteConn(connIdTo); +} diff --git a/src/ui/form/stat/statisticscontroller.h b/src/ui/form/stat/statisticscontroller.h index d9f44287..7d2038eb 100644 --- a/src/ui/form/stat/statisticscontroller.h +++ b/src/ui/form/stat/statisticscontroller.h @@ -3,6 +3,8 @@ #include
+class StatBlockManager; + class StatisticsController : public BaseController { Q_OBJECT @@ -10,6 +12,10 @@ class StatisticsController : public BaseController public: explicit StatisticsController(QObject *parent = nullptr); + StatBlockManager *statBlockManager() const; + + void deleteBlockedConn(qint64 connIdTo = 0); + signals: void afterSaveWindowState(IniUser *ini); void afterRestoreWindowState(IniUser *ini); diff --git a/src/ui/model/connblocklistmodel.cpp b/src/ui/model/connblocklistmodel.cpp index 75f6b92d..4b3b8d54 100644 --- a/src/ui/model/connblocklistmodel.cpp +++ b/src/ui/model/connblocklistmodel.cpp @@ -321,11 +321,6 @@ QVariant ConnBlockListModel::dataDecoration(const QModelIndex &index) const return QVariant(); } -void ConnBlockListModel::deleteConn(qint64 connIdTo) -{ - statBlockManager()->deleteConn(connIdTo); -} - const ConnRow &ConnBlockListModel::connRowAt(int row) const { updateRowCache(row); @@ -333,13 +328,6 @@ const ConnRow &ConnBlockListModel::connRowAt(int row) const return m_connRow; } -void ConnBlockListModel::clear() -{ - statBlockManager()->deleteConn(); - - hostInfoCache()->clear(); -} - void ConnBlockListModel::updateConnIdRange() { const qint64 oldIdMin = connIdMin(); @@ -351,6 +339,10 @@ void ConnBlockListModel::updateConnIdRange() if (idMin == oldIdMin && idMax == oldIdMax) return; + if (idMax == 0) { + hostInfoCache()->clear(); + } + updateConnRows(oldIdMin, oldIdMax, idMin, idMax); } diff --git a/src/ui/model/connblocklistmodel.h b/src/ui/model/connblocklistmodel.h index 2f6be9a1..a7b0c755 100644 --- a/src/ui/model/connblocklistmodel.h +++ b/src/ui/model/connblocklistmodel.h @@ -59,13 +59,8 @@ public: int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - void deleteConn(qint64 connIdTo); - const ConnRow &connRowAt(int row) const; -public slots: - void clear(); - protected slots: void updateConnIdRange();