Move port stats hidden rows to the end
This avoids having to recalculate row indices
This commit is contained in:
parent
9849973562
commit
d950432bc9
@ -279,7 +279,7 @@ QVariant PortStatsModel::headerData(int section, Qt::Orientation orientation, in
|
||||
{
|
||||
QPalette palette = QApplication::palette();
|
||||
return section & 0x1 ?
|
||||
palette.base() : palette.alternateBase();
|
||||
palette.alternateBase() : palette.base();
|
||||
}
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
|
@ -26,15 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
class QTimer;
|
||||
|
||||
typedef enum {
|
||||
// Info
|
||||
e_INFO_START = 0,
|
||||
|
||||
e_INFO_USER = e_INFO_START,
|
||||
|
||||
e_INFO_END = e_INFO_USER,
|
||||
|
||||
// State
|
||||
e_STATE_START,
|
||||
e_STATE_START = 0,
|
||||
|
||||
e_COMBO_STATE = e_STATE_START,
|
||||
|
||||
@ -71,12 +64,19 @@ typedef enum {
|
||||
|
||||
e_STATISTICS_END = e_STAT_RX_FRAME_ERRORS,
|
||||
|
||||
// Info
|
||||
e_INFO_START,
|
||||
|
||||
// XXX: keep hidden rows at end to avoid having to recalculate rows
|
||||
e_INFO_USER = e_INFO_START,
|
||||
|
||||
e_INFO_END = e_INFO_USER,
|
||||
|
||||
|
||||
e_STAT_MAX
|
||||
} PortStat;
|
||||
|
||||
static const QStringList PortStatName = (QStringList()
|
||||
<< "User"
|
||||
|
||||
<< "Status"
|
||||
|
||||
<< "Frames Sent"
|
||||
@ -102,6 +102,8 @@ static const QStringList PortStatName = (QStringList()
|
||||
<< "Receive Errors"
|
||||
<< "Receive Fifo Errors"
|
||||
<< "Receive Frame Errors"
|
||||
|
||||
<< "User"
|
||||
);
|
||||
|
||||
static QStringList LinkStateName = (QStringList()
|
||||
|
@ -22,12 +22,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include <QSet>
|
||||
|
||||
class PortStatsProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PortStatsProxyModel(QObject *parent = 0)
|
||||
: QSortFilterProxyModel(parent)
|
||||
PortStatsProxyModel(QSet<int> hiddenRows = QSet<int>(),
|
||||
QObject *parent = 0)
|
||||
: QSortFilterProxyModel(parent), hiddenRows_(hiddenRows)
|
||||
{
|
||||
setFilterRegExp(QRegExp(".*"));
|
||||
}
|
||||
@ -44,9 +47,10 @@ protected:
|
||||
bool filterAcceptsRow(int sourceRow,
|
||||
const QModelIndex &/*sourceParent*/) const
|
||||
{
|
||||
// Hide row 0 - username (needed only by this filter class)
|
||||
return (sourceRow > 0) ? true : false;
|
||||
return hiddenRows_.contains(sourceRow) ? false : true;
|
||||
}
|
||||
private:
|
||||
QSet<int> hiddenRows_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -43,7 +43,9 @@ PortStatsWindow::PortStatsWindow(PortGroupList *pgl, QWidget *parent)
|
||||
this->pgl = pgl;
|
||||
model = pgl->getPortStatsModel();
|
||||
|
||||
proxyStatsModel = new PortStatsProxyModel(this);
|
||||
// Hide 'user' row
|
||||
proxyStatsModel = new PortStatsProxyModel(
|
||||
QSet<int>({e_INFO_USER}), this);
|
||||
if (proxyStatsModel) {
|
||||
proxyStatsModel->setSourceModel(model);
|
||||
tvPortStats->setModel(proxyStatsModel);
|
||||
@ -57,15 +59,14 @@ PortStatsWindow::PortStatsWindow(PortGroupList *pgl, QWidget *parent)
|
||||
tvPortStats->verticalHeader()->minimumSectionSize());
|
||||
|
||||
// XXX: Set Delegates for port stats view
|
||||
// RowBorderDelegate: Group related stats by drawing a horizontal line
|
||||
// RowBorderDelegate: Group related stats using a horizontal line
|
||||
// IconOnlyDelegate : For status, show only icons not icons+text
|
||||
int offset = proxyStatsModel ? -1 : 0; // adjust for hidden 'user' row
|
||||
tvPortStats->setItemDelegate(
|
||||
new RowBorderDelegate(
|
||||
QSet<int>({
|
||||
e_STAT_FRAMES_SENT + offset,
|
||||
e_STAT_FRAME_SEND_RATE + offset,
|
||||
e_STAT_RX_DROPS + offset}),
|
||||
e_STAT_FRAMES_SENT,
|
||||
e_STAT_FRAME_SEND_RATE,
|
||||
e_STAT_RX_DROPS}),
|
||||
this));
|
||||
|
||||
statusDelegate = new IconOnlyDelegate(this);
|
||||
@ -81,7 +82,7 @@ PortStatsWindow::PortStatsWindow(PortGroupList *pgl, QWidget *parent)
|
||||
statusDelegate);
|
||||
#else
|
||||
// ... so we use this hard-coded hack
|
||||
tvPortStats->setItemDelegateForRow(e_COMBO_STATE + offset, statusDelegate);
|
||||
tvPortStats->setItemDelegateForRow(e_COMBO_STATE, statusDelegate);
|
||||
#endif
|
||||
|
||||
connect(tvPortStats->selectionModel(),
|
||||
|
Loading…
Reference in New Issue
Block a user