From fe432ee08830454b84f63e04c99d600d9fba72e0 Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Fri, 13 Jan 2006 20:34:45 +0000 Subject: [PATCH] Fixed: Issue #129 Fixed: Issue #131 Fixed: Issue #132 Fixed: Issue #139 Fixed: Issue #143 --- Source/UnSwConfiguration.dfm | 3 +- Source/UnSwDialog.dfm | 179 ++++++++++++++----- Source/UnSwDialog.pas | 334 ++++++++++++++++++++++++++++++++--- Source/UnSwSettings.pas | 57 +++++- 4 files changed, 505 insertions(+), 68 deletions(-) diff --git a/Source/UnSwConfiguration.dfm b/Source/UnSwConfiguration.dfm index 6aaaae4..74d2d80 100644 --- a/Source/UnSwConfiguration.dfm +++ b/Source/UnSwConfiguration.dfm @@ -259,7 +259,7 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration Top = 23 Width = 54 Height = 13 - Caption = 'Version 0.2' + Caption = 'Version 0.3' end object TLabel Left = 135 @@ -328,6 +328,7 @@ object frmUnSwConfiguration: TfrmUnSwConfiguration Height = 25 Anchors = [akRight, akBottom] Caption = 'OK' + Default = True ModalResult = 1 TabOrder = 2 end diff --git a/Source/UnSwDialog.dfm b/Source/UnSwDialog.dfm index cade155..afa139e 100644 --- a/Source/UnSwDialog.dfm +++ b/Source/UnSwDialog.dfm @@ -4,10 +4,10 @@ object frmUnSwDialog: TfrmUnSwDialog BorderIcons = [biSystemMenu] Caption = 'UnitSwitcher' ClientHeight = 398 - ClientWidth = 292 + ClientWidth = 311 Color = clBtnFace Constraints.MinHeight = 240 - Constraints.MinWidth = 270 + Constraints.MinWidth = 290 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 @@ -33,7 +33,7 @@ object frmUnSwDialog: TfrmUnSwDialog object sbStatus: TStatusBar Left = 0 Top = 379 - Width = 292 + Width = 311 Height = 19 Panels = < item @@ -43,8 +43,8 @@ object frmUnSwDialog: TfrmUnSwDialog object pnlMain: TPanel Left = 0 Top = 0 - Width = 292 - Height = 288 + Width = 311 + Height = 307 Align = alClient BevelOuter = bvNone BorderWidth = 4 @@ -52,18 +52,18 @@ object frmUnSwDialog: TfrmUnSwDialog object pnlSearch: TPanel Left = 4 Top = 4 - Width = 284 + Width = 303 Height = 25 Align = alTop BevelOuter = bvNone TabOrder = 0 DesignSize = ( - 284 + 303 25) object edtSearch: TEdit Left = 0 Top = 0 - Width = 284 + Width = 303 Height = 21 Anchors = [akLeft, akTop, akRight] TabOrder = 0 @@ -74,12 +74,13 @@ object frmUnSwDialog: TfrmUnSwDialog object lstUnits: TListBox Left = 4 Top = 29 - Width = 284 - Height = 255 + Width = 303 + Height = 274 Style = lbVirtualOwnerDraw Align = alClient ItemHeight = 20 MultiSelect = True + PopupMenu = pmnUnits TabOrder = 1 OnData = lstUnitsData OnDblClick = lstUnitsDblClick @@ -89,16 +90,16 @@ object frmUnSwDialog: TfrmUnSwDialog object pnlButtons: TPanel Left = 0 Top = 343 - Width = 292 + Width = 311 Height = 36 Align = alBottom BevelOuter = bvNone - TabOrder = 2 + TabOrder = 1 DesignSize = ( - 292 + 311 36) object btnCancel: TButton - Left = 213 + Left = 232 Top = 5 Width = 75 Height = 25 @@ -109,7 +110,7 @@ object frmUnSwDialog: TfrmUnSwDialog TabOrder = 1 end object btnOK: TButton - Left = 132 + Left = 151 Top = 5 Width = 75 Height = 25 @@ -131,38 +132,65 @@ object frmUnSwDialog: TfrmUnSwDialog end object pnlIncludeTypes: TPanel Left = 0 - Top = 288 - Width = 292 - Height = 55 + Top = 307 + Width = 311 + Height = 36 Align = alBottom BevelOuter = bvNone - TabOrder = 1 - object chkDataModules: TCheckBox - Left = 4 - Top = 19 - Width = 137 - Height = 17 - Caption = 'Show &DataModule units' - TabOrder = 1 - OnClick = TypeFilterChange - end - object chkForms: TCheckBox - Left = 4 - Top = 2 - Width = 101 - Height = 17 - Caption = 'Show &Form units' + TabOrder = 3 + object pnlIncludeUnitTypes: TPanel + Left = 149 + Top = 0 + Width = 162 + Height = 36 + Align = alClient + BevelOuter = bvNone 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 - object chkProjectSource: TCheckBox - Left = 4 - Top = 36 - Width = 121 - Height = 17 - Caption = 'Show &Project source' - TabOrder = 2 - OnClick = TypeFilterChange + object pnlIncludeFormTypes: TPanel + Left = 0 + Top = 0 + Width = 149 + Height = 36 + Align = alLeft + BevelOuter = bvNone + 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 object ilsTypes: TImageList @@ -580,5 +608,70 @@ object frmUnSwDialog: TfrmUnSwDialog ShortCut = 16449 OnExecute = actSelectAllExecute 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 diff --git a/Source/UnSwDialog.pas b/Source/UnSwDialog.pas index 3d760c2..4b737de 100644 --- a/Source/UnSwDialog.pas +++ b/Source/UnSwDialog.pas @@ -16,6 +16,7 @@ uses Forms, Graphics, ImgList, + Menus, StdCtrls, Windows, @@ -36,38 +37,65 @@ type end; TfrmUnSwDialog = class(TForm) + actMRUNext: TAction; + actMRUPrior: TAction; + actOpenFolder: TAction; + actOpenProperties: TAction; + actSelectAll: TAction; + actSelectInvert: TAction; + actSortByName: TAction; + actSortByType: TAction; + alMain: TActionList; btnCancel: TButton; btnConfiguration: TButton; btnOK: TButton; chkDataModules: TCheckBox; chkForms: TCheckBox; chkProjectSource: TCheckBox; + chkUnits: TCheckBox; edtSearch: TEdit; ilsTypes: TImageList; lstUnits: TListBox; + pmnUnits: TPopupMenu; + pmnUnitsOpenFolder: TMenuItem; + pmnUnitsOpenProperties: TMenuItem; + pmnUnitsSelectAll: TMenuItem; + pmnUnitsSelectInvert: TMenuItem; + pmnUnitsSep1: TMenuItem; + pmnUnitsSep2: TMenuItem; + pmnUnitsSortByName: TMenuItem; + pmnUnitsSortByType: TMenuItem; pnlButtons: TPanel; + pnlIncludeFormTypes: TPanel; pnlIncludeTypes: TPanel; + pnlIncludeUnitTypes: TPanel; pnlMain: TPanel; pnlSearch: TPanel; 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 edtSearchChange(Sender: TObject); procedure edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); - procedure TypeFilterChange(Sender: TObject); - procedure lstUnitsDblClick(Sender: TObject); + procedure FormResize(Sender: TObject); + procedure FormShow(Sender: TObject); procedure lstUnitsData(Control: TWinControl; Index: Integer; var Data: string); + procedure lstUnitsDblClick(Sender: TObject); procedure lstUnitsDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); + procedure SortExecute(Sender: TObject); + procedure TypeFilterChange(Sender: TObject); private FLoading: Boolean; FUnitList: TUnSwUnitList; FActiveUnit: TUnSwUnit; FFormsOnly: Boolean; + FMRUIndex: Integer; + FMRUList: TStrings; FTypeFilteredList: TUnSwUnitList; FInputFilteredList: TUnSwUnitList; @@ -82,6 +110,7 @@ type procedure UpdateList(); function GetActiveUnits(): TUnSwUnitList; + procedure SelectMRUItem(); procedure LoadSettings(); procedure SaveSettings(); @@ -94,15 +123,120 @@ type implementation uses Messages, + ShellAPI, SysUtils, UnSwConfiguration, 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} +{ 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 } procedure TUnSwStyleVisitor.VisitModule(const AUnit: TUnSwModuleUnit); begin @@ -162,12 +296,10 @@ begin UpdateTypeFilter(); end; -function SortByName(Item1, Item2: Pointer): Integer; -begin - Result := CompareText(TUnSwUnit(Item1).Name, TUnSwUnit(Item2).Name) -end; - function TfrmUnSwDialog.InternalExecute(): TUnSwUnitList; +var + iIndex: Integer; + begin Result := nil; FTypeFilteredList := TUnSwUnitList.Create(); @@ -183,15 +315,25 @@ begin if FFormsOnly then begin - pnlIncludeTypes.Visible := False; - Self.Caption := 'UnitSwitcher - View Form'; + pnlIncludeUnitTypes.Visible := False; + Self.Caption := 'UnitSwitcher - View Form'; end else - Self.Caption := 'UnitSwitcher - View Unit'; + Self.Caption := 'UnitSwitcher - View Unit'; FStyleVisitor := TUnSwStyleVisitor.Create(); try 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(); + end; SaveSettings(); finally @@ -234,21 +376,81 @@ begin end; finally FreeAndNil(activeUnits); - end else + end; + + if lstUnits.SelCount = 0 then lstUnits.Selected[0] := True; 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(); begin - FTypeFilter.IncludeUnits := not FFormsOnly; - FTypeFilter.IncludeForms := (FFormsOnly or chkForms.Checked); - FTypeFilter.IncludeDataModules := (FFormsOnly or chkDataModules.Checked); + FTypeFilter.IncludeUnits := ((not FFormsOnly) and chkUnits.Checked); FTypeFilter.IncludeProjectSource := ((not FFormsOnly) and chkProjectSource.Checked); + FTypeFilter.IncludeForms := chkForms.Checked; + FTypeFilter.IncludeDataModules := chkDataModules.Checked; FTypeFilteredList.Clone(FUnitList); FTypeFilteredList.AcceptVisitor(FTypeFilter); - FTypeFilteredList.Sort(SortByName); + + if actSortByName.Checked then + FTypeFilteredList.Sort(SortByName) + else + FTypeFilteredList.Sort(SortByType); + UpdateList(); end; @@ -290,8 +492,17 @@ begin try chkDataModules.Checked := dialogSettings.IncludeDataModules; chkForms.Checked := dialogSettings.IncludeForms; + chkUnits.Checked := dialogSettings.IncludeUnits; 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.ClientHeight := dialogSettings.Height; finally @@ -311,8 +522,14 @@ begin dialogSettings.IncludeDataModules := chkForms.Checked; dialogSettings.IncludeForms := chkDataModules.Checked; + dialogSettings.IncludeUnits := chkUnits.Checked; dialogSettings.IncludeProjectSource := chkProjectSource.Checked; + if actSortByName.Checked then + dialogSettings.Sort := dsName + else + dialogSettings.Sort := dsType; + dialogSettings.Width := Self.ClientWidth; dialogSettings.Height := Self.ClientHeight; @@ -325,6 +542,81 @@ begin lstUnits.SelectAll(); 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); begin if TfrmUnSwConfiguration.Execute() then @@ -341,7 +633,7 @@ procedure TfrmUnSwDialog.edtSearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin 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 lstUnits.Perform(WM_KEYDOWN, Key, 0); end; diff --git a/Source/UnSwSettings.pas b/Source/UnSwSettings.pas index 2f85439..ea95256 100644 --- a/Source/UnSwSettings.pas +++ b/Source/UnSwSettings.pas @@ -8,6 +8,7 @@ unit UnSwSettings; interface uses + Classes, Graphics, Registry; @@ -28,6 +29,8 @@ type procedure WriteColor(const ARegistry: TRegistry; const AValue: TColor; const AName: String); end; + TUnSwDialogSort = (dsName, dsType); + TUnSwDialogSettings = class(TUnSwBaseSettings) private FHeight: Integer; @@ -35,7 +38,9 @@ type FIncludeForms: Boolean; FIncludeProjectSource: Boolean; FIncludeUnits: Boolean; + FMRUList: TStrings; FPrefix: String; + FSort: TUnSwDialogSort; FWidth: Integer; protected function GetKeyName(const AName: String): String; override; @@ -43,12 +48,15 @@ type procedure Save(const ARegistry: TRegistry); override; public constructor Create(const APrefix: String); + destructor Destroy(); override; property Height: Integer read FHeight write FHeight; property IncludeDataModules: Boolean read FIncludeDataModules write FIncludeDataModules; property IncludeForms: Boolean read FIncludeForms write FIncludeForms; property IncludeProjectSource: Boolean read FIncludeProjectSource write FIncludeProjectSource; 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; end; @@ -170,7 +178,17 @@ constructor TUnSwDialogSettings.Create(const APrefix: String); begin inherited Create(); - FPrefix := APrefix; + FMRUList := TStringList.Create(); + FPrefix := APrefix; + + TStringList(FMRUList).CaseSensitive := False +end; + +destructor TUnSwDialogSettings.Destroy(); +begin + FreeAndNil(FMRUList); + + inherited; end; @@ -180,6 +198,11 @@ begin end; procedure TUnSwDialogSettings.Load(const ARegistry: TRegistry); +var + eSort: TUnSwDialogSort; + iSort: Integer absolute eSort; + sMRU: String; + begin // Conversion v0.1 -> v0.2 if ARegistry.ValueExists('IncludeDataModules') then @@ -202,17 +225,44 @@ begin ReadIntegerDef(ARegistry, FWidth, 'Width'); 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; procedure TUnSwDialogSettings.Save(const ARegistry: TRegistry); +var + sMRU: String; + begin WriteBool(ARegistry, FIncludeDataModules, 'IncludeDataModules'); WriteBool(ARegistry, FIncludeForms, 'IncludeForms'); WriteBool(ARegistry, FIncludeProjectSource, 'IncludeProjectSource'); WriteBool(ARegistry, FIncludeUnits, 'IncludeUnits'); - WriteInteger(ARegistry, FWidth, 'Width'); - WriteInteger(ARegistry, FHeight, 'Height'); + WriteInteger(ARegistry, FWidth, 'Width'); + 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; @@ -267,6 +317,7 @@ procedure TUnSwSettings.ResetDefaults(); ADialog.IncludeForms := True; ADialog.IncludeProjectSource := True; ADialog.IncludeUnits := True; + ADialog.Sort := dsName; ADialog.Width := 300; ADialog.Height := 425; end;