Moved more model code out of UI.
Upgraded to Qt5 using PyQt.