Qt: fixed combobox itemindex when list contain duplicates. issue #20863

git-svn-id: trunk@34079 -
This commit is contained in:
zeljko 2011-12-10 08:22:53 +00:00
parent 2389b0aed4
commit 43874efc17
2 changed files with 23 additions and 8 deletions

View File

@ -911,6 +911,7 @@ type
procedure ClearItems; procedure ClearItems;
procedure setBorder(const ABorder: Boolean); procedure setBorder(const ABorder: Boolean);
function currentIndex: Integer; function currentIndex: Integer;
function findText(AText: WideString): Integer;
function getDroppedDown: Boolean; function getDroppedDown: Boolean;
function getEditable: Boolean; function getEditable: Boolean;
function getMaxVisibleItems: Integer; function getMaxVisibleItems: Integer;
@ -8503,6 +8504,11 @@ begin
Result := QComboBox_currentIndex(QComboBoxH(Widget)); Result := QComboBox_currentIndex(QComboBoxH(Widget));
end; end;
function TQtComboBox.findText(AText: WideString): Integer;
begin
Result := QComboBox_findText(QComboBoxH(Widget), @AText);
end;
function TQtComboBox.getDroppedDown: Boolean; function TQtComboBox.getDroppedDown: Boolean;
begin begin
Result := QWidget_isVisible(QComboBox_view(QComboBoxH(Widget))); Result := QWidget_isVisible(QComboBox_view(QComboBoxH(Widget)));

View File

@ -1352,8 +1352,8 @@ var
QtComboBox: TQtComboBox; QtComboBox: TQtComboBox;
begin begin
Result := False; Result := False;
if not ACustomComboBox.HandleAllocated then if not WSCheckHandleAllocated(ACustomComboBox, 'GetDroppedDown') then
exit; Exit;
QtComboBox := TQtComboBox(ACustomComboBox.Handle); QtComboBox := TQtComboBox(ACustomComboBox.Handle);
Result := QtComboBox.getDroppedDown; Result := QtComboBox.getDroppedDown;
end; end;
@ -1367,8 +1367,6 @@ class function TQtWSCustomComboBox.GetItemIndex(
const ACustomComboBox: TCustomComboBox): integer; const ACustomComboBox: TCustomComboBox): integer;
var var
QtComboBox: TQtComboBox; QtComboBox: TQtComboBox;
WStr: WideString;
i: Integer;
begin begin
Result := -1; Result := -1;
if not WSCheckHandleAllocated(ACustomComboBox, 'GetItemIndex') then if not WSCheckHandleAllocated(ACustomComboBox, 'GetItemIndex') then
@ -1376,11 +1374,12 @@ begin
QtComboBox := TQtComboBox(ACustomComboBox.Handle); QtComboBox := TQtComboBox(ACustomComboBox.Handle);
if QtComboBox.getEditable then if QtComboBox.getEditable then
begin begin
WStr := QtComboBox.getText; Result := QtComboBox.findText(QtComboBox.getText);
i := QComboBox_findText(QComboBoxH(QtComboBox.Widget), @WStr); if Result = -1 then
Result := i; exit;
Result := QtComboBox.currentIndex;
end else end else
Result := TQtComboBox(ACustomComboBox.Handle).currentIndex; Result := QtComboBox.currentIndex;
end; end;
class function TQtWSCustomComboBox.GetMaxLength( class function TQtWSCustomComboBox.GetMaxLength(
@ -1388,6 +1387,8 @@ class function TQtWSCustomComboBox.GetMaxLength(
var var
LineEdit: TQtLineEdit; LineEdit: TQtLineEdit;
begin begin
if not WSCheckHandleAllocated(ACustomComboBox, 'GetMaxLength') then
Exit;
LineEdit := TQtComboBox(ACustomComboBox.Handle).LineEdit; LineEdit := TQtComboBox(ACustomComboBox.Handle).LineEdit;
if LineEdit <> nil then if LineEdit <> nil then
begin begin
@ -1484,6 +1485,8 @@ end;
class procedure TQtWSCustomComboBox.SetDropDownCount( class procedure TQtWSCustomComboBox.SetDropDownCount(
const ACustomComboBox: TCustomComboBox; NewCount: Integer); const ACustomComboBox: TCustomComboBox; NewCount: Integer);
begin begin
if not WSCheckHandleAllocated(ACustomComboBox, 'SetDropDownCount') then
Exit;
TQtComboBox(ACustomComboBox.Handle).setMaxVisibleItems(NewCount); TQtComboBox(ACustomComboBox.Handle).setMaxVisibleItems(NewCount);
end; end;
@ -1492,6 +1495,8 @@ class procedure TQtWSCustomComboBox.SetDroppedDown(
var var
QtComboBox: TQtComboBox; QtComboBox: TQtComboBox;
begin begin
if not WSCheckHandleAllocated(ACustomComboBox, 'SetDroppedDown') then
Exit;
QtComboBox := TQtComboBox(ACustomComboBox.Handle); QtComboBox := TQtComboBox(ACustomComboBox.Handle);
QtComboBox.setDroppedDown(ADroppedDown); QtComboBox.setDroppedDown(ADroppedDown);
end; end;
@ -1503,6 +1508,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
class procedure TQtWSCustomComboBox.SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer); class procedure TQtWSCustomComboBox.SetItemIndex(const ACustomComboBox: TCustomComboBox; NewIndex: integer);
begin begin
if not WSCheckHandleAllocated(ACustomComboBox, 'SetItemIndex') then
Exit;
TQtComboBox(ACustomComboBox.Handle).setCurrentIndex(NewIndex); TQtComboBox(ACustomComboBox.Handle).setCurrentIndex(NewIndex);
end; end;
@ -1548,6 +1555,8 @@ class function TQtWSCustomComboBox.GetItems(const ACustomComboBox: TCustomComboB
var var
ComboBox: TQtComboBox; ComboBox: TQtComboBox;
begin begin
if not WSCheckHandleAllocated(ACustomComboBox, 'GetItems') then
Exit;
ComboBox := TQtComboBox(ACustomComboBox.Handle); ComboBox := TQtComboBox(ACustomComboBox.Handle);
if not Assigned(ComboBox.FList) then if not Assigned(ComboBox.FList) then
begin begin