QString usage refactoring.
SQL building refactoring.
Refactoring of sort dialog.