Added customizable wxDocManager::OnMRUFileNotExist() virtual method.

This method can be overridden to customize the previously hard-coded handling
of the case when a file selected from the MRU menu doesn't exist any more: we
used to always remove it from the file history completely. This may, however,
be inappropriate and, in fact, probably never, or very rarely, is the right
thing to do when the file that we failed to open still exists.

So never remove the file from the MRU if we failed to open an existing file
(also don't give an error about it as it should have been already given by
CreateDocument()) and, while we still do it for the non-existent files, allow
to override this behaviour by overriding the new OnMRUFileNotExist() method.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68334 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-07-22 16:16:09 +00:00
parent 1ecc323f26
commit d38eb01c91
4 changed files with 48 additions and 11 deletions

View File

@@ -749,6 +749,36 @@ public:
protected:
/**
Called when a file selected from the MRU list doesn't exist any more.
The default behaviour is to remove the file from the MRU (most recently
used) files list and the corresponding menu and notify the user about
it but this method can be overridden to customize it.
For example, an application may want to just give an error about the
missing file @a filename but not remove it from the file history. Or it
could ask the user whether the file should be kept or removed.
Notice that this method is called only if the file selected by user
from the MRU files in the menu doesn't exist, but not if opening it
failed for any other reason because in the latter case the default
behaviour of removing the file from the MRU list is inappropriate.
If you still want to do it, you would need to do it by calling
RemoveFileFromHistory() explicitly in the part of the file opening code
that may fail.
@since 2.9.3
@param n
The index of the file in the MRU list, it can be passed to
RemoveFileFromHistory() to remove this file from the list.
@param filename
The full name of the file.
*/
virtual void OnMRUFileNotExist(unsigned n, const wxString& filename);
/**
The currently active view.
*/