Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Fix empty port stats when viewing rsvd ports only
Browse files Browse the repository at this point in the history
This was a regression introduced in 1.3.0 as part of the port stats UX
improvement. The 'user' row was changed from the first (0) to the last,
but the proxy model continued to use a hard-coded value of 0 to check
for user to determine whether to show a port column or not.
  • Loading branch information
pstavirs committed Nov 8, 2023
1 parent d067019 commit 483f7fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
13 changes: 5 additions & 8 deletions client/portstatsproxymodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>

#include <QSortFilterProxyModel>

#include <QSet>

class PortStatsProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
PortStatsProxyModel(QSet<int> hiddenRows = QSet<int>(),
QObject *parent = 0)
: QSortFilterProxyModel(parent), hiddenRows_(hiddenRows)
PortStatsProxyModel(int userRow, QObject *parent = 0)
: QSortFilterProxyModel(parent), userRow_(userRow)
{
setFilterRegExp(QRegExp(".*"));
}
Expand All @@ -39,18 +36,18 @@ class PortStatsProxyModel : public QSortFilterProxyModel
bool filterAcceptsColumn(int sourceColumn,
const QModelIndex &sourceParent) const
{
QModelIndex index = sourceModel()->index(0, sourceColumn, sourceParent);
QModelIndex index = sourceModel()->index(userRow_, sourceColumn,sourceParent);
QString user = sourceModel()->data(index).toString();

return filterRegExp().exactMatch(user) ? true : false;
}
bool filterAcceptsRow(int sourceRow,
const QModelIndex &/*sourceParent*/) const
{
return hiddenRows_.contains(sourceRow) ? false : true;
return sourceRow == userRow_ ? false : true;
}
private:
QSet<int> hiddenRows_;
int userRow_;
};

#endif
Expand Down
3 changes: 1 addition & 2 deletions client/portstatswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ PortStatsWindow::PortStatsWindow(PortGroupList *pgl, QWidget *parent)
model = pgl->getPortStatsModel();

// Hide 'user' row
proxyStatsModel = new PortStatsProxyModel(
QSet<int>({e_INFO_USER}), this);
proxyStatsModel = new PortStatsProxyModel(e_INFO_USER, this);
if (proxyStatsModel) {
proxyStatsModel->setSourceModel(model);
tvPortStats->setModel(proxyStatsModel);
Expand Down

0 comments on commit 483f7fb

Please sign in to comment.