Fix header view resize mode settings if the model is lazily populated.

QHeaderView asserts when setting a resize mode for column currently not
existing in the model, and forgets settings if the column is temporarily
removed from the model.
Fix SidePane size hint when using a lazily populated model.
Only query tool id when actually needed.
Fix Qt4/Qt5 incompatibility, Qt::UserRole changed its value.

Use the maximum of both unconditionally, allows using the Qt5 client with
a Qt4 server and vice versa.