Include <algorithm> for std::sort.
Add fallback implementation for Qt 4.7 here.

senderSignalIndex() was introduced in 4.8 only.