return;
}
- if (text.length() >= 3)
- query = "%" + text + "%";
- else
- query = text + "%";
+ query = toSearchQuery(text);
QSqlQuery &q = MyList::instance()->database()->prepare(
- "SELECT a.aid, b.title AS main_title, a.title, a.language, a.type FROM anime_title a "
- " LEFT JOIN anime_title b on b.aid = a.aid "
- " WHERE a.title ILIKE :query "
- " AND b.type = 1 "
- " ORDER BY a.title ASC, a.aid ASC "
- " LIMIT 100");
- q.bindValue(":word", text);
+ "SELECT at.title_id, at.aid, at.type, at.language, at.title "
+ " FROM anime_title at "
+ " WHERE at.title ILIKE :query "
+ " ORDER BY at.title <-> :query2 ASC "
+ " LIMIT :limit");
q.bindValue(":query", query);
-
+ q.bindValue(":query2", query);
+ q.bindValue(":limit", 100);
MyList::instance()->database()->exec(q);
model->setQuery(q);