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