CMake config + a number of small fixes

Created a CMakeList configuration file to make building on any platform a bit easier.
Fixed a few warnings (c-style casts) and some Qt4-5 incompatibilities.
Renamed the protoc-generated files so that out-of-source builds don't get into a conflict with these stray files in the source directory.
Fixed a couple of easy-to-fix segmentation faults when trying to walk along an empty history.

With these modifications, the application compiles cleanly on a "stock" Ubuntu 14.04 distro with all the dependencies installed from package manager, and using Qt4 instead of Qt5.

The cmake config would still need the addition of a find-package (or similar) to find Qt5 to match the original qmake configuration.