X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fforms%2Feventeditor%2FfrmEventEditor.cpp;h=52e4d2dbe40d3844ed55d28a051262941c838a27;hp=4c95dc30e282167d3b50108aeab3f910ae5527a6;hb=a191ad71a0d6823b9710067c7cccf8905290dc9c;hpb=e5e8bdcfe81d4184b57623167b55cd6bdab9fe90 diff --git a/source/forms/eventeditor/frmEventEditor.cpp b/source/forms/eventeditor/frmEventEditor.cpp index 4c95dc3..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); } @@ -70,8 +70,15 @@ void frmEventEditor::SetupForm(CalendarDataStorage *dataStorage, XCALPreferences calendarID = eventInfo.calendarID; + // Set the calendar combination box to the name. + + string combinedName = dataStorage->GetCalendar(calendarID).accountName; + combinedName += " : "; + combinedName += dataStorage->GetCalendar(eventInfo.calendarID).calendarName; + // Load the calendar info. + cmbCalendar->SetSelection(cmbCalendar->FindString(combinedName)); cmbCalendar->Show(false); lblCalendar->Show(false); @@ -80,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. @@ -122,14 +129,20 @@ void frmEventEditor::SetupForm(CalendarDataStorage *dataStorage, XCALPreferences eventData.LoadFile(eventFilePath); // TODO: Set the duration data. + + } else { + + // Setup the date and time with some default values (today's date and time). + + SetDefaultDateTime(); - return; } - - // Setup the date and time with some default values (today's date and time). - - SetDefaultDateTime(); + // Enable window updating and update window name. + + UpdateWindowName(); + enableUpdates = true; + } void frmEventEditor::SetEditMode(bool editMode){ @@ -146,7 +159,10 @@ void frmEventEditor::SaveContact(wxCommandEvent &event){ void frmEventEditor::SaveNewContact(wxCommandEvent &event){ - SaveContact(); + if (!SaveContact()) + { + return; + } // Reset the form for a new entry. @@ -165,18 +181,16 @@ void frmEventEditor::SaveNewContact(wxCommandEvent &event){ szrDetails->Layout(); szrList->Layout(); - - } -void frmEventEditor::SaveContact(){ +bool frmEventEditor::SaveContact(){ // Verify that a calendar has been selected. if (cmbCalendar->GetSelection() == -1 && editMode == false){ wxMessageBox("Please select a calendar for this entry.", "No calendar selected", wxOK); - return; + return false; } @@ -185,7 +199,7 @@ void frmEventEditor::SaveContact(){ if (txtEventName->GetValue().IsEmpty()){ wxMessageBox("The event name cannot be left empty.", "Event name is empty", wxOK); - return; + return false; } @@ -210,8 +224,21 @@ void frmEventEditor::SaveContact(){ // Set the data into the calendar event object. - eventData.summaryData = txtEventName->GetValue().ToStdString(); - eventData.descriptionList.push_back(txtEventDescription->GetValue().ToStdString()); + eventData.summaryData = string(txtEventName->GetValue().ToUTF8()); + + if (eventData.descriptionList.size() > 0) + { + eventData.descriptionList[0] = string(txtEventDescription->GetValue().ToUTF8()); + } + else + { + eventData.descriptionList.push_back(string(txtEventDescription->GetValue().ToUTF8())); + eventData.descriptionListAltRep.push_back(""); + eventData.descriptionListLanguage.push_back(""); + eventData.descriptionListTokens.push_back(""); + } + + eventData.descriptionList.push_back(string(txtEventDescription->GetValue().ToUTF8())); eventData.descriptionListAltRep.push_back(""); eventData.descriptionListLanguage.push_back(""); eventData.descriptionListTokens.push_back(""); @@ -254,12 +281,12 @@ void 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 += "/"; @@ -282,7 +309,8 @@ void frmEventEditor::SaveContact(){ // the main window. EventProperties *eventInfo = new EventProperties; - eventInfo->eventName = txtEventName->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(); @@ -329,7 +357,8 @@ void frmEventEditor::SaveContact(){ // the main window. EventProperties *eventInfo = new EventProperties; - eventInfo->eventName = txtEventName->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(); @@ -346,14 +375,37 @@ void frmEventEditor::SaveContact(){ } + return true; + } -void frmEventEditor::CloseWindow(wxCommandEvent &event){ +void frmEventEditor::CloseWindow(wxCommandEvent &event) +{ this->Close(); } +void frmEventEditor::CloseWindow(wxCloseEvent &event) +{ + + WindowData *deleteWindowData = new WindowData; + + deleteWindowData->DataType = 1; + deleteWindowData->WindowPointer = (void*)this; + deleteWindowData->WindowID = windowID; + + // Delete the window from the window list. + + wxCommandEvent deleteEvent(XCMAIN_DELETEWINDOWINFO); + deleteEvent.SetId(ID_DELETEWINDOW); + deleteEvent.SetClientData(deleteWindowData); + wxPostEvent(this->GetParent(), deleteEvent); + + this->Destroy(); + +} + bool frmEventEditor::ProcessEvent(wxEvent& event) { @@ -469,4 +521,77 @@ void frmEventEditor::SetDefaultDateTime(){ txtEndTime->SetValue((wxString)formattedTime); -} \ No newline at end of file +} + +void frmEventEditor::SetWindowMenuItemID(int windowID) +{ + + this->windowID = windowID; + +} + +void frmEventEditor::ProcessCalendarControl(wxCommandEvent &event) +{ + + UpdateWindowName(); + +} + +void frmEventEditor::ProcessEventName(wxCommandEvent &event) +{ + + UpdateWindowName(); + +} + +void frmEventEditor::UpdateWindowName() +{ + + // Generate the window title. + + wxString windowTitle; + + if (cmbCalendar->GetSelection() == -1) + { + windowTitle += "(calendar not selected)"; + } + else + { + windowTitle += cmbCalendar->GetStringSelection(); + } + + if (txtEventName->IsEmpty()) + { + windowTitle += " - "; + windowTitle += "(unamed event)"; + } + else + { + windowTitle += " - "; + windowTitle += txtEventName->GetValue(); + } + + SetTitle(windowTitle); + + // Check if post window title updating is enabled before + // going any further. + + if (enableUpdates == false) + { + return; + } + + WindowData *updateWindowData = new WindowData; + + updateWindowData->DataType = 1; + updateWindowData->WindowPointer = (void*)this; + updateWindowData->WindowID = windowID; + + // Delete the window from the window list. + + wxCommandEvent updateEvent(XCMAIN_UPDATEWINDOWINFO); + updateEvent.SetId(ID_UPDATEWINDOW); + updateEvent.SetClientData(updateWindowData); + wxPostEvent(this->GetParent(), updateEvent); + +}