changeset 23870:a5ec1fc3d9a5

editor: use function instead several occurrences of identical code * file-editor.cc (find_tab_widget): remove const attribute and move clearing the editor tab map before calling this function here; (request_open_file, check_conflict_save, handle_delete_debugger): move code from here * file-editor.h: remove const attribute from find_tab_widget
author Torsten <mttl@mailbox.org>
date Thu, 10 Aug 2017 21:57:53 +0200
parents b3d59e080eae
children 5352f632859b
files libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h
diffstat 2 files changed, 7 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Thu Aug 10 15:13:12 2017 -0400
+++ b/libgui/src/m-editor/file-editor.cc	Thu Aug 10 21:57:53 2017 +0200
@@ -227,8 +227,13 @@
 
 // Check whether this file is already open in the editor.
 QWidget *
-file_editor::find_tab_widget (const QString& file) const
+file_editor::find_tab_widget (const QString& file)
 {
+  // Have all file editor tabs signal what their filenames are.
+  editor_tab_map.clear ();
+  emit fetab_file_name_query (nullptr);
+
+  // Check all tabs for the given file name
   QWidget *retval = nullptr;
 
   for (editor_tab_map_const_iterator p = editor_tab_map.begin ();
@@ -305,10 +310,6 @@
     }
   else
     {
-      // Have all file editor tabs signal what their filenames are.
-      editor_tab_map.clear ();
-      emit fetab_file_name_query (nullptr);
-
       // Check whether this file is already open in the editor.
       QWidget *tab = find_tab_widget (openFileName);
 
@@ -478,10 +479,6 @@
 file_editor::check_conflict_save (const QString& saveFileName,
                                   bool remove_on_success)
 {
-  // Have all file editor tabs signal what their filenames are.
-  editor_tab_map.clear ();
-  emit fetab_file_name_query (nullptr);
-
   // Check whether this file is already open in the editor.
   QWidget *tab = find_tab_widget (saveFileName);
 
@@ -552,10 +549,6 @@
 {
   if (! file.isEmpty ())
     {
-      // Have all file editor tabs signal what their filenames are.
-      editor_tab_map.clear ();
-      emit fetab_file_name_query (nullptr);
-
       // Check whether this file is already open in the editor.
       QWidget *tab = find_tab_widget (file);
 
--- a/libgui/src/m-editor/file-editor.h	Thu Aug 10 15:13:12 2017 -0400
+++ b/libgui/src/m-editor/file-editor.h	Thu Aug 10 21:57:53 2017 +0200
@@ -348,7 +348,7 @@
 
   bool editor_tab_has_focus ();
 
-  QWidget * find_tab_widget (const QString& openFileName) const;
+  QWidget * find_tab_widget (const QString& openFileName);
   QAction * add_action (QMenu *menu, const QIcon& icon, const QString& text,
                         const char *member);