Changeset 12 for trunk/UFormMain.pas


Ignore:
Timestamp:
May 5, 2014, 3:33:31 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Fixed project path replaced by directory select dialog and recent list menu.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFormMain.pas

    r11 r12  
    1919  TFormMain = class(TForm)
    2020    ACompare: TAction;
     21    AExit: TAction;
    2122    ASearch: TAction;
    2223    AShowList: TAction;
     
    2627    ActionList1: TActionList;
    2728    ImageList1: TImageList;
    28     LastOpenedList1: TLastOpenedList;
     29    LastOpenedListOpen: TLastOpenedList;
     30    LastOpenedListCompare: TLastOpenedList;
    2931    MainMenu1: TMainMenu;
    3032    Memo1: TMemo;
    3133    MenuItem1: TMenuItem;
    3234    MenuItem10: TMenuItem;
     35    MenuItemCompareRecent: TMenuItem;
    3336    MenuItem2: TMenuItem;
    3437    MenuItem3: TMenuItem;
     
    4043    MenuItem9: TMenuItem;
    4144    MenuItemOpenRecent: TMenuItem;
     45    PopupMenuCompareRecent: TPopupMenu;
     46    PopupMenuOpenRecent: TPopupMenu;
    4247    StatusBar1: TStatusBar;
    4348    ToolBar1: TToolBar;
     
    4651    ToolButton3: TToolButton;
    4752    ToolButton4: TToolButton;
     53    ToolButton5: TToolButton;
     54    ToolButton6: TToolButton;
    4855    TreeView1: TTreeView;
    4956    procedure ACompareExecute(Sender: TObject);
     57    procedure AExitExecute(Sender: TObject);
    5058    procedure AOpenDirExecute(Sender: TObject);
    5159    procedure ASearchExecute(Sender: TObject);
     
    5361    procedure AShowLogExecute(Sender: TObject);
    5462    procedure AViemSystemExecute(Sender: TObject);
    55     procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    5663    procedure FormCreate(Sender: TObject);
    5764    procedure FormDestroy(Sender: TObject);
    5865    procedure FormShow(Sender: TObject);
    59     procedure LastOpenedList1Change(Sender: TObject);
     66    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     67    procedure LastOpenedListCompareChange(Sender: TObject);
     68    procedure LastOpenedListOpenChange(Sender: TObject);
    6069    procedure MenuItemOpenRecentClick(Sender: TObject);
    6170    procedure TreeView1SelectionChanged(Sender: TObject);
     
    6372    procedure DoLog(Text: string);
    6473    procedure OpenDir(Dir: string);
     74    procedure CompareDir(Dir: string);
    6575  public
    6676    AutoOpen: Boolean;
     
    8595begin
    8696  AutoOpen := True;
    87   LastOpenedList1.LoadFromRegistry(RegContext(RootKey, RootPath));
    88   if AutoOpen and (LastOpenedList1.Items.Count > 0) then
    89     OpenDir(LastOpenedList1.Items[0])
     97  LastOpenedListOpen.LoadFromRegistry(RegContext(RootKey, RootPath + '/OpenRecent'));
     98  LastOpenedListCompare.LoadFromRegistry(RegContext(RootKey, RootPath + '/CompareRecent'));
     99  if AutoOpen and (LastOpenedListOpen.Items.Count > 0) then
     100    OpenDir(LastOpenedListOpen.Items[0])
    90101    else Reload;
    91102end;
    92103
    93 procedure TFormMain.LastOpenedList1Change(Sender: TObject);
    94 begin
    95   LastOpenedList1.LoadToMenuItem(MenuItemOpenRecent, AOpenDirExecute);
     104procedure TFormMain.LastOpenedListCompareChange(Sender: TObject);
     105begin
     106  LastOpenedListOpen.LoadToMenuItem(MenuItemCompareRecent, ACompareExecute);
     107  LastOpenedListOpen.LoadToMenuItem(PopupMenuCompareRecent.Items, ACompareExecute);
     108end;
     109
     110procedure TFormMain.LastOpenedListOpenChange(Sender: TObject);
     111begin
     112  LastOpenedListOpen.LoadToMenuItem(MenuItemOpenRecent, AOpenDirExecute);
     113  LastOpenedListOpen.LoadToMenuItem(PopupMenuOpenRecent.Items, AOpenDirExecute);
    96114end;
    97115
     
    118136begin
    119137  Config.LoadFromDir(Dir);
    120   LastOpenedList1.AddItem(Dir);
     138  LastOpenedListOpen.AddItem(Dir);
    121139  Reload;
    122140end;
    123141
    124 procedure TFormMain.Reload;
    125 var
    126   Options: TLoadTreeOptions;
    127 begin
    128   TreeView1.Items.Clear;
    129   if Assigned(Config.TopNode) then begin
    130     TreeView1.Items.AddChild(nil, Config.TopNode.GetName);
    131     Options := [];
    132     if AViemSystem.Checked then Include(Options, toShowSystem);
    133     Config.TopNode.LoadTreeNode(TreeView1.TopItem, Options);
    134     TreeView1.TopItem.Expanded := True;
    135     StatusBar1.Panels[0].Text := 'Count: ' + IntToStr(Config.TopNode.GetCount);
    136   end else begin
    137     StatusBar1.Panels[0].Text := '';
    138   end;
    139 end;
    140 
    141 procedure TFormMain.FocusTreeNode(Node: TMenuNode);
    142 var
    143   TreeNode: TTreeNode;
    144 begin
    145   TreeNode := TreeView1.Items.FindNodeWithData(Node);
    146   if Assigned(TreeNode) then begin
    147     TreeNode.Selected := True;
    148     TreeNode.ExpandParents;
    149   end;
    150 end;
    151 
    152 procedure TFormMain.AOpenDirExecute(Sender: TObject);
    153 var
    154   OutDir: string;
    155 begin
    156   if Sender is TMenuItem then begin
    157     OpenDir(TMenuItem(Sender).Caption);
    158   end;
    159   if SelectDirectory('Select Linux source directory', Config.BaseDir, OutDir) then begin
    160     OpenDir(OutDir);
    161   end;
    162 end;
    163 
    164 procedure TFormMain.ASearchExecute(Sender: TObject);
    165 begin
    166   FormSearch.Show;
    167 end;
    168 
    169 procedure TFormMain.ACompareExecute(Sender: TObject);
     142procedure TFormMain.CompareDir(Dir: string);
    170143var
    171144  List1, List2: TStringList;
     
    180153    Config2 := TConfigMenu.Create;
    181154    Config.TopNode.SaveToList(List1);
    182     Config2.LoadFromDir('/opt/elinos-D6.0/linux/linux-p4-3.0/');
     155    Config2.LoadFromDir(Dir);
    183156    Config2.TopNode.SaveToList(List2);
    184157    Config.CompareStringLists(List1, List2, Missing1, Missing2);
     
    199172end;
    200173
     174procedure TFormMain.Reload;
     175var
     176  Options: TLoadTreeOptions;
     177begin
     178  TreeView1.Items.Clear;
     179  if Assigned(Config.TopNode) then begin
     180    TreeView1.Items.AddChild(nil, Config.TopNode.GetName);
     181    Options := [];
     182    if AViemSystem.Checked then Include(Options, toShowSystem);
     183    Config.TopNode.LoadTreeNode(TreeView1.TopItem, Options);
     184    TreeView1.TopItem.Expanded := True;
     185    StatusBar1.Panels[0].Text := 'Count: ' + IntToStr(Config.TopNode.GetCount);
     186  end else begin
     187    StatusBar1.Panels[0].Text := '';
     188  end;
     189end;
     190
     191procedure TFormMain.FocusTreeNode(Node: TMenuNode);
     192var
     193  TreeNode: TTreeNode;
     194begin
     195  TreeNode := TreeView1.Items.FindNodeWithData(Node);
     196  if Assigned(TreeNode) then begin
     197    TreeNode.Selected := True;
     198    TreeNode.ExpandParents;
     199  end;
     200end;
     201
     202procedure TFormMain.AOpenDirExecute(Sender: TObject);
     203var
     204  OutDir: string;
     205begin
     206  if Sender is TMenuItem then begin
     207    OpenDir(TMenuItem(Sender).Caption);
     208  end else begin
     209    if SelectDirectory('Select Linux source directory', Config.BaseDir, OutDir) then begin
     210      OpenDir(OutDir);
     211    end;
     212  end;
     213end;
     214
     215procedure TFormMain.ASearchExecute(Sender: TObject);
     216begin
     217  FormSearch.Show;
     218end;
     219
     220procedure TFormMain.ACompareExecute(Sender: TObject);
     221var
     222  OutDir: string;
     223begin
     224  if Sender is TMenuItem then begin
     225    CompareDir(TMenuItem(Sender).Caption);
     226  end else begin
     227    if SelectDirectory('Select Linux source directory for compare', Config.BaseDir, OutDir) then begin
     228      CompareDir(OutDir);
     229    end;
     230  end;
     231end;
     232
     233procedure TFormMain.AExitExecute(Sender: TObject);
     234begin
     235  Application.Terminate;
     236end;
     237
    201238procedure TFormMain.AShowListExecute(Sender: TObject);
    202239begin
     
    217254procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    218255begin
    219   LastOpenedList1.SaveToRegistry(RegContext(RootKey, RootPath));
     256  LastOpenedListOpen.SaveToRegistry(RegContext(RootKey, RootPath + '/OpenRecent'));
     257  LastOpenedListCompare.SaveToRegistry(RegContext(RootKey, RootPath + '/CompareRecent'));
    220258end;
    221259
Note: See TracChangeset for help on using the changeset viewer.