mirror of
https://github.com/tnodir/fort
synced 2024-11-15 04:15:22 +00:00
UI: ConnectionsPage: Use StatBlockManager via StatisticsController
This commit is contained in:
parent
e963811322
commit
909cd4da8c
@ -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
|
||||
|
@ -1,3 +1,16 @@
|
||||
#include "statisticscontroller.h"
|
||||
|
||||
#include <stat/statblockmanager.h>
|
||||
#include <util/ioc/ioccontainer.h>
|
||||
|
||||
StatisticsController::StatisticsController(QObject *parent) : BaseController(parent) { }
|
||||
|
||||
StatBlockManager *StatisticsController::statBlockManager() const
|
||||
{
|
||||
return IoC<StatBlockManager>();
|
||||
}
|
||||
|
||||
void StatisticsController::deleteBlockedConn(qint64 connIdTo)
|
||||
{
|
||||
statBlockManager()->deleteConn(connIdTo);
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <form/basecontroller.h>
|
||||
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user