Avoid overriding wxDirDialog::GetPath[s]() unnecessarily
Don't duplicate practically the same code in all ports, just add m_paths itself to the base class. The only drawback of doing this is that it's unused in the ports not (yet) using it, but this saves enough code in the aggregate to be worth it.
This commit is contained in:
@@ -90,19 +90,20 @@ public:
|
|||||||
virtual wxString GetMessage() const { return m_message; }
|
virtual wxString GetMessage() const { return m_message; }
|
||||||
virtual wxString GetPath() const
|
virtual wxString GetPath() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxString(), "When using wxDD_MULTIPLE, must call GetPaths() instead" );
|
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxString(),
|
||||||
|
"When using wxDD_MULTIPLE, must call GetPaths() instead" );
|
||||||
return m_path;
|
return m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void GetPaths(wxArrayString& paths) const
|
virtual void GetPaths(wxArrayString& paths) const
|
||||||
{
|
{
|
||||||
paths.clear();
|
paths = m_paths;
|
||||||
paths.push_back(m_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_message;
|
wxString m_message;
|
||||||
wxString m_path;
|
wxString m_path;
|
||||||
|
wxArrayString m_paths;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -37,9 +37,7 @@ public:
|
|||||||
|
|
||||||
public: // overrides from wxGenericDirDialog
|
public: // overrides from wxGenericDirDialog
|
||||||
|
|
||||||
wxString GetPath() const wxOVERRIDE;
|
|
||||||
void SetPath(const wxString& path) wxOVERRIDE;
|
void SetPath(const wxString& path) wxOVERRIDE;
|
||||||
void GetPaths(wxArrayString& paths) const wxOVERRIDE;
|
|
||||||
|
|
||||||
|
|
||||||
// Implementation only.
|
// Implementation only.
|
||||||
@@ -56,8 +54,6 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxArrayString m_paths;
|
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxDirDialog);
|
wxDECLARE_DYNAMIC_CLASS(wxDirDialog);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -24,18 +24,9 @@ public:
|
|||||||
|
|
||||||
void SetPath(const wxString& path) wxOVERRIDE;
|
void SetPath(const wxString& path) wxOVERRIDE;
|
||||||
|
|
||||||
// can be used only when wxDD_MULTIPLE flag is not set
|
|
||||||
wxString GetPath() const wxOVERRIDE;
|
|
||||||
|
|
||||||
// should be used only when wxDD_MULTIPLE flag is set
|
|
||||||
void GetPaths(wxArrayString& paths) const wxOVERRIDE;
|
|
||||||
|
|
||||||
virtual int ShowModal() wxOVERRIDE;
|
virtual int ShowModal() wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Used for wxDD_MULTIPLE
|
|
||||||
wxArrayString m_paths;
|
|
||||||
|
|
||||||
// The real implementations of ShowModal(), used for Windows versions
|
// The real implementations of ShowModal(), used for Windows versions
|
||||||
// before and since Vista.
|
// before and since Vista.
|
||||||
int ShowSHBrowseForFolder(WXHWND owner);
|
int ShowSHBrowseForFolder(WXHWND owner);
|
||||||
|
@@ -51,10 +51,6 @@ public:
|
|||||||
// only for compatibility with older versions
|
// only for compatibility with older versions
|
||||||
virtual void SetTitle(const wxString& title) wxOVERRIDE;
|
virtual void SetTitle(const wxString& title) wxOVERRIDE;
|
||||||
|
|
||||||
virtual wxString GetPath() const wxOVERRIDE;
|
|
||||||
virtual void GetPaths(wxArrayString& paths) const wxOVERRIDE;
|
|
||||||
|
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA
|
#if wxOSX_USE_COCOA
|
||||||
virtual void ShowWindowModal() wxOVERRIDE;
|
virtual void ShowWindowModal() wxOVERRIDE;
|
||||||
virtual void ModalFinishedCallback(void* panel, int returnCode) wxOVERRIDE;
|
virtual void ModalFinishedCallback(void* panel, int returnCode) wxOVERRIDE;
|
||||||
@@ -72,7 +68,6 @@ private:
|
|||||||
// Common part of all ctors.
|
// Common part of all ctors.
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
wxArrayString m_paths;
|
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
|
|
||||||
wxDECLARE_DYNAMIC_CLASS(wxDirDialog);
|
wxDECLARE_DYNAMIC_CLASS(wxDirDialog);
|
||||||
|
@@ -163,6 +163,11 @@ void wxDirDialog::GTKOnAccept()
|
|||||||
wxSetWorkingDirectory(m_paths.Last());
|
wxSetWorkingDirectory(m_paths.Last());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!HasFlag(wxDD_MULTIPLE))
|
||||||
|
{
|
||||||
|
m_path = m_paths.Last();
|
||||||
|
}
|
||||||
|
|
||||||
EndDialog(wxID_OK);
|
EndDialog(wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,15 +193,4 @@ void wxDirDialog::SetPath(const wxString& dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxDirDialog::GetPath() const
|
|
||||||
{
|
|
||||||
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxString(), "When using wxDD_MULTIPLE, must call GetPaths() instead" );
|
|
||||||
return m_paths.Last();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxDirDialog::GetPaths(wxArrayString& paths) const
|
|
||||||
{
|
|
||||||
paths = m_paths;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_DIRDLG
|
#endif // wxUSE_DIRDLG
|
||||||
|
@@ -151,19 +151,6 @@ void wxDirDialog::SetPath(const wxString& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxDirDialog::GetPath() const
|
|
||||||
{
|
|
||||||
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxEmptyString,
|
|
||||||
"When using wxDD_MULTIPLE, must call GetPaths() instead" );
|
|
||||||
|
|
||||||
return m_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxDirDialog::GetPaths(wxArrayString& paths) const
|
|
||||||
{
|
|
||||||
paths = m_paths;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxDirDialog::ShowModal()
|
int wxDirDialog::ShowModal()
|
||||||
{
|
{
|
||||||
WX_HOOK_MODAL_DIALOG();
|
WX_HOOK_MODAL_DIALOG();
|
||||||
@@ -293,7 +280,7 @@ int wxDirDialog::ShowIFileOpenDialog(WXHWND owner)
|
|||||||
{
|
{
|
||||||
if ( !HasFlag(wxDD_MULTIPLE) )
|
if ( !HasFlag(wxDD_MULTIPLE) )
|
||||||
{
|
{
|
||||||
m_path = m_paths.front();
|
m_path = m_paths.Last();
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxID_OK;
|
return wxID_OK;
|
||||||
|
@@ -157,6 +157,11 @@ void wxDirDialog::ModalFinishedCallback(void* panel, int returnCode)
|
|||||||
m_paths.Add([url fileSystemRepresentation]);
|
m_paths.Add([url fileSystemRepresentation]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !HasFlag(wxDD_MULTIPLE) )
|
||||||
|
{
|
||||||
|
m_path = m_paths.Last();
|
||||||
|
}
|
||||||
|
|
||||||
result = wxID_OK;
|
result = wxID_OK;
|
||||||
}
|
}
|
||||||
SetReturnCode(result);
|
SetReturnCode(result);
|
||||||
@@ -171,16 +176,4 @@ void wxDirDialog::SetTitle(const wxString &title)
|
|||||||
wxDialog::SetTitle(title);
|
wxDialog::SetTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxDirDialog::GetPath() const
|
|
||||||
{
|
|
||||||
wxCHECK_MSG( !HasFlag(wxDD_MULTIPLE), wxString(), "When using wxDD_MULTIPLE, must call GetPaths() instead" );
|
|
||||||
return m_paths.Last();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxDirDialog::GetPaths(wxArrayString& paths) const
|
|
||||||
{
|
|
||||||
paths = m_paths;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // wxUSE_DIRDLG
|
#endif // wxUSE_DIRDLG
|
||||||
|
Reference in New Issue
Block a user