RxDBGrid - another fix from commit 3485

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3487 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2014-08-15 10:03:26 +00:00
parent b40bdc4ddd
commit 5a6d0dd650

View File

@ -1,6 +1,6 @@
{ rxmemds unit { rxmemds unit
Copyright (C) 2005-2010 Lagunov Aleksey alexs@yandex.ru and Lazarus team Copyright (C) 2005-2014 Lagunov Aleksey alexs@hotbox.ru and Lazarus team
original conception from rx library for Delphi (c) original conception from rx library for Delphi (c)
This library is free software; you can redistribute it and/or modify it This library is free software; you can redistribute it and/or modify it
@ -91,8 +91,8 @@ type
procedure SetOnFilterRecordEx(const AValue: TFilterRecordEvent); procedure SetOnFilterRecordEx(const AValue: TFilterRecordEvent);
procedure Sort; procedure Sort;
function CalcRecordSize: Integer; function CalcRecordSize: Integer;
// function FindFieldData(Buffer: Pointer; Field: TField): Pointer;overload; function FindFieldData(Buffer: Pointer; Field: TField): Pointer;overload;
function FindFieldData(Buffer: Pointer; FieldNo:Integer): Pointer; //overload; function FindFieldData(Buffer: Pointer; FieldNo:Integer): Pointer;overload;
function GetMemoryRecord(Index: Integer): TMemoryRecord; function GetMemoryRecord(Index: Integer): TMemoryRecord;
function GetCapacity: Integer; function GetCapacity: Integer;
function RecordFilter: Boolean; function RecordFilter: Boolean;
@ -612,17 +612,21 @@ begin
end; end;
end; end;
{
function TRxMemoryData.FindFieldData(Buffer: Pointer; Field: TField): Pointer; function TRxMemoryData.FindFieldData(Buffer: Pointer; Field: TField): Pointer;
var var
Index: Integer; Index: Integer;
begin begin
{.$IFDEF TEST_RXMDS}
Index := FieldDefs.IndexOf(Field.FieldName); Index := FieldDefs.IndexOf(Field.FieldName);
//
if Index <> Field.FieldNo - 1 then if Index <> Field.FieldNo - 1 then
raise exception.Create('Index <> Field.FieldNo - 1'); raise exception.Create('Index <> Field.FieldNo - 1');
{.$ENDIF}
// Index := Field.FieldNo - 1;
//
Result:=FindFieldData(Buffer, Index); Result:=FindFieldData(Buffer, Index);
end; end;
}
function TRxMemoryData.FindFieldData(Buffer: Pointer; FieldNo: Integer): Pointer; function TRxMemoryData.FindFieldData(Buffer: Pointer; FieldNo: Integer): Pointer;
begin begin
Result := nil; Result := nil;
@ -876,8 +880,7 @@ begin
if Field.FieldNo > 0 then if Field.FieldNo > 0 then
{$ENDIF} {$ENDIF}
begin begin
Data := FindFieldData(RecBuf, Field.FieldNo-1); Data := FindFieldData(RecBuf, Field);
// Data := FindFieldData(RecBuf, Field);
if Data <> nil then begin if Data <> nil then begin
Result := Boolean(Data[0]); Result := Boolean(Data[0]);
Inc(Data); Inc(Data);
@ -892,7 +895,6 @@ begin
else else
Move(Data^, Buffer^, CalcFieldLen(Field.DataType, Field.Size)); Move(Data^, Buffer^, CalcFieldLen(Field.DataType, Field.Size));
end; end;
Result := true;
end end
else else
begin begin
@ -928,8 +930,7 @@ begin
Validate(Buffer); Validate(Buffer);
if FieldKind <> fkInternalCalc then if FieldKind <> fkInternalCalc then
begin begin
// Data := FindFieldData(RecBuf, Field); Data := FindFieldData(RecBuf, Field);
Data := FindFieldData(RecBuf, Field.FieldNo-1);
if Data <> nil then if Data <> nil then
begin begin
if DataType = ftVariant then if DataType = ftVariant then
@ -1194,8 +1195,7 @@ begin
if (Fields[I].FieldKind in fkStoredFields) and if (Fields[I].FieldKind in fkStoredFields) and
(Fields[I].DataType = ftAutoInc) then (Fields[I].DataType = ftAutoInc) then
begin begin
// Data := FindFieldData(Buffer, Fields[I]); Data := FindFieldData(Buffer, Fields[I]);
Data := FindFieldData(Buffer, Fields[I].FieldNo-1);
if Data <> nil then begin if Data <> nil then begin
Boolean(Data[0]) := True; Boolean(Data[0]) := True;
Inc(Data); Inc(Data);
@ -1339,8 +1339,7 @@ var
Item:TMemoryRecord; Item:TMemoryRecord;
begin begin
Item:=Records[SrcRecNo]; Item:=Records[SrcRecNo];
// Data1 := FindFieldData(Item.Data, AField); Data1 := FindFieldData(Item.Data, AField);
Data1 := FindFieldData(Item.Data, AField.FieldNo-1);
Inc(Data1); //Skip null flag Inc(Data1); //Skip null flag
case AField.DataType of case AField.DataType of
@ -1669,7 +1668,7 @@ end;
procedure TRxMemoryData.SortOnFieldsEx(const FieldNames: string; procedure TRxMemoryData.SortOnFieldsEx(const FieldNames: string;
CaseInsensitive: Boolean; Asc: array of boolean); CaseInsensitive: Boolean; Asc: array of boolean);
begin begin
{ TODO -oalexs : Необходимо написать сортировку по массиву }
end; end;
procedure TRxMemoryData.Sort; procedure TRxMemoryData.Sort;
@ -1739,21 +1738,14 @@ var
I: Integer; I: Integer;
begin begin
Result := 0; Result := 0;
if FIndexList <> nil then if FIndexList <> nil then begin
begin for I := 0 to FIndexList.Count - 1 do begin
for I := 0 to FIndexList.Count - 1 do
begin
F := TField(FIndexList[I]); F := TField(FIndexList[I]);
// Data1 := FindFieldData(Item1.Data, F); Data1 := FindFieldData(Item1.Data, F);
Data1 := FindFieldData(Item1.Data, F.FieldNo-1); if Data1 <> nil then begin
if Data1 <> nil then Data2 := FindFieldData(Item2.Data, F);
begin if Data2 <> nil then begin
// Data2 := FindFieldData(Item2.Data, F); if Boolean(Data1[0]) and Boolean(Data2[0]) then begin
Data2 := FindFieldData(Item2.Data, F.FieldNo-1);
if Data2 <> nil then
begin
if Boolean(Data1[0]) and Boolean(Data2[0]) then
begin
Inc(Data1); Inc(Data1);
Inc(Data2); Inc(Data2);
Result := CompareFields(Data1, Data2, F.DataType, Result := CompareFields(Data1, Data2, F.DataType,