Cleanup code by using forward declarations.

Use misc methods of avoiding unnecesary header includes.
Replace manual typedefs with stdint.h, replace PRI64[xdu] with PRI[xdu]64 from inttypes.h
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones, remove extern declarations from .cpp files.