From 382c94b326242c9f54f0fdb8671aa3823f1c5241 Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Thu, 7 May 2015 18:56:32 +0530 Subject: [PATCH] Behaviour Change: 'Clear All' in the port stats window now clears only the visible ports in the window, not all ports of all portgroups. This behaviour is the more appropriate behaviour when two or more clients are connected to the same portgroup and are using mutually exclusive ports within the portgroup - this way they don't affect each other's ports (assuming they have only their used ports visible) --- client/portstatswindow.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/client/portstatswindow.cpp b/client/portstatswindow.cpp index 10247bb..3e2cb9a 100644 --- a/client/portstatswindow.cpp +++ b/client/portstatswindow.cpp @@ -163,12 +163,29 @@ void PortStatsWindow::on_tbClear_clicked() } } +// 'All' => all ports currently visible, not all ports in all portgroups void PortStatsWindow::on_tbClearAll_clicked() { - // FIXME: we clear all, not just all ports currently displayed!!! - for (int i = 0; i < pgl->numPortGroups(); i++) + QAbstractItemModel *mdl = tvPortStats->model(); + QModelIndexList shownColumns; + QList portList; + + // Find the 'visible' columns + for(int vi = 0; vi < mdl->columnCount(); vi++) { + int li = tvPortStats->horizontalHeader()->logicalIndex(vi); + if (!tvPortStats->isColumnHidden(li)) { + shownColumns.append(mdl->index(0, li)); + } + } + + // Get ports corresponding to the shown columns + model->portListFromIndex(shownColumns, portList); + + // Clear shown ports, portgroup by portgroup + for (int i = 0; i < portList.size(); i++) { - pgl->portGroupByIndex(i).clearPortStats(); + pgl->portGroupByIndex(portList.at(i).portGroupId) + .clearPortStats(&portList[i].portList); } } @@ -177,10 +194,7 @@ void PortStatsWindow::on_tbFilter_clicked() bool ok; QList currentColumns, newColumns; PortStatsFilterDialog dialog; - QAbstractItemModel *mdl = model; - - if (proxyStatsModel) - mdl = proxyStatsModel; + QAbstractItemModel *mdl = tvPortStats->model(); // create the input list for the filter dialog - // list of logical-indexes ordered by their current visual indexes