Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Copyright (c) 2011-2016 The Starwels developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #ifndef STARWELS_QT_PEERTABLEMODEL_H
  5. #define STARWELS_QT_PEERTABLEMODEL_H
  6. #include "net_processing.h" // For CNodeStateStats
  7. #include "net.h"
  8. #include <QAbstractTableModel>
  9. #include <QStringList>
  10. class ClientModel;
  11. class PeerTablePriv;
  12. QT_BEGIN_NAMESPACE
  13. class QTimer;
  14. QT_END_NAMESPACE
  15. struct CNodeCombinedStats {
  16. CNodeStats nodeStats;
  17. CNodeStateStats nodeStateStats;
  18. bool fNodeStateStatsAvailable;
  19. };
  20. class NodeLessThan
  21. {
  22. public:
  23. NodeLessThan(int nColumn, Qt::SortOrder fOrder) :
  24. column(nColumn), order(fOrder) {}
  25. bool operator()(const CNodeCombinedStats &left, const CNodeCombinedStats &right) const;
  26. private:
  27. int column;
  28. Qt::SortOrder order;
  29. };
  30. /**
  31. Qt model providing information about connected peers, similar to the
  32. "getpeerinfo" RPC call. Used by the rpc console UI.
  33. */
  34. class PeerTableModel : public QAbstractTableModel
  35. {
  36. Q_OBJECT
  37. public:
  38. explicit PeerTableModel(ClientModel *parent = 0);
  39. ~PeerTableModel();
  40. const CNodeCombinedStats *getNodeStats(int idx);
  41. int getRowByNodeId(NodeId nodeid);
  42. void startAutoRefresh();
  43. void stopAutoRefresh();
  44. enum ColumnIndex {
  45. NetNodeId = 0,
  46. Address = 1,
  47. Subversion = 2,
  48. Ping = 3
  49. };
  50. /** @name Methods overridden from QAbstractTableModel
  51. @{*/
  52. int rowCount(const QModelIndex &parent) const;
  53. int columnCount(const QModelIndex &parent) const;
  54. QVariant data(const QModelIndex &index, int role) const;
  55. QVariant headerData(int section, Qt::Orientation orientation, int role) const;
  56. QModelIndex index(int row, int column, const QModelIndex &parent) const;
  57. Qt::ItemFlags flags(const QModelIndex &index) const;
  58. void sort(int column, Qt::SortOrder order);
  59. /*@}*/
  60. public Q_SLOTS:
  61. void refresh();
  62. private:
  63. ClientModel *clientModel;
  64. QStringList columns;
  65. std::unique_ptr<PeerTablePriv> priv;
  66. QTimer *timer;
  67. };
  68. #endif // STARWELS_QT_PEERTABLEMODEL_H