Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
widgets: Cleanup objects in destructors and minor code cleanup
[xestiacalendar/.git] / source / widgets / XCCalendarListAccountCtrl.cpp
index 7ae30f8..dbd105e 100644 (file)
@@ -18,6 +18,9 @@
 
 #include "XCCalendarListAccountCtrl.h"
 
+BEGIN_EVENT_TABLE(XCCalendarListAccountCtrl, wxPanel)
+END_EVENT_TABLE()
+
 using namespace std;
 
 XCCalendarListAccountCtrl::XCCalendarListAccountCtrl(wxWindow* parent, string accountName) : 
@@ -34,7 +37,7 @@ XCCalendarListAccountCtrl::XCCalendarListAccountCtrl(wxWindow* parent, string ac
        
        // Setup the label.
        
-       lblAccountName = new wxStaticText(this, wxID_ANY, wxString(accountName), wxDefaultPosition, wxDefaultSize, 0, "");
+       lblAccountName = new wxStaticText(this, wxID_ANY, wxString(accountName.c_str(), wxConvUTF8), wxDefaultPosition, wxDefaultSize, 0, "");
                
        // Setup the font.
                
@@ -42,6 +45,11 @@ XCCalendarListAccountCtrl::XCCalendarListAccountCtrl(wxWindow* parent, string ac
        accountFont.MakeBold();
        lblAccountName->SetFont(accountFont);
                
+       // Connect events to the controls.
+       
+       chkShowAll->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxMouseEventHandler(XCCalendarListAccountCtrl::ShowAllCheckboxClick), NULL, this);
+       chkShowAll->SetValue(wxCHK_CHECKED);
+       
        // Connect them to the sizer.
        
        szrMain->Add(chkShowAll, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
@@ -53,6 +61,33 @@ XCCalendarListAccountCtrl::~XCCalendarListAccountCtrl(){
        
        // Delete the calendar controls.
        
+       // Unbind the controls.
+       
+       chkShowAll->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxMouseEventHandler(XCCalendarListAccountCtrl::ShowAllCheckboxClick), NULL, this);
+       
+       // Delete the calendar list controls.
+       
+       for (std::vector<XCCalendarListCalendarCtrl*>::iterator calendarIter = calendarControlList.begin();
+               calendarIter != calendarControlList.end(); calendarIter++){
+       
+               delete *calendarIter;
+                       
+       }
+       
+       // Clear the list of deleted controls.
+       
+       calendarControlList.clear();
+       
+       // Clear the widget controls.
+
+       delete chkShowAll;
+       chkShowAll = nullptr;
+       
+       delete lblAccountName;
+       lblAccountName = nullptr;
+
+       this->SetSizer(nullptr, true);
+       
 }
 
 void XCCalendarListAccountCtrl::AddCalendar(XCCalendarListCalendarCtrl *calendarControl){
@@ -65,4 +100,79 @@ void XCCalendarListAccountCtrl::AddCalendar(XCCalendarListCalendarCtrl *calendar
        
        calendarControlList.push_back(calendarControl);
        
+}
+
+void XCCalendarListAccountCtrl::ShowAllCheckboxClick( wxMouseEvent &mouseEvent ){
+       
+       if (chkShowAll->Get3StateValue() == wxCHK_CHECKED){
+               
+               wxCommandEvent event(XCCALENDARCTRL_SHOWACCOUNTENTRIES);
+               event.SetInt(accountID);
+               event.SetId(ID_SHOWENTRIES);
+               wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
+               
+       } else {
+               
+               wxCommandEvent event(XCCALENDARCTRL_HIDEACCOUNTENTRIES);
+               event.SetInt(accountID);
+               event.SetId(ID_HIDEENTRIES);
+               wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
+               
+       }
+       
+}
+
+wxCheckBoxState XCCalendarListAccountCtrl::GetShowCheckboxState(){
+       
+       return chkShowAll->Get3StateValue();
+       
+}
+
+int XCCalendarListAccountCtrl::GetAccountID(){
+       
+       return accountID;
+       
+}
+
+void XCCalendarListAccountCtrl::SetAccountID(int accountID){
+       
+       this->accountID = accountID;
+       
+}
+
+void XCCalendarListAccountCtrl::SetAccountPreferencesID(int accountID){
+       
+       this->accountPreferencesID = accountPreferencesID;
+       
+}
+
+vector<int> XCCalendarListAccountCtrl::GetHiddenCalendarList(){
+       
+       vector<int> calendarList;
+       
+       for (vector<XCCalendarListCalendarCtrl*>::iterator calendarControlListIter = calendarControlList.begin(); 
+               calendarControlListIter != calendarControlList.end(); calendarControlListIter++){
+               
+               if ((*calendarControlListIter)->GetShowCheckboxState() == wxCHK_UNCHECKED){
+                       
+                       calendarList.push_back((*calendarControlListIter)->GetCalendarID());
+                       
+               }
+                       
+       }
+       
+       return calendarList;
+       
+}
+
+void XCCalendarListAccountCtrl::SetCheckBoxValue(wxCheckBoxState newValue){
+       
+       if (newValue == wxCHK_CHECKED){
+               showAccounts = true;
+       } else {
+               showAccounts = false;           
+       }
+       
+       chkShowAll->SetValue(newValue);
+       
 }
\ No newline at end of file
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