X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=formations.cpp;h=dc07a1f666b5d5790690f4e8ed152ff30e9d9d9b;hb=aa802626d5a5bfaa21bf38556b80665450909bed;hp=55e6de8c95f7d0429c8ff79bd19e6c109c1bb914;hpb=54bd286ed213509da23c43d0c80f731dd1bb7a18;p=pkanalytics diff --git a/formations.cpp b/formations.cpp index 55e6de8..dc07a1f 100644 --- a/formations.cpp +++ b/formations.cpp @@ -37,7 +37,7 @@ QVariant FormationsModel::data(const QModelIndex &index, int role) const if (index.column() == 0) { if (index.row() == 0) { return QString::fromUtf8("(None/unknown)"); - } else if (index.row() == formations.size() + 1) { + } else if (index.row() == int(formations.size() + 1)) { return QString::fromUtf8("Add new…"); } else { return QString::fromUtf8(formations[index.row() - 1].name); @@ -70,12 +70,10 @@ unsigned FormationsModel::insert_new(const std::string &name) fprintf(stderr, "INSERT finalize: %s\n", sqlite3_errmsg(db)); abort(); } - - beginResetModel(); // Simplest for our use, though not ideal. - int formation_id = sqlite3_last_insert_rowid(db); - formations.push_back(Formation{ formation_id, name }); + beginResetModel(); // Simplest for our use, though not ideal. + load_data(); endResetModel(); return formation_id;