X-Git-Url: http://Server1/repobrowser/?p=xestiacalendar%2F.git;a=blobdiff_plain;f=source%2Fforms%2Feventeditor%2FfrmEventEditor.cpp;h=ad9b1846008d2bb06d669c61ace5396244f23bb6;hp=f262d6a037268a75df24d8e47ccfadcd4ae8ebb6;hb=8c3ffd801b8a316dcaf51f988002e324979d9bbd;hpb=cba151c4b833a26c63984769f921bab5e755decd diff --git a/source/forms/eventeditor/frmEventEditor.cpp b/source/forms/eventeditor/frmEventEditor.cpp index f262d6a..ad9b184 100644 --- a/source/forms/eventeditor/frmEventEditor.cpp +++ b/source/forms/eventeditor/frmEventEditor.cpp @@ -66,13 +66,24 @@ void frmEventEditor::SetupForm(CalendarDataStorage *dataStorage, XCALPreferences CDSGetCalendarEntryInfo eventInfo = dataStorage->GetEvent(eventID); + // Set the calendar ID. + + 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); szrDetails->Layout(); - szrList->Layout(); + szrList->Layout(); // Load the data into the form. @@ -118,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){ @@ -142,7 +159,10 @@ void frmEventEditor::SaveContact(wxCommandEvent &event){ void frmEventEditor::SaveNewContact(wxCommandEvent &event){ - SaveContact(); + if (!SaveContact()) + { + return; + } // Reset the form for a new entry. @@ -161,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; } @@ -181,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; } @@ -206,11 +224,24 @@ void frmEventEditor::SaveContact(){ // Set the data into the calendar event object. - eventData.SummaryData = txtEventName->GetValue().ToStdString(); - eventData.DescriptionList.push_back(txtEventDescription->GetValue().ToStdString()); - eventData.DescriptionListAltRep.push_back(""); - eventData.DescriptionListLanguage.push_back(""); - eventData.DescriptionListTokens.push_back(""); + eventData.summaryData = txtEventName->GetValue().ToStdString(); + + if (eventData.descriptionList.size() > 0) + { + eventData.descriptionList[0] = txtEventDescription->GetValue().ToStdString(); + } + else + { + eventData.descriptionList.push_back(txtEventDescription->GetValue().ToStdString()); + eventData.descriptionListAltRep.push_back(""); + eventData.descriptionListLanguage.push_back(""); + eventData.descriptionListTokens.push_back(""); + } + + eventData.descriptionList.push_back(txtEventDescription->GetValue().ToStdString()); + eventData.descriptionListAltRep.push_back(""); + eventData.descriptionListLanguage.push_back(""); + eventData.descriptionListTokens.push_back(""); stringstream stringData; @@ -222,8 +253,8 @@ void frmEventEditor::SaveContact(){ stringData << txtStartTime->GetValue().ToStdString().substr(3, 2).c_str(); stringData << "00Z"; - eventData.DateTimeStartData = stringData.str(); - eventData.DateTimeStampData = stringData.str(); + eventData.dateTimeStartData = stringData.str(); + eventData.dateTimeStampData = stringData.str(); stringData.str(""); @@ -235,7 +266,7 @@ void frmEventEditor::SaveContact(){ stringData << txtEndTime->GetValue().ToStdString().substr(3, 2).c_str(); stringData << "00Z"; - eventData.DateTimeEndData = stringData.str(); + eventData.dateTimeEndData = stringData.str(); // TODO: Implement Duration. @@ -264,7 +295,7 @@ void frmEventEditor::SaveContact(){ eventFile += NewUUID; eventFile += ".ics"; - eventData.UniqueID = NewUUID; + eventData.uniqueID = NewUUID; // Write the file. @@ -279,6 +310,7 @@ void frmEventEditor::SaveContact(){ EventProperties *eventInfo = new EventProperties; eventInfo->eventName = txtEventName->GetValue().ToStdString(); + eventInfo->eventDescipriton = txtEventDescription->GetValue().ToStdString(); eventInfo->calendarID = calendarIDList[cmbCalendar->GetSelection()]; eventInfo->eventID = addEventResult.calendarEntryID; eventInfo->eventYear = dapStartDate->GetValue().GetYear(); @@ -295,6 +327,7 @@ void frmEventEditor::SaveContact(){ eventFilePath = eventFile; editMode = true; + calendarID = eventInfo->calendarID; eventID = addEventResult.calendarEntryID; @@ -325,7 +358,8 @@ void frmEventEditor::SaveContact(){ EventProperties *eventInfo = new EventProperties; eventInfo->eventName = txtEventName->GetValue().ToStdString(); - eventInfo->calendarID = calendarIDList[cmbCalendar->GetSelection()]; + eventInfo->eventDescipriton = txtEventDescription->GetValue().ToStdString(); + eventInfo->calendarID = calendarID; eventInfo->eventID = eventID; eventInfo->eventYear = dapStartDate->GetValue().GetYear(); eventInfo->eventMonth = dapStartDate->GetValue().GetMonth(); @@ -341,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) { @@ -464,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. + + string windowTitle; + + if (cmbCalendar->GetSelection() == -1) + { + windowTitle += "(calendar not selected)"; + } + else + { + windowTitle += cmbCalendar->GetStringSelection().ToStdString(); + } + + if (txtEventName->IsEmpty()) + { + windowTitle += " - "; + windowTitle += "(unamed event)"; + } + else + { + windowTitle += " - "; + windowTitle += txtEventName->GetValue().ToStdString(); + } + + 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); + +}