Model refactoring, sorting, smarter buttons!

The tool can now sort by attributes :)
I also added smarter button behavior for the Query tab (delete enables
and disables if a row is selected/not).
Removed the edit button because it is more trouble than it is worth.
In the process, refactored the model a bit to reuse code more
efficiently.