Skip to content

Commit 64e9d93

Browse files
author
mhugent
committed
Emit signals from QgsHttpTransaction that allow progress bar and canceling of current transation
git-svn-id: http://svn.osgeo.org/qgis/trunk@9938 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 87a8e8d commit 64e9d93

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/core/qgshttptransaction.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ bool QgsHttpTransaction::getSynchronously( QByteArray &respondedContent, int red
184184
// QgsDebugMsg("Response received; being '" + httpresponsestring + "'.");
185185
#endif
186186

187-
delete http;
187+
delete http;
188+
http = 0;
188189

189190
// Did we get an error? If so, bail early
190191
if ( !mError.isNull() )
@@ -287,6 +288,9 @@ void QgsHttpTransaction::dataProgress( int done, int total )
287288
// We saw something come back, therefore restart the watchdog timer
288289
mWatchdogTimer->start( NETWORK_TIMEOUT_MSEC );
289290

291+
emit dataReadProgress(done);
292+
emit totalSteps(total);
293+
290294
QString status;
291295

292296
if ( total )
@@ -464,4 +468,12 @@ QString QgsHttpTransaction::errorString()
464468
return mError;
465469
}
466470

471+
void QgsHttpTransaction::abort()
472+
{
473+
if(http)
474+
{
475+
http->abort();
476+
}
477+
}
478+
467479
// ENDS

src/core/qgshttptransaction.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,18 @@ class CORE_EXPORT QgsHttpTransaction : public QObject
9999

100100
void networkTimedOut();
101101

102+
/**Aborts the current transaction*/
103+
void abort();
104+
102105
signals:
103106

104-
/** \brief emit a signal to notify of a progress event */
105-
void setProgress( int theProgress, int theTotalSteps );
107+
/**legacy code. This signal is currently not emitted and only kept for API compatibility*/
108+
void setProgress(int done, int total);
109+
110+
/**Signal for progress update */
111+
void dataReadProgress( int theProgress);
112+
/**Signal for adjusted number of steps*/
113+
void totalSteps(int theTotalSteps);
106114

107115
/** \brief emit a signal to be caught by qgisapp and display a msg on status bar */
108116
void statusChanged( QString theStatusQString );

0 commit comments

Comments
 (0)