X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=formations.h;h=efc87feaa34bfc3b520b7c9d73327d43c6967947;hb=93050ae334fcb08e23b4aa21867af7f9b8a92338;hp=5eda723964d268bc35a1ea3eedb90a61f23f0b3c;hpb=67da94217a271b0b76d42c75d1a78ee5ba942825;p=pkanalytics diff --git a/formations.h b/formations.h index 5eda723..efc87fe 100644 --- a/formations.h +++ b/formations.h @@ -18,6 +18,8 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role) const override; QVariant data(const QModelIndex &index, int role) const override; + unsigned insert_new(const std::string &name); // Returns the new ID. + int get_formation_id(unsigned row) const { if (row == 0) { return 0; @@ -27,7 +29,22 @@ public: } return formations[row - 1].formation_id; } - std::string get_formation_name_by_id(unsigned formation_id); + std::string get_formation_name_by_id(unsigned formation_id) { + for (unsigned i = 0; i < formations.size(); ++i) { + if (formations[i].formation_id == int(formation_id)) { + return formations[i].name; + } + } + abort(); + } + unsigned get_row_from_id(unsigned formation_id) { + for (unsigned i = 0; i < formations.size(); ++i) { + if (formations[i].formation_id == int(formation_id)) { + return i + 1; + } + } + abort(); + } private: struct Formation {