Include previous searches in History panel items

This commit is contained in:
Christian Dywan 2010-02-25 23:09:31 +01:00
parent cc79b94c34
commit 3f886f7153
3 changed files with 10 additions and 9 deletions

View file

@ -373,9 +373,9 @@ midori_history_initialize (KatzeArray* array,
"CREATE TABLE IF NOT EXISTS "
"search (keywords text, uri text, day integer);"
"CREATE TEMP VIEW history_view AS SELECT "
"1 AS type, uri, title FROM history;"
"1 AS type, uri, title, day FROM history;"
"CREATE TEMP VIEW search_view AS SELECT "
"2 AS type, uri, keywords AS title FROM search;",
"2 AS type, uri, keywords AS title, day FROM search;",
NULL, NULL, errmsg) != SQLITE_OK)
return NULL;

View file

@ -361,7 +361,7 @@ midori_location_action_popup_timeout_cb (gpointer data)
sqlcmd = "SELECT type, uri, title, count() AS ct FROM history_view "
"WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
"UNION ALL "
"SELECT type, uri, title, count() AS ct FROM search_view "
"SELECT type, replace(uri, '%s', title) AS uri, title, count() AS ct FROM search_view "
"WHERE title LIKE ?1 GROUP BY uri "
"ORDER BY ct DESC LIMIT ?2";
sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL);
@ -450,12 +450,10 @@ midori_location_action_popup_timeout_cb (gpointer data)
FAVICON_COL, icon, -1);
else if (type == 2 /* search_view */)
{
gchar* search_uri = sokoke_search_uri ((gchar*)uri, (gchar*)title);
gchar* search_title = g_strdup_printf (_("Search for %s"), title);
gtk_list_store_insert_with_values (store, NULL, matches,
URI_COL, search_uri, TITLE_COL, search_title, YALIGN_COL, 0.25,
URI_COL, uri, TITLE_COL, search_title, YALIGN_COL, 0.25,
STYLE_COL, 1, FAVICON_COL, icon, -1);
g_free (search_uri);
g_free (search_title);
}

View file

@ -210,9 +210,12 @@ midori_history_read_from_db (MidoriHistory* history,
{
gchar* filterstr;
sqlcmd = "SELECT uri, title, date "
"FROM history WHERE uri LIKE ? or title LIKE ? "
"GROUP BY uri ORDER BY date ASC";
sqlcmd = "SELECT uri, title, day FROM history_view "
"WHERE uri LIKE ? or title LIKE ? GROUP BY uri "
"UNION ALL "
"SELECT replace(uri, '%s', title) AS uri, title, day "
"FROM search_view WHERE title LIKE ?1 GROUP BY uri "
"ORDER BY day ASC";
result = sqlite3_prepare_v2 (db, sqlcmd, -1, &statement, NULL);
filterstr = g_strdup_printf ("%%%s%%", filter);
sqlite3_bind_text (statement, 1, filterstr, -1, g_free);