Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Implemented code to hide/show calendar entries
[xestiacalendar/.git] / source / widgets / XCCalendarDay.cpp
index 13b01d4..bde3504 100644 (file)
@@ -27,9 +27,6 @@ END_EVENT_TABLE()
 
 XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size)
         : wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL, title){
-       
-       Connect(wxID_ANY, XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectOthersEvent));
-       Connect(ID_DESELECTALLITEMS, XCCALENDARDAY_DESELECTALLENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectAllEvent));
 
        this->SetMinSize( wxSize( 100,100 ) );
        
@@ -88,12 +85,30 @@ XCCalendarDay::XCCalendarDay(wxWindow *parent, const wxString& title, const wxPo
        
        UpdateTopIcons();
        
+       Connect(ID_DESELECTOTHERENTRIES, XCCALENDARDAY_DESELECTOTHERENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectOthersEvent));
+       Connect(ID_DESELECTALLITEMS, XCCALENDARDAY_DESELECTALLENTRIES, wxCommandEventHandler(XCCalendarDay::DeselectAllEvent));
+       Connect(ID_HIDEENTRIES, XCCALENDARDAY_HIDEACCOUNTENTRIES, wxCommandEventHandler(XCCalendarDay::HideAccountEntries));
+       Connect(ID_SHOWENTRIES, XCCALENDARDAY_SHOWACCOUNTENTRIES, wxCommandEventHandler(XCCalendarDay::ShowAccountEntries));
+       Connect(ID_HIDECALENDARENTRIES, XCCALENDARDAY_HIDECALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::HideCalendarEntries));
+       Connect(ID_SHOWCALENDARENTRIES, XCCALENDARDAY_SHOWCALENDARENTRIES, wxCommandEventHandler(XCCalendarDay::ShowCalendarEntries));
+       
 }
 
 XCCalendarDay::~XCCalendarDay(){
        
        // Destory the controls from the widget.
        
+       for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+               CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+       
+               delete((*CalendarEntryIter));
+                       
+       }
+       
+       CalendarEntryList.clear();
+       
+       this->Refresh();
+       
 }
 
 void XCCalendarDay::Repaint(){
@@ -193,10 +208,11 @@ void XCCalendarDay::ResizeFrameEvent(wxSizeEvent &SizeEvent)
 
 void XCCalendarDay::DeselectOthersEvent(wxCommandEvent &DeselectEvent)
 {
-
+       
        int SelectedEntryID = DeselectEvent.GetInt();
 
        wxCommandEvent DeselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
+       DeselectEntryEvent.SetId(ID_ENTRYDESELECT);
        
        for (vector<XCCalendarDayEntry*>::iterator EntryIter = CalendarEntryList.begin();
                EntryIter != CalendarEntryList.end(); EntryIter++){
@@ -226,8 +242,9 @@ void XCCalendarDay::DeselectAllEvent(wxCommandEvent &DeselectEvent)
 {
        
        int SelectedEntryID = DeselectEvent.GetInt();
-
+       
        wxCommandEvent DeselectEntryEvent(XCCALENDARDAYENTRY_DESELECT);
+       DeselectEntryEvent.SetId(ID_ENTRYDESELECT);
        
        for (vector<XCCalendarDayEntry*>::iterator EntryIter = CalendarEntryList.begin();
                EntryIter != CalendarEntryList.end(); EntryIter++){
@@ -238,7 +255,7 @@ void XCCalendarDay::DeselectAllEvent(wxCommandEvent &DeselectEvent)
        
 }
 
-void XCCalendarDay::SetupControl(int SetupDay, int SetupMonth, int SetupYear, bool SetupIsInMonth, XCCalendarMonthView *MonthViewPointer, CalendarDataStorage *dataStorage)
+void XCCalendarDay::SetupControl(int SetupDay, int SetupMonth, int SetupYear, bool SetupIsInMonth, XCCalendarMonthView *MonthViewPointer, CalendarDataStorage *dataStorage, vector<int> *hideAccounts, vector<int> *hideCalendars)
 {
        
        // Set the day
@@ -279,14 +296,175 @@ void XCCalendarDay::SetupControl(int SetupDay, int SetupMonth, int SetupYear, bo
                
                newEntry->SetColour(&newEntryCalendarInfo.calendarColour);
                newEntry->SetTime(newEntryInfo.entryStartHour, newEntryInfo.entryStartMinute, newEntryInfo.entryStartSecond);
-               newEntry->SetEntryIDs(newEntryCalendarInfo.accountID, newEntryInfo.calendarID, newEntryInfo.calendarEntryID);
+               newEntry->SetEntryIDs(newEntryCalendarInfo.accountID, newEntryInfo.calendarID, newEntryInfo.calendarEntryID);           
                
                EventListFrameSizer->Add(newEntry, 0, wxEXPAND, 5);
                wxSizerItem *afterSpacer = EventListFrameSizer->Add(0, 5, 0, 0, 5);
                
                newEntry->SetAfterSpacer(afterSpacer);
                
+               // Go through the list of calendar entries to hide by account.
+               
+               for (vector<int>::iterator hideAccountsItem = hideAccounts->begin();
+                       hideAccountsItem != hideAccounts->end(); hideAccountsItem++){
+                               
+                       if (*hideAccountsItem = newEntryCalendarInfo.accountID){
+                               newEntry->Show(false);
+                               newEntry->GetAfterSpacer()->Show(false);
+                       }
+                               
+               }
+               
+               // Go through the list of calendar entries to hide by calendar.
+               
+               for (vector<int>::iterator hideCalendarsItem = hideCalendars->begin();
+                       hideCalendarsItem != hideCalendars->end(); hideCalendarsItem++){
+                               
+                       if (*hideCalendarsItem == newEntryInfo.calendarID){
+                               newEntry->Show(false);
+                               newEntry->GetAfterSpacer()->Show(false);
+                       }                       
+                               
+               }
+               
                CalendarEntryList.push_back(newEntry);
        }
        
 }
+
+void XCCalendarDay::HideAccountEntries(wxCommandEvent &accountData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+               CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+               
+               (*CalendarEntryIter)->SetShowAccountStatus(false);
+                       
+               if ((*CalendarEntryIter)->GetAccountID() == accountData.GetInt()){
+                       
+                       wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*CalendarEntryIter));
+                       (*CalendarEntryIter)->Show(false);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*CalendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(false);
+                       
+               }
+                       
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::ShowAccountEntries(wxCommandEvent &accountData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+               CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+               
+               (*CalendarEntryIter)->SetShowAccountStatus(true);
+                       
+               if ((*CalendarEntryIter)->GetShowCalendarStatus() == false){
+                       continue;
+               }
+                       
+               if ((*CalendarEntryIter)->GetAccountID() == accountData.GetInt()){
+                       
+                       wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*CalendarEntryIter));
+                       (*CalendarEntryIter)->Show(true);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*CalendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(true);
+                       
+               }
+                       
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::HideCalendarEntries(wxCommandEvent &calendarData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+               CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+                       
+               if ((*CalendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
+                       
+                       (*CalendarEntryIter)->SetShowCalendarStatus(false);
+                       
+                       wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*CalendarEntryIter));
+                       (*CalendarEntryIter)->Show(false);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*CalendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(false);
+                       
+               }
+                       
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
+
+void XCCalendarDay::ShowCalendarEntries(wxCommandEvent &calendarData){
+       
+       // Go through each of the controls and hide the controls (and spacing) that
+       // have the matched account IDs.
+       
+       int sizerPosition = 0;
+       
+       for (vector<XCCalendarDayEntry*>::iterator CalendarEntryIter = CalendarEntryList.begin();
+               CalendarEntryIter != CalendarEntryList.end(); CalendarEntryIter++){
+                       
+               if ((*CalendarEntryIter)->GetCalendarID() == calendarData.GetInt()){
+                       
+                       (*CalendarEntryIter)->SetShowCalendarStatus(true);
+                       
+                       if ((*CalendarEntryIter)->GetShowAccountStatus() == false){
+                               
+                               // Don't show the calendar entry because the account status
+                               // is set to hidden. Continue to the next one.
+                               
+                               continue;
+                               
+                       }
+                       
+                       wxSizerItem *calendarItem = EventListFrameSizer->GetItem((*CalendarEntryIter));
+                       (*CalendarEntryIter)->Show(true);
+                       
+                       // Get the spacing and hide it as well.
+                       
+                       wxSizerItem *afterSpacer = (*CalendarEntryIter)->GetAfterSpacer();
+                       afterSpacer->Show(true);
+                       
+               }
+                       
+       }
+       
+       this->Refresh();
+       Repaint();
+       
+}
\ 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