tvplanit: Fix incorrect sorting of events in case of ini datastore.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4856 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-28 19:28:31 +00:00
parent a804344102
commit e575855f93
2 changed files with 43 additions and 19 deletions

View File

@@ -926,7 +926,7 @@ begin
{ paint extra borders around the editor } { paint extra borders around the editor }
OKToDrawEditFrame := True; OKToDrawEditFrame := True;
if Assigned(FDayView.ActiveEvent) then if Assigned(FDayView.ActiveEvent) then
OKToDrawEditFrame := not (FDayView.ActiveEvent.AllDayEvent); OKToDrawEditFrame := not FDayView.ActiveEvent.AllDayEvent;
with TVpDayViewOpener(FDayView) do with TVpDayViewOpener(FDayView) do
if (dvInPlaceEditor <> nil) and dvInplaceEditor.Visible and OKToDrawEditFrame then if (dvInPlaceEditor <> nil) and dvInplaceEditor.Visible and OKToDrawEditFrame then

View File

@@ -25,6 +25,7 @@ type
procedure StrToContact(AString: String; AContact: TVpContact); procedure StrToContact(AString: String; AContact: TVpContact);
procedure StrToEvent(AString: String; AEvent: TVpEvent); procedure StrToEvent(AString: String; AEvent: TVpEvent);
procedure StrToEventTimes(AString: String; var AStartTime, AEndTime: TDateTime);
procedure StrToResource(AString: String; AResource: TVpResource); procedure StrToResource(AString: String; AResource: TVpResource);
procedure StrToTask(AString: String; ATask: TVpTask); procedure StrToTask(AString: String; ATask: TVpTask);
@@ -451,6 +452,27 @@ begin
end; end;
end; end;
procedure TVpIniDatastore.StrToEventTimes(AString: String;
var AStartTime, AEndTime: TDateTime);
var
L: TStrings;
begin
L := TStringList.Create;
try
Split(AString, L);
if L.Count < 2 then
IniError(RSIniFileStructure);
if L[0] = '' then
AStartTime := 0 else
AStartTime := StrToDateTime(L[0], FFormatSettings);
if L[1] = '' then
AEndTime := 0 else
AEndtime := StrToDateTime(L[1], FFormatSettings);
finally
L.Free;
end;
end;
procedure TVpIniDatastore.StrToEvent(AString: String; AEvent: TVpEvent); procedure TVpIniDatastore.StrToEvent(AString: String; AEvent: TVpEvent);
var var
L: TStrings; L: TStrings;
@@ -573,6 +595,7 @@ var
s: String; s: String;
key: String; key: String;
resID, id: Integer; resID, id: Integer;
tStart, tEnd: TDateTime;
begin begin
if FFileName = '' then if FFileName = '' then
exit; exit;
@@ -601,26 +624,27 @@ begin
s := ini.ReadString(key, L[j], ''); s := ini.ReadString(key, L[j], '');
StrToContact(s, contact); StrToContact(s, contact);
end; end;
end;
key := Format('Events of resource %d', [resID]); key := Format('Events of resource %d', [resID]);
L.Clear; L.Clear;
ini.ReadSection(key, L); ini.ReadSection(key, L);
for j:=0 to L.Count-1 do begin for j:=0 to L.Count-1 do begin
id := StrToInt(L[j]); id := StrToInt(L[j]);
event := res.Schedule.AddEvent(id, 0, 1); s := ini.ReadString(key, L[j], '');
s := ini.ReadString(key, L[j], ''); StrToEventTimes(s, tStart, tEnd);
StrToEvent(s, event); event := res.Schedule.AddEvent(id, tStart, tEnd);
end; StrToEvent(s, event);
end;
key := Format('Tasks of resource %d', [resID]); key := Format('Tasks of resource %d', [resID]);
L.Clear; L.Clear;
ini.ReadSection(key, L); ini.ReadSection(key, L);
for j:=0 to L.Count-1 do begin for j:=0 to L.Count-1 do begin
id := StrToInt(L[j]); id := StrToInt(L[j]);
task := res.Tasks.AddTask(id); task := res.Tasks.AddTask(id);
s := ini.ReadString(key, L[j], ''); s := ini.ReadString(key, L[j], '');
StrToTask(s, task); StrToTask(s, task);
end;
end; end;
finally finally