changeset 18082:c3e7da9836bd stable

allow saving an editor file as the current one (bug #40759) * file-editor-tab.cc (handle_save_file_as_answer): just save the file if the selected file name is the same as the current file name (handle_save_file_as_answer_close): removed the case that the selected file name is the same as the current one because the latter is not valid here (message_duplicate_file_name): removed message since not needed anymore * file-editor-tab.h: removed message_duplicate_file_name
author Torsten <ttl@justmail.de>
date Thu, 05 Dec 2013 06:49:48 +0100
parents 42df174ec2ff
children b330e4da766f
files libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h
diffstat 2 files changed, 7 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Wed Dec 04 14:51:45 2013 -0800
+++ b/libgui/src/m-editor/file-editor-tab.cc	Thu Dec 05 06:49:48 2013 +0100
@@ -1158,31 +1158,12 @@
 }
 
 void
-file_editor_tab::message_duplicate_file_name (const QString& saveFileName)
-{
-  // Could overwrite the file here (and tell user the file was
-  // overwritten), but the user could have unintentionally
-  // selected the same name not intending to overwrite.
-
-  // Create a NonModal message about error.
-  QMessageBox* msgBox
-    = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"),
-                       tr ("File not saved! The selected file name\n%1\n"
-                           "is the same as the current file name").
-                       arg (saveFileName),
-                       QMessageBox::Ok, 0);
-
-  show_dialog (msgBox);
-}
-
-void
 file_editor_tab::handle_save_file_as_answer (const QString& saveFileName)
 {
   if (saveFileName == _file_name)
     {
-      message_duplicate_file_name (saveFileName);
-      // Nothing done, allow editing again.
-      _edit_area->setReadOnly (false);
+      // same name as actual file, save it as "save" would do
+      save_file (saveFileName);
     }
   else
     {
@@ -1194,17 +1175,11 @@
 void
 file_editor_tab::handle_save_file_as_answer_close (const QString& saveFileName)
 {
-  if (saveFileName == _file_name)
-    {
-      message_duplicate_file_name (saveFileName);
-      // Nothing done, allow editing again.
-      _edit_area->setReadOnly (false);
-    }
-  else
-    {
-      // Have editor check for conflict, delete tab after save.
-      emit editor_check_conflict_save (saveFileName, true);
-    }
+  // saveFileName == _file_name can not happen, because we only can get here
+  // when we close a tab and _file_name is not a valid file name yet
+
+  // Have editor check for conflict, delete tab after save.
+  emit editor_check_conflict_save (saveFileName, true);
 }
 
 void
--- a/libgui/src/m-editor/file-editor-tab.h	Wed Dec 04 14:51:45 2013 -0800
+++ b/libgui/src/m-editor/file-editor-tab.h	Thu Dec 05 06:49:48 2013 +0100
@@ -179,7 +179,6 @@
   bool valid_file_name (const QString& file=QString ());
   void save_file (const QString& saveFileName, bool remove_on_success = false);
   void save_file_as (bool remove_on_success = false);
-  void message_duplicate_file_name (const QString& fileName);
 
   void update_lexer ();
   void request_add_breakpoint (int line);