1
0
mirror of synced 2024-11-14 16:33:54 +00:00

Fixed: Issue #129

Fixed: Issue #131
Fixed: Issue #132
Fixed: Issue #139
Fixed: Issue #143
This commit is contained in:
Mark van Renswoude 2006-01-13 20:34:45 +00:00
parent 58b808b101
commit fe432ee088
4 changed files with 505 additions and 68 deletions

View File

@ -259,7 +259,7 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration
Top = 23 Top = 23
Width = 54 Width = 54
Height = 13 Height = 13
Caption = 'Version 0.2' Caption = 'Version 0.3'
end end
object TLabel object TLabel
Left = 135 Left = 135
@ -328,6 +328,7 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration
Height = 25 Height = 25
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Caption = 'OK' Caption = 'OK'
Default = True
ModalResult = 1 ModalResult = 1
TabOrder = 2 TabOrder = 2
end end

View File

@ -4,10 +4,10 @@ object frmUnSwDialog: TfrmUnSwDialog
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
Caption = 'UnitSwitcher' Caption = 'UnitSwitcher'
ClientHeight = 398 ClientHeight = 398
ClientWidth = 292 ClientWidth = 311
Color = clBtnFace Color = clBtnFace
Constraints.MinHeight = 240 Constraints.MinHeight = 240
Constraints.MinWidth = 270 Constraints.MinWidth = 290
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -11 Font.Height = -11
@ -33,7 +33,7 @@ object frmUnSwDialog: TfrmUnSwDialog
object sbStatus: TStatusBar object sbStatus: TStatusBar
Left = 0 Left = 0
Top = 379 Top = 379
Width = 292 Width = 311
Height = 19 Height = 19
Panels = < Panels = <
item item
@ -43,8 +43,8 @@ object frmUnSwDialog: TfrmUnSwDialog
object pnlMain: TPanel object pnlMain: TPanel
Left = 0 Left = 0
Top = 0 Top = 0
Width = 292 Width = 311
Height = 288 Height = 307
Align = alClient Align = alClient
BevelOuter = bvNone BevelOuter = bvNone
BorderWidth = 4 BorderWidth = 4
@ -52,18 +52,18 @@ object frmUnSwDialog: TfrmUnSwDialog
object pnlSearch: TPanel object pnlSearch: TPanel
Left = 4 Left = 4
Top = 4 Top = 4
Width = 284 Width = 303
Height = 25 Height = 25
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 0 TabOrder = 0
DesignSize = ( DesignSize = (
284 303
25) 25)
object edtSearch: TEdit object edtSearch: TEdit
Left = 0 Left = 0
Top = 0 Top = 0
Width = 284 Width = 303
Height = 21 Height = 21
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 0 TabOrder = 0
@ -74,12 +74,13 @@ object frmUnSwDialog: TfrmUnSwDialog
object lstUnits: TListBox object lstUnits: TListBox
Left = 4 Left = 4
Top = 29 Top = 29
Width = 284 Width = 303
Height = 255 Height = 274
Style = lbVirtualOwnerDraw Style = lbVirtualOwnerDraw
Align = alClient Align = alClient
ItemHeight = 20 ItemHeight = 20
MultiSelect = True MultiSelect = True
PopupMenu = pmnUnits
TabOrder = 1 TabOrder = 1
OnData = lstUnitsData OnData = lstUnitsData
OnDblClick = lstUnitsDblClick OnDblClick = lstUnitsDblClick
@ -89,16 +90,16 @@ object frmUnSwDialog: TfrmUnSwDialog
object pnlButtons: TPanel object pnlButtons: TPanel
Left = 0 Left = 0
Top = 343 Top = 343
Width = 292 Width = 311
Height = 36 Height = 36
Align = alBottom Align = alBottom
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 2 TabOrder = 1
DesignSize = ( DesignSize = (
292 311
36) 36)
object btnCancel: TButton object btnCancel: TButton
Left = 213 Left = 232
Top = 5 Top = 5
Width = 75 Width = 75
Height = 25 Height = 25
@ -109,7 +110,7 @@ object frmUnSwDialog: TfrmUnSwDialog
TabOrder = 1 TabOrder = 1
end end
object btnOK: TButton object btnOK: TButton
Left = 132 Left = 151
Top = 5 Top = 5
Width = 75 Width = 75
Height = 25 Height = 25
@ -131,38 +132,65 @@ object frmUnSwDialog: TfrmUnSwDialog
end end
object pnlIncludeTypes: TPanel object pnlIncludeTypes: TPanel
Left = 0 Left = 0
Top = 288 Top = 307
Width = 292 Width = 311
Height = 55 Height = 36
Align = alBottom Align = alBottom
BevelOuter = bvNone BevelOuter = bvNone
TabOrder = 1 TabOrder = 3
object chkDataModules: TCheckBox object pnlIncludeUnitTypes: TPanel
Left = 4 Left = 149
Top = 19 Top = 0
Width = 137 Width = 162
Height = 17 Height = 36
Caption = 'Show &DataModule units' Align = alClient
TabOrder = 1 BevelOuter = bvNone
OnClick = TypeFilterChange
end
object chkForms: TCheckBox
Left = 4
Top = 2
Width = 101
Height = 17
Caption = 'Show &Form units'
TabOrder = 0 TabOrder = 0
OnClick = TypeFilterChange object chkProjectSource: TCheckBox
Left = 4
Top = 17
Width = 121
Height = 17
Caption = 'Show &Project source'
TabOrder = 0
OnClick = TypeFilterChange
end
object chkUnits: TCheckBox
Left = 4
Top = 0
Width = 77
Height = 17
Caption = 'Show &Units'
TabOrder = 1
OnClick = TypeFilterChange
end
end end
object chkProjectSource: TCheckBox object pnlIncludeFormTypes: TPanel
Left = 4 Left = 0
Top = 36 Top = 0
Width = 121 Width = 149
Height = 17 Height = 36
Caption = 'Show &Project source' Align = alLeft
TabOrder = 2 BevelOuter = bvNone
OnClick = TypeFilterChange TabOrder = 1
object chkDataModules: TCheckBox
Left = 4
Top = 19
Width = 137
Height = 17
Caption = 'Show &DataModule units'
TabOrder = 0
OnClick = TypeFilterChange
end
object chkForms: TCheckBox
Left = 4
Top = 2
Width = 101
Height = 17
Caption = 'Show &Form units'
TabOrder = 1
OnClick = TypeFilterChange
end
end end
end end
object ilsTypes: TImageList object ilsTypes: TImageList
@ -580,5 +608,70 @@ object frmUnSwDialog: TfrmUnSwDialog
ShortCut = 16449 ShortCut = 16449
OnExecute = actSelectAllExecute OnExecute = actSelectAllExecute
end end
object actSelectInvert: TAction
Caption = '&Invert Selection'
ShortCut = 16457
OnExecute = actSelectInvertExecute
end
object actSortByName: TAction
Caption = 'Sort by &Name'
GroupIndex = 1
ShortCut = 49230
OnExecute = SortExecute
end
object actSortByType: TAction
Caption = 'Sort by &Type'
GroupIndex = 1
ShortCut = 49236
OnExecute = SortExecute
end
object actOpenFolder: TAction
Caption = 'Open containing &folder'
ShortCut = 49222
OnExecute = actOpenFolderExecute
end
object actOpenProperties: TAction
Caption = '&Properties'
ShortCut = 49165
OnExecute = actOpenPropertiesExecute
end
object actMRUNext: TAction
Caption = 'actMRUNext'
ShortCut = 16422
OnExecute = actMRUNextExecute
end
object actMRUPrior: TAction
Caption = 'actMRUPrior'
ShortCut = 16424
OnExecute = actMRUPriorExecute
end
end
object pmnUnits: TPopupMenu
Left = 64
Top = 32
object pmnUnitsSelectAll: TMenuItem
Action = actSelectAll
end
object pmnUnitsSelectInvert: TMenuItem
Action = actSelectInvert
end
object pmnUnitsSep1: TMenuItem
Caption = '-'
end
object pmnUnitsSortByName: TMenuItem
Action = actSortByName
end
object pmnUnitsSortByType: TMenuItem
Action = actSortByType
end
object pmnUnitsSep2: TMenuItem
Caption = '-'
end
object pmnUnitsOpenFolder: TMenuItem
Action = actOpenFolder
end
object pmnUnitsOpenProperties: TMenuItem
Action = actOpenProperties
end
end end
end end

View File

@ -16,6 +16,7 @@ uses
Forms, Forms,
Graphics, Graphics,
ImgList, ImgList,
Menus,
StdCtrls, StdCtrls,
Windows, Windows,
@ -36,38 +37,65 @@ type
end; end;
TfrmUnSwDialog = class(TForm) TfrmUnSwDialog = class(TForm)
actMRUNext: TAction;
actMRUPrior: TAction;
actOpenFolder: TAction;
actOpenProperties: TAction;
actSelectAll: TAction;
actSelectInvert: TAction;
actSortByName: TAction;
actSortByType: TAction;
alMain: TActionList;
btnCancel: TButton; btnCancel: TButton;
btnConfiguration: TButton; btnConfiguration: TButton;
btnOK: TButton; btnOK: TButton;
chkDataModules: TCheckBox; chkDataModules: TCheckBox;
chkForms: TCheckBox; chkForms: TCheckBox;
chkProjectSource: TCheckBox; chkProjectSource: TCheckBox;
chkUnits: TCheckBox;
edtSearch: TEdit; edtSearch: TEdit;
ilsTypes: TImageList; ilsTypes: TImageList;
lstUnits: TListBox; lstUnits: TListBox;
pmnUnits: TPopupMenu;
pmnUnitsOpenFolder: TMenuItem;
pmnUnitsOpenProperties: TMenuItem;
pmnUnitsSelectAll: TMenuItem;
pmnUnitsSelectInvert: TMenuItem;
pmnUnitsSep1: TMenuItem;
pmnUnitsSep2: TMenuItem;
pmnUnitsSortByName: TMenuItem;
pmnUnitsSortByType: TMenuItem;
pnlButtons: TPanel; pnlButtons: TPanel;
pnlIncludeFormTypes: TPanel;
pnlIncludeTypes: TPanel; pnlIncludeTypes: TPanel;
pnlIncludeUnitTypes: TPanel;
pnlMain: TPanel; pnlMain: TPanel;
pnlSearch: TPanel; pnlSearch: TPanel;
sbStatus: TStatusBar; sbStatus: TStatusBar;
alMain: TActionList;
actSelectAll: TAction;
procedure FormShow(Sender: TObject);
procedure actSelectAllExecute(Sender: TObject);
procedure FormResize(Sender: TObject); procedure actMRUNextExecute(Sender: TObject);
procedure actMRUPriorExecute(Sender: TObject);
procedure actOpenFolderExecute(Sender: TObject);
procedure actOpenPropertiesExecute(Sender: TObject);
procedure actSelectAllExecute(Sender: TObject);
procedure actSelectInvertExecute(Sender: TObject);
procedure btnConfigurationClick(Sender: TObject); procedure btnConfigurationClick(Sender: TObject);
procedure edtSearchChange(Sender: TObject); procedure edtSearchChange(Sender: TObject);
procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure TypeFilterChange(Sender: TObject); procedure FormResize(Sender: TObject);
procedure lstUnitsDblClick(Sender: TObject); procedure FormShow(Sender: TObject);
procedure lstUnitsData(Control: TWinControl; Index: Integer; var Data: string); procedure lstUnitsData(Control: TWinControl; Index: Integer; var Data: string);
procedure lstUnitsDblClick(Sender: TObject);
procedure lstUnitsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure lstUnitsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
procedure SortExecute(Sender: TObject);
procedure TypeFilterChange(Sender: TObject);
private private
FLoading: Boolean; FLoading: Boolean;
FUnitList: TUnSwUnitList; FUnitList: TUnSwUnitList;
FActiveUnit: TUnSwUnit; FActiveUnit: TUnSwUnit;
FFormsOnly: Boolean; FFormsOnly: Boolean;
FMRUIndex: Integer;
FMRUList: TStrings;
FTypeFilteredList: TUnSwUnitList; FTypeFilteredList: TUnSwUnitList;
FInputFilteredList: TUnSwUnitList; FInputFilteredList: TUnSwUnitList;
@ -82,6 +110,7 @@ type
procedure UpdateList(); procedure UpdateList();
function GetActiveUnits(): TUnSwUnitList; function GetActiveUnits(): TUnSwUnitList;
procedure SelectMRUItem();
procedure LoadSettings(); procedure LoadSettings();
procedure SaveSettings(); procedure SaveSettings();
@ -94,15 +123,120 @@ type
implementation implementation
uses uses
Messages, Messages,
ShellAPI,
SysUtils, SysUtils,
UnSwConfiguration, UnSwConfiguration,
UnSwSettings; UnSwSettings;
type
TUnSwOpenVisitor = class(TInterfacedObject, IUnSwVisitor)
private
FProcessed: TStringList;
protected
function IsProcessed(const AFileName: String; const ARegister: Boolean = True): Boolean;
procedure OpenFile(const AFileName: String); virtual; abstract;
procedure VisitModule(const AUnit: TUnSwModuleUnit);
procedure VisitProject(const AUnit: TUnSwProjectUnit);
public
constructor Create();
destructor Destroy(); override;
end;
TUnSwOpenFolderVisitor = class(TUnSwOpenVisitor)
protected
procedure OpenFile(const AFileName: String); override;
end;
TUnSwOpenPropertiesVisitor = class(TUnSwOpenVisitor)
protected
procedure OpenFile(const AFileName: String); override;
end;
{$R *.dfm} {$R *.dfm}
{ TUnSwOpenVisitor }
constructor TUnSwOpenVisitor.Create();
begin
inherited Create();
FProcessed := TStringList.Create();
FProcessed.CaseSensitive := False;
end;
destructor TUnSwOpenVisitor.Destroy();
begin
FreeAndNil(FProcessed);
inherited;
end;
function TUnSwOpenVisitor.IsProcessed(const AFileName: String;
const ARegister: Boolean): Boolean;
begin
Result := (FProcessed.IndexOf(AFileName) > -1);
if (not Result) and ARegister then
FProcessed.Add(AFileName);
end;
procedure TUnSwOpenVisitor.VisitModule(const AUnit: TUnSwModuleUnit);
begin
OpenFile(AUnit.FileName);
end;
procedure TUnSwOpenVisitor.VisitProject(const AUnit: TUnSwProjectUnit);
begin
OpenFile(AUnit.FileName);
end;
{ TUnSwOpenFolderVisitor }
procedure TUnSwOpenFolderVisitor.OpenFile(const AFileName: String);
var
sFile: String;
sPath: String;
sParams: String;
begin
sFile := ExpandFileName(AFileName);
sPath := ExtractFilePath(sFile);
if not IsProcessed(sPath) then
begin
sParams := '/e,';
// If it's a file, have explorer highlight it
if not DirectoryExists(AFileName) then
sParams := sParams + '/select,';
sParams := sParams + ExtractShortPathName(sFile);
ShellExecute(0, 'open', 'explorer.exe', PChar(sParams), nil, SW_SHOWNORMAL);
end;
end;
{ TUnSwOpenPropertiesVisitor }
procedure TUnSwOpenPropertiesVisitor.OpenFile(const AFileName: String);
var
pInfo: TShellExecuteInfo;
begin
if not IsProcessed(AFileName) then
begin
// Regular ShellExecute doesn't work
FillChar(pInfo, SizeOf(pInfo), #0);
pInfo.cbSize := SizeOf(TShellExecuteInfo);
pInfo.lpFile := PChar(AFileName);
pInfo.nShow := SW_SHOWNORMAL;
pInfo.fMask := SEE_MASK_INVOKEIDLIST;
pInfo.lpVerb := 'properties';
ShellExecuteEx(@pInfo);
end;
end;
{ TUnSwStyleVisitor } { TUnSwStyleVisitor }
procedure TUnSwStyleVisitor.VisitModule(const AUnit: TUnSwModuleUnit); procedure TUnSwStyleVisitor.VisitModule(const AUnit: TUnSwModuleUnit);
begin begin
@ -162,12 +296,10 @@ begin
UpdateTypeFilter(); UpdateTypeFilter();
end; end;
function SortByName(Item1, Item2: Pointer): Integer;
begin
Result := CompareText(TUnSwUnit(Item1).Name, TUnSwUnit(Item2).Name)
end;
function TfrmUnSwDialog.InternalExecute(): TUnSwUnitList; function TfrmUnSwDialog.InternalExecute(): TUnSwUnitList;
var
iIndex: Integer;
begin begin
Result := nil; Result := nil;
FTypeFilteredList := TUnSwUnitList.Create(); FTypeFilteredList := TUnSwUnitList.Create();
@ -183,15 +315,25 @@ begin
if FFormsOnly then if FFormsOnly then
begin begin
pnlIncludeTypes.Visible := False; pnlIncludeUnitTypes.Visible := False;
Self.Caption := 'UnitSwitcher - View Form'; Self.Caption := 'UnitSwitcher - View Form';
end else end else
Self.Caption := 'UnitSwitcher - View Unit'; Self.Caption := 'UnitSwitcher - View Unit';
FStyleVisitor := TUnSwStyleVisitor.Create(); FStyleVisitor := TUnSwStyleVisitor.Create();
try try
if Self.ShowModal() = mrOk then if Self.ShowModal() = mrOk then
begin
iIndex := FMRUList.IndexOf(edtSearch.Text);
if iIndex > -1 then
FMRUList.Delete(iIndex);
while FMRUList.Count >= 10 do
FMRUList.Delete(Pred(FMRUList.Count));
FMRUList.Insert(0, edtSearch.Text);
Result := GetActiveUnits(); Result := GetActiveUnits();
end;
SaveSettings(); SaveSettings();
finally finally
@ -234,21 +376,81 @@ begin
end; end;
finally finally
FreeAndNil(activeUnits); FreeAndNil(activeUnits);
end else end;
if lstUnits.SelCount = 0 then
lstUnits.Selected[0] := True; lstUnits.Selected[0] := True;
end; end;
end; end;
function SortByName(Item1, Item2: Pointer): Integer;
begin
Result := CompareText(TUnSwUnit(Item1).Name, TUnSwUnit(Item2).Name)
end;
function SortByType(Item1, Item2: Pointer): Integer;
const
Above = -1;
Equal = 0;
Below = 1;
function SortByModuleType(Item1, Item2: TUnSwUnitType): Integer;
begin
Result := Equal;
if Item1 <> Item2 then
case Item1 of
swutForm:
case Item2 of
swutDataModule: Result := Below;
swutUnit: Result := Above;
end;
swutDataModule: Result := Above;
swutUnit: Result := Below;
end;
end;
var
pItem1: TUnSwUnit;
pItem2: TUnSwUnit;
begin
// #ToDo3 Refactor SortByType
// The following order is assumed:
// Project source, DataModules, Forms, Units
Result := Equal;
pItem1 := TUnSwUnit(Item1);
pItem2 := TUnSwUnit(Item2);
if pItem1.ClassType <> pItem2.ClassType then
begin
if pItem1 is TUnSwProjectUnit then
Result := Above
else if pItem2 is TUnSwProjectUnit then
Result := Below;
end else if pItem1 is TUnSwModuleUnit then
Result := SortByModuleType(TUnSwModuleUnit(pItem1).UnitType,
TUnSwModuleUnit(pItem2).UnitType);
if Result = Equal then
Result := SortByName(Item1, Item2);
end;
procedure TfrmUnSwDialog.UpdateTypeFilter(); procedure TfrmUnSwDialog.UpdateTypeFilter();
begin begin
FTypeFilter.IncludeUnits := not FFormsOnly; FTypeFilter.IncludeUnits := ((not FFormsOnly) and chkUnits.Checked);
FTypeFilter.IncludeForms := (FFormsOnly or chkForms.Checked);
FTypeFilter.IncludeDataModules := (FFormsOnly or chkDataModules.Checked);
FTypeFilter.IncludeProjectSource := ((not FFormsOnly) and chkProjectSource.Checked); FTypeFilter.IncludeProjectSource := ((not FFormsOnly) and chkProjectSource.Checked);
FTypeFilter.IncludeForms := chkForms.Checked;
FTypeFilter.IncludeDataModules := chkDataModules.Checked;
FTypeFilteredList.Clone(FUnitList); FTypeFilteredList.Clone(FUnitList);
FTypeFilteredList.AcceptVisitor(FTypeFilter); FTypeFilteredList.AcceptVisitor(FTypeFilter);
FTypeFilteredList.Sort(SortByName);
if actSortByName.Checked then
FTypeFilteredList.Sort(SortByName)
else
FTypeFilteredList.Sort(SortByType);
UpdateList(); UpdateList();
end; end;
@ -290,8 +492,17 @@ begin
try try
chkDataModules.Checked := dialogSettings.IncludeDataModules; chkDataModules.Checked := dialogSettings.IncludeDataModules;
chkForms.Checked := dialogSettings.IncludeForms; chkForms.Checked := dialogSettings.IncludeForms;
chkUnits.Checked := dialogSettings.IncludeUnits;
chkProjectSource.Checked := dialogSettings.IncludeProjectSource; chkProjectSource.Checked := dialogSettings.IncludeProjectSource;
case dialogSettings.Sort of
dsName: actSortByName.Checked := True;
dsType: actSortByType.Checked := True;
end;
FMRUList := dialogSettings.MRUList;
FMRUIndex := -1;
Self.ClientWidth := dialogSettings.Width; Self.ClientWidth := dialogSettings.Width;
Self.ClientHeight := dialogSettings.Height; Self.ClientHeight := dialogSettings.Height;
finally finally
@ -311,8 +522,14 @@ begin
dialogSettings.IncludeDataModules := chkForms.Checked; dialogSettings.IncludeDataModules := chkForms.Checked;
dialogSettings.IncludeForms := chkDataModules.Checked; dialogSettings.IncludeForms := chkDataModules.Checked;
dialogSettings.IncludeUnits := chkUnits.Checked;
dialogSettings.IncludeProjectSource := chkProjectSource.Checked; dialogSettings.IncludeProjectSource := chkProjectSource.Checked;
if actSortByName.Checked then
dialogSettings.Sort := dsName
else
dialogSettings.Sort := dsType;
dialogSettings.Width := Self.ClientWidth; dialogSettings.Width := Self.ClientWidth;
dialogSettings.Height := Self.ClientHeight; dialogSettings.Height := Self.ClientHeight;
@ -325,6 +542,81 @@ begin
lstUnits.SelectAll(); lstUnits.SelectAll();
end; end;
procedure TfrmUnSwDialog.actSelectInvertExecute(Sender: TObject);
var
iItem: Integer;
begin
for iItem := Pred(lstUnits.Count) downto 0 do
lstUnits.Selected[iItem] := not lstUnits.Selected[iItem];
end;
procedure TfrmUnSwDialog.SortExecute(Sender: TObject);
begin
(Sender as TAction).Checked := True;
UpdateTypeFilter();
end;
procedure TfrmUnSwDialog.SelectMRUItem();
begin
if (FMRUIndex < -1) or (FMRUIndex > Pred(FMRUList.Count)) then
exit;
if FMRUIndex = -1 then
edtSearch.Text := ''
else
edtSearch.Text := FMRUList[FMRUIndex];
ActiveControl := edtSearch;
edtSearch.SelectAll();
end;
procedure TfrmUnSwDialog.actMRUNextExecute(Sender: TObject);
begin
if FMRUIndex < Pred(FMRUList.Count) then
Inc(FMRUIndex);
SelectMRUItem();
end;
procedure TfrmUnSwDialog.actMRUPriorExecute(Sender: TObject);
begin
if FMRUIndex >= -1 then
Dec(FMRUIndex);
SelectMRUItem();
end;
procedure TfrmUnSwDialog.actOpenFolderExecute(Sender: TObject);
var
pUnits: TUnSwUnitList;
begin
pUnits := GetActiveUnits();
if Assigned(pUnits) then
try
pUnits.AcceptVisitor(TUnSwOpenFolderVisitor.Create());
finally
FreeAndNil(pUnits);
end;
end;
procedure TfrmUnSwDialog.actOpenPropertiesExecute(Sender: TObject);
var
pUnits: TUnSwUnitList;
begin
pUnits := GetActiveUnits();
if Assigned(pUnits) then
try
pUnits.AcceptVisitor(TUnSwOpenPropertiesVisitor.Create());
finally
FreeAndNil(pUnits);
end;
end;
procedure TfrmUnSwDialog.btnConfigurationClick(Sender: TObject); procedure TfrmUnSwDialog.btnConfigurationClick(Sender: TObject);
begin begin
if TfrmUnSwConfiguration.Execute() then if TfrmUnSwConfiguration.Execute() then
@ -341,7 +633,7 @@ procedure TfrmUnSwDialog.edtSearchKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState); Shift: TShiftState);
begin begin
if ((Shift = []) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) or if ((Shift = []) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) or
((Shift = [ssCtrl]) and (Key in [VK_UP, VK_DOWN, VK_HOME, VK_END])) or ((Shift = [ssCtrl]) and (Key in [VK_HOME, VK_END])) or
((Shift = [ssShift]) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) then ((Shift = [ssShift]) and (Key in [VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT])) then
lstUnits.Perform(WM_KEYDOWN, Key, 0); lstUnits.Perform(WM_KEYDOWN, Key, 0);
end; end;

View File

@ -8,6 +8,7 @@ unit UnSwSettings;
interface interface
uses uses
Classes,
Graphics, Graphics,
Registry; Registry;
@ -28,6 +29,8 @@ type
procedure WriteColor(const ARegistry: TRegistry; const AValue: TColor; const AName: String); procedure WriteColor(const ARegistry: TRegistry; const AValue: TColor; const AName: String);
end; end;
TUnSwDialogSort = (dsName, dsType);
TUnSwDialogSettings = class(TUnSwBaseSettings) TUnSwDialogSettings = class(TUnSwBaseSettings)
private private
FHeight: Integer; FHeight: Integer;
@ -35,7 +38,9 @@ type
FIncludeForms: Boolean; FIncludeForms: Boolean;
FIncludeProjectSource: Boolean; FIncludeProjectSource: Boolean;
FIncludeUnits: Boolean; FIncludeUnits: Boolean;
FMRUList: TStrings;
FPrefix: String; FPrefix: String;
FSort: TUnSwDialogSort;
FWidth: Integer; FWidth: Integer;
protected protected
function GetKeyName(const AName: String): String; override; function GetKeyName(const AName: String): String; override;
@ -43,12 +48,15 @@ type
procedure Save(const ARegistry: TRegistry); override; procedure Save(const ARegistry: TRegistry); override;
public public
constructor Create(const APrefix: String); constructor Create(const APrefix: String);
destructor Destroy(); override;
property Height: Integer read FHeight write FHeight; property Height: Integer read FHeight write FHeight;
property IncludeDataModules: Boolean read FIncludeDataModules write FIncludeDataModules; property IncludeDataModules: Boolean read FIncludeDataModules write FIncludeDataModules;
property IncludeForms: Boolean read FIncludeForms write FIncludeForms; property IncludeForms: Boolean read FIncludeForms write FIncludeForms;
property IncludeProjectSource: Boolean read FIncludeProjectSource write FIncludeProjectSource; property IncludeProjectSource: Boolean read FIncludeProjectSource write FIncludeProjectSource;
property IncludeUnits: Boolean read FIncludeUnits write FIncludeUnits; property IncludeUnits: Boolean read FIncludeUnits write FIncludeUnits;
property MRUList: TStrings read FMRUList write FMRUList;
property Sort: TUnSwDialogSort read FSort write FSort;
property Width: Integer read FWidth write FWidth; property Width: Integer read FWidth write FWidth;
end; end;
@ -170,7 +178,17 @@ constructor TUnSwDialogSettings.Create(const APrefix: String);
begin begin
inherited Create(); inherited Create();
FPrefix := APrefix; FMRUList := TStringList.Create();
FPrefix := APrefix;
TStringList(FMRUList).CaseSensitive := False
end;
destructor TUnSwDialogSettings.Destroy();
begin
FreeAndNil(FMRUList);
inherited;
end; end;
@ -180,6 +198,11 @@ begin
end; end;
procedure TUnSwDialogSettings.Load(const ARegistry: TRegistry); procedure TUnSwDialogSettings.Load(const ARegistry: TRegistry);
var
eSort: TUnSwDialogSort;
iSort: Integer absolute eSort;
sMRU: String;
begin begin
// Conversion v0.1 -> v0.2 // Conversion v0.1 -> v0.2
if ARegistry.ValueExists('IncludeDataModules') then if ARegistry.ValueExists('IncludeDataModules') then
@ -202,17 +225,44 @@ begin
ReadIntegerDef(ARegistry, FWidth, 'Width'); ReadIntegerDef(ARegistry, FWidth, 'Width');
ReadIntegerDef(ARegistry, FHeight, 'Height'); ReadIntegerDef(ARegistry, FHeight, 'Height');
// The 'absolute' acts as an implicit typecast
eSort := FSort;
ReadIntegerDef(ARegistry, iSort, 'Sort');
FSort := eSort;
if ARegistry.ValueExists('MRU') then
begin
SetLength(sMRU, ARegistry.GetDataSize('MRU'));
if Length(sMRU) > 0 then
begin
ARegistry.ReadBinaryData('MRU', PChar(sMRU)^, Length(sMRU));
FMRUList.Text := sMRU;
end;
end;
end; end;
procedure TUnSwDialogSettings.Save(const ARegistry: TRegistry); procedure TUnSwDialogSettings.Save(const ARegistry: TRegistry);
var
sMRU: String;
begin begin
WriteBool(ARegistry, FIncludeDataModules, 'IncludeDataModules'); WriteBool(ARegistry, FIncludeDataModules, 'IncludeDataModules');
WriteBool(ARegistry, FIncludeForms, 'IncludeForms'); WriteBool(ARegistry, FIncludeForms, 'IncludeForms');
WriteBool(ARegistry, FIncludeProjectSource, 'IncludeProjectSource'); WriteBool(ARegistry, FIncludeProjectSource, 'IncludeProjectSource');
WriteBool(ARegistry, FIncludeUnits, 'IncludeUnits'); WriteBool(ARegistry, FIncludeUnits, 'IncludeUnits');
WriteInteger(ARegistry, FWidth, 'Width'); WriteInteger(ARegistry, FWidth, 'Width');
WriteInteger(ARegistry, FHeight, 'Height'); WriteInteger(ARegistry, FHeight, 'Height');
WriteInteger(ARegistry, Integer(FSort), 'Sort');
if FMRUList.Count > 0 then
begin
sMRU := FMRUList.Text;
ARegistry.WriteBinaryData('MRU', PChar(sMRU)^, Length(sMRU));
end else
ARegistry.DeleteValue('MRU');
end; end;
@ -267,6 +317,7 @@ procedure TUnSwSettings.ResetDefaults();
ADialog.IncludeForms := True; ADialog.IncludeForms := True;
ADialog.IncludeProjectSource := True; ADialog.IncludeProjectSource := True;
ADialog.IncludeUnits := True; ADialog.IncludeUnits := True;
ADialog.Sort := dsName;
ADialog.Width := 300; ADialog.Width := 300;
ADialog.Height := 425; ADialog.Height := 425;
end; end;