AIFDR/inasafe — pull request #881 by akbargumbira (2014-03-14 11:01:17+00:00)
Title: Fix  #864

# Problem
On Windows 32 bit AND QGIS 2.2, the QNetworkReply.isFinished() method always returns false even if the QNetworkReply.finished slot is called. I could not find the underlying problem for this. What I could think is: QGIS 2.2 do some monkey patching to QT since it is working on QGIS 2.0 on all platforms (Windows 32, 64, Linux Mint, Ubuntu).

# Solution
See the process of my debugging on #864
I changed the use of readyRead slot and finished slot. Slot readyRead is used to save the downloaded buffer from QNetworkReply (it is good to save this buffer for downloading a large file). Once finished slot is called, then I save the downloaded buffer to a file and mark a variable called is_finish on class Downloader.

So, there are two finish mark from QNetworkReply: QNetworkReply.isfinished() and Downloader object field is_finish.

I also add the class Downloader as it was kinky to use nested functions and track its variable.

# Test Workaround
- This PR has been tested to check OSM Downloader functionality on:

| QGIS 2.0 | QGIS 2.2 | QGIS Master (7264777)
------------ | ------------|------------|----------------
Windows XP 32 bit | - | - | -
Windows 7 32 bit | OK | OK | -
Windows 7 64 bit | OK | OK | -
Linux Mint 64 bit | OK | OK | OK
Ubuntu 12.04 64 bit | OK | - | -

- A unittest is failing: test_osm_downloader.test_download