RefactoringRope/ProgressHandle.py

changeset 68
397a14ba3ca6
parent 62
1077db8d0589
child 76
936b2a98fe4e
equal deleted inserted replaced
67:b33946b65854 68:397a14ba3ca6
5 5
6 """ 6 """
7 Module implementing a TaskHandle class with a progress dialog. 7 Module implementing a TaskHandle class with a progress dialog.
8 """ 8 """
9 9
10 from PyQt4.QtGui import QApplication, QProgressDialog, QLabel 10 from PyQt4.QtGui import QApplication, QLabel
11 11
12 import rope.base.taskhandle 12 import rope.base.taskhandle
13 13
14 14
15 class ProgressHandle(rope.base.taskhandle.TaskHandle): 15 class ProgressHandle(rope.base.taskhandle.TaskHandle):
28 rope.base.taskhandle.TaskHandle.__init__(self, title, interruptable) 28 rope.base.taskhandle.TaskHandle.__init__(self, title, interruptable)
29 if interruptable: 29 if interruptable:
30 cancelLabel = QApplication.translate("ProgressHandle", "Interrupt") 30 cancelLabel = QApplication.translate("ProgressHandle", "Interrupt")
31 else: 31 else:
32 cancelLabel = "" 32 cancelLabel = ""
33 self.__progress = QProgressDialog("", cancelLabel, 0, 100, parent) 33 barFormat = QApplication.translate("ProgressHandle", "%v/%m files")
34 try:
35 from E5Gui.E5ProgressDialog import E5ProgressDialog
36 self.__progress = E5ProgressDialog("", cancelLabel, 0, 1,
37 barFormat, parent)
38 except ImportError:
39 from PyQt4.QtGui import QProgressDialog, QProgressBar
40 self.__progress = QProgressDialog("", cancelLabel, 0, 1, parent)
41 bar = QProgressBar(self.__progress)
42 bar.setFormat(barFormat)
43 self.__progress.setBar(bar)
34 label = QLabel("") 44 label = QLabel("")
35 label.setWordWrap(True) 45 label.setWordWrap(True)
36 self.__progress.setLabel(label) 46 self.__progress.setLabel(label)
47 self.__progress.setWindowTitle(
48 QApplication.translate("ProgressHandle", "eric5 - {0}")
49 .format(title))
37 self.add_observer(self.__updateProgress) 50 self.add_observer(self.__updateProgress)
38 51
39 def __updateProgress(self): 52 def __updateProgress(self):
40 """ 53 """
41 Private slot to handle the task progress. 54 Private slot to handle the task progress.
44 if jobset: 57 if jobset:
45 text = '' 58 text = ''
46 if jobset.get_name() is not None: 59 if jobset.get_name() is not None:
47 text += jobset.get_name() 60 text += jobset.get_name()
48 if jobset.get_active_job_name() is not None: 61 if jobset.get_active_job_name() is not None:
49 text += ' : ' + jobset.get_active_job_name() 62 text += ': ' + jobset.get_active_job_name()
50 self.__progress.setLabelText(text) 63 self.__progress.setLabelText(text)
51 percent = jobset.get_percent_done() 64 if jobset.count is not None:
52 if percent is not None: 65 self.__progress.setMaximum(jobset.count)
53 self.__progress.setValue(percent) 66 self.__progress.setValue(jobset.done)
54 QApplication.processEvents() 67 QApplication.processEvents()
55 if not self.is_stopped() and self.__progress.wasCanceled(): 68 if not self.is_stopped() and self.__progress.wasCanceled():
56 self.stop() 69 self.stop()
57 70
58 def show(self): 71 def show(self):

eric ide

mercurial