From 9b28c55963041cbfef1c321c1a9b5f86091157f4 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Fri, 6 Jan 2006 05:57:45 +0000 Subject: [PATCH] Fixed: View Form dialog shows the Form name instead of the Unit name --- Source/UnSwDialog.pas | 13 ++++++++++--- Source/UnSwFilters.pas | 43 ++++++++++++++++++++++++++++++------------ Source/UnSwObjects.pas | 9 ++++++++- 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/Source/UnSwDialog.pas b/Source/UnSwDialog.pas index 4c1164c..9767497 100644 --- a/Source/UnSwDialog.pas +++ b/Source/UnSwDialog.pas @@ -128,7 +128,11 @@ begin FTypeFilteredList := TUnSwUnitList.Create(); FInputFilteredList := TUnSwUnitList.Create(); FTypeFilter := TUnSwUnitTypeFilter.Create(FTypeFilteredList); - FInputFilter := TUnSwUnitSimpleFilter.Create(FInputFilteredList); + + if FFormsOnly then + FInputFilter := TUnSwUnitSimpleFormNameFilter.Create(FInputFilteredList) + else + FInputFilter := TUnSwUnitSimpleNameFilter.Create(FInputFilteredList); try if not FFormsOnly then begin @@ -185,7 +189,7 @@ procedure TfrmUnSwDialog.UpdateTypeFilter(); begin FTypeFilter.IncludeUnits := not FFormsOnly; FTypeFilter.IncludeForms := (FFormsOnly or chkForms.Checked); - FTypeFilter.IncludeDataModules := ((not FFormsOnly) and chkDataModules.Checked); + FTypeFilter.IncludeDataModules := (FFormsOnly or chkDataModules.Checked); FTypeFilter.IncludeProjectSource := ((not FFormsOnly) and chkProjectSource.Checked); FTypeFilteredList.Clone(FUnitList); @@ -256,6 +260,10 @@ begin with TListBox(Control) do begin pUnit := FInputFilteredList[Index]; + if FFormsOnly and (pUnit is TUnSwModuleUnit) then + sText := TUnSwModuleUnit(pUnit).FormName + else + sText := pUnit.Name; if odSelected in State then begin @@ -275,7 +283,6 @@ begin ilsTypes.Draw(Canvas, rText.Left, rText.Top, FIconVisitor.ImageIndex); Inc(rText.Left, ilsTypes.Width + 4); - sText := pUnit.Name; DrawText(Canvas.Handle, PChar(sText), Length(sText), rText, DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_END_ELLIPSIS); end; diff --git a/Source/UnSwFilters.pas b/Source/UnSwFilters.pas index 5fb6b31..09f9201 100644 --- a/Source/UnSwFilters.pas +++ b/Source/UnSwFilters.pas @@ -5,7 +5,7 @@ uses UnSwObjects; type - TUnSwUnitFilter = class(TUnSwNoRefIntfObject, IUnSwVisitor) + TUnSwUnitFilter = class(TUnSwNoRefIntfObject, IUnSwVisitor) private FList: TUnSwUnitList; protected @@ -20,18 +20,26 @@ type constructor Create(const AList: TUnSwUnitList); virtual; end; - TUnSwUnitSimpleFilter = class(TUnSwUnitFilter) + TUnSwUnitSimpleFilter = class(TUnSwUnitFilter) private FFilter: String; procedure SetFilter(const Value: String); - protected - procedure VisitUnit(const AUnit: TUnSwUnit); override; public property Filter: String read FFilter write SetFilter; end; - TUnSwUnitTypeFilter = class(TUnSwUnitFilter) + TUnSwUnitSimpleNameFilter = class(TUnSwUnitSimpleFilter) + protected + procedure VisitUnit(const AUnit: TUnSwUnit); override; + end; + + TUnSwUnitSimpleFormNameFilter = class(TUnSwUnitSimpleNameFilter) + protected + procedure VisitModule(const AUnit: TUnSwModuleUnit); override; + end; + + TUnSwUnitTypeFilter = class(TUnSwUnitFilter) private FIncludeDataModules: Boolean; FIncludeForms: Boolean; @@ -84,19 +92,30 @@ end; { TUnSwUnitSimpleFilter } -procedure TUnSwUnitSimpleFilter.VisitUnit(const AUnit: TUnSwUnit); -begin - if (Length(FFilter) > 0) and - (AnsiPos(FFilter, LowerCase(AUnit.Name)) = 0) then - FilterUnit(AUnit); -end; - procedure TUnSwUnitSimpleFilter.SetFilter(const Value: String); begin FFilter := LowerCase(Value); end; +{ TUnSwUnitSimpleNameFilter } +procedure TUnSwUnitSimpleNameFilter.VisitUnit(const AUnit: TUnSwUnit); +begin + if (Length(Filter) > 0) and + (AnsiPos(Filter, LowerCase(AUnit.Name)) = 0) then + FilterUnit(AUnit); +end; + + +{ TUnSwUnitSimpleFormNameFilter } +procedure TUnSwUnitSimpleFormNameFilter.VisitModule(const AUnit: TUnSwModuleUnit); +begin + if (Length(Filter) > 0) and + (AnsiPos(Filter, LowerCase(AUnit.FormName)) = 0) then + FilterUnit(AUnit); +end; + + { TUnSwUnitTypeFilter } constructor TUnSwUnitTypeFilter.Create(const AList: TUnSwUnitList); begin diff --git a/Source/UnSwObjects.pas b/Source/UnSwObjects.pas index 70a4357..757f983 100644 --- a/Source/UnSwObjects.pas +++ b/Source/UnSwObjects.pas @@ -73,8 +73,9 @@ type private FModule: IOTAModuleInfo; protected - function GetName(): String; override; function GetFileName(): String; override; + function GetFormName(): String; + function GetName(): String; override; function GetUnitType(): TUnSwUnitType; public constructor Create(const AModule: IOTAModuleInfo); @@ -82,6 +83,7 @@ type procedure Activate(const ASource: Boolean); override; + property FormName: String read GetFormName; property UnitType: TUnSwUnitType read GetUnitType; end; @@ -194,6 +196,11 @@ begin Result := FModule.Name; end; +function TUnSwModuleUnit.GetFormName(): String; +begin + Result := FModule.FormName; +end; + function TUnSwModuleUnit.GetFileName(): String; begin Result := FModule.FileName;