X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=formations.h;h=c02317329588a3ff305090d1d2276c17c00b311e;hb=e89ed5aca344eac629ea515ade96fbde5ecab0c0;hp=5eda723964d268bc35a1ea3eedb90a61f23f0b3c;hpb=67da94217a271b0b76d42c75d1a78ee5ba942825;p=pkanalytics diff --git a/formations.h b/formations.h index 5eda723..c023173 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 == 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 == formation_id) { + return i + 1; + } + } + abort(); + } private: struct Formation {