Skip to content

Commit d69667b

Browse files
committed
[processing] added progress display in qgsMessageBar
1 parent 3d775d6 commit d69667b

File tree

3 files changed

+67
-7
lines changed

3 files changed

+67
-7
lines changed

python/plugins/processing/core/Processing.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
from processing import interface
2019

2120
__author__ = 'Victor Olaya'
2221
__date__ = 'August 2012'
@@ -28,6 +27,8 @@
2827
from PyQt4.QtCore import *
2928
from PyQt4.QtGui import *
3029
from qgis.core import *
30+
from processing import interface
31+
from processing.gui.MessageBarProgress import MessageBarProgress
3132
from processing.tools import dataobjects
3233
from processing.core.ProcessingConfig import ProcessingConfig
3334
from processing.core.GeoAlgorithm import GeoAlgorithm
@@ -341,11 +342,13 @@ def cancel():
341342
algEx.start()
342343
algEx.wait()
343344
else:
344-
progress = SilentProgress()
345+
#progress = SilentProgress()
346+
progress = MessageBarProgress()
345347
ret = UnthreadedAlgorithmExecutor.runalg(alg, progress)
346348
if onFinish is not None and ret:
347349
onFinish(alg, progress)
348350
QApplication.restoreOverrideCursor()
351+
progress.close()
349352
return alg
350353

351354

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
SilentProgress.py
6+
---------------------
7+
Date : April 2013
8+
Copyright : (C) 2013 by Victor Olaya
9+
Email : volayaf at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
21+
__author__ = 'Victor Olaya'
22+
__date__ = 'April 2013'
23+
__copyright__ = '(C) 2013, Victor Olaya'
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
__revision__ = '$Format:%H$'
26+
27+
from processing import interface
28+
from PyQt4.QtCore import *
29+
from PyQt4 import QtGui
30+
31+
class MessageBarProgress():
32+
33+
def __init__(self):
34+
self.progressMessageBar = interface.iface.messageBar().createMessage("Executing algorithm")
35+
self.progress = QtGui.QProgressBar()
36+
self.progress.setMaximum(100)
37+
self.progress.setAlignment(Qt.AlignLeft|Qt.AlignVCenter)
38+
self.progressMessageBar.layout().addWidget(self.progress)
39+
interface.iface.messageBar().pushWidget(self.progressMessageBar, interface.iface.messageBar().INFO)
40+
41+
def setText(self, text):
42+
pass
43+
44+
def setPercentage(self, i):
45+
self.progress.setValue(i)
46+
47+
def setInfo(self, _):
48+
pass
49+
50+
def setCommand(self, _):
51+
pass
52+
53+
def setDebugInfo(self, _):
54+
pass
55+
56+
def setConsoleInfo(self, _):
57+
pass
58+
59+
def close(self):
60+
interface.iface.messageBar().clearWidgets()
61+
62+

python/plugins/processing/tools/dataobjects.py

-5
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ def getObjectFromUri(uri, forceLoad = True):
196196
These methods are used by the GeoAlgorithm class and allow the developer to use transparently
197197
any layer that is loaded into QGIS, without having to worry about its origin'''
198198

199-
@staticmethod
200199
def exportVectorLayer(layer):
201200
'''Takes a QgsVectorLayer and returns the filename to refer to it, which allows external
202201
apps which support only file-based layers to use it. It performs the necessary export
@@ -245,8 +244,6 @@ def exportVectorLayer(layer):
245244
return unicode(layer.source())
246245

247246

248-
249-
@staticmethod
250247
def exportRasterLayer(layer):
251248
'''Takes a QgsRasterLayer and returns the filename to refer to it, which allows external
252249
apps which support only file-based layers to use it. It performs the necessary export
@@ -259,8 +256,6 @@ def exportRasterLayer(layer):
259256
#TODO:Do the conversion here
260257
return unicode(layer.source())
261258

262-
263-
@staticmethod
264259
def exportTable( table):
265260
'''Takes a QgsVectorLayer and returns the filename to refer to its attributes table,
266261
which allows external apps which support only file-based layers to use it.

0 commit comments

Comments
 (0)