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:
juha 2017-03-01 16:17:09 +00:00
parent 522a0f5505
commit 49d21d2dbc
5 changed files with 106 additions and 70 deletions

View File

@ -25,10 +25,13 @@ type
//TImageIndexEvent = function (Str: String; Data: TObject; //TImageIndexEvent = function (Str: String; Data: TObject;
// var IsEnabled: Boolean): Integer of object; // var IsEnabled: Boolean): Integer of object;
TStringArray = array of string; TStringArray = array of string;
{ TListViewDataItem }
TListViewDataItem = record TListViewDataItem = record
Data: Pointer; Data: Pointer;
StringArray: TStringArray; StringArray: TStringArray;
//constructor Initialize(ColumnCount: integer); Does not work. Why?
class operator =(a,b : TListViewDataItem) : Boolean; class operator =(a,b : TListViewDataItem) : Boolean;
end; end;
TListViewDataList = specialize TFPGList<TListViewDataItem>; TListViewDataList = specialize TFPGList<TListViewDataItem>;
@ -82,7 +85,13 @@ var
implementation implementation
{ TListViewDataItem } { TListViewDataItem }
{
constructor TListViewDataItem.Initialize(ColumnCount: integer);
begin
Data := Nil;
SetLength(StringArray, ColumnCount);
end;
}
class operator TListViewDataItem. = (a, b: TListViewDataItem): Boolean; class operator TListViewDataItem. = (a, b: TListViewDataItem): Boolean;
begin begin
Result := (a.Data=b.Data) and (a.StringArray=b.StringArray); Result := (a.Data=b.Data) and (a.StringArray=b.StringArray);

View File

@ -1,33 +1,32 @@
object NewOtherDialog: TNewOtherDialog object NewOtherDialog: TNewOtherDialog
Left = 281 Left = 281
Height = 421 Height = 434
Top = 204 Top = 191
Width = 561 Width = 774
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
Caption = 'NewOtherDialog' Caption = 'NewOtherDialog'
ClientHeight = 421 ClientHeight = 434
ClientWidth = 561 ClientWidth = 774
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.5' LCLVersion = '1.7'
object Panel1: TPanel object Panel1: TPanel
Left = 6 Left = 6
Height = 374 Height = 389
Top = 6 Top = 6
Width = 549 Width = 762
Align = alClient Align = alClient
BorderSpacing.Around = 6 BorderSpacing.Around = 6
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 374 ClientHeight = 389
ClientWidth = 549 ClientWidth = 762
TabOrder = 0 TabOrder = 0
object ItemsTreeView: TTreeView object ItemsTreeView: TTreeView
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 0 Left = 0
Height = 374 Height = 389
Top = 0 Top = 0
Width = 263 Width = 328
Align = alClient Align = alClient
DefaultItemHeight = 16
ReadOnly = True ReadOnly = True
ScrollBars = ssAutoBoth ScrollBars = ssAutoBoth
TabOrder = 0 TabOrder = 0
@ -40,20 +39,20 @@ object NewOtherDialog: TNewOtherDialog
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
Left = 268 Left = 333
Height = 374 Height = 389
Top = 0 Top = 0
Width = 281 Width = 429
Align = alRight Align = alRight
Caption = 'DescriptionGroupBox' Caption = 'DescriptionGroupBox'
ClientHeight = 353 ClientHeight = 363
ClientWidth = 277 ClientWidth = 425
TabOrder = 1 TabOrder = 1
object DescriptionLabel: TLabel object DescriptionLabel: TLabel
Left = 6 Left = 6
Height = 17 Height = 14
Top = 6 Top = 6
Width = 265 Width = 413
Align = alTop Align = alTop
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'DescriptionLabel' Caption = 'DescriptionLabel'
@ -61,11 +60,13 @@ object NewOtherDialog: TNewOtherDialog
WordWrap = True WordWrap = True
end end
object InheritableComponentsListView: TListView object InheritableComponentsListView: TListView
AnchorSideTop.Control = CompFilterEdit
AnchorSideTop.Side = asrBottom
Left = 0 Left = 0
Height = 324 Height = 304
Top = 29 Top = 54
Width = 277 Width = 419
Align = alClient Anchors = [akTop, akLeft, akRight, akBottom]
Columns = < Columns = <
item item
Caption = 'Form' Caption = 'Form'
@ -80,13 +81,28 @@ object NewOtherDialog: TNewOtherDialog
RowSelect = True RowSelect = True
ScrollBars = ssAutoBoth ScrollBars = ssAutoBoth
SortType = stText SortType = stText
TabOrder = 0 TabOrder = 1
ViewStyle = vsReport ViewStyle = vsReport
end 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 end
object Splitter1: TSplitter object Splitter1: TSplitter
Left = 263 Left = 328
Height = 374 Height = 389
Top = 0 Top = 0
Width = 5 Width = 5
Align = alRight Align = alRight
@ -95,9 +111,9 @@ object NewOtherDialog: TNewOtherDialog
end end
object ButtonPanel: TButtonPanel object ButtonPanel: TButtonPanel
Left = 6 Left = 6
Height = 29 Height = 27
Top = 386 Top = 401
Width = 549 Width = 762
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
OKButton.OnClick = OkButtonClick OKButton.OnClick = OkButtonClick

View File

@ -39,10 +39,18 @@ unit NewDialog;
interface interface
uses uses
Buttons, SysUtils, Classes, ComCtrls, Controls, Dialogs, SysUtils, Classes,
Forms, StdCtrls, ExtCtrls, FileProcs, ButtonPanel, // LCL
IDEWindowIntf, IDEImagesIntf, NewItemIntf, PackageIntf, ProjectIntf, ComCtrls, Controls, Dialogs, Forms, StdCtrls, ExtCtrls,
LazIDEIntf, IDEHelpIntf, IDEDialogs, LazUTF8, ButtonPanel, ListViewFilterEdit,
// LazUtils
LazUTF8,
// CodeTools
FileProcs,
// IdeIntf
IDEWindowIntf, IDEImagesIntf, NewItemIntf, ProjectIntf,
LazIDEIntf, IDEHelpIntf, IDEDialogs,
// IDE
InputHistory, LazarusIDEStrConsts, Project, MainIntf; InputHistory, LazarusIDEStrConsts, Project, MainIntf;
type type
@ -123,6 +131,7 @@ type
DescriptionLabel: TLabel; DescriptionLabel: TLabel;
ItemsTreeView: TTreeView; ItemsTreeView: TTreeView;
InheritableComponentsListView: TListView; InheritableComponentsListView: TListView;
CompFilterEdit: TListViewFilterEdit;
Panel1: TPanel; Panel1: TPanel;
Splitter1: TSplitter; Splitter1: TSplitter;
procedure HelpButtonClick(Sender: TObject); procedure HelpButtonClick(Sender: TObject);
@ -244,7 +253,7 @@ procedure TNewOtherDialog.FillProjectInheritableItemsList;
var var
aComponentList: TStringList; aComponentList: TStringList;
i: integer; i: integer;
alistItem: TListItem; ListItem: TListViewDataItem;
AnUnitInfo: TUnitInfo; AnUnitInfo: TUnitInfo;
Begin Begin
try try
@ -256,24 +265,25 @@ Begin
if (not Project1.Units[i].IsPartOfProject) if (not Project1.Units[i].IsPartOfProject)
or (not FilenameIsPascalUnit(Project1.Units[i].Filename)) then or (not FilenameIsPascalUnit(Project1.Units[i].Filename)) then
continue; continue;
if Project1.Units[i].ComponentName<>'' then if Project1.Units[i].ComponentName<>'' then
aComponentList.AddObject(Project1.Units[i].ComponentName, Project1.Units[i]); aComponentList.AddObject(Project1.Units[i].ComponentName, Project1.Units[i]);
end; end;
// Sort lists (by component name) // Sort lists (by component name)
aComponentList.Sort; aComponentList.Sort;
// Populate components listview, keeping references to each UnitInfo // Populate components listview, keeping references to each UnitInfo
for i := 0 to aComponentList.Count-1 do for i := 0 to aComponentList.Count-1 do
begin begin
alistItem := InheritableComponentsListView.Items.Add; AnUnitInfo := TUnitInfo(aComponentList.Objects[i]);
alistItem.Caption := aComponentList[i]; //ListItem.Initialize(2);
AnUnitInfo:=TUnitInfo(aComponentList.Objects[i]); ListItem.Data := Nil;
alistItem.SubItems.Add(AnUnitInfo.ShortFilename); SetLength(ListItem.StringArray, 2);
aListItem.Data := aComponentList.Objects[i]; ListItem.StringArray[0] := aComponentList[i];
ListItem.StringArray[1] := AnUnitInfo.ShortFilename;
ListItem.Data := aComponentList.Objects[i];
CompFilterEdit.Items.Add(ListItem);
end; end;
CompFilterEdit.InvalidateFilter;
finally finally
aComponentList.Free; aComponentList.Free;
end; end;
@ -361,10 +371,10 @@ begin
if TNewItemProjectFile(aNewItemTemplate).Descriptor is TFileDescInheritedComponent if TNewItemProjectFile(aNewItemTemplate).Descriptor is TFileDescInheritedComponent
then begin then begin
InheritableComponentsListView.Visible := true; InheritableComponentsListView.Visible := true;
InheritableComponentsListView.Height:=InheritableComponentsListView.Parent.ClientHeight-50; //InheritableComponentsListView.Height:=InheritableComponentsListView.Parent.ClientHeight-50;
if InheritableComponentsListView.Items.Count>0 then //if InheritableComponentsListView.Items.Count>0 then
InheritableComponentsListView.Selected := InheritableComponentsListView.Items[0]; // InheritableComponentsListView.Selected := InheritableComponentsListView.Items[0];
end end;
end; end;
end; end;
end end
@ -396,6 +406,7 @@ begin
SetupComponents; SetupComponents;
FillItemsTree(AOnlyModules); FillItemsTree(AOnlyModules);
FillProjectInheritableItemsList; FillProjectInheritableItemsList;
CompFilterEdit.Clear;
InheritableComponentsListView.Visible := false; InheritableComponentsListView.Visible := false;
IDEDialogLayoutList.ApplyLayout(Self, 570, 400); IDEDialogLayoutList.ApplyLayout(Self, 570, 400);

View File

@ -3,18 +3,17 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
Height = 501 Height = 501
Top = 151 Top = 151
Width = 446 Width = 446
ActiveControl = FilterEdit
Caption = 'OpenLoadedPackagesDlg' Caption = 'OpenLoadedPackagesDlg'
ClientHeight = 501 ClientHeight = 501
ClientWidth = 446 ClientWidth = 446
OnClose = FormClose OnClose = FormClose
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.5' LCLVersion = '1.7'
object HintMemo: TMemo object HintMemo: TMemo
Left = 3 Left = 3
Height = 121 Height = 121
Top = 332 Top = 333
Width = 440 Width = 440
Align = alBottom Align = alBottom
BorderSpacing.Left = 3 BorderSpacing.Left = 3
@ -33,8 +32,8 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Splitter1 AnchorSideBottom.Control = Splitter1
Left = 3 Left = 3
Height = 300 Height = 294
Top = 27 Top = 34
Width = 440 Width = 440
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 3 BorderSpacing.Left = 3
@ -55,15 +54,15 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5
Top = 327 Top = 328
Width = 446 Width = 446
Align = alBottom Align = alBottom
ResizeAnchor = akBottom ResizeAnchor = akBottom
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 36 Height = 35
Top = 459 Top = 460
Width = 434 Width = 434
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
@ -80,7 +79,7 @@ object OpenLoadedPackagesDlg: TOpenLoadedPackagesDlg
end end
object FilterEdit: TListViewFilterEdit object FilterEdit: TListViewFilterEdit
Left = 3 Left = 3
Height = 21 Height = 28
Top = 3 Top = 3
Width = 147 Width = 147
ButtonWidth = 23 ButtonWidth = 23

View File

@ -190,12 +190,12 @@ begin
if APackage.Modified then AddState(lisOIPmodified); if APackage.Modified then AddState(lisOIPmodified);
if APackage.Missing then AddState(lisOIPmissing); if APackage.Missing then AddState(lisOIPmissing);
case APackage.Installed of case APackage.Installed of
pitStatic: AddState(lisOIPinstalledStatic); pitStatic: AddState(lisOIPinstalledStatic);
pitDynamic: AddState(lisOIPinstalledDynamic); pitDynamic: AddState(lisOIPinstalledDynamic);
end; end;
case APackage.AutoInstall of case APackage.AutoInstall of
pitStatic: AddState(lisOIPautoInstallStatic); pitStatic: AddState(lisOIPautoInstallStatic);
pitDynamic: AddState(lisOIPautoInstallDynamic); pitDynamic: AddState(lisOIPautoInstallDynamic);
end; end;
if APackage.ReadOnly then AddState(lisOIPreadonly); if APackage.ReadOnly then AddState(lisOIPreadonly);
end; end;
@ -204,14 +204,15 @@ procedure TOpenLoadedPackagesDlg.UpdatePackageList;
procedure UpdateOnePackage(aPkg: TLazPackage); procedure UpdateOnePackage(aPkg: TLazPackage);
var var
Data: TListViewDataItem; ListItem: TListViewDataItem;
begin begin
Data.Data := nil; //ListItem.Initialize(3);
SetLength(Data.StringArray, 3); ListItem.Data := Nil;
Data.StringArray[0] := aPkg.Name; SetLength(ListItem.StringArray, 3);
Data.StringArray[1] := aPkg.Version.AsString; ListItem.StringArray[0] := aPkg.Name;
Data.StringArray[2] := PkgStateToString(aPkg); ListItem.StringArray[1] := aPkg.Version.AsString;
FilterEdit.Items.Add(Data); ListItem.StringArray[2] := PkgStateToString(aPkg);
FilterEdit.Items.Add(ListItem);
end; end;
var var