You've already forked lazarus-ccr
tvplanit: Add option to select category to ical event import form.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8382 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,15 +4,20 @@ unit VpImportPreview_ICalEvent;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
uses lazlogger,
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
|
||||
VpData, VpBaseDS, VpImportPreview, VpICal;
|
||||
VpData, VpBaseDS, VpImportPreview, VpICal, Grids;
|
||||
|
||||
type
|
||||
|
||||
{ TVpImportPreviewICalEventForm }
|
||||
|
||||
TVpImportPreviewICalEventForm = class(TVpImportPreviewForm)
|
||||
procedure GridGetEditText(Sender: TObject; ACol, ARow: Integer;
|
||||
var Value: string);
|
||||
procedure GridPickListSelect(Sender: TObject);
|
||||
procedure GridSetEditText(Sender: TObject; ACol, ARow: Integer;
|
||||
const Value: string);
|
||||
private
|
||||
FCalendar: TVpICalendar;
|
||||
FDatastore: TVpCustomDatastore;
|
||||
@ -32,8 +37,6 @@ type
|
||||
property Calendar: TVpICalendar read FCalendar write SetCalendar;
|
||||
property Datastore: TVpCustomDatastore read FDatastore write FDatastore;
|
||||
property DefaultCategory: String read FDefaultCategory write FDefaultCategory;
|
||||
// property Kind: TVpICalItemKind read FKind write SetKind;
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
@ -66,14 +69,19 @@ end;
|
||||
|
||||
function TVpImportPreviewICalEventForm.GetCellText(ACol, ARow: Integer): String;
|
||||
var
|
||||
item: TVpICalEntry;
|
||||
event: TVpICalEvent;
|
||||
begin
|
||||
Result := '';
|
||||
if (ACol = 1) and (ARow >= Grid.FixedRows) then
|
||||
if (ARow >= Grid.FixedRows) then
|
||||
begin
|
||||
item := TVpICalEntry(FItems[ARow - Grid.FixedRows]);
|
||||
if item <> nil then
|
||||
Result := GetEventText(TVpICalEvent(item));
|
||||
event := TVpICalEvent(FItems[ARow - Grid.FixedRows]);
|
||||
if event <> nil then
|
||||
case ACol of
|
||||
1: Result := GetEventText(event);
|
||||
2: Result := Grid.Columns[2].PickList[event.PickedCategory];
|
||||
//if FDatastore <> nil then
|
||||
// Result := FDatastore.FindBestEventCategory(TVpICalEvent(item).Categories);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -109,8 +117,10 @@ begin
|
||||
// Categories
|
||||
if Assigned(FDatastore) then
|
||||
begin
|
||||
cat := FDatastore.FindBestEventCategory(AEvent.Categories);
|
||||
if cat = '' then cat := FDefaultCategory;
|
||||
cat := AEvent.Categories.Text;
|
||||
if cat = '' then cat := '(none)';
|
||||
// cat := FDatastore.FindBestEventCategory(AEvent.Categories);
|
||||
// if cat = '' then cat := FDefaultCategory;
|
||||
Result := Result + cat;
|
||||
end;
|
||||
|
||||
@ -170,6 +180,44 @@ begin
|
||||
Result := Result + LineEnding + RSNoAlarm;
|
||||
end;
|
||||
|
||||
procedure TVpImportPreviewICalEventForm.GridGetEditText(Sender: TObject; ACol,
|
||||
ARow: Integer; var Value: string);
|
||||
var
|
||||
event: TVpICalEvent;
|
||||
begin
|
||||
DebugLn('GetEditText: "' + Value + '"');
|
||||
event := TVpICalEvent(FItems[Grid.Row - Grid.FixedRows]);
|
||||
if event <> nil then
|
||||
Value := Grid.Columns[2].PickList[event.PickedCategory];
|
||||
end;
|
||||
|
||||
procedure TVpImportPreviewICalEventForm.GridPickListSelect(Sender: TObject);
|
||||
var
|
||||
item: TVpICalEntry;
|
||||
cat: String;
|
||||
col: TGridcolumn;
|
||||
begin
|
||||
item := TVpICalEntry(FItems[Grid.Row - Grid.FixedRows]);
|
||||
if item <> nil then
|
||||
begin
|
||||
col := Grid.Columns[2];
|
||||
//TVpICalEvent(item).PickedCategory := Grid.Columns[2].PickList.IndexOf(ItemIndex);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TVpImportPreviewICalEventForm.GridSetEditText(Sender: TObject; ACol,
|
||||
ARow: Integer; const Value: string);
|
||||
var
|
||||
event: TVpICalEvent;
|
||||
begin
|
||||
event := TVpICalEvent(FItems[Grid.Row - Grid.FixedRows]);
|
||||
if event <> nil then
|
||||
event.PickedCategory := Grid.Columns[2].PickList.IndexOf(Value);;
|
||||
// DebugLn('SetEditText: "' + Value + '"');
|
||||
end;
|
||||
|
||||
|
||||
function TVpImportPreviewICalEventForm.IsChecked(ARow: Integer): Boolean;
|
||||
var
|
||||
item: TVpICalEntry;
|
||||
@ -185,6 +233,9 @@ end;
|
||||
procedure TVpImportPreviewICalEventForm.PrepareItems;
|
||||
var
|
||||
i: Integer;
|
||||
L: TStrings;
|
||||
event: TVpICalEvent;
|
||||
cat: String;
|
||||
begin
|
||||
FItems.Clear;
|
||||
if FCalendar <> nil then
|
||||
@ -192,6 +243,33 @@ begin
|
||||
if (FCalendar.Entry[i] is TVpICalEvent) then
|
||||
FItems.Add(FCalendar.Entry[i]);
|
||||
inherited;
|
||||
|
||||
if (FCalendar <> nil) and (FDataStore <> nil) and (Grid.Columns.Count = 2) then
|
||||
begin
|
||||
with Grid.Columns.Add do
|
||||
begin
|
||||
SizePriority := 0;
|
||||
Width := 160;
|
||||
Title.Caption := 'Category';
|
||||
ButtonStyle := cbsPickList;
|
||||
L := TStringList.Create;
|
||||
try
|
||||
for i := 0 to 9 do
|
||||
L.Add(FDatastore.CategoryColorMap.GetName(i));
|
||||
PickList.Assign(L);
|
||||
finally
|
||||
L.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
for i := 0 to FItems.Count-1 do
|
||||
begin
|
||||
event := TVpICalEvent(FItems[i]);
|
||||
cat := FDatastore.FindBestEventCategory(event.Categories);
|
||||
if cat = '' then cat := FDefaultCategory;
|
||||
event.PickedCategory := Grid.Columns[2].PickList.IndexOf(cat)
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpImportPreviewICalEventForm.SetCalendar(const AValue: TVpICalendar);
|
||||
|
Reference in New Issue
Block a user