Prevent qtconsole frontend freeze on lots of output.

The output from the kernel is now clipped to last `buffer_size`
before displaying and a timer is used to flush the pending output
text instead of attempting to display text on every stream
output from kernel. The timer interval is adjusted based on
actual time taken to append a screenful of text to widget.
This throttles the widget repaints and avoids choking the Qt
event loop leaving time to handle other Qt events.

Test cases:
  In [1]: for i in xrange(1000000): print i
  In [2]: range(100000)

Without this commit the first input causes the qtconsole frontend
to freeze, not responding to `Ctrl+C`.
Merge pull request #3409 from pankajp/qt-console-freeze-on-output-clip

Prevent qtconsole frontend freeze on lots of output.

The output from the kernel is now clipped to last buffer_size
before displaying and a timer is used to flush the pending output
text instead of attempting to display text on every stream
output from kernel. The timer interval is adjusted based on
actual time taken to append a screenful of text to widget.
This throttles the widget repaints and avoids choking the Qt
event loop leaving time to handle other Qt events.