From: Steve Brokenshire Date: Sat, 3 Feb 2018 13:24:44 +0000 (+0000) Subject: utf8: Implemented further UTF8 support X-Git-Tag: release-0.06~4 X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=commitdiff_plain;h=a191ad71a0d6823b9710067c7cccf8905290dc9c utf8: Implemented further UTF8 support --- diff --git a/source/forms/calendareditor/frmCalendarEditor.cpp b/source/forms/calendareditor/frmCalendarEditor.cpp index 0373461..c885721 100644 --- a/source/forms/calendareditor/frmCalendarEditor.cpp +++ b/source/forms/calendareditor/frmCalendarEditor.cpp @@ -118,9 +118,9 @@ void frmCalendarEditor::ProcessCalendar( wxCommandEvent &event ){ } calendarInfo->editMode = editMode; - calendarInfo->accountName = cmbAccount->GetStringSelection(); - calendarInfo->calendarName = txtName->GetValue().ToStdString(); - calendarInfo->calendarDescription = txtDescription->GetValue().ToStdString(); + calendarInfo->accountName = std::string(cmbAccount->GetStringSelection().ToUTF8()); + calendarInfo->calendarName = std::string(txtName->GetValue().ToUTF8()); + calendarInfo->calendarDescription = std::string(txtDescription->GetValue().ToUTF8()); calendarInfo->calendarColour = (clpColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString() + "FF"); @@ -135,10 +135,10 @@ void frmCalendarEditor::ProcessCalendar( wxCommandEvent &event ){ void frmCalendarEditor::SetData(int calendarID, std::string accountName, std::string calendarName, std::string calendarDescription, Colour calendarColour){ - txtName->SetValue(wxString(calendarName.c_str())); - txtDescription->SetValue(wxString(calendarDescription.c_str())); + txtName->SetValue(wxString(calendarName.c_str(), wxConvUTF8)); + txtDescription->SetValue(wxString(calendarDescription.c_str(), wxConvUTF8)); clpColour->SetColour(wxColour(calendarColour.red, calendarColour.green, calendarColour.blue)); - cmbAccount->SetStringSelection(wxString(accountName)); + cmbAccount->SetStringSelection(wxString(accountName.c_str(), wxConvUTF8)); this->calendarID = calendarID; } \ No newline at end of file diff --git a/source/forms/eventeditor/frmEventEditor.cpp b/source/forms/eventeditor/frmEventEditor.cpp index ad9b184..52e4d2d 100644 --- a/source/forms/eventeditor/frmEventEditor.cpp +++ b/source/forms/eventeditor/frmEventEditor.cpp @@ -53,7 +53,7 @@ void frmEventEditor::SetupForm(CalendarDataStorage *dataStorage, XCALPreferences CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar((*calendarSeek)); combinedName += calendarInfo.calendarName; - cmbCalendar->Append((wxString)combinedName); + cmbCalendar->Append(wxString(combinedName.c_str(), wxConvUTF8)); calendarIDList.push_back(calendarInfo.calendarID); } @@ -87,8 +87,8 @@ void frmEventEditor::SetupForm(CalendarDataStorage *dataStorage, XCALPreferences // Load the data into the form. - txtEventName->SetValue(wxString(eventInfo.entryName)); - txtEventDescription->SetValue(wxString(eventInfo.entryDescription)); + txtEventName->SetValue(wxString(eventInfo.entryName.c_str(), wxConvUTF8)); + txtEventDescription->SetValue(wxString(eventInfo.entryDescription.c_str(), wxConvUTF8)); // Load the start and end dates. @@ -224,21 +224,21 @@ bool frmEventEditor::SaveContact(){ // Set the data into the calendar event object. - eventData.summaryData = txtEventName->GetValue().ToStdString(); + eventData.summaryData = string(txtEventName->GetValue().ToUTF8()); if (eventData.descriptionList.size() > 0) { - eventData.descriptionList[0] = txtEventDescription->GetValue().ToStdString(); + eventData.descriptionList[0] = string(txtEventDescription->GetValue().ToUTF8()); } else { - eventData.descriptionList.push_back(txtEventDescription->GetValue().ToStdString()); + eventData.descriptionList.push_back(string(txtEventDescription->GetValue().ToUTF8())); eventData.descriptionListAltRep.push_back(""); eventData.descriptionListLanguage.push_back(""); eventData.descriptionListTokens.push_back(""); } - eventData.descriptionList.push_back(txtEventDescription->GetValue().ToStdString()); + eventData.descriptionList.push_back(string(txtEventDescription->GetValue().ToUTF8())); eventData.descriptionListAltRep.push_back(""); eventData.descriptionListLanguage.push_back(""); eventData.descriptionListTokens.push_back(""); @@ -281,12 +281,12 @@ bool frmEventEditor::SaveContact(){ CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar(calendarIDList[cmbCalendar->GetSelection()]); CDSGetAccountInfo accountInfo = dataStorage->GetAccount(calendarInfo.accountName); - string calendarDirectory = GetUserDir().ToStdString(); + string calendarDirectory = string(GetUserDir().ToUTF8()); calendarDirectory += "accounts"; calendarDirectory += "/"; - calendarDirectory += preferences->accounts.GetAccountDirectory(accountInfo.accountPreferencesID).ToStdString(); + calendarDirectory += string(preferences->accounts.GetAccountDirectory(accountInfo.accountPreferencesID).ToUTF8()); calendarDirectory += "."; - calendarDirectory += preferences->accounts.GetAccountType(accountInfo.accountPreferencesID).ToStdString(); + calendarDirectory += string(preferences->accounts.GetAccountType(accountInfo.accountPreferencesID).ToUTF8()); calendarDirectory += "/"; calendarDirectory += calendarInfo.calendarTextID; calendarDirectory += "/"; @@ -309,8 +309,8 @@ bool frmEventEditor::SaveContact(){ // the main window. EventProperties *eventInfo = new EventProperties; - eventInfo->eventName = txtEventName->GetValue().ToStdString(); - eventInfo->eventDescipriton = txtEventDescription->GetValue().ToStdString(); + eventInfo->eventName = string(txtEventName->GetValue().ToUTF8()); + eventInfo->eventDescipriton = string(txtEventDescription->GetValue().ToUTF8()); eventInfo->calendarID = calendarIDList[cmbCalendar->GetSelection()]; eventInfo->eventID = addEventResult.calendarEntryID; eventInfo->eventYear = dapStartDate->GetValue().GetYear(); @@ -357,8 +357,8 @@ bool frmEventEditor::SaveContact(){ // the main window. EventProperties *eventInfo = new EventProperties; - eventInfo->eventName = txtEventName->GetValue().ToStdString(); - eventInfo->eventDescipriton = txtEventDescription->GetValue().ToStdString(); + eventInfo->eventName = string(txtEventName->GetValue().ToUTF8()); + eventInfo->eventDescipriton = string(txtEventDescription->GetValue().ToUTF8()); eventInfo->calendarID = calendarID; eventInfo->eventID = eventID; eventInfo->eventYear = dapStartDate->GetValue().GetYear(); @@ -549,7 +549,7 @@ void frmEventEditor::UpdateWindowName() // Generate the window title. - string windowTitle; + wxString windowTitle; if (cmbCalendar->GetSelection() == -1) { @@ -557,7 +557,7 @@ void frmEventEditor::UpdateWindowName() } else { - windowTitle += cmbCalendar->GetStringSelection().ToStdString(); + windowTitle += cmbCalendar->GetStringSelection(); } if (txtEventName->IsEmpty()) @@ -568,7 +568,7 @@ void frmEventEditor::UpdateWindowName() else { windowTitle += " - "; - windowTitle += txtEventName->GetValue().ToStdString(); + windowTitle += txtEventName->GetValue(); } SetTitle(windowTitle); diff --git a/source/forms/main/frmMain.cpp b/source/forms/main/frmMain.cpp index 2f826de..11246ae 100644 --- a/source/forms/main/frmMain.cpp +++ b/source/forms/main/frmMain.cpp @@ -199,7 +199,7 @@ void frmMain::LoadAccountData(){ for (int accountSeek = 0; accountSeek < accountCount; accountSeek++){ - CDSAccountResult addResult = calendarData.AddAccount(string(preferences->accounts.GetAccountName(accountSeek).mb_str()), accountSeek); + CDSAccountResult addResult = calendarData.AddAccount(string(preferences->accounts.GetAccountName(accountSeek).ToUTF8()), accountSeek); } @@ -207,7 +207,7 @@ void frmMain::LoadAccountData(){ for (int accountSeek = 0; accountSeek < accountCount; accountSeek++){ - CDSGetAccountInfo accountInfo = calendarData.GetAccount(string(preferences->accounts.GetAccountName(accountSeek).mb_str())); + CDSGetAccountInfo accountInfo = calendarData.GetAccount(string(preferences->accounts.GetAccountName(accountSeek).ToUTF8())); // Build the path. @@ -240,9 +240,9 @@ void frmMain::LoadAccountData(){ // Find the entries and load each entry. - string calendarListDirectory = calendarListFilename; + wxString calendarListDirectory = wxString(calendarListFilename.c_str(), wxConvUTF8); calendarListDirectory += "/"; - calendarListDirectory += calendarList.calendarShortName[calendarSeek]; + calendarListDirectory += wxString(calendarList.calendarShortName[calendarSeek].c_str(), wxConvUTF8); calendarListDirectory += "/"; wxDir entryListDirectory(calendarListDirectory); @@ -253,8 +253,8 @@ void frmMain::LoadAccountData(){ while (continueProcessing){ string entryListFullFilename; - entryListFullFilename += calendarListDirectory; - entryListFullFilename += string(entryListFilename.mb_str()); + entryListFullFilename += string(calendarListDirectory.ToUTF8()); + entryListFullFilename += string(entryListFilename.ToUTF8()); continueProcessing = entryListDirectory.GetNext(&entryListFilename); CDSAddEntryResult addEventResult = calendarData.AddEvent(calendarInfo.calendarID, entryListFullFilename); @@ -454,7 +454,7 @@ void frmMain::DeleteCalendar( wxCommandEvent& event ) accountDirectoryPath += "accounts/"; accountDirectoryPath += string(preferences->accounts.GetAccountDirectory(calendarEventInfo->accountPreferencesID).ToUTF8()); accountDirectoryPath += "."; - accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarEventInfo->accountPreferencesID).mb_str()); + accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarEventInfo->accountPreferencesID).ToUTF8()); accountDirectoryPath += "/"; string calendarListFilenameFull = accountDirectoryPath; @@ -463,7 +463,7 @@ void frmMain::DeleteCalendar( wxCommandEvent& event ) string calendarDirectoryPath = accountDirectoryPath; calendarDirectoryPath += calendarInfo.calendarTextID; - wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull)); + wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull.c_str(), wxConvUTF8)); // Delete the calendar directory. @@ -497,7 +497,7 @@ void frmMain::DeleteCalendar( wxCommandEvent& event ) // Delete the calendar directory. - //wxRmdir(wxString(calendarDirectoryPath.c_str(), wxConvUTF8)); + wxRmDir(wxString(calendarDirectoryPath.c_str(), wxConvUTF8)); delete calendarListFile; calendarListFile = nullptr; @@ -566,7 +566,7 @@ void frmMain::DeleteEvent( wxCommandEvent& event ){ CDSGetCalendarEntryInfo eventDeleteData = calendarData.GetEvent(eventInfo->eventID); CDSGetCalendarInfo calendarDeleteData = calendarData.GetCalendar(eventInfo->calendarID); - if (wxMessageBox(wxString::Format("Are you sure you want to delete the event %s from the %s calendar?", eventDeleteData.entryName, calendarDeleteData.calendarName), "Delete event", wxYES_NO|wxICON_QUESTION) == wxNO){ + if (wxMessageBox(wxString::Format("Are you sure you want to delete the event %s from the %s calendar?", wxString(eventDeleteData.entryName.c_str(), wxConvUTF8), wxString(calendarDeleteData.calendarName.c_str(), wxConvUTF8)), "Delete event", wxYES_NO|wxICON_QUESTION) == wxNO){ return; } @@ -579,7 +579,7 @@ void frmMain::DeleteEvent( wxCommandEvent& event ){ // Get the filename and delete the entry. - wxRemoveFile(wxString(eventDeleteData.entryFilename.c_str())); + wxRemoveFile(wxString(eventDeleteData.entryFilename.c_str(), wxConvUTF8)); // Delete the entry from the calendar data storage. diff --git a/source/objects/calendarlist/CalendarList.cpp b/source/objects/calendarlist/CalendarList.cpp index 98fe763..8d4f1b5 100644 --- a/source/objects/calendarlist/CalendarList.cpp +++ b/source/objects/calendarlist/CalendarList.cpp @@ -26,7 +26,7 @@ XCAccountCalendarList::XCAccountCalendarList(string calendarListFilename){ wxString calendarListFilenameFull; - calendarListFilenameFull.Append(calendarListFilename); + calendarListFilenameFull.Append(wxString(calendarListFilename.c_str(), wxConvUTF8)); calendarListFilenameFull.Append(wxT("/calendarlist.db")); wxFileConfig *calendarListFile = new wxFileConfig("", "", calendarListFilenameFull);