mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update UI when renaming files
This commit is contained in:
parent
3e99a59056
commit
7843714995
@ -266,8 +266,10 @@ class Boss(QObject):
|
||||
det_msg=job.traceback, show=True)
|
||||
self.gui.file_list.build(current_container())
|
||||
self.gui.action_save.setEnabled(True)
|
||||
# TODO: Update the rest of the GUI. This means renaming open editors and
|
||||
# then calling update_editors_from_container()
|
||||
if oldname in editors:
|
||||
editors[newname] = editors.pop(oldname)
|
||||
self.gui.central.rename_editor(editors[newname], newname)
|
||||
self.apply_container_update_to_gui()
|
||||
# }}}
|
||||
|
||||
# Global history {{{
|
||||
|
@ -58,7 +58,10 @@ class ItemDelegate(QStyledItemDelegate): # {{{
|
||||
if top_level:
|
||||
suffix = '%s(%d)' % (NBSP, index.model().rowCount(index))
|
||||
else:
|
||||
suffix = NBSP + human_readable(current_container().filesize(unicode(index.data(NAME_ROLE).toString())))
|
||||
try:
|
||||
suffix = NBSP + human_readable(current_container().filesize(unicode(index.data(NAME_ROLE).toString())))
|
||||
except EnvironmentError:
|
||||
suffix = NBSP + human_readable(0)
|
||||
br = painter.boundingRect(option.rect, Qt.AlignRight|Qt.AlignVCenter, suffix)
|
||||
if top_level and index.row() > 0:
|
||||
option.rect.adjust(0, 5, 0, 0)
|
||||
|
@ -75,6 +75,13 @@ class Central(QStackedWidget):
|
||||
self.editor_tabs.setTabToolTip(index, _('Full path:') + ' ' + name)
|
||||
editor.modification_state_changed.connect(self.editor_modified)
|
||||
|
||||
def rename_editor(self, editor, name):
|
||||
for i in xrange(self.editor_tabs.count()):
|
||||
if self.editor_tabs.widget(i) is editor:
|
||||
fname = name.rpartition('/')[2]
|
||||
self.editor_tabs.setTabText(i, fname)
|
||||
self.editor_tabs.setTabToolTip(i, _('Full path:') + ' ' + name)
|
||||
|
||||
def show_editor(self, editor):
|
||||
self.setCurrentIndex(1)
|
||||
self.editor_tabs.setCurrentWidget(editor)
|
||||
|
Loading…
x
Reference in New Issue
Block a user