mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 15:59:13 +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)
|
TQtListWidget = class(TQtListView)
|
||||||
private
|
private
|
||||||
|
FCheckable: boolean;
|
||||||
FCurrentItemChangeHook: QListWidget_hookH;
|
FCurrentItemChangeHook: QListWidget_hookH;
|
||||||
FSelectionChangeHook: QListWidget_hookH;
|
FSelectionChangeHook: QListWidget_hookH;
|
||||||
FItemClickedHook: QListWidget_hookH;
|
FItemClickedHook: QListWidget_hookH;
|
||||||
@ -940,6 +941,7 @@ type
|
|||||||
procedure scrollToItem(row: integer; hint: QAbstractItemViewScrollHint);
|
procedure scrollToItem(row: integer; hint: QAbstractItemViewScrollHint);
|
||||||
procedure removeItem(AIndex: Integer);
|
procedure removeItem(AIndex: Integer);
|
||||||
procedure exchangeItems(AIndex1, AIndex2: Integer);
|
procedure exchangeItems(AIndex1, AIndex2: Integer);
|
||||||
|
property Checkable: boolean read FCheckable write FCheckable;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TQtHeaderView }
|
{ TQtHeaderView }
|
||||||
@ -7061,6 +7063,7 @@ end;
|
|||||||
|
|
||||||
function TQtListWidget.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
function TQtListWidget.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||||
begin
|
begin
|
||||||
|
FCheckable := False;
|
||||||
FDontPassSelChange := False;
|
FDontPassSelChange := False;
|
||||||
Result := QListWidget_create();
|
Result := QListWidget_create();
|
||||||
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
|
QWidget_setAttribute(Result, QtWA_NoMousePropagation);
|
||||||
@ -7125,7 +7128,7 @@ begin
|
|||||||
QEventMouseButtonRelease,
|
QEventMouseButtonRelease,
|
||||||
QEventMouseButtonDblClick:
|
QEventMouseButtonDblClick:
|
||||||
begin
|
begin
|
||||||
if (LCLObject.ClassType = TCheckListBox) and
|
if (Checkable) and
|
||||||
(QEvent_type(Event) <> QEventMouseButtonDblClick) and
|
(QEvent_type(Event) <> QEventMouseButtonDblClick) and
|
||||||
(QMouseEvent_button(QMouseEventH(Event)) = QtLeftButton) then
|
(QMouseEvent_button(QMouseEventH(Event)) = QtLeftButton) then
|
||||||
begin
|
begin
|
||||||
@ -7212,7 +7215,7 @@ begin
|
|||||||
{$ifdef VerboseQt}
|
{$ifdef VerboseQt}
|
||||||
WriteLn('TQtListWidget.signalItemClicked');
|
WriteLn('TQtListWidget.signalItemClicked');
|
||||||
{$endif}
|
{$endif}
|
||||||
if LCLObject.ClassType = TCheckListBox then
|
if Checkable then
|
||||||
begin
|
begin
|
||||||
FillChar(Msg, SizeOf(Msg), #0);
|
FillChar(Msg, SizeOf(Msg), #0);
|
||||||
Msg.Msg := LM_CHANGED;
|
Msg.Msg := LM_CHANGED;
|
||||||
|
@ -45,6 +45,8 @@ type
|
|||||||
|
|
||||||
TQtWSCustomCheckListBox = class(TWSCustomCheckListBox)
|
TQtWSCustomCheckListBox = class(TWSCustomCheckListBox)
|
||||||
published
|
published
|
||||||
|
class function CreateHandle(const AWinControl: TWinControl;
|
||||||
|
const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class function GetItemEnabled(const ACheckListBox: TCustomCheckListBox;
|
class function GetItemEnabled(const ACheckListBox: TCustomCheckListBox;
|
||||||
const AIndex: integer): Boolean; override;
|
const AIndex: integer): Boolean; override;
|
||||||
class function GetState(const ACheckListBox: TCustomCheckListBox;
|
class function GetState(const ACheckListBox: TCustomCheckListBox;
|
||||||
@ -73,6 +75,37 @@ const
|
|||||||
{QtChecked } cbChecked
|
{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(
|
class function TQtWSCustomCheckListBox.GetItemEnabled(
|
||||||
const ACheckListBox: TCustomCheckListBox; const AIndex: integer): Boolean;
|
const ACheckListBox: TCustomCheckListBox; const AIndex: integer): Boolean;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user