Mercurial > octave
changeset 23922:7d703bca19b8
maint: Merged away accidental head
author | Torsten Lilge <lilge@irt.uni-hannover.de> |
---|---|
date | Wed, 16 Aug 2017 08:19:16 +0200 |
parents | ab1aa0e57b72 (current diff) 0b971884080c (diff) |
children | 62dc81691d73 |
files | |
diffstat | 5 files changed, 48 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc Tue Aug 15 15:53:15 2017 -0700 +++ b/libgui/src/files-dock-widget.cc Wed Aug 16 08:19:16 2017 +0200 @@ -665,9 +665,13 @@ { new_name = path.absolutePath () + '/' + new_name; old_name = path.absolutePath () + '/' + old_name; - emit file_remove_signal (old_name, new_name); // editor: close old - path.rename (old_name, new_name); - emit file_renamed_signal (); // editor: load new file + // editor: close old + emit file_remove_signal (old_name, new_name); + // Do the renaming + bool st = path.rename (old_name, new_name); + // editor: load new/old file depending on success + emit file_renamed_signal (st); + // Clear cache of file browser _file_system_model->revert (); } } @@ -709,9 +713,11 @@ { // Close the file in the editor if open emit file_remove_signal (info.filePath (), QString ()); - // Remove the file. This operation might fail, but we will not - // reopen a possibly related editor tab in this case. - _file_system_model->remove (index); + // Remove the file. + bool st = _file_system_model->remove (index); + // reload the old file if removing was not successful + if (! st) + emit file_renamed_signal (false); } _file_system_model->revert ();
--- a/libgui/src/files-dock-widget.h Tue Aug 15 15:53:15 2017 -0700 +++ b/libgui/src/files-dock-widget.h Wed Aug 16 08:19:16 2017 +0200 @@ -136,7 +136,7 @@ void file_remove_signal (const QString& old_name, const QString& new_name); /** Emitted, when a file or directory is renamed. */ - void file_renamed_signal (void); + void file_renamed_signal (bool); private: void process_new_file (const QString& parent_name);
--- a/libgui/src/m-editor/file-editor.cc Tue Aug 15 15:53:15 2017 -0700 +++ b/libgui/src/m-editor/file-editor.cc Wed Aug 16 08:19:16 2017 +0200 @@ -589,6 +589,9 @@ file_editor::handle_file_remove (const QString& old_name, const QString& new_name) { + // Clear old lsit of files to reload + _tmp_closed_files.clear (); + // Check if old name is a file or directory QFileInfo old (old_name); if (old.isDir ()) @@ -609,25 +612,21 @@ editor_tab->file_has_changed (QString (), true); // Close the tab _no_focus = false; // Back to normal + _tmp_closed_files << old_name; // for reloading if error removing + if (! new_name.isEmpty ()) + _tmp_closed_files << new_name; // store new name + else + _tmp_closed_files << ""; // no new name, just removing this file + + // Get and store the related encoding + for (editor_tab_map_const_iterator p = editor_tab_map.begin (); + p != editor_tab_map.end (); p++) { - // New name is set, store new name and its encoding - // loading this file after the renaming is complete. - // The new name is not signaled after the renaming for being able - // to use this construct for renaming a whole directory, too. - - _tmp_closed_files = QStringList (); - _tmp_closed_files << new_name; - - // Get and store the related encoding - for (editor_tab_map_const_iterator p = editor_tab_map.begin (); - p != editor_tab_map.end (); p++) + if (editor_tab == p->second.fet_ID) { - if (editor_tab == p->second.fet_ID) - { - _tmp_closed_files << p->second.encoding; - break; - } + _tmp_closed_files << p->second.encoding; + break; } } } @@ -646,8 +645,6 @@ emit fetab_file_name_query (nullptr); // Loop over all open files and pick those within old_dir - _tmp_closed_files = QStringList (); - for (editor_tab_map_const_iterator p = editor_tab_map.begin (); p != editor_tab_map.end (); p++) { @@ -663,6 +660,8 @@ editor_tab->file_has_changed (QString (), true); // Close _no_focus = false; // Back to normal + // Store file for possible later reload + _tmp_closed_files << p->first; // Add the new file path and the encoding for later reloading // if new_name is given @@ -670,20 +669,26 @@ { QDir new_dir (new_name); _tmp_closed_files << new_dir.absoluteFilePath (rel_path_to_file); - _tmp_closed_files << p->second.encoding; } + else + _tmp_closed_files << ""; // no new name, just removing this file + + _tmp_closed_files << p->second.encoding; // store the encoding } } } // Slot for signal indicating that a file was renamed void -file_editor::handle_file_renamed () +file_editor::handle_file_renamed (bool load_new) { _no_focus = true; // Remember for not focussing editor - for (int i = 0; i < _tmp_closed_files.count (); i = i + 2) - request_open_file (_tmp_closed_files.at (i), - _tmp_closed_files.at (i+1)); + for (int i = 0; i < _tmp_closed_files.count (); i = i + 3) + { + if (! _tmp_closed_files.at (i + load_new).isEmpty ()) + request_open_file (_tmp_closed_files.at (i + load_new), + _tmp_closed_files.at (i+2)); + } _no_focus = false; // Back to normal focus }
--- a/libgui/src/m-editor/file-editor.h Tue Aug 15 15:53:15 2017 -0700 +++ b/libgui/src/m-editor/file-editor.h Wed Aug 16 08:19:16 2017 +0200 @@ -282,7 +282,7 @@ void handle_edit_file_request (const QString& file); void handle_file_remove (const QString&, const QString&); - void handle_file_renamed (void); + void handle_file_renamed (bool load_new = true); // Tells the editor to react on changed settings. void notice_settings (const QSettings *settings); @@ -475,7 +475,10 @@ QStringList _mru_files; QStringList _mru_files_encodings; - // List of temporarily closed files while they are renamed + // List of temporarily closed files for later reloading. + // Order: first closed old file + // first new location of closed file + // encoding to use for reload QStringList _tmp_closed_files; };
--- a/libgui/src/main-window.cc Tue Aug 15 15:53:15 2017 -0700 +++ b/libgui/src/main-window.cc Wed Aug 16 08:19:16 2017 +0200 @@ -1819,8 +1819,8 @@ SIGNAL (file_remove_signal (const QString&, const QString&)), editor_window, SLOT (handle_file_remove (const QString&, const QString&))); - connect (file_browser_window, SIGNAL (file_renamed_signal (void)), - editor_window, SLOT (handle_file_renamed (void))); + connect (file_browser_window, SIGNAL (file_renamed_signal (bool)), + editor_window, SLOT (handle_file_renamed (bool))); #endif octave_link::post_event (this,