Fix sorting and filtering speed issues.

Now we sort using qStableSort and kind of comply with most Qt's policies
regarding signals emitted when sorting. I am not sure what made the old code
sluggish, but the problem seems to be gone, and the new implementation
is cleaner anyway.