summaryrefslogtreecommitdiffstats
path: root/listmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'listmodel.cpp')
-rw-r--r--listmodel.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/listmodel.cpp b/listmodel.cpp
index 437ec3e..71a5040 100644
--- a/listmodel.cpp
+++ b/listmodel.cpp
@@ -165,10 +165,10 @@ bool ListModel::removeItem(const QVariant &item){
if(rowToDelete == -1){
return false;
}
- bool success = removeRows(rowToDelete, 1, QModelIndex());
+ mDeleteQuery->bindValue(":name", item.toString());
+ bool success = mDeleteQuery->exec();
if(success){
- mDeleteQuery->bindValue(":name", item.toString());
- success = mDeleteQuery->exec();
+ success = removeRows(rowToDelete, 1, QModelIndex());
}
return success;
}
@@ -185,6 +185,14 @@ bool ListModel::renameItem(const QVariant &oldName, const QVariant &newName){
return success;
}
+int ListModel::defaultId(){
+ if(!mItems.isEmpty()){
+ return mItems.at(0)->id();
+ }
+ addItem("(default)");
+ return mItems.at(0)->id();
+}
+
void ListModel::populate(){
QString query = QString("SELECT i%1id, t%1name FROM %1 ORDER BY t%1name").arg(mTable);
QSqlQuery q(query);