]> git.sesse.net Git - pkanalytics/blobdiff - formations.h
Make it possible to insert new formations from the UI.
[pkanalytics] / formations.h
index 5eda723964d268bc35a1ea3eedb90a61f23f0b3c..aa85c79feb97b57838b63d8f276f927a33fa3f00 100644 (file)
@@ -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;
@@ -28,6 +30,14 @@ public:
                return formations[row - 1].formation_id;
        }
        std::string get_formation_name_by_id(unsigned formation_id);
+       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 {