Mercurial > octave
comparison libgui/src/files-dock-widget.cc @ 30210:351dbe4da930
GUI: Display dialog if deleting or renaming a file fails (bug #61225).
* libgui/src/files-dock-widget.cc (files_dock_widget::contextmenu_rename,
files_dock_widget::contextmenu_delete): Display dialog if deleting or renaming
a file fails.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 27 Sep 2021 12:59:34 +0200 |
parents | 02461b0ccc00 |
children | d4d83344d653 |
comparison
equal
deleted
inserted
replaced
30209:54774a713d7c | 30210:351dbe4da930 |
---|---|
712 // editor: close old | 712 // editor: close old |
713 emit file_remove_signal (old_name, new_name); | 713 emit file_remove_signal (old_name, new_name); |
714 // Do the renaming | 714 // Do the renaming |
715 QFile f (old_name); // Must use QFile, not QDir (bug #56298) | 715 QFile f (old_name); // Must use QFile, not QDir (bug #56298) |
716 bool st = f.rename (new_name); | 716 bool st = f.rename (new_name); |
717 if (! st) | |
718 QMessageBox::warning (this, tr ("Rename error"), | |
719 tr ("Could not rename file \"%1\" to \"%2\"."). | |
720 arg (old_name).arg (new_name)); | |
717 // editor: load new/old file depending on success | 721 // editor: load new/old file depending on success |
718 emit file_renamed_signal (st); | 722 emit file_renamed_signal (st); |
719 // Clear cache of file browser | 723 // Clear cache of file browser |
720 m_file_system_model->revert (); | 724 m_file_system_model->revert (); |
721 } | 725 } |
779 { | 783 { |
780 // Close the file in the editor if open | 784 // Close the file in the editor if open |
781 emit file_remove_signal (info.filePath (), QString ()); | 785 emit file_remove_signal (info.filePath (), QString ()); |
782 // Remove the file. | 786 // Remove the file. |
783 bool st = m_file_system_model->remove (index); | 787 bool st = m_file_system_model->remove (index); |
784 // Reload the old file if removing was not successful | |
785 if (! st) | 788 if (! st) |
786 emit file_renamed_signal (false); | 789 { |
790 QMessageBox::warning (this, tr ("Deletion error"), | |
791 tr ("Could not delete file \"%1\"."). | |
792 arg (info.filePath ())); | |
793 // Reload the old file | |
794 emit file_renamed_signal (false); | |
795 } | |
787 } | 796 } |
788 | 797 |
789 m_file_system_model->revert (); | 798 m_file_system_model->revert (); |
790 | 799 |
791 } | 800 } |