Recent

Author Topic: tvPlanit - import from iCal into Cathegory  (Read 230 times)

Nicole

  • Sr. Member
  • ****
  • Posts: 336
tvPlanit - import from iCal into Cathegory
« on: July 25, 2022, 02:59:07 pm »
The context menue of tvPlanit allows to import directly from iCal format.

Is it possible to import into a certain cathegory as target?
e.g. holidays from the USA to a different one as holidays from Germany?

wp

  • Hero Member
  • *****
  • Posts: 10043
Re: tvPlanit - import from iCal into Cathegory
« Reply #1 on: July 26, 2022, 06:14:13 pm »
This is an excerpt from the ical import code for an ical item:

Code: Pascal  [Select][+][-]
  1. procedure TVpEvent.LoadFromICalendar(AEntry: TVpICalEvent);
  2. ...
  3.   { Category }
  4.   { tvplanit has only 1 category, ical may have several. We pick the first one
  5.     defined in the datastore. If none is defined we create the first one. }
  6.   if AEntry.CategoryCount > 0 then begin
  7.     datastore := TVpCustomDatastore(Owner.Owner.Owner.Owner);
  8.     k := -1;
  9.     for i := 0 to AEntry.CategoryCount-1 do begin
  10.       cat := AEntry.category[i];
  11.       j := datastore.CategoryColorMap.IndexOfCategory(cat);
  12.       if j <> -1 then begin
  13.         k := j;
  14.         break;
  15.       end;
  16.     end;
  17.     if k = -1 then begin // category not found in data store
  18.       k := datastore.CategoryColorMap.IndexOfFirstUnusedCategory;
  19.       if k <> -1 then
  20.         datastore.CategoryColorMap.SetCategoryName(k, AEntry.Category[0]);
  21.     end;
  22.     if k <> -1 then
  23.       FCategory := k;
  24.   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.

 

TinyPortal © 2005-2018