]> git.sesse.net Git - pkanalytics/commitdiff
Move some meaty member functions out-of-line from EventsModel.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 11:43:53 +0000 (13:43 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 1 May 2023 11:43:53 +0000 (13:43 +0200)
stats.cpp

index 5124ca320c629ab5eb9189deaca323db37b54705..63676cbe02503af7fa4a241d50be291c4f6b4e1f 100644 (file)
--- a/stats.cpp
+++ b/stats.cpp
@@ -43,45 +43,8 @@ public:
        {
                return 3;
        }
-       QVariant headerData(int section, Qt::Orientation orientation, int role) const override
-       {
-               if (role != Qt::DisplayRole) {
-                       return QVariant();
-               }
-               if (orientation == Qt::Horizontal) {
-                       if (section == 0) {
-                               return "Time";
-                       } else if (section == 1) {
-                               return "Player";
-                       } else {
-                               return "Type";
-                       }
-               } else {
-                       return "";
-               }
-       }
-
-       QVariant data(const QModelIndex &index, int role) const override
-       {
-               if (role != Qt::DisplayRole) {
-                       return QVariant();
-               }
-               refresh_if_needed();
-               if (index.column() == 0) {
-                       return QString::fromUtf8(format_timestamp(events[index.row()].t));
-               } else if (index.column() == 1) {
-                       optional<int> player_id = events[index.row()].player_id;
-                       if (player_id) {
-                               const Player &p = players[*player_id];
-                               return QString::fromUtf8(p.name + " (" + p.number + ")");
-                       } else {
-                               return QVariant();
-                       }
-               } else if (index.column() == 2) {
-                       return QString::fromUtf8(events[index.row()].type);
-               }
-               return QVariant();
-       }
+       QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+       QVariant data(const QModelIndex &index, int role) const override;
 
 private:
        struct Player {
@@ -104,6 +67,46 @@ private:
        void refresh_if_needed() const;
 };
 
+QVariant EventsModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+       if (role != Qt::DisplayRole) {
+               return QVariant();
+       }
+       if (orientation == Qt::Horizontal) {
+               if (section == 0) {
+                       return "Time";
+               } else if (section == 1) {
+                       return "Player";
+               } else {
+                       return "Type";
+               }
+       } else {
+               return "";
+       }
+}
+
+QVariant EventsModel::data(const QModelIndex &index, int role) const
+{
+       if (role != Qt::DisplayRole) {
+               return QVariant();
+       }
+       refresh_if_needed();
+       if (index.column() == 0) {
+               return QString::fromUtf8(format_timestamp(events[index.row()].t));
+       } else if (index.column() == 1) {
+               optional<int> player_id = events[index.row()].player_id;
+               if (player_id) {
+                       const Player &p = players[*player_id];
+                       return QString::fromUtf8(p.name + " (" + p.number + ")");
+               } else {
+                       return QVariant();
+               }
+       } else if (index.column() == 2) {
+               return QString::fromUtf8(events[index.row()].type);
+       }
+       return QVariant();
+}
+
 void EventsModel::refresh_if_needed() const
 {
        if (!stale) {