Modify dirtied question if many dirtied editors present.

Also mark editors as clean when updating editors from container.
This commit is contained in:
Kovid Goyal 2013-12-02 09:01:45 +05:30
parent 6de811922f
commit a7ab2ae11b

View File

@ -96,6 +96,11 @@ class Boss(QObject):
dirtied = {name for name, ed in editors.iteritems() if ed.is_modified} dirtied = {name for name, ed in editors.iteritems() if ed.is_modified}
if not dirtied: if not dirtied:
return True return True
if len(dirtied) > 4:
return question_dialog(self.gui, _('Unsaved changes'), _(
'You have unsaved changes in many opened files. If you proceed,'
' you will lose them. Proceed anyway?') % ', '.join(dirtied))
return question_dialog(self.gui, _('Unsaved changes'), _( return question_dialog(self.gui, _('Unsaved changes'), _(
'You have unsaved changes in the files %s. If you proceed,' 'You have unsaved changes in the files %s. If you proceed,'
' you will lose them. Proceed anyway?') % ', '.join(dirtied)) ' you will lose them. Proceed anyway?') % ', '.join(dirtied))
@ -155,6 +160,7 @@ class Boss(QObject):
for name, ed in tuple(editors.iteritems()): for name, ed in tuple(editors.iteritems()):
if c.has_name(name): if c.has_name(name):
ed.replace_data(c.raw_data(name)) ed.replace_data(c.raw_data(name))
ed.is_modified = False
else: else:
self.close_editor(name) self.close_editor(name)
@ -162,8 +168,8 @@ class Boss(QObject):
container = current_container() container = current_container()
self.gui.file_list.build(container) self.gui.file_list.build(container)
self.update_global_history_actions() self.update_global_history_actions()
self.set_modified()
self.update_editors_from_container() self.update_editors_from_container()
self.set_modified()
def delete_requested(self, spine_items, other_items): def delete_requested(self, spine_items, other_items):
if not self.check_dirtied(): if not self.check_dirtied():