Mercurial > hg > syntilista
diff src/main.cpp @ 109:62e570222f66
Return inserted person ID from addPerson() (or negative value in case of errors.)
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 04 Jul 2017 09:53:38 +0300 |
parents | 8ceaafde9b52 |
children | 7a3e9d4c9b71 |
line wrap: on
line diff
--- a/src/main.cpp Mon Jul 03 11:55:59 2017 +0300 +++ b/src/main.cpp Tue Jul 04 09:53:38 2017 +0300 @@ -1084,7 +1084,7 @@ } -int PersonSQLModel::addPerson(const PersonInfo &info) +qint64 PersonSQLModel::addPerson(const PersonInfo &info) { // beginInsertRows(QModelIndex(), rowCount(), rowCount()); @@ -1102,9 +1102,11 @@ QSqlDatabase::database().commit(); + QVariant idp = np.lastInsertId(); + // endInsertRows(); updateModel(); - return 0; + return idp.isValid() ? idp.toInt() : -2; }