If several doc templates use the same document and view classes, they should

share their filters in Save As


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2004-06-03 19:04:16 +00:00
parent bbce0c0ce6
commit 041295149d
2 changed files with 35 additions and 1 deletions

View File

@@ -276,6 +276,9 @@ public:
bool IsVisible() const { return ((m_flags & wxTEMPLATE_VISIBLE) == wxTEMPLATE_VISIBLE); }
wxClassInfo* GetDocClassInfo() const { return m_docClassInfo; }
wxClassInfo* GetViewClassInfo() const { return m_viewClassInfo; }
virtual bool FileMatchesTemplate(const wxString& path);
protected:

View File

@@ -253,11 +253,42 @@ bool wxDocument::SaveAs()
if (!docTemplate)
return FALSE;
#if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXMAC__)
wxString filter = docTemplate->GetDescription() + wxT(" (") + docTemplate->GetFileFilter() + wxT(")|") + docTemplate->GetFileFilter();
// Now see if there are some other template with identical view and document
// classes, whose filters may also be used.
if (docTemplate->GetViewClassInfo() && docTemplate->GetDocClassInfo())
{
wxObjectListNode* node = wxDocManager::GetDocumentManager()->GetTemplates().GetFirst();
while (node)
{
wxDocTemplate *t = (wxDocTemplate*) node->GetData();
if (t->IsVisible() && t != docTemplate &&
t->GetViewClassInfo() == docTemplate->GetViewClassInfo() &&
t->GetDocClassInfo() == docTemplate->GetDocClassInfo())
{
// add a '|' to separate this filter from the previous one
if ( !filter.IsEmpty() )
filter << wxT('|');
filter << t->GetDescription() << wxT(" (") << t->GetFileFilter() << wxT(") |")
<< t->GetFileFilter();
}
node = node->GetNext();
}
}
#else
wxString filter = docTemplate->GetFileFilter() ;
#endif
wxString tmp = wxFileSelector(_("Save as"),
docTemplate->GetDirectory(),
wxFileNameFromPath(GetFilename()),
docTemplate->GetDefaultExtension(),
docTemplate->GetFileFilter(),
filter,
wxSAVE | wxOVERWRITE_PROMPT,
GetDocumentWindow());