[commhistory-daemon] Build with either Qt4 or Qt5

Also includes some adaptation to the qtcontacts-sqlite backend.