[tests] Don't require GUI for the tests
remove unused functions from contactwriter
Introduce QueryBuilder class

This class will help simplify the code in contactsreader
to allow more flexibility in constructing queries for
performance reasons.

This commit just introduces the class and its tests,
it does not take it into use yet.
start switching over to QueryBuilder

Use QueryBuilder for constructing the temporary
contact ids table, but in this commit only at
a surface level: leave buildWhere alone for now.

This commit pushes the LIMIT handling up from
contactsdatabase to contactreader (contactwriter
does not use it).

The call from the readContacts() variant that
uses a list of ids needs a bit of special
handling for that, but it's special handling
that is beneficial anyway: it's more efficient
to pass in a truncated boundIds list than to
construct the full list and then use only part of it.

This also fixes a bug where readContacts could
return QContactManager::DoesNotExistError when
actually the query just had a maxCountHint.