Merged revision(s) 54654 #4dddd8003a, 54694 #17a13c6d81, 54696 #d76aa4f29a from trunk:

qt,qt5: fixed av because parent can be nil. issue #31684
........
Qt, Qt5: fixed selection with TListView. issue #31595
........
Qt, Qt5: fixed triggering of selection change in TCheckListBox. issue #31697
........

git-svn-id: branches/fixes_1_8@54703 -
This commit is contained in:
maxim 2017-04-23 22:42:58 +00:00
parent cc2a699a9e
commit 4ecd8150e8
4 changed files with 60 additions and 10 deletions

View File

@ -13040,7 +13040,7 @@ begin
SlotMouse(Sender, Event);
HandleCheckChangedEvent(MousePos, Item, Event);
if not QListWidgetItem_isSelected(Item) then
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelSelect);
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelClearAndSelect);
QEvent_ignore(Event);
Result := True;
exit;
@ -13848,6 +13848,23 @@ function TQtCheckListBox.EventFilter(Sender: QObjectH; Event: QEventH
): Boolean; cdecl;
begin
Result := False;
if (QEvent_type(Event) = QEventKeyPress) and
(QtVersionMajor = 4) and (QtVersionMinor >= 8) and
((QKeyEvent_key(QKeyEventH(Event)) = QtKey_Up) or
(QKeyEvent_key(QKeyEventH(Event)) = QtKey_Down)) then
begin
{issue #31697}
Result:=inherited EventFilter(Sender, Event);
if ItemCount > 0 then
begin
if (getSelCount = 0) then
begin
Selected[0] := True;
Result := True;
end;
inherited signalSelectionChanged();
end;
end else
if (QEvent_type(Event) = QEventMouseButtonDblClick) then
// issue #25089
else
@ -13905,7 +13922,10 @@ begin
if Assigned(Item) and (currentItem <> Item) then
begin
// DebugLn('TQtCheckListBox forced item change');
Self.setCurrentItem(Item, True);
// Self.setCurrentItem(Item, True);
{issue #31697}
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelSelectCurrent);
inherited signalSelectionChanged();
end;
end;
end;
@ -13959,6 +13979,11 @@ begin
Msg.Msg := LM_CHANGED;
Msg.WParam := PtrInt(QListWidget_row(QListWidgetH(Widget), Item));
DeliverMessage(Msg);
if (QtVersionMajor = 4) and (QtVersionMinor >= 8) then
begin
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelSelectCurrent);
inherited signalSelectionChanged();
end;
end;
function TQtCheckListBox.GetItemCheckState(AIndex: Integer): QtCheckState;

View File

@ -632,7 +632,7 @@ begin
if AWinControl.HandleObjectShouldBeVisible and
(LowerCase(AWinControl.Font.Name) = 'default') then
begin
if AWinControl.IsParentFont then
if AWinControl.IsParentFont and Assigned(AWinControl.Parent) then
SetFont(AWinControl, AWinControl.Parent.Font) {DO NOT TOUCH THIS PLEASE !}
else
SetFont(AWinControl, AWinControl.Font); {DO NOT TOUCH THIS PLEASE !}

View File

@ -13015,7 +13015,7 @@ begin
SlotMouse(Sender, Event);
HandleCheckChangedEvent(MousePos, Item, Event);
if not QListWidgetItem_isSelected(Item) then
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelSelect);
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelClearAndSelect);
QEvent_ignore(Event);
Result := True;
exit;
@ -13824,6 +13824,22 @@ function TQtCheckListBox.EventFilter(Sender: QObjectH; Event: QEventH
): Boolean; cdecl;
begin
Result := False;
if (QEvent_type(Event) = QEventKeyPress) and
((QKeyEvent_key(QKeyEventH(Event)) = QtKey_Up) or
(QKeyEvent_key(QKeyEventH(Event)) = QtKey_Down)) then
begin
{issue #31697}
Result:=inherited EventFilter(Sender, Event);
if ItemCount > 0 then
begin
if (getSelCount = 0) then
begin
Selected[0] := True;
Result := True;
end;
inherited signalSelectionChanged();
end;
end else
if (QEvent_type(Event) = QEventMouseButtonDblClick) then
// issue #25089
else
@ -13882,7 +13898,9 @@ begin
if Assigned(Item) and (currentItem <> Item) then
begin
// DebugLn('TQtCheckListBox forced item change');
Self.setCurrentItem(Item, True);
{issue #31697}
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelSelectCurrent);
inherited signalSelectionChanged();
end;
end;
end;
@ -13936,6 +13954,8 @@ begin
Msg.Msg := LM_CHANGED;
Msg.WParam := PtrInt(QListWidget_row(QListWidgetH(Widget), Item));
DeliverMessage(Msg);
QListWidget_setCurrentItem(QListWidgetH(Widget), Item, QItemSelectionModelSelectCurrent);
inherited signalSelectionChanged();
end;
function TQtCheckListBox.GetItemCheckState(AIndex: Integer): QtCheckState;

View File

@ -625,12 +625,17 @@ begin
Exit;
Widget := TQtWidget(AWinControl.Handle);
Widget.BeginUpdate;
// issue #28437
if AWinControl.HandleObjectShouldBeVisible and not AWinControl.IsParentFont and
(AWinControl.Font.Name = 'default') then
SetFont(AWinControl, AWinControl.Font);
// issue #28437, #30966 - regression from r53365: when FontChanged() is called
// here handle is recreated inside LCL, so we are dead - SEGFAULT.
if AWinControl.HandleObjectShouldBeVisible and
(LowerCase(AWinControl.Font.Name) = 'default') then
begin
if AWinControl.IsParentFont and Assigned(AWinControl.Parent) then
SetFont(AWinControl, AWinControl.Parent.Font) {DO NOT TOUCH THIS PLEASE !}
else
SetFont(AWinControl, AWinControl.Font); {DO NOT TOUCH THIS PLEASE !}
end;
Widget.setVisible(AWinControl.HandleObjectShouldBeVisible);
Widget.EndUpdate;