/***************************************************** ** ** Document --- queryClose ** ******************************************************/ bool Document::queryClose() { if ( ! dirty ) return true; int i = doMessageBox( mainwindow, wxString::Format( wxT( "%s: %s ?" ), _( "Do you want to save the chart" ), getHName().c_str()), wxYES_NO | wxCANCEL | wxCENTRE ); if ( i == wxID_CANCEL ) return false; else if ( i == wxID_YES ) { return save(); } else { dirty = false; return true; } }
/***************************************************** ** ** Document --- saveAs ** ******************************************************/ bool Document::saveAs() { wxString filename = dataSet->getName(); if ( filename == wxT( "" )) { filename = wxString::Format( wxT( "%s.mtx" ), (const wxChar*)getHName() ); } wxString filetypes = _( "Maitreya text (*.mtx)|*.mtx| All files (*.*)|*.*" ); wxFileDialog saveFileDialog( mainwindow, _("Save file as" ), config->defSavePath, filename, filetypes, wxFD_SAVE, wxDefaultPosition ); if ( saveFileDialog.ShowModal() == wxID_OK ) { // Bugfix 7.0.3 GetDirectory returns home directory on some Linux distros instead of selected dir //filename.Clear(); //filename << saveFileDialog.GetDirectory() << wxFileName::GetPathSeparator() //<< saveFileDialog.GetFilename(); filename = saveFileDialog.GetPath(); if ( ! Horoscope::saveAs( (const wxChar*)filename )) { doMessageBox( mainwindow, wxString::Format( wxT( "%s %s" ), _( "Cannot save file" ), (const wxChar*)filename ), wxOK | wxICON_ERROR | wxCENTRE ); return false; } dirty = false; wxCommandEvent event( DOC_SAVED, mainwindow->GetId() ); event.SetEventObject( this ); wxPostEvent( mainwindow->GetParent(), event ); config->defSavePath = saveFileDialog.GetDirectory(); } else { return false; } return true; }
/***************************************************** ** ** Document --- saveAs ** ******************************************************/ bool Document::saveAs() { wxString filename = dataSet->getName(); if ( filename == wxT( "" )) { filename = wxString::Format( wxT( "%s.mtx" ), getHName().c_str() ); } wxString filetypes = _( "Maitreya text (*.mtx)|*.mtx| All files (*.*)|*.*" ); wxFileDialog saveFileDialog( mainwindow, _("Save file as" ), config->viewprefs->defSavePath, filename, filetypes, wxFD_SAVE, wxDefaultPosition ); if ( saveFileDialog.ShowModal() == wxID_OK ) { // Bugfix 7.0.3 GetDirectory returns home directory instead of selected dir //filename.Clear(); //filename << saveFileDialog.GetDirectory() << wxFileName::GetPathSeparator() //<< saveFileDialog.GetFilename(); filename = saveFileDialog.GetPath(); if ( ! Horoscope::saveAs( filename )) { doMessageBox( mainwindow, wxString::Format( wxT( "%s %s" ), _( "Cannot save file" ), filename.c_str() ), wxOK | wxICON_ERROR | wxCENTRE ); return false; } dirty = false; DocumentManager::get()->documentSaved( this ); config->viewprefs->defSavePath = saveFileDialog.GetDirectory(); } else { return false; } return true; }