Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmCalendarEditor: Added form to edit calendars
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 11 Jan 2017 18:59:35 +0000 (18:59 +0000)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Wed, 11 Jan 2017 18:59:35 +0000 (18:59 +0000)
source/forms/calendareditor/frmCalendarEditor.cpp [new file with mode: 0644]
source/forms/calendareditor/frmCalendarEditor.h [new file with mode: 0644]

diff --git a/source/forms/calendareditor/frmCalendarEditor.cpp b/source/forms/calendareditor/frmCalendarEditor.cpp
new file mode 100644 (file)
index 0000000..f39a5d6
--- /dev/null
@@ -0,0 +1,126 @@
+#include "frmCalendarEditor.h"
+
+using namespace std;
+
+frmCalendarEditor::frmCalendarEditor( wxWindow* parent )
+:
+frmCalendarEditorADT( parent )
+{
+
+}
+
+void frmCalendarEditor::SetMode(bool setMode){
+       
+       editMode = setMode;
+       
+       if (editMode == true){
+               
+               lblAccount->Show(false);
+               cmbAccount->Show(false);
+               btnCreate->SetLabel(_("Update"));
+               
+       }
+       
+}
+
+void frmCalendarEditor::CloseWindow( wxCommandEvent &event )
+{
+       
+       this->Close();
+       
+}
+
+void frmCalendarEditor::SetupAccounts(XCALPreferences *preferencesData){
+       
+       for (int accountSeek = 0; accountSeek < preferencesData->accounts.GetCount(); accountSeek++){
+               
+               // Check if the account is a supported type before adding.
+               
+               if (preferencesData->accounts.GetAccountType(accountSeek) != wxT("Local")){
+                       
+                       // Go to the next account.
+                       
+                       continue;
+                       
+               }
+               
+               cmbAccount->Append(preferencesData->accounts.GetAccountName(accountSeek));
+               accountPrefencesIDList.push_back(accountSeek);
+               
+       }
+       
+       this->preferencesData = preferencesData;
+       
+}
+
+void frmCalendarEditor::ProcessCalendar( wxCommandEvent &event ){
+       
+       // Check that an account has been selected before continuing.
+       
+       if (cmbAccount->GetCurrentSelection() == -1 && editMode == false){
+               wxMessageBox(_("No account was selected for this calendar."), _("Error"));
+               return;
+       }
+       
+       // Check that the calendar has a name before continuing.
+       
+       if (txtName->IsEmpty()){
+               wxMessageBox(_("No name for the calendar has been entered."), _("Error"));
+               return;
+       }
+       
+       // Post an event to the main window to create or edit the calendar with the
+       // details given.
+       
+       CalendarProperties *calendarInfo = new CalendarProperties;
+       
+       // Setup the data.
+       
+       if (editMode == true){
+               
+               calendarInfo->accountPreferencesID = accountPrefencesIDList[cmbAccount->GetCurrentSelection()];
+               calendarInfo->calendarID = calendarID;
+               
+       } else {
+
+               // Go through the list of accounts and find the matching account name.
+               
+               int accountSeek = 0;
+               
+               for (accountSeek = 0; accountSeek < preferencesData->accounts.GetCount(); accountSeek++){
+                       
+                       if ((wxString)cmbAccount->GetStringSelection() == preferencesData->accounts.GetAccountName(accountSeek)){
+                               break;
+                       }
+                       
+               }
+               
+               calendarInfo->accountPreferencesID = accountPrefencesIDList[cmbAccount->GetCurrentSelection()];
+               
+       }
+
+       calendarInfo->editMode = editMode;
+       calendarInfo->accountName = cmbAccount->GetStringSelection();
+       calendarInfo->calendarName = txtName->GetValue().ToStdString();
+       calendarInfo->calendarDescription = txtDescription->GetValue().ToStdString();
+       
+       calendarInfo->calendarColour = (clpColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX).ToStdString() + "FF");
+       
+       wxCommandEvent processCalendarEvent(XCMAIN_PROCESSCALENDAR);
+       processCalendarEvent.SetId(ID_PROCESSCALENDAR);
+       processCalendarEvent.SetClientData((void*)calendarInfo);
+       wxPostEvent(this->GetParent(), processCalendarEvent);
+       
+       this->Close();
+       
+}
+
+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()));        
+       clpColour->SetColour(wxColour(calendarColour.red, calendarColour.green, calendarColour.blue));
+       cmbAccount->SetStringSelection(wxString(accountName));
+       this->calendarID = calendarID;
+       
+}
\ No newline at end of file
diff --git a/source/forms/calendareditor/frmCalendarEditor.h b/source/forms/calendareditor/frmCalendarEditor.h
new file mode 100644 (file)
index 0000000..5418cde
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef __frmCalendarEditor__
+#define __frmCalendarEditor__
+
+/**
+@file
+Subclass of frmCalendarEditorADT, which is generated by wxFormBuilder.
+*/
+
+#include <string>
+#include <vector>
+
+#include "../../AppXestiaCalendar.h"
+
+#include "preferences.h"
+#include "events.h"
+#include "structs.h"
+#include "colour.h"
+
+//// end generated include
+
+/** Implementing frmCalendarEditorADT */
+class frmCalendarEditor : public frmCalendarEditorADT
+{
+       private:
+               bool editMode = false;
+               XCALPreferences *preferencesData = nullptr;
+               vector<int> accountPrefencesIDList;
+               int calendarID = 0;
+               std::string accountName = "";
+       
+       protected:
+               void CloseWindow( wxCommandEvent &event );
+               void ProcessCalendar( wxCommandEvent &event );
+       public:
+               /** Constructor */
+               frmCalendarEditor( wxWindow* parent );
+       //// end generated class members
+               void SetMode(bool setMode);
+               void SetupAccounts(XCALPreferences *preferencesData);
+               void SetData(int calendarID, std::string accountName, std::string calendarName, std::string calendarDescription, Colour calendarColour);
+       
+};
+
+#endif // __frmCalendarEditor__
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