This is an excerpt from the ical import code for an ical item:
procedure TVpEvent.LoadFromICalendar(AEntry: TVpICalEvent);
...
{ Category }
{ tvplanit has only 1 category, ical may have several. We pick the first one
defined in the datastore. If none is defined we create the first one. }
if AEntry.CategoryCount > 0 then begin
datastore := TVpCustomDatastore(Owner.Owner.Owner.Owner);
k := -1;
for i := 0 to AEntry.CategoryCount-1 do begin
cat := AEntry.category[i];
j := datastore.CategoryColorMap.IndexOfCategory(cat);
if j <> -1 then begin
k := j;
break;
end;
end;
if k = -1 then begin // category not found in data store
k := datastore.CategoryColorMap.IndexOfFirstUnusedCategory;
if k <> -1 then
datastore.CategoryColorMap.SetCategoryName(k, AEntry.Category[0]);
end;
if k <> -1 then
FCategory := k;
end;
As you can see the code iterates over the categories contained in the ical event and searches each one among the categories defined in the datastore. When there is a match this particular ical event category becomes the category of the new tvplanit event and other categories will be ignored (because VpEvent can have only a single category). If there is no match a new category is created in the datastore for the ical event. Note, however, that tvplanit internally allows only for 10 categories so far.
If you want to import an ical item and put it into a specific category you could do this:
- In your datastore.CategoryMap find the first unused category (where the "Description" field is named like the category item) and set its "Description" to the desired name.
- Open the ical file in an editor and type this category name as first item in the "CATEGORIES:" line.
- Now the import should pick up this new category.