mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 03:35:57 +02:00
Qt: optimisation: save few kbs by adding checkable property to TQtListWidget instead of checking for TCheckListBox class
git-svn-id: trunk@23663 -
This commit is contained in:
parent
f091ac2f5d
commit
fd8aec52d9
@ -911,6 +911,7 @@ type
|
||||
|
||||
TQtListWidget = class(TQtListView)
|
||||
private
|
||||
FCheckable: boolean;
|
||||
FCurrentItemChangeHook: QListWidget_hookH;
|
||||
FSelectionChangeHook: QListWidget_hookH;
|
||||
FItemClickedHook: QListWidget_hookH;
|
||||
@ -940,6 +941,7 @@ type
|
||||
procedure scrollToItem(row: integer; hint: QAbstractItemViewScrollHint);
|
||||
procedure removeItem(AIndex: Integer);
|
||||
procedure exchangeItems(AIndex1, AIndex2: Integer);
|
||||
property Checkable: boolean read FCheckable write FCheckable;
|
||||
end;
|
||||
|
||||
{ TQtHeaderView }
|
||||
@ -7061,6 +7063,7 @@ end;
|
||||
|
||||
function TQtListWidget.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||
begin
|
||||
FCheckable := False;
|
||||
FDontPassSelChange := False;
|
||||
Result := QListWidget_create();
|
||||
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
|
||||
@ -7125,7 +7128,7 @@ begin
|
||||
QEventMouseButtonRelease,
|
||||
QEventMouseButtonDblClick:
|
||||
begin
|
||||
if (LCLObject.ClassType = TCheckListBox) and
|
||||
if (Checkable) and
|
||||
(QEvent_type(Event) <> QEventMouseButtonDblClick) and
|
||||
(QMouseEvent_button(QMouseEventH(Event)) = QtLeftButton) then
|
||||
begin
|
||||
@ -7212,7 +7215,7 @@ begin
|
||||
{$ifdef VerboseQt}
|
||||
WriteLn('TQtListWidget.signalItemClicked');
|
||||
{$endif}
|
||||
if LCLObject.ClassType = TCheckListBox then
|
||||
if Checkable then
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
Msg.Msg := LM_CHANGED;
|
||||
|
@ -45,6 +45,8 @@ type
|
||||
|
||||
TQtWSCustomCheckListBox = class(TWSCustomCheckListBox)
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl;
|
||||
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class function GetItemEnabled(const ACheckListBox: TCustomCheckListBox;
|
||||
const AIndex: integer): Boolean; override;
|
||||
class function GetState(const ACheckListBox: TCustomCheckListBox;
|
||||
@ -73,6 +75,37 @@ const
|
||||
{QtChecked } cbChecked
|
||||
);
|
||||
|
||||
class function TQtWSCustomCheckListBox.CreateHandle(
|
||||
const AWinControl: TWinControl; const AParams: TCreateParams
|
||||
): TLCLIntfHandle;
|
||||
var
|
||||
QtListWidget: TQtListWidget;
|
||||
SelMode: QAbstractItemViewSelectionMode;
|
||||
begin
|
||||
QtListWidget := TQtListWidget.Create(AWinControl, AParams);
|
||||
|
||||
QtListWidget.Checkable := True;
|
||||
|
||||
if TCheckListBox(AWinControl).MultiSelect then
|
||||
if TCheckListBox(AWinControl).ExtendedSelect then
|
||||
SelMode := QAbstractItemViewExtendedSelection
|
||||
else
|
||||
SelMode := QAbstractItemViewMultiSelection
|
||||
else
|
||||
SelMode := QAbstractItemViewSingleSelection;
|
||||
|
||||
QtListWidget.setSelectionMode(SelMode);
|
||||
|
||||
QtListWidget.AttachEvents;
|
||||
|
||||
// create our FList helper
|
||||
QtListWidget.FList := TQtListStrings.Create(QtListWidget);
|
||||
|
||||
QtListWidget.OwnerDrawn := TCheckListBox(AWinControl).Style in [lbOwnerDrawFixed, lbOwnerDrawVariable];
|
||||
|
||||
Result := TLCLIntfHandle(QtListWidget);
|
||||
end;
|
||||
|
||||
class function TQtWSCustomCheckListBox.GetItemEnabled(
|
||||
const ACheckListBox: TCustomCheckListBox; const AIndex: integer): Boolean;
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user