Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
utf8: Implemented further UTF8 support
[xestiacalendar/.git] / source / forms / main / frmMain.cpp
1 // frmMain.h - frmMain form functions
2 //
3 // (c) 2016-2017 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
7 // Xestia Calendar is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Calendar is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "frmMain.h"
21 wxDEFINE_EVENT(XCMAIN_PROCESSCALENDAR, wxCommandEvent);
22 wxDEFINE_EVENT(XCMAIN_EDITCALENDAR, wxCommandEvent);
23 wxDEFINE_EVENT(XCMAIN_DELETECALENDAR, wxCommandEvent);
24 wxDEFINE_EVENT(XCMAIN_ADDEVENT, wxCommandEvent);
25 wxDEFINE_EVENT(XCMAIN_UPDATEEVENT, wxCommandEvent);
26 wxDEFINE_EVENT(XCMAIN_EDITEVENT, wxCommandEvent);
27 wxDEFINE_EVENT(XCMAIN_DELETEEVENT, wxCommandEvent);
29 wxDEFINE_EVENT(XCMAIN_ADDWINDOWINFO, wxCommandEvent);
30 wxDEFINE_EVENT(XCMAIN_UPDATEWINDOWINFO, wxCommandEvent);
31 wxDEFINE_EVENT(XCMAIN_DELETEWINDOWINFO, wxCommandEvent);
33 frmMain::frmMain( wxWindow* parent )
34 :
35 frmMainADT( parent )
36 {
37         // Setup the default settings if they don't
38         // exist.
39         
40         // Setup the preferences.
41         wxString prefDirectory = GetUserPrefDir();
42         preferences = new XCALPreferences(prefDirectory);
43         
44         // Load the settings.
45         
46         wxString fullPrefPath;
47         
48         fullPrefPath.Append(prefDirectory);
49         fullPrefPath.Append(wxT("settings"));
51         wxFileConfig *settingfile = new wxFileConfig("", "", fullPrefPath);
52     
53         wxString ValueInc;
54         settingfile->Read(wxT("SaveWindowPosition"), &ValueInc);
55     
56         if (ValueInc == wxT("true")){
57                 
58                 wxRect windowPosition;
59         
60                 long posX, posY, posH, posW = 0;
62                 bool posXValid, posYValid, posHValid, posWValid = false;
64                 posXValid = settingfile->Read(wxT("WindowPositionX"), &posX);
65                 posYValid = settingfile->Read(wxT("WindowPositionY"), &posY);
66                 posHValid = settingfile->Read(wxT("WindowPositionHeight"), &posH);
67                 posWValid = settingfile->Read(wxT("WindowPositionWidth"), &posW);
69                 if (posXValid == true && posYValid == true && posHValid == true && posWValid == true){
71                         this->SetSize(posX, posY, posH, posW);
73                 } else {
75                         this->SetSize(-1, -1, 800, 600);
76                         
77                 }
78         
79         }
81         // Load the account data.
82         
83         LoadAccountData();
84         
85         // Setup the form control.
86         
87         mainCalendarCtrl = new XCCalendarCtrl(this, &calendarData);
88         szrMain->Add(mainCalendarCtrl, 1, wxEXPAND, 5);
89         szrMain->Layout();
91         // Bind events to the control.
92         
93         Bind(XCMAIN_PROCESSCALENDAR, &frmMain::ProcessCalendar, this, ID_PROCESSCALENDAR);
94         Bind(XCMAIN_EDITCALENDAR, &frmMain::EditCalendar, this, ID_EDITCALENDAR);
95         Bind(XCMAIN_DELETECALENDAR, &frmMain::DeleteCalendar, this, ID_DELETECALENDAR);
96         Bind(XCMAIN_ADDEVENT, &frmMain::AddEvent, this, ID_ADDENTRY);
97         Bind(XCMAIN_UPDATEEVENT, &frmMain::UpdateEvent, this, ID_UPDATEENTRY);
98         Bind(XCMAIN_EDITEVENT, &frmMain::EditEvent, this, ID_EDITEVENT);
99         Bind(XCMAIN_DELETEEVENT, &frmMain::DeleteEvent, this, ID_DELETEEVENT);
100         
101         Bind(XCMAIN_ADDWINDOWINFO, &frmMain::WindowAdd, this, ID_ADDWINDOW);
102         Bind(XCMAIN_UPDATEWINDOWINFO, &frmMain::WindowUpdate, this, ID_UPDATEWINDOW);
103         Bind(XCMAIN_DELETEWINDOWINFO, &frmMain::WindowDelete, this, ID_DELETEWINDOW);
106 void frmMain::QuitApp( wxCloseEvent& event )
109         // Run the QuitApp function.
111         QuitApp();
115 void frmMain::QuitApp( wxCommandEvent& event )
117     
118         // Run the QuitApp function.
119     
120         QuitApp();
121     
124 void frmMain::QuitApp()
127         // Function to run when quitting.
129         //Go through the windows and close each one (be it search
130         //or contact editor). Abort if user wants to cancel.
132         // Close the contact editor windows.
134         // Close the contact windows.
136         // Close the search windows.
138         // Write out the ETag databases.
140         // Save Preferences: Save the window position if that option is enabled.
142         wxString SetFilename = GetUserPrefDir();
144 #if defined(__HAIKU__)
148 #elif defined(__WIN32__)
150         SetFilename.Append(wxT("settings"));
152 #else
154         // *nix OSes
156         SetFilename.Append(wxT("settings"));
158 #endif
160         wxFileConfig *cfgfile = new wxFileConfig("", "", SetFilename);
162         bool SaveWindowPos = false;
163         wxString SaveWindowInc;
164         cfgfile->Read(wxT("SaveWindowPosition"), &SaveWindowInc);
166         if (SaveWindowInc == wxT("true")){
167         
168                 SaveWindowPos = true;
169         
170         }
172         if (SaveWindowPos == true){
173         
174                 wxRect frmMainPos = this->GetRect();
175         
176                 cfgfile->Write(wxT("WindowPositionX"), frmMainPos.GetX());
177                 cfgfile->Write(wxT("WindowPositionY"), frmMainPos.GetY());
178                 cfgfile->Write(wxT("WindowPositionHeight"), frmMainPos.GetHeight());
179                 cfgfile->Write(wxT("WindowPositionWidth"), frmMainPos.GetWidth());
180         
181         }
183         delete cfgfile;
184         cfgfile = nullptr;
186         //Everything closed... exit.
188         std::exit(0);
190         Close();
194 void frmMain::LoadAccountData(){
195         
196         // Get the list of accounts and put into the calendar data storage.
197         
198         int accountCount = preferences->accounts.GetCount();
199         
200         for (int accountSeek = 0; accountSeek < accountCount; accountSeek++){
201                 
202                 CDSAccountResult addResult = calendarData.AddAccount(string(preferences->accounts.GetAccountName(accountSeek).ToUTF8()), accountSeek);
203                 
204         }
205         
206         // Get the list of calendars and put them into the calendar data storage.
207         
208         for (int accountSeek = 0; accountSeek < accountCount; accountSeek++){
209         
210                 CDSGetAccountInfo accountInfo = calendarData.GetAccount(string(preferences->accounts.GetAccountName(accountSeek).ToUTF8()));
211         
212                 // Build the path.
213                 
214                 string calendarListFilename = string(GetUserDir().mb_str());
215                 calendarListFilename += "accounts/";
216                 calendarListFilename += string(preferences->accounts.GetAccountDirectory(accountSeek).mb_str());
217                 calendarListFilename += ".";
218                 calendarListFilename += string(preferences->accounts.GetAccountType(accountSeek).mb_str());
219                 
220                 // Get the list of calendars.
221                 
222                 XCAccountCalendarList calendarList(calendarListFilename);
223                 
224                 // Add the calendar and set the calendar ID for it.
225                 
226                 for (int calendarSeek = 0; calendarSeek < calendarList.calendarShortName.size(); calendarSeek++){
227                         
228                         // Add the calendar.
229                         
230                         CDSCalendarResult calendarAddResult = calendarData.AddCalendar(accountInfo.accountID, 
231                                 calendarList.calendarName[calendarSeek], 
232                                 calendarList.calendarShortName[calendarSeek],
233                                 calendarList.calendarColour[calendarSeek],
234                                 calendarList.calendarDescription[calendarSeek]);
235                         
236                         // Set the calendar ID.
237                         
238                         CDSGetCalendarInfo calendarInfo = calendarData.GetCalendar(string(preferences->accounts.GetAccountName(accountSeek).mb_str()), calendarList.calendarShortName[calendarSeek]);
239                         calendarList.calendarStorageID[calendarSeek] = calendarInfo.calendarID;
240                         
241                         // Find the entries and load each entry.
242                         
243                         wxString calendarListDirectory = wxString(calendarListFilename.c_str(), wxConvUTF8);
244                         calendarListDirectory += "/";
245                         calendarListDirectory += wxString(calendarList.calendarShortName[calendarSeek].c_str(), wxConvUTF8);
246                         calendarListDirectory += "/";
247                         
248                         wxDir entryListDirectory(calendarListDirectory);
249                         wxString entryListFilename;
250                         
251                         bool continueProcessing = entryListDirectory.GetFirst(&entryListFilename, "*.ics", wxDIR_NO_FOLLOW|wxDIR_FILES);
252                         
253                         while (continueProcessing){
254                                 
255                                 string entryListFullFilename;
256                                 entryListFullFilename += string(calendarListDirectory.ToUTF8());
257                                 entryListFullFilename += string(entryListFilename.ToUTF8());
258                                 
259                                 continueProcessing = entryListDirectory.GetNext(&entryListFilename);
260                                 CDSAddEntryResult addEventResult = calendarData.AddEvent(calendarInfo.calendarID, entryListFullFilename);
261                                 
262                         }                       
263                         
264                 }
265                 
266         }
267         
270 void frmMain::ShowPreferencesWindow( wxCommandEvent& event )
273         // Close all windows first.
274         
275         if (CloseAllWindows() == false)
276         {
277                 return;
278         }
279         
280         // Open the preferences window.
281     
282         reloadAccounts = FALSE;
283     
284         frmPreferences *framePreferences = new frmPreferences ( this );
285         framePreferences->SetupPointers(&reloadAccounts);
286         framePreferences->ShowModal();
287         delete framePreferences;
288         framePreferences = NULL;
289     
290         // Reload the preferences.
291         
292         if (reloadAccounts == true){
293             
294                 // Reload the accounts as a change has been made within
295                 // the application.
296         
297                 wxString prefDirectory = GetUserPrefDir();
298                 XCALPreferences *oldPreferences = preferences;
299                 preferences = new XCALPreferences(prefDirectory);
300                 
301                 delete oldPreferences;
302                 oldPreferences = nullptr;
303                 
304                 // Clear all of the data from the calendar data storage.
305                 
306                 calendarData.Clear();
307                 LoadAccountData();
308                 
309                 // Politely ask the calendar control to reload it's view.
311                 wxCommandEvent updateGrid(XCCALENDARCTRL_CHANGEGRID);
312                 updateGrid.SetId(ID_CHANGEGRID);
313                 wxPostEvent(mainCalendarCtrl, updateGrid);
314                 
315         }
316     
319 void frmMain::ShowAboutWindow( wxCommandEvent& event )
322         // Show the about window.
323     
324         frmAbout *frameAbout = new frmAbout ( this );
325         frameAbout->SetupAboutWindow();
326         frameAbout->ShowModal();
327         delete frameAbout;
328         frameAbout = NULL;
329     
332 void frmMain::ShowUpdateWindow( wxCommandEvent& event )
335         frmUpdate *frameUpdate = new frmUpdate ( this );
336         frameUpdate->FetchData();
337         frameUpdate->ShowModal();
338         delete frameUpdate;
339         frameUpdate = NULL;
340         
343 void frmMain::OpenNewAccountDialog( wxCommandEvent& event )
345         
346         // Open the new account dialog.
347     
348         reloadAccounts = false;
349     
350         frmNewAccount *frameNewAccount = new frmNewAccount ( this );
351         frameNewAccount->SetupPointers(&reloadAccounts, &calendarData);
352         frameNewAccount->ShowModal();
353         delete frameNewAccount;
354         frameNewAccount = NULL;
355         
356         // Reload the preferences.
357         
358         if (reloadAccounts == true){
359             
360                 // Reload the accounts as a change has been made within
361                 // the application.
362         
363                 wxString prefDirectory = GetUserPrefDir();
364                 XCALPreferences *oldPreferences = preferences;
365                 preferences = new XCALPreferences(prefDirectory);
366                 
367                 delete oldPreferences;
368                 oldPreferences = nullptr;
369                 
370                 // Clear all of the data from the calendar data storage.
371                 
372                 calendarData.Clear();
373                 LoadAccountData();
374                 
375                 // Politely ask the calendar control to reload it's view.
377                 wxCommandEvent updateGrid(XCCALENDARCTRL_CHANGEGRID);
378                 updateGrid.SetId(ID_CHANGEGRID);
379                 wxPostEvent(mainCalendarCtrl, updateGrid);
380                 
381         }
382         
385 void frmMain::CreateNewCalendar( wxCommandEvent& event )
387         
388         frmCalendarEditor *frameNewCalendar = new frmCalendarEditor ( this );
389         frameNewCalendar->SetMode(false);
390         frameNewCalendar->SetupAccounts(preferences);
391         frameNewCalendar->ShowModal();
392         delete frameNewCalendar;
393         frameNewCalendar = nullptr;
394         
397 void frmMain::EditCalendar( wxCommandEvent& event )
399         
400         // Close all windows first.
401         
402         if (CloseAllWindows() == false)
403         {
404                 return;
405         }
406         
407         // Get the calendar data.
408         
409         CDSGetCalendarInfo calendarInfo = calendarData.GetCalendar(event.GetInt());
410         
411         frmCalendarEditor *frameNewCalendar = new frmCalendarEditor ( this );
412         frameNewCalendar->SetMode(true);
413         frameNewCalendar->SetupAccounts(preferences);
414         frameNewCalendar->SetData(event.GetInt(), calendarInfo.accountName, calendarInfo.calendarName, calendarInfo.calendarDescription, calendarInfo.calendarColour);
415         frameNewCalendar->ShowModal();
416         delete frameNewCalendar;
417         frameNewCalendar = nullptr;
418         
421 void frmMain::DeleteCalendar( wxCommandEvent& event )
424         // Close all windows first.
425         
426         if (CloseAllWindows() == false)
427         {
428                 return;
429         }
430         
431         CalendarProperties *calendarEventInfo = (CalendarProperties*)event.GetClientData();
432         
433         // Get the calendar data.
434         
435         CDSGetCalendarInfo calendarInfo = calendarData.GetCalendar(calendarEventInfo->calendarID);
436         
437         if (wxMessageBox(wxString::Format("Are you sure you want to delete the calendar %s from the %s account?", wxString(calendarInfo.calendarName.c_str(), wxConvUTF8), wxString(calendarInfo.accountName.c_str(), wxConvUTF8)), "Delete calendar", wxYES_NO|wxICON_QUESTION) == wxNO){
438                 return;
439         }
440         
441         // Go through the grid and delete each calendar entry widget that 
442         // is associated with the calendar.
443         
444         wxCommandEvent deleteCalendar(XCCALENDARCTRL_DELETECALENDARENTRIES);
445         deleteCalendar.SetId(ID_DELETECALENDARENTRIES);
446         deleteCalendar.SetInt(calendarInfo.calendarID);
447         wxPostEvent(mainCalendarCtrl, deleteCalendar);
448         
449         // Get the account configuration file and delete the calendar information.
450         
451         CDSGetAccountInfo accountInfo = calendarData.GetAccount(calendarInfo.accountName.c_str());
452         
453         string accountDirectoryPath = string(GetUserDir().mb_str());    
454         accountDirectoryPath += "accounts/";
455         accountDirectoryPath += string(preferences->accounts.GetAccountDirectory(calendarEventInfo->accountPreferencesID).ToUTF8());
456         accountDirectoryPath += ".";
457         accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarEventInfo->accountPreferencesID).ToUTF8());
458         accountDirectoryPath += "/";
459         
460         string calendarListFilenameFull = accountDirectoryPath;
461         calendarListFilenameFull += "calendarlist.db";
462         
463         string calendarDirectoryPath = accountDirectoryPath;
464         calendarDirectoryPath += calendarInfo.calendarTextID;
465         
466         wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull.c_str(), wxConvUTF8));
467         
468         // Delete the calendar directory.
470         wxDir entryListDirectory(wxString(calendarDirectoryPath.c_str(), wxConvUTF8));
471         wxString entryListFilename;
472         
473         bool continueProcessing = entryListDirectory.GetFirst(&entryListFilename, "*", wxDIR_NO_FOLLOW|wxDIR_FILES);
474         
475         while (continueProcessing){
476                                 
477                 string entryListFullFilename;
478                 entryListFullFilename += wxString(calendarDirectoryPath.c_str(), wxConvUTF8);
479                 entryListFullFilename += "/";
480                 entryListFullFilename += string(entryListFilename.mb_str());
481                 
482                 wxRemoveFile(wxString(entryListFullFilename.c_str(), wxConvUTF8));
483                 
484                 continueProcessing = entryListDirectory.GetNext(&entryListFilename);
485                                 
486         }
487         
488         entryListDirectory.Close();
489         
490         // Delete the calendar from the account calendar list.
491         
492         calendarListFile->DeleteGroup(wxString(calendarInfo.calendarTextID));
493         
494         // Delete the calendar from the calendar data storage.
495         
496         calendarData.DeleteCalendar(calendarEventInfo->calendarID);
497         
498         // Delete the calendar directory.
499         
500         wxRmDir(wxString(calendarDirectoryPath.c_str(), wxConvUTF8));
501         
502         delete calendarListFile;
503         calendarListFile = nullptr;
504         
505         delete calendarEventInfo;
506         calendarEventInfo = nullptr;
507         
510 void frmMain::CreateNewEvent( wxCommandEvent& event ){
511         
512         frmEventEditor *frameNewEvent = new frmEventEditor ( this );
513         frameNewEvent->SetupForm(&calendarData, preferences);
514         frameNewEvent->SetWindowMenuItemID(++WindowMenuItemID);
515         
516         // Add the window to the window list.
517         
518         WindowData *newWindowData = new WindowData;
519     
520         newWindowData->DataType = 1;
521         newWindowData->WindowPointer = (void*)frameNewEvent;
522         newWindowData->WindowID = WindowMenuItemID;
523         
524         wxCommandEvent addevent(XCMAIN_ADDWINDOWINFO);
525         addevent.SetId(ID_ADDWINDOW);
526         addevent.SetClientData(newWindowData);
527         wxPostEvent(this, addevent);
528         
529         frameNewEvent->Show();
530         
533 void frmMain::EditEvent( wxCommandEvent& event ){
534         
535         frmEventEditor *frameEditEvent = new frmEventEditor ( this );
536         frameEditEvent->SetEventID(event.GetInt());
537         frameEditEvent->SetEditMode(true);
538         frameEditEvent->SetWindowMenuItemID(++WindowMenuItemID);
539         frameEditEvent->SetupForm(&calendarData, preferences);
540         
541         // Add the window to the window list.
542         
543         WindowData *newWindowData = new WindowData;
544     
545         newWindowData->DataType = 1;
546         newWindowData->WindowPointer = (void*)frameEditEvent;
547         newWindowData->WindowID = WindowMenuItemID;
548         
549         wxCommandEvent addevent(XCMAIN_ADDWINDOWINFO);
550         addevent.SetId(ID_ADDWINDOW);
551         addevent.SetClientData(newWindowData);
552         wxPostEvent(this, addevent);
554         // Setup the form and display it.
555         
556         frameEditEvent->Show();
557         
560 void frmMain::DeleteEvent( wxCommandEvent& event ){
561         
562         EventProperties *eventInfo = (EventProperties*)event.GetClientData();
563         
564         // Get the event information.
565         
566         CDSGetCalendarEntryInfo eventDeleteData = calendarData.GetEvent(eventInfo->eventID);
567         CDSGetCalendarInfo calendarDeleteData = calendarData.GetCalendar(eventInfo->calendarID);
568         
569         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){
570                 return;
571         }
572         
573         // Go through the grid and delete the entry from the GUI.
574         
575         wxCommandEvent deleteEvent(XCCALENDARCTRL_DELETEENTRY);
576         deleteEvent.SetId(ID_DELETEENTRY);
577         deleteEvent.SetInt(eventInfo->eventID);
578         wxPostEvent(mainCalendarCtrl, deleteEvent);
579         
580         // Get the filename and delete the entry.
581         
582         wxRemoveFile(wxString(eventDeleteData.entryFilename.c_str(), wxConvUTF8));
583         
584         // Delete the entry from the calendar data storage.
585         
586         calendarData.DeleteEvent(eventInfo->eventID);
587         
588         delete eventInfo;
589         eventInfo = nullptr;
590         
593 void frmMain::AddEvent( wxCommandEvent& event )
595         
596         EventProperties *eventInfo = (EventProperties*)event.GetClientData();
597         
598         wxCommandEvent addEvent(XCCALENDARCTRL_ADDENTRY);
599         addEvent.SetId(ID_ADDENTRY);
600         addEvent.SetClientData(eventInfo);
601         wxPostEvent(mainCalendarCtrl, addEvent);
602         
605 void frmMain::UpdateEvent( wxCommandEvent& event )
607         
608         EventProperties *eventInfo = (EventProperties*)event.GetClientData();
609         
610         wxCommandEvent updateEvent(XCCALENDARCTRL_UPDATEENTRY);
611         updateEvent.SetId(ID_UPDATEENTRY);
612         updateEvent.SetClientData(eventInfo);
613         wxPostEvent(mainCalendarCtrl, updateEvent);
614         
617 void frmMain::ProcessCalendar( wxCommandEvent& event )
619         
620         CalendarProperties *calendarInfo = (CalendarProperties*)event.GetClientData();
621         
622         // Get the account name.
623         
624         CDSGetAccountInfo accountInfo = calendarData.GetAccount(calendarInfo->accountName.c_str());
625         
626         // Build the account directory path.
627         
628         string accountDirectoryPath = string(GetUserDir().mb_str());
629         accountDirectoryPath += "accounts/";
630         accountDirectoryPath += string(preferences->accounts.GetAccountDirectory(calendarInfo->accountPreferencesID).ToUTF8());
631         accountDirectoryPath += ".";
632         accountDirectoryPath += string(preferences->accounts.GetAccountType(calendarInfo->accountPreferencesID).mb_str());
633         accountDirectoryPath += "/";
634         
635         // Generate a UUID for the new calendar.
636         
637         string calendarPath = accountDirectoryPath;
639         string calendarUUID = "";
641         if (calendarInfo->editMode == false){
643                 calendarUUID = GenerateUUID();
644                 calendarPath += calendarUUID;
645                 
646         } else {
647         
648                 calendarUUID = calendarData.GetCalendar(calendarInfo->calendarID).calendarTextID;
649                 calendarPath += calendarPath;
650                 
651         }
652         
653         calendarPath += "/";
654         
655         // Open the account's calendar file and add to the list of calendars.
656         
657         string calendarListFilenameFull = accountDirectoryPath;
658         calendarListFilenameFull += "calendarlist.db";
659         
660         wxFileConfig *calendarListFile = new wxFileConfig("", "", wxString(calendarListFilenameFull.c_str(), wxConvUTF8));
661         
662         wxString calendarDescription = wxString(calendarInfo->calendarDescription.c_str(), wxConvUTF8);
663         
664         calendarDescription.Replace("\n", "\\n", true);
665         
666         // Create the directory for the calendar entries if 
667         // not editing a calendar.
668         
669         calendarListFile->SetPath(wxString(calendarUUID));
670         calendarListFile->Write(wxT("name"), wxString(calendarInfo->calendarName.c_str(), wxConvUTF8));
671         calendarListFile->Write(wxT("description"), calendarDescription);
672         calendarListFile->Write(wxT("colour"), wxString(calendarInfo->calendarColour));
673         
674         if (calendarInfo->editMode == false){
675         
676                 wxMkDir(wxString(calendarPath.c_str(), wxConvUTF8), wxS_DIR_DEFAULT);
677                 calendarData.AddCalendar(accountInfo.accountID, calendarInfo->calendarName, calendarUUID, calendarInfo->calendarColour, calendarInfo->calendarDescription);
678                 
679         } else {
680                 
681                 calendarData.UpdateCalendar(calendarInfo->calendarID, calendarInfo->calendarName, calendarInfo->calendarColour, calendarInfo->calendarDescription);
682                 
683                 // Post event to update the colour in the calendar entries.
684                 
685                 updateColourData.calendarID = calendarInfo->calendarID;
686                 updateColourData.newColour.red = calendarInfo->calendarColour.red;
687                 updateColourData.newColour.green = calendarInfo->calendarColour.green;
688                 updateColourData.newColour.blue = calendarInfo->calendarColour.blue;
689                 updateColourData.newColour.alpha = calendarInfo->calendarColour.alpha;
690                 
691                 wxCommandEvent updateColour(XCCALENDARCTRL_UPDATECALENDARCOLOUR);
692                 updateColour.SetClientData(&updateColourData);
693                 updateColour.SetId(ID_UPDATECOLOUR);
694                 wxPostEvent(mainCalendarCtrl, updateColour);
695                 
696         }
697         
698         // Add the calendar to the calendar data storage.
699         
700         delete calendarListFile;
701         calendarListFile = nullptr;
702         
703         delete calendarInfo;
704         calendarInfo = nullptr;
705         
708 void frmMain::ShowHelp( wxCommandEvent& event )
710         
711         wxMessageBox(_("The help documentation will be implemented in a future version of Xestia Calendar."), _("Unimplemented"));
712         
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy