X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f3660dcb2f3b7fe836bebaee720332b4ea50a35b..4791fafb6d69dda73abc0a92c6a9ab19ce13801a:/src/generic/filedlgg.cpp diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 644fbe5576..55da3ff5ff 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -140,7 +140,7 @@ int wxCALLBACK wxFileDataTimeCompare( long data1, long data2, long data) #endif #if defined(__DOS__) || defined(__WINDOWS__) || defined (__OS2__) -#define IsTopMostDir(dir) (dir.IsEmpty()) +#define IsTopMostDir(dir) (dir.empty()) #endif #if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) @@ -157,6 +157,7 @@ extern size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, w wxFileData::wxFileData( const wxString &filePath, const wxString &fileName, fileType type, int image_id ) { + Init(); m_fileName = fileName; m_filePath = filePath; m_type = type; @@ -165,6 +166,13 @@ wxFileData::wxFileData( const wxString &filePath, const wxString &fileName, file ReadData(); } +void wxFileData::Init() +{ + m_size = 0; + m_type = wxFileData::is_file; + m_image = wxFileIconsTable::file; +} + void wxFileData::Copy( const wxFileData& fileData ) { m_fileName = fileData.GetFileName(); @@ -173,7 +181,7 @@ void wxFileData::Copy( const wxFileData& fileData ) m_dateTime = fileData.GetDateTime(); m_permissions = fileData.GetPermissions(); m_type = fileData.GetType(); - m_image = GetImageId(); + m_image = fileData.GetImageId(); } void wxFileData::ReadData() @@ -507,20 +515,20 @@ void wxFileCtrl::UpdateFiles() #if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXMAC__) || defined(__OS2__) if ( IsTopMostDir(m_dirName) ) - { + { wxArrayString names, paths; wxArrayInt icons; size_t n, count = wxGetAvailableDrives(paths, names, icons); for (n=0; nSetFocus(); + + return true; } wxGenericFileDialog::~wxGenericFileDialog() { - if (wxConfig::Get(false)) + if (!m_bypassGenericImpl) { - wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"), - ms_lastViewStyle); - wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"), - ms_lastShowHidden); - } + if (wxConfig::Get(false)) + { + wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"), + ms_lastViewStyle); + wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"), + ms_lastShowHidden); + } - const int count = m_choice->GetCount(); - for ( int i = 0; i < count; i++ ) - { - delete (wxString *)m_choice->GetClientData(i); + const int count = m_choice->GetCount(); + for ( int i = 0; i < count; i++ ) + { + delete (wxString *)m_choice->GetClientData(i); + } } } @@ -1098,8 +1151,14 @@ void wxGenericFileDialog::SetWildcard(const wxString& wildCard) wildFilters); wxCHECK_RET( count, wxT("wxFileDialog: bad wildcard string") ); - m_choice->Clear(); - for ( size_t n = 0; n < count; n++ ) + const size_t countOld = m_choice->GetCount(); + size_t n; + for ( n = 0; n < countOld; n++ ) + { + delete (wxString *)m_choice->GetClientData(n); + } + + for ( n = 0; n < count; n++ ) { m_choice->Append( wildDescriptions[n], new wxString( wildFilters[n] ) ); } @@ -1166,7 +1225,7 @@ void wxGenericFileDialog::OnSelected( wxListEvent &event ) if (!IsTopMostDir(dir)) dir += wxFILE_SEP_PATH; dir += filename; - if (wxDirExists(dir)) return; + if (wxPathExists(dir)) return; ignoreChanges = true; m_text->SetValue( filename ); @@ -1177,7 +1236,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn ) { wxString filename( fn ); wxString dir = m_list->GetDir(); - if (filename.IsEmpty()) return; + if (filename.empty()) return; if (filename == wxT(".")) return; // "some/place/" means they want to chdir not try to load "place" @@ -1204,7 +1263,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn ) if (filename.BeforeFirst(wxT('/')) == wxT("~")) { - filename = wxGetUserHome() + filename.Remove(0, 1); + filename = wxString(wxGetUserHome()) + filename.Remove(0, 1); } #endif // __UNIX__ @@ -1228,7 +1287,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn ) filename = dir; } - if (wxDirExists(filename)) + if (wxPathExists(filename)) { m_list->GoToDir( filename ); UpdateControls();