Completed search widget and fixed some SQL

SQL fixed:
Some SQL statements that previously used sqlite3 now use QtSql