31 |
|
|
32 |
|
uses |
33 |
|
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, DbCtrls, |
34 |
< |
ExtCtrls, IBSQLParser, DB, StdCtrls, IBCustomDataSet; |
34 |
> |
ExtCtrls, IBSQLParser, DB, StdCtrls, IBCustomDataSet, LCLVersion; |
35 |
|
|
36 |
|
type |
37 |
|
|
95 |
|
FForceAutoComplete: boolean; |
96 |
|
FInCheckAndInsert: boolean; |
97 |
|
FLastKeyValue: variant; |
98 |
+ |
FCurText: string; |
99 |
|
procedure DoActiveChanged(Data: PtrInt); |
100 |
|
function GetAutoCompleteText: TComboBoxAutoCompleteText; |
101 |
|
function GetListSource: TDataSource; |
146 |
|
|
147 |
|
implementation |
148 |
|
|
149 |
< |
uses IBQuery, LCLType, Variants, LCLProc; |
149 |
> |
uses IBQuery, LCLType, Variants, LCLProc, LazUTF8; |
150 |
|
|
151 |
|
{ TIBLookupControlLink } |
152 |
|
|
316 |
|
var |
317 |
|
iSelStart: Integer; // char position |
318 |
|
sCompleteText, sPrefixText, sResultText: string; |
318 |
– |
curText: string; |
319 |
|
begin |
320 |
|
if assigned(ListSource) and assigned(ListSource.DataSet) and (ListSource.DataSet is TIBCustomDataSet) |
321 |
|
and ListSource.DataSet.Active then |
322 |
|
begin |
323 |
+ |
FCurText := Text; |
324 |
|
FUpdating := true; |
325 |
|
try |
326 |
|
iSelStart := SelStart;//Capture original cursor position |
327 |
|
if ((iSelStart < UTF8Length(Text)) and |
328 |
|
(cbactEndOfLineComplete in AutoCompleteText)) then |
329 |
|
Exit; |
329 |
– |
curText := Text; |
330 |
|
sPrefixText := UTF8Copy(Text, 1, iSelStart); |
331 |
|
ListSource.DataSet.Active := false; |
332 |
|
ListSource.DataSet.Active := true; |
333 |
< |
Text := curText; |
334 |
< |
if not FExiting and (FForceAutoComplete or Focused) and (Text <> '')then |
333 |
> |
Text := FCurText; |
334 |
> |
if not FExiting and (FForceAutoComplete or Focused) and (FCurText <> '')then |
335 |
|
begin |
336 |
|
if ListSource.DataSet.Active and (ListSource.DataSet.RecordCount > 0) then |
337 |
|
begin |
338 |
|
sCompleteText := ListSource.DataSet.FieldByName(ListField).AsString; |
339 |
< |
if (sCompleteText <> Text) then |
339 |
> |
if (sCompleteText <> FCurText) then |
340 |
|
begin |
341 |
|
sResultText := sCompleteText; |
342 |
|
if ((cbactEndOfLineComplete in AutoCompleteText) and |
361 |
|
procedure TIBLookupComboEditBox.UpdateSQL(Sender: TObject; |
362 |
|
Parser: TSelectSQLParser); |
363 |
|
var FieldPosition: integer; |
364 |
+ |
FilterText: string; |
365 |
|
begin |
366 |
|
if FFiltered then |
367 |
|
begin |
368 |
+ |
if FUpdating then |
369 |
+ |
FilterText := FCurText |
370 |
+ |
else |
371 |
+ |
FilterText := Text; |
372 |
|
if cbactSearchCaseSensitive in AutoCompleteText then |
373 |
|
Parser.Add2WhereClause(GetRelationNameQualifier + '"' + ListField + '" Like ''' + |
374 |
< |
SQLSafe(Text) + '%''') |
374 |
> |
SQLSafe(FilterText) + '%''') |
375 |
|
else |
376 |
< |
Parser.Add2WhereClause(GetRelationNameQualifier + 'Upper("' + ListField + '") Like Upper(''' + |
377 |
< |
SQLSafe(Text) + '%'')'); |
376 |
> |
Parser.Add2WhereClause('Upper(' + GetRelationNameQualifier + '"' + ListField + '") Like Upper(''' + |
377 |
> |
SQLSafe(FilterText) + '%'')'); |
378 |
|
|
379 |
< |
end; |
380 |
< |
if cbactSearchAscending in AutoCompleteText then |
381 |
< |
begin |
382 |
< |
FieldPosition := Parser.GetFieldPosition(ListField); |
378 |
< |
if FieldPosition = 0 then Exit; |
379 |
> |
if cbactSearchAscending in AutoCompleteText then |
380 |
> |
begin |
381 |
> |
FieldPosition := Parser.GetFieldPosition(ListField); |
382 |
> |
if FieldPosition = 0 then Exit; |
383 |
|
|
384 |
< |
Parser.OrderByClause := IntToStr(FieldPosition) + ' ascending'; |
384 |
> |
Parser.OrderByClause := IntToStr(FieldPosition) + ' ascending'; |
385 |
> |
end; |
386 |
|
end; |
387 |
|
end; |
388 |
|
|