From 1b9c548768a00f57a7cbb79e6d4b104787eb7d75 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Fri, 27 Jul 2007 13:30:46 +0300 Subject: [PATCH] Use insert or replace. Sort categories by priority. --- src/poi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/poi.c b/src/poi.c index adc3e99..848d41f 100644 --- a/src/poi.c +++ b/src/poi.c @@ -109,14 +109,15 @@ sqlite3_stmt *sql_cat; gint i; g_printf("Checking default categories\n"); -sqlite3_prepare_v2(db,"insert into category (cat_id, label, desc, enabled)" - " values (?, ?, ?, 1)", +sqlite3_prepare_v2(db,"insert or replace into category (cat_id, label, desc, enabled, priority)" + " values (?, ?, ?, 1, ?)", -1, &sql_cat, NULL); for (i=0; default_poi_categories[i].name; i++) { sqlite3_bind_int(sql_cat, 1, default_poi_categories[i].type); sqlite3_bind_text(sql_cat, 2, default_poi_categories[i].name , -1, SQLITE_TRANSIENT); sqlite3_bind_text(sql_cat, 3, default_poi_categories[i].desc , -1, SQLITE_TRANSIENT); + sqlite3_bind_int(sql_cat, 4, default_poi_categories[i].type/100); sqlite3_step(sql_cat); sqlite3_reset(sql_cat); sqlite3_clear_bindings(sql_cat); @@ -156,6 +157,7 @@ poi_db_create(sqlite3 *db) "desc text, " "icon text, " "color char(7), " + "priority integer default 2, " "enabled integer);"); if (SQLITE_OK != sqlite3_exec(db, create_sql, NULL, NULL, NULL) @@ -244,7 +246,7 @@ poi_db_prepare(sqlite3 *db) " from category c" " left outer join poi p on c.cat_id = p.cat_id" " group by c.cat_id, c.label, c.desc, c.enabled " - " order by c.label", -1, &_stmt_selall_cat, NULL); + " order by c.priority,c.label", -1, &_stmt_selall_cat, NULL); return TRUE; } -- 2.39.5