Fix #810349 (The ability to stop multiple selected jobs)

This commit is contained in:
Kovid Goyal 2011-07-14 15:07:28 -06:00
parent 79b1c42db0
commit ba574b6cc0
2 changed files with 19 additions and 14 deletions

View File

@ -29,9 +29,6 @@
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
@ -46,7 +43,7 @@
<item>
<widget class="QPushButton" name="kill_button">
<property name="text">
<string>&amp;Stop selected job</string>
<string>&amp;Stop selected jobs</string>
</property>
</widget>
</item>

View File

@ -268,7 +268,8 @@ class JobManager(QAbstractTableModel): # {{{
# }}}
# Jobs UI {{{
class ProgressBarDelegate(QAbstractItemDelegate):
class ProgressBarDelegate(QAbstractItemDelegate): # {{{
def sizeHint(self, option, index):
return QSize(120, 30)
@ -285,8 +286,9 @@ class ProgressBarDelegate(QAbstractItemDelegate):
opts.progress = percent
opts.text = QString(_('Unavailable') if percent == 0 else '%d%%'%percent)
QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
# }}}
class DetailView(QDialog, Ui_Dialog):
class DetailView(QDialog, Ui_Dialog): # {{{
def __init__(self, parent, job):
QDialog.__init__(self, parent)
@ -319,8 +321,9 @@ class DetailView(QDialog, Ui_Dialog):
self.next_pos = f.tell()
if more:
self.log.appendPlainText(more.decode('utf-8', 'replace'))
# }}}
class JobsButton(QFrame):
class JobsButton(QFrame): # {{{
def __init__(self, horizontal=False, size=48, parent=None):
QFrame.__init__(self, parent)
@ -405,6 +408,7 @@ class JobsButton(QFrame):
self.stop()
QCoreApplication.instance().alert(self, 5000)
# }}}
class JobsDialog(QDialog, Ui_JobsDialog):
@ -447,7 +451,6 @@ class JobsDialog(QDialog, Ui_JobsDialog):
except:
pass
def show_job_details(self, index):
row = index.row()
job = self.jobs_view.model().row_to_job(row)
@ -456,18 +459,23 @@ class JobsDialog(QDialog, Ui_JobsDialog):
d.timer.stop()
def show_details(self, *args):
for index in self.jobs_view.selectedIndexes():
index = self.jobs_view.currentIndex()
if index.isValid():
self.show_job_details(index)
return
def kill_job(self, *args):
if question_dialog(self, _('Are you sure?'), _('Do you really want to stop the selected job?')):
for index in self.jobs_view.selectionModel().selectedRows():
row = index.row()
rows = [index.row() for index in
self.jobs_view.selectionModel().selectedRows()]
if question_dialog(self, _('Are you sure?'),
ngettext('Do you really want to stop the selected job?',
'Do you really want to stop all the selected jobs?',
len(rows))):
for row in rows:
self.model.kill_job(row, self)
def kill_all_jobs(self, *args):
if question_dialog(self, _('Are you sure?'), _('Do you really want to stop all non-device jobs?')):
if question_dialog(self, _('Are you sure?'),
_('Do you really want to stop all non-device jobs?')):
self.model.kill_all_jobs()
def closeEvent(self, e):