summaryrefslogtreecommitdiffstats
path: root/src/util/statmodel.h
blob: f66bbf02adc088ce81b7b814661181474133f378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include <QAbstractTableModel>
#include <QVariant>
#include <QVector>
#include <QHash>
#include <QList>
#include <QModelIndex>
#include <QString>

#include "util/stat.h"

class StatModel final : public QAbstractTableModel {
    Q_OBJECT
  public:
    enum StatColumn {
        STAT_COLUMN_NAME = 0,
        STAT_COLUMN_COUNT,
        STAT_COLUMN_TYPE,
        STAT_COLUMN_UNITS,
        STAT_COLUMN_SUM,
        STAT_COLUMN_MIN,
        STAT_COLUMN_MAX,
        STAT_COLUMN_MEAN,
        STAT_COLUMN_VARIANCE,
        STAT_COLUMN_STDDEV,
        NUM_STAT_COLUMNS
    };

    StatModel(QObject* pParent=NULL);
    virtual ~StatModel();

    ////////////////////////////////////////////////////////////////////////////
    // QAbstractItemModel methods
    ////////////////////////////////////////////////////////////////////////////
    int rowCount(const QModelIndex& parent = QModelIndex()) const;
    int columnCount(const QModelIndex& parent = QModelIndex()) const;
    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
    bool setHeaderData(int section, Qt::Orientation orientation,
                       const QVariant& value, int role = Qt::EditRole);
    QVariant headerData(int section, Qt::Orientation orientation,
                        int role = Qt::DisplayRole) const;

  public slots:
    void statUpdated(const Stat& stat);

  private:
    QVector<QHash<int, QVariant> > m_headerInfo;
    QList<Stat> m_stats;
    QHash<QString, int> m_statNameToRow;
};