Browse Source

[Qt] minor optimisations in peertablemodel

- remove an unneeded include of net.h in peertablemodel.cpp
- add const after size() in PeerTablePriv
- remove 2x unneeded else in functions
- replace a (int) typecast by (QVariant) to use Qt style
- remove unneeded include of peertablemodel.h from rpcconsole.cpp
0.13
Philip Kaufmann 10 years ago
parent
commit
92684bb872
  1. 15
      src/qt/peertablemodel.cpp
  2. 1
      src/qt/rpcconsole.cpp

15
src/qt/peertablemodel.cpp

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
#include "guiconstants.h"
#include "guiutil.h"
#include "net.h"
#include "sync.h"
#include <QDebug>
@ -96,19 +95,18 @@ public: @@ -96,19 +95,18 @@ public:
mapNodeRows.insert(std::pair<NodeId, int>(stats.nodeStats.nodeid, row++));
}
int size()
int size() const
{
return cachedNodeStats.size();
}
CNodeCombinedStats *index(int idx)
{
if(idx >= 0 && idx < cachedNodeStats.size()) {
if (idx >= 0 && idx < cachedNodeStats.size())
return &cachedNodeStats[idx];
} else {
return 0;
}
}
};
PeerTableModel::PeerTableModel(ClientModel *parent) :
@ -171,7 +169,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const @@ -171,7 +169,7 @@ QVariant PeerTableModel::data(const QModelIndex &index, int role) const
}
} else if (role == Qt::TextAlignmentRole) {
if (index.column() == Ping)
return (int)(Qt::AlignRight | Qt::AlignVCenter);
return (QVariant)(Qt::AlignRight | Qt::AlignVCenter);
}
return QVariant();
@ -204,14 +202,9 @@ QModelIndex PeerTableModel::index(int row, int column, const QModelIndex &parent @@ -204,14 +202,9 @@ QModelIndex PeerTableModel::index(int row, int column, const QModelIndex &parent
CNodeCombinedStats *data = priv->index(row);
if (data)
{
return createIndex(row, column, data);
}
else
{
return QModelIndex();
}
}
const CNodeCombinedStats *PeerTableModel::getNodeStats(int idx)
{

1
src/qt/rpcconsole.cpp

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
#include "clientmodel.h"
#include "guiutil.h"
#include "peertablemodel.h"
#include "platformstyle.h"
#include "chainparams.h"

Loading…
Cancel
Save