X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fwidgets%2FXCCalendarList.cpp;h=84662bd386202074352863dde75194851ad05aaf;hb=baa27c175ee6111fd4b88a3c53614a9b6be3541e;hp=62efb9c7899c9b026ac9b2ffb2f990d440b5297d;hpb=339434b90a0a03c3102b82a5dc45334b338bc59c;p=xestiacalendar%2F.git diff --git a/source/widgets/XCCalendarList.cpp b/source/widgets/XCCalendarList.cpp index 62efb9c..84662bd 100644 --- a/source/widgets/XCCalendarList.cpp +++ b/source/widgets/XCCalendarList.cpp @@ -44,7 +44,27 @@ XCCalendarList::~XCCalendarList(){ void XCCalendarList::UpdateCalendarList(CalendarDataStorage *dataStorage){ - // TODO: Verify if the generated code has changed. + // Verify if the generated code has changed. Return if not. + + CDSGetChecksumResult currentChecksum = dataStorage->GetChecksum("internal_updatedata"); + + if (checksumUpdate == currentChecksum.checksumValue){ + + // Checksum matches so return. + return; + + } + + // TODO: Delete the old controls. + + for (vector::iterator accountCtrlIter = accountControlList.begin(); + accountCtrlIter != accountControlList.end(); accountCtrlIter++){ + + delete *accountCtrlIter; + + } + + accountControlList.clear(); // Get the list of accounts and create them one by one. @@ -55,6 +75,7 @@ void XCCalendarList::UpdateCalendarList(CalendarDataStorage *dataStorage){ // Create the control and add it to the list. XCCalendarListAccountCtrl *newAccountCtrl = new XCCalendarListAccountCtrl(this, accountListData.accountList[AccountSeek].accountName); + newAccountCtrl->SetAccountID(accountListData.accountList[AccountSeek].accountID); szrMain->Add(newAccountCtrl, 0, wxEXPAND, 5); @@ -69,6 +90,7 @@ void XCCalendarList::UpdateCalendarList(CalendarDataStorage *dataStorage){ CDSGetCalendarInfo calendarInfo = dataStorage->GetCalendar(accountListData.accountList[AccountSeek].accountName, accountCalendarList.calendarListTextID[calendarSeek]); XCCalendarListCalendarCtrl *newCalendarCtrl = new XCCalendarListCalendarCtrl(this, calendarInfo.calendarName, calendarInfo.calendarColour); + newCalendarCtrl->SetCalendarID(accountCalendarList.calendarList[calendarSeek]); newAccountCtrl->AddCalendar(newCalendarCtrl); @@ -78,4 +100,64 @@ void XCCalendarList::UpdateCalendarList(CalendarDataStorage *dataStorage){ } + // Set the updated checksum. + + checksumUpdate = currentChecksum.checksumValue; + +} + +std::vector XCCalendarList::GetHiddenAccountsList(){ + + std::vector accountList; + + // Go through each of the account controls and work + // out which entries should be hidden based on account. + + for (std::vector::iterator accountListIter = accountControlList.begin(); + accountListIter != accountControlList.end(); accountListIter++){ + + if ((*accountListIter)->GetShowCheckboxState() == wxCHK_UNCHECKED){ + + accountList.push_back((*accountListIter)->GetAccountID()); + + } + + } + + return accountList; + +} + +std::vector XCCalendarList::GetHiddenCalendarsList(){ + + std::vector calendarList; + + // Go through each of the calendar controls and + // work out which entries should be hidden based on + // calendar. + + for (std::vector::iterator accountListIter = accountControlList.begin(); + accountListIter != accountControlList.end(); accountListIter++){ + + // Get the list of hidden calendars. + + vector calendarHiddenList = (*accountListIter)->GetHiddenCalendarList(); + + for (vector::iterator calendarHiddenIter = calendarHiddenList.begin(); + calendarHiddenIter != calendarHiddenList.end(); calendarHiddenIter++){ + + vector::iterator calendarHiddenFind = find(calendarList.begin(), calendarList.end(), *calendarHiddenIter); + + if (calendarHiddenFind == calendarList.end()){ + + calendarList.push_back(*calendarHiddenIter); + + } + + } + + } + + return calendarList; + } \ No newline at end of file