Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
f39a5d6ed96b1c9829be013cbafaf36b68be5f5b
[xestiacalendar/.git] / source / forms / calendareditor / frmCalendarEditor.cpp
1 #include "frmCalendarEditor.h"
3 using namespace std;
5 frmCalendarEditor::frmCalendarEditor( wxWindow* parent )
6 :
7 frmCalendarEditorADT( parent )
8 {
10 }
12 void frmCalendarEditor::SetMode(bool setMode){
13         
14         editMode = setMode;
15         
16         if (editMode == true){
17                 
18                 lblAccount->Show(false);
19                 cmbAccount->Show(false);
20                 btnCreate->SetLabel(_("Update"));
21                 
22         }
23         
24 }
26 void frmCalendarEditor::CloseWindow( wxCommandEvent &event )
27 {
28         
29         this->Close();
30         
31 }
33 void frmCalendarEditor::SetupAccounts(XCALPreferences *preferencesData){
34         
35         for (int accountSeek = 0; accountSeek < preferencesData->accounts.GetCount(); accountSeek++){
36                 
37                 // Check if the account is a supported type before adding.
38                 
39                 if (preferencesData->accounts.GetAccountType(accountSeek) != wxT("Local")){
40                         
41                         // Go to the next account.
42                         
43                         continue;
44                         
45                 }
46                 
47                 cmbAccount->Append(preferencesData->accounts.GetAccountName(accountSeek));
48                 accountPrefencesIDList.push_back(accountSeek);
49                 
50         }
51         
52         this->preferencesData = preferencesData;
53         
54 }
56 void frmCalendarEditor::ProcessCalendar( wxCommandEvent &event ){
57         
58         // Check that an account has been selected before continuing.
59         
60         if (cmbAccount->GetCurrentSelection() == -1 && editMode == false){
61                 wxMessageBox(_("No account was selected for this calendar."), _("Error"));
62                 return;
63         }
64         
65         // Check that the calendar has a name before continuing.
66         
67         if (txtName->IsEmpty()){
68                 wxMessageBox(_("No name for the calendar has been entered."), _("Error"));
69                 return;
70         }
71         
72         // Post an event to the main window to create or edit the calendar with the
73         // details given.
74         
75         CalendarProperties *calendarInfo = new CalendarProperties;
76         
77         // Setup the data.
78         
79         if (editMode == true){
80                 
81                 calendarInfo->accountPreferencesID = accountPrefencesIDList[cmbAccount->GetCurrentSelection()];
82                 calendarInfo->calendarID = calendarID;
83                 
84         } else {
86                 // Go through the list of accounts and find the matching account name.
87                 
88                 int accountSeek = 0;
89                 
90                 for (accountSeek = 0; accountSeek < preferencesData->accounts.GetCount(); accountSeek++){
91                         
92                         if ((wxString)cmbAccount->GetStringSelection() == preferencesData->accounts.GetAccountName(accountSeek)){
93                                 break;
94                         }
95                         
96                 }
97                 
98                 calendarInfo->accountPreferencesID = accountPrefencesIDList[cmbAccount->GetCurrentSelection()];
99                 
100         }
102         calendarInfo->editMode = editMode;
103         calendarInfo->accountName = cmbAccount->GetStringSelection();
104         calendarInfo->calendarName = txtName->GetValue().ToStdString();
105         calendarInfo->calendarDescription = txtDescription->GetValue().ToStdString();
106         
107         calendarInfo->calendarColour = (clpColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString() + "FF");
108         
109         wxCommandEvent processCalendarEvent(XCMAIN_PROCESSCALENDAR);
110         processCalendarEvent.SetId(ID_PROCESSCALENDAR);
111         processCalendarEvent.SetClientData((void*)calendarInfo);
112         wxPostEvent(this->GetParent(), processCalendarEvent);
113         
114         this->Close();
115         
118 void frmCalendarEditor::SetData(int calendarID, std::string accountName, std::string calendarName, std::string calendarDescription, Colour calendarColour){
119         
120         txtName->SetValue(wxString(calendarName.c_str()));
121         txtDescription->SetValue(wxString(calendarDescription.c_str()));        
122         clpColour->SetColour(wxColour(calendarColour.red, calendarColour.green, calendarColour.blue));
123         cmbAccount->SetStringSelection(wxString(accountName));
124         this->calendarID = calendarID;
125         
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