From 21f7884352f9ec4f3e54790cc69d335d1b891ffe Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 6 Jun 2016 23:07:00 +0100 Subject: [PATCH] Added CATEGORIES property for saving data from a CalendarTaskObject. Added the code and unit tests for the CATEGORIES property. --- .../calendartask/CalendarTask-Save.cpp | 38 +++++++++++++++++++ source/tests/xestiacalendar_icaltasksave.h | 4 ++ 2 files changed, 42 insertions(+) diff --git a/source/objects/calendartask/CalendarTask-Save.cpp b/source/objects/calendartask/CalendarTask-Save.cpp index 1708aa4..2b34da7 100644 --- a/source/objects/calendartask/CalendarTask-Save.cpp +++ b/source/objects/calendartask/CalendarTask-Save.cpp @@ -843,6 +843,44 @@ void CalendarTaskObject::SaveObjectData(string *SaveData){ } + // Process the CATEGORIES value. + + if (CategoriesList.size() > 0){ + + for (int CategoriesListSeek = 0; CategoriesListSeek < CategoriesList.size(); + CategoriesListSeek++){ + + DataLine += "CATEGORIES"; + + if (CategoriesListLanguage[CategoriesListSeek].size() > 0){ + + DataLine += ";LANGUAGE="; + DataLine += CategoriesListLanguage[CategoriesListSeek]; + + } + + if (CategoriesListTokens[CategoriesListSeek].size() > 0){ + + DataLine += ";"; + DataLine += CategoriesListTokens[CategoriesListSeek]; + + } + + DataLine += ":"; + DataLine += CategoriesList[CategoriesListSeek]; + DataLine += "\n"; + + DataLineProcessed = OutputText(&DataLine); + + *SaveData += DataLineProcessed; + + DataLine.clear(); + DataLineProcessed.clear(); + + } + + } + *SaveData += "END:VTODO\n"; } \ No newline at end of file diff --git a/source/tests/xestiacalendar_icaltasksave.h b/source/tests/xestiacalendar_icaltasksave.h index 49753a4..fc4d311 100644 --- a/source/tests/xestiacalendar_icaltasksave.h +++ b/source/tests/xestiacalendar_icaltasksave.h @@ -93,6 +93,10 @@ TEST(iCalendarSaveTask, SaveTaskTests){ "ATTENDEE;DIR=\"null:nodata\";SENT-BY=\"mailto:sent.by@example.com\";CN=\"Attendee \n" " The Third\";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED;LANGUAGE=kw;EXAMPLE=DATA:Atte\n" " ndee Three\n" + "CATEGORIES:CATEGORY ONE, CATEGORY TWO\n" + "CATEGORIES;LANGUAGE=en:CATEGORY THREE, CATEGORY FOUR\n" + "CATEGORIES;LANGUAGE=en-GB;SAMPLE=TOKEN:CATEGORY FIVE, CATEGORY SIX, CATEGORY \n" + " SEVEN\n" "END:VTODO\n" "END:VCALENDAR"; -- 2.39.5