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 }
OKToDrawEditFrame := True;
if Assigned(FDayView.ActiveEvent) then
OKToDrawEditFrame := not (FDayView.ActiveEvent.AllDayEvent);
OKToDrawEditFrame := not FDayView.ActiveEvent.AllDayEvent;
with TVpDayViewOpener(FDayView) do
if (dvInPlaceEditor <> nil) and dvInplaceEditor.Visible and OKToDrawEditFrame then

View File

@ -25,6 +25,7 @@ type
procedure StrToContact(AString: String; AContact: TVpContact);
procedure StrToEvent(AString: String; AEvent: TVpEvent);
procedure StrToEventTimes(AString: String; var AStartTime, AEndTime: TDateTime);
procedure StrToResource(AString: String; AResource: TVpResource);
procedure StrToTask(AString: String; ATask: TVpTask);
@ -451,6 +452,27 @@ begin
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);
var
L: TStrings;
@ -573,6 +595,7 @@ var
s: String;
key: String;
resID, id: Integer;
tStart, tEnd: TDateTime;
begin
if FFileName = '' then
exit;
@ -601,15 +624,15 @@ begin
s := ini.ReadString(key, L[j], '');
StrToContact(s, contact);
end;
end;
key := Format('Events of resource %d', [resID]);
L.Clear;
ini.ReadSection(key, L);
for j:=0 to L.Count-1 do begin
id := StrToInt(L[j]);
event := res.Schedule.AddEvent(id, 0, 1);
s := ini.ReadString(key, L[j], '');
StrToEventTimes(s, tStart, tEnd);
event := res.Schedule.AddEvent(id, tStart, tEnd);
StrToEvent(s, event);
end;
@ -622,6 +645,7 @@ begin
s := ini.ReadString(key, L[j], '');
StrToTask(s, task);
end;
end;
finally
ini.Free;