ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/ibcontrols/IBLookupComboEditBox.pas
(Generate patch)

Comparing ibx/trunk/ibcontrols/IBLookupComboEditBox.pas (file contents):
Revision 35 by tony, Tue Jan 26 14:38:47 2016 UTC vs.
Revision 65 by tony, Wed Jul 12 09:13:04 2017 UTC

# Line 31 | Line 31 | interface
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  
# Line 95 | Line 95 | type
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;
# Line 145 | Line 146 | type
146  
147   implementation
148  
149 < uses IBQuery, LCLType, Variants, LCLProc;
149 > uses IBQuery, LCLType, Variants, LCLProc, LazUTF8;
150  
151   { TIBLookupControlLink }
152  
# Line 315 | Line 316 | procedure TIBLookupComboEditBox.UpdateLi
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
# Line 350 | Line 350 | begin
350                 SelLength := UTF8Length(Text);
351               end;
352               KeyValue := ListSource.DataSet.FieldByName(KeyField).AsVariant;
353 +           end
354 +           else
355 +           begin
356 +             SelStart := iSelStart;
357 +             SelLength := 0;
358             end;
359           end;
360      finally
# Line 361 | Line 366 | end;
366   procedure TIBLookupComboEditBox.UpdateSQL(Sender: TObject;
367    Parser: TSelectSQLParser);
368   var FieldPosition: integer;
369 +    FilterText: string;
370   begin
371    if FFiltered then
372    begin
373 +    if FUpdating then
374 +      FilterText := FCurText
375 +    else
376 +      FilterText := Text;
377      if cbactSearchCaseSensitive in AutoCompleteText then
378        Parser.Add2WhereClause(GetRelationNameQualifier + '"' + ListField + '" Like ''' +
379 <                                  SQLSafe(Text) + '%''')
379 >                                  SQLSafe(FilterText) + '%''')
380      else
381 <      Parser.Add2WhereClause(GetRelationNameQualifier + 'Upper("' + ListField + '") Like Upper(''' +
382 <                                  SQLSafe(Text) + '%'')');
381 >      Parser.Add2WhereClause('Upper(' + GetRelationNameQualifier + '"' +  ListField + '") Like Upper(''' +
382 >                                  SQLSafe(FilterText) + '%'')');
383  
384 <  end;
385 <  if cbactSearchAscending in AutoCompleteText then
386 <  begin
387 <    FieldPosition := Parser.GetFieldPosition(ListField);
378 <    if FieldPosition = 0 then Exit;
384 >    if cbactSearchAscending in AutoCompleteText then
385 >    begin
386 >      FieldPosition := Parser.GetFieldPosition(ListField);
387 >      if FieldPosition = 0 then Exit;
388  
389 <    Parser.OrderByClause := IntToStr(FieldPosition) + ' ascending';
389 >      Parser.OrderByClause := IntToStr(FieldPosition) + ' ascending';
390 >    end;
391    end;
392   end;
393  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines