Ignore:
Timestamp:
Jul 13, 2015, 11:44:23 AM (9 years ago)
Author:
chronos
Message:
  • Added: Support for reading file status from working copy.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormBrowse.pas

    r11 r15  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ExtCtrls, Menus, ActnList, UFindFile, UVCS;
     9  ExtCtrls, Menus, ActnList, UFindFile, UVCS, Contnrs;
    1010
    1111type
     
    2323    ActionList1: TActionList;
    2424    ListView1: TListView;
     25    MainMenu1: TMainMenu;
    2526    MenuItem1: TMenuItem;
    2627    MenuItem2: TMenuItem;
     
    4647      Selected: Boolean);
    4748  private
    48     FileList: TStringList;
     49    FileList: TObjectList;
    4950  public
    5051    Directory: string;
     
    6768procedure TFormBrowse.ListView1Data(Sender: TObject; Item: TListItem);
    6869begin
    69   if (Item.Index >= 0) and (Item.Index < FileList.Count) then begin
    70     Item.Caption := ExtractFileName(FileList[Item.Index]);
     70  if (Item.Index >= 0) and (Item.Index < FileList.Count) then
     71  with TFileStatus(FileList[Item.Index]) do begin
     72    Item.Caption := ExtractFileName(FileName);
     73    if State <> fssNonVersioned then begin
     74      Item.SubItems.Add(Version);
     75      Item.SubItems.Add(DateToStr(Time));
     76      Item.SubItems.Add(Author);
     77      Item.SubItems.Add(FileStatusStateText[State]);
     78    end;
    7179  end;
    7280end;
     
    124132procedure TFormBrowse.FormCreate(Sender: TObject);
    125133begin
    126   FileList := TStringList.Create;
     134  FileList := TObjectList.Create;
    127135end;
    128136
     
    142150  FoundFileList: TStrings;
    143151  I: Integer;
    144 begin
     152  FileStatusList: TFileStatusList;
     153  NewFileItem: TFileStatus;
     154  FS: TFileStatus;
     155  RelativeName: string;
     156begin
     157  FileList.Clear;
     158  if Assigned(Core.Project) then begin
     159  FileStatusList := TFileStatusList.Create;
     160  try
     161  Core.Project.WorkingCopy.GetStatus(Directory, FileStatusList);
     162
    145163  if DirectoryExistsUTF8(Directory) then begin
    146164    FindFile := TFindFile.Create(nil);
     
    150168      FindFile.InSubFolders := False;
    151169      FoundFileList := FindFile.SearchForFiles;
    152       FileList.Assign(FoundFileList);
     170      //FoundFileList.Sort;
     171      for I := 0 to FoundFileList.Count - 1 do begin
     172        NewFileItem := TFileStatus.Create;
     173        NewFileItem.FileName := FoundFileList[I];
     174        RelativeName := NewFileItem.FileName;
     175        if Copy(RelativeName, 1, Length(Core.Project.WorkingCopy.Path)) = Core.Project.WorkingCopy.Path then
     176          Delete(RelativeName, 1, Length(Core.Project.WorkingCopy.Path));
     177        if Copy(RelativeName, 1, 1) = DirectorySeparator then
     178          Delete(RelativeName, 1, Length(DirectorySeparator));
     179        FS := FileStatusList.SearchByName(RelativeName);
     180        if Assigned(FS) then begin
     181          NewFileItem.Assign(FS);
     182        end;
     183        FileList.Add(NewFileItem);
     184      end;
    153185      for I := FileList.Count - 1 downto 0 do
    154         if ExtractFileName(FileList[I]) = '.' then FileList.Delete(I);
    155       FileList.Sort;
     186        if ExtractFileName(TFileStatus(FileList[I]).FileName) = '.' then FileList.Delete(I);
    156187      ListView1.Items.Count := FileList.Count;
    157188    finally
     
    159190    end;
    160191  end else ListView1.Items.Count := 0;
     192  finally
     193    FileStatusList.Free;
     194  end;
     195  end;
    161196  ListView1.Refresh;
    162197end;
Note: See TracChangeset for help on using the changeset viewer.