mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 18:58:04 +02:00
IDE: Add a FilterEdit for NewDialog's inherited components. Try to improve the FilterEdit comp. Issue #31419.
git-svn-id: trunk@54321 -
This commit is contained in:
parent
522a0f5505
commit
49d21d2dbc
@ -25,10 +25,13 @@ type
|
||||
//TImageIndexEvent = function (Str: String; Data: TObject;
|
||||
// var IsEnabled: Boolean): Integer of object;
|
||||
TStringArray = array of string;
|
||||
|
||||
{ TListViewDataItem }
|
||||
|
||||
TListViewDataItem = record
|
||||
Data: Pointer;
|
||||
StringArray: TStringArray;
|
||||
|
||||
//constructor Initialize(ColumnCount: integer); Does not work. Why?
|
||||
class operator =(a,b : TListViewDataItem) : Boolean;
|
||||
end;
|
||||
TListViewDataList = specialize TFPGList<TListViewDataItem>;
|
||||
@ -82,7 +85,13 @@ var
|
||||
implementation
|
||||
|
||||
{ TListViewDataItem }
|
||||
|
||||
{
|
||||
constructor TListViewDataItem.Initialize(ColumnCount: integer);
|
||||
begin
|
||||
Data := Nil;
|
||||
SetLength(StringArray, ColumnCount);
|
||||
end;
|
||||
}
|
||||
class operator TListViewDataItem. = (a, b: TListViewDataItem): Boolean;
|
||||
begin
|
||||
Result := (a.Data=b.Data) and (a.StringArray=b.StringArray);
|
||||
|
@ -1,33 +1,32 @@
|
||||
object NewOtherDialog: TNewOtherDialog
|
||||
Left = 281
|
||||
Height = 421
|
||||
Top = 204
|
||||
Width = 561
|
||||
Height = 434
|
||||
Top = 191
|
||||
Width = 774
|
||||
BorderIcons = [biSystemMenu]
|
||||
Caption = 'NewOtherDialog'
|
||||
ClientHeight = 421
|
||||
ClientWidth = 561
|
||||
ClientHeight = 434
|
||||
ClientWidth = 774
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.5'
|
||||
LCLVersion = '1.7'
|
||||
object Panel1: TPanel
|
||||
Left = 6
|
||||
Height = 374
|
||||
Height = 389
|
||||
Top = 6
|
||||
Width = 549
|
||||
Width = 762
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 374
|
||||
ClientWidth = 549
|
||||
ClientHeight = 389
|
||||
ClientWidth = 762
|
||||
TabOrder = 0
|
||||
object ItemsTreeView: TTreeView
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 0
|
||||
Height = 374
|
||||
Height = 389
|
||||
Top = 0
|
||||
Width = 263
|
||||
Width = 328
|
||||
Align = alClient
|
||||
DefaultItemHeight = 16
|
||||
ReadOnly = True
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 0
|
||||
@ -40,20 +39,20 @@ object NewOtherDialog: TNewOtherDialog
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Owner
|
||||
AnchorSideRight.Control = Owner
|
||||
Left = 268
|
||||
Height = 374
|
||||
Left = 333
|
||||
Height = 389
|
||||
Top = 0
|
||||
Width = 281
|
||||
Width = 429
|
||||
Align = alRight
|
||||
Caption = 'DescriptionGroupBox'
|
||||
ClientHeight = 353
|
||||
ClientWidth = 277
|
||||
ClientHeight = 363
|
||||
ClientWidth = 425
|
||||
TabOrder = 1
|
||||
object DescriptionLabel: TLabel
|
||||
Left = 6
|
||||
Height = 17
|
||||
Height = 14
|
||||
Top = 6
|
||||
Width = 265
|
||||
Width = 413
|
||||
Align = alTop
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'DescriptionLabel'
|
||||
@ -61,11 +60,13 @@ object NewOtherDialog: TNewOtherDialog
|
||||
WordWrap = True
|
||||
end
|
||||
object InheritableComponentsListView: TListView
|
||||
AnchorSideTop.Control = CompFilterEdit
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 0
|
||||
Height = 324
|
||||
Top = 29
|
||||
Width = 277
|
||||
Align = alClient
|
||||
Height = 304
|
||||
Top = 54
|
||||
Width = 419
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Columns = <
|
||||
item
|
||||
Caption = 'Form'
|
||||
@ -80,13 +81,28 @@ object NewOtherDialog: TNewOtherDialog
|
||||
RowSelect = True
|
||||
ScrollBars = ssAutoBoth
|
||||
SortType = stText
|
||||
TabOrder = 0
|
||||
TabOrder = 1
|
||||
ViewStyle = vsReport
|
||||
end
|
||||
object CompFilterEdit: TListViewFilterEdit
|
||||
AnchorSideTop.Control = DescriptionLabel
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 28
|
||||
Top = 26
|
||||
Width = 413
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
MaxLength = 0
|
||||
TabOrder = 0
|
||||
Text = 'listviewfilteredit1'
|
||||
FilteredListview = InheritableComponentsListView
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 263
|
||||
Height = 374
|
||||
Left = 328
|
||||
Height = 389
|
||||
Top = 0
|
||||
Width = 5
|
||||
Align = alRight
|
||||
@ -95,9 +111,9 @@ object NewOtherDialog: TNewOtherDialog
|
||||
end
|
||||
object ButtonPanel: TButtonPanel
|
||||
Left = 6
|
||||
Height = 29
|
||||
Top = 386
|
||||
Width = 549
|
||||
Height = 27
|
||||
Top = 401
|
||||
Width = 762
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
OKButton.OnClick = OkButtonClick
|
||||
|
@ -39,10 +39,18 @@ unit NewDialog;
|
||||
interface
|
||||
|
||||
uses
|
||||
Buttons, SysUtils, Classes, ComCtrls, Controls, Dialogs,
|
||||
Forms, StdCtrls, ExtCtrls, FileProcs, ButtonPanel,
|
||||
IDEWindowIntf, IDEImagesIntf, NewItemIntf, PackageIntf, ProjectIntf,
|
||||
LazIDEIntf, IDEHelpIntf, IDEDialogs, LazUTF8,
|
||||
SysUtils, Classes,
|
||||
// LCL
|
||||
ComCtrls, Controls, Dialogs, Forms, StdCtrls, ExtCtrls,
|
||||
ButtonPanel, ListViewFilterEdit,
|
||||
// LazUtils
|
||||
LazUTF8,
|
||||
// CodeTools
|
||||
FileProcs,
|
||||
// IdeIntf
|
||||
IDEWindowIntf, IDEImagesIntf, NewItemIntf, ProjectIntf,
|
||||
LazIDEIntf, IDEHelpIntf, IDEDialogs,
|
||||
// IDE
|
||||
InputHistory, LazarusIDEStrConsts, Project, MainIntf;
|
||||
|
||||
type
|
||||
@ -123,6 +131,7 @@ type
|
||||
DescriptionLabel: TLabel;
|
||||
ItemsTreeView: TTreeView;
|
||||
InheritableComponentsListView: TListView;
|
||||
CompFilterEdit: TListViewFilterEdit;
|
||||
Panel1: TPanel;
|
||||
Splitter1: TSplitter;
|
||||
procedure HelpButtonClick(Sender: TObject);
|
||||
@ -244,7 +253,7 @@ procedure TNewOtherDialog.FillProjectInheritableItemsList;
|
||||
var
|
||||
aComponentList: TStringList;
|
||||
i: integer;
|
||||
alistItem: TListItem;
|
||||
ListItem: TListViewDataItem;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
Begin
|
||||
try
|
||||
@ -256,24 +265,25 @@ Begin
|
||||
if (not Project1.Units[i].IsPartOfProject)
|
||||
or (not FilenameIsPascalUnit(Project1.Units[i].Filename)) then
|
||||
continue;
|
||||
|
||||
if Project1.Units[i].ComponentName<>'' then
|
||||
aComponentList.AddObject(Project1.Units[i].ComponentName, Project1.Units[i]);
|
||||
end;
|
||||
|
||||
// Sort lists (by component name)
|
||||
aComponentList.Sort;
|
||||
|
||||
// Populate components listview, keeping references to each UnitInfo
|
||||
for i := 0 to aComponentList.Count-1 do
|
||||
begin
|
||||
alistItem := InheritableComponentsListView.Items.Add;
|
||||
alistItem.Caption := aComponentList[i];
|
||||
AnUnitInfo:=TUnitInfo(aComponentList.Objects[i]);
|
||||
alistItem.SubItems.Add(AnUnitInfo.ShortFilename);
|
||||
aListItem.Data := aComponentList.Objects[i];
|
||||
AnUnitInfo := TUnitInfo(aComponentList.Objects[i]);
|
||||
//ListItem.Initialize(2);
|
||||
ListItem.Data := Nil;
|
||||
SetLength(ListItem.StringArray, 2);
|
||||
ListItem.StringArray[0] := aComponentList[i];
|
||||
ListItem.StringArray[1] := AnUnitInfo.ShortFilename;
|
||||
ListItem.Data := aComponentList.Objects[i];
|
||||
CompFilterEdit.Items.Add(ListItem);
|
||||
end;
|
||||
|
||||
CompFilterEdit.InvalidateFilter;
|
||||
finally
|
||||
aComponentList.Free;
|
||||
end;
|
||||
@ -361,10 +371,10 @@ begin
|
||||
if TNewItemProjectFile(aNewItemTemplate).Descriptor is TFileDescInheritedComponent
|
||||
then begin
|
||||
InheritableComponentsListView.Visible := true;
|
||||
InheritableComponentsListView.Height:=InheritableComponentsListView.Parent.ClientHeight-50;
|
||||
if InheritableComponentsListView.Items.Count>0 then
|
||||
InheritableComponentsListView.Selected := InheritableComponentsListView.Items[0];
|
||||
end
|
||||
//InheritableComponentsListView.Height:=InheritableComponentsListView.Parent.ClientHeight-50;
|
||||
//if InheritableComponentsListView.Items.Count>0 then
|
||||
// InheritableComponentsListView.Selected := InheritableComponentsListView.Items[0];
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
@ -396,6 +406,7 @@ begin
|
||||
SetupComponents;
|
||||
FillItemsTree(AOnlyModules);
|
||||
FillProjectInheritableItemsList;
|
||||
CompFilterEdit.Clear;
|
||||
InheritableComponentsListView.Visible := false;
|
||||
IDEDialogLayoutList.ApplyLayout(Self, 570, 400);
|
||||
|
||||
|
@ -3,18 +3,17 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
|
||||
Height = 501
|
||||
Top = 151
|
||||
Width = 446
|
||||
ActiveControl = FilterEdit
|
||||
Caption = 'OpenLoadedPackagesDlg'
|
||||
ClientHeight = 501
|
||||
ClientWidth = 446
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.5'
|
||||
LCLVersion = '1.7'
|
||||
object HintMemo: TMemo
|
||||
Left = 3
|
||||
Height = 121
|
||||
Top = 332
|
||||
Top = 333
|
||||
Width = 440
|
||||
Align = alBottom
|
||||
BorderSpacing.Left = 3
|
||||
@ -33,8 +32,8 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
|
||||
AnchorSideRight.Side = asrBottom
|
||||
AnchorSideBottom.Control = Splitter1
|
||||
Left = 3
|
||||
Height = 300
|
||||
Top = 27
|
||||
Height = 294
|
||||
Top = 34
|
||||
Width = 440
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
BorderSpacing.Left = 3
|
||||
@ -55,15 +54,15 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
|
||||
Cursor = crVSplit
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 327
|
||||
Top = 328
|
||||
Width = 446
|
||||
Align = alBottom
|
||||
ResizeAnchor = akBottom
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 36
|
||||
Top = 459
|
||||
Height = 35
|
||||
Top = 460
|
||||
Width = 434
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
@ -80,7 +79,7 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
|
||||
end
|
||||
object FilterEdit: TListViewFilterEdit
|
||||
Left = 3
|
||||
Height = 21
|
||||
Height = 28
|
||||
Top = 3
|
||||
Width = 147
|
||||
ButtonWidth = 23
|
||||
|
@ -190,12 +190,12 @@ begin
|
||||
if APackage.Modified then AddState(lisOIPmodified);
|
||||
if APackage.Missing then AddState(lisOIPmissing);
|
||||
case APackage.Installed of
|
||||
pitStatic: AddState(lisOIPinstalledStatic);
|
||||
pitDynamic: AddState(lisOIPinstalledDynamic);
|
||||
pitStatic: AddState(lisOIPinstalledStatic);
|
||||
pitDynamic: AddState(lisOIPinstalledDynamic);
|
||||
end;
|
||||
case APackage.AutoInstall of
|
||||
pitStatic: AddState(lisOIPautoInstallStatic);
|
||||
pitDynamic: AddState(lisOIPautoInstallDynamic);
|
||||
pitStatic: AddState(lisOIPautoInstallStatic);
|
||||
pitDynamic: AddState(lisOIPautoInstallDynamic);
|
||||
end;
|
||||
if APackage.ReadOnly then AddState(lisOIPreadonly);
|
||||
end;
|
||||
@ -204,14 +204,15 @@ procedure TOpenLoadedPackagesDlg.UpdatePackageList;
|
||||
|
||||
procedure UpdateOnePackage(aPkg: TLazPackage);
|
||||
var
|
||||
Data: TListViewDataItem;
|
||||
ListItem: TListViewDataItem;
|
||||
begin
|
||||
Data.Data := nil;
|
||||
SetLength(Data.StringArray, 3);
|
||||
Data.StringArray[0] := aPkg.Name;
|
||||
Data.StringArray[1] := aPkg.Version.AsString;
|
||||
Data.StringArray[2] := PkgStateToString(aPkg);
|
||||
FilterEdit.Items.Add(Data);
|
||||
//ListItem.Initialize(3);
|
||||
ListItem.Data := Nil;
|
||||
SetLength(ListItem.StringArray, 3);
|
||||
ListItem.StringArray[0] := aPkg.Name;
|
||||
ListItem.StringArray[1] := aPkg.Version.AsString;
|
||||
ListItem.StringArray[2] := PkgStateToString(aPkg);
|
||||
FilterEdit.Items.Add(ListItem);
|
||||
end;
|
||||
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user