Check-in [1aa1fecbe6]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Changed order of columns (filename, path, status, type)
Timelines: family | ancestors | descendants | both | lazarus
Files: files | file ages | folders
SHA1:1aa1fecbe6f277fbc73777c310e37289ac99b215
User & Date: tinus 2014-08-10 14:43:36
Context
2014-08-10
14:56
Prevent list index out of bound. Added filetype column contents. check-in: 6e73d56796 user: tinus tags: lazarus
14:43
Changed order of columns (filename, path, status, type) check-in: 1aa1fecbe6 user: tinus tags: lazarus
14:25
Annotation syntax highlighter now delegates the file's contents to the appropriate syntax highlighter. check-in: 8464715270 user: tinus tags: lazarus
Changes

Changes to src/a_filelist.lfm.

19
20
21
22
23
24
25





26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
    Color = clWindow
    Columns = <    
      item
        Caption = 'Name'
        MinWidth = 50
        Width = 150
      end    





      item
        Caption = 'Status'
        Width = 20
      end    
      item
        Caption = 'Path'
        ImageIndex = 11
        Width = 342
      end    
      item
        Visible = False
        Width = 1
      end>
    HideSelection = False
    Items.LazData = {
      B00000000300000009000000FFFFFFFFFFFFFFFF020000000C000000665F636F
      6D6D69742E6C666D03000000334B42050000007372632F6102000000FFFFFFFF
      FFFFFFFF020000000900000050616C656F2E6C70690400000032354B42070000
      007372632F70726A09000000FFFFFFFFFFFFFFFF020000000C000000665F636F
      6D6D69742E70617303000000354D42050000007372632F7AFFFFFFFFFFFFFFFF

      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    }
    MultiSelect = True
    ReadOnly = True
    RowSelect = True
    ScrollBars = ssAutoBoth
    SmallImages = modMain.imlFileStatuses
    SortColumn = 2
    SortType = stBoth
    TabOrder = 0
    ViewStyle = vsReport
    OnColumnClick = lvwFilesColumnClick
    OnCompare = lvwFilesCompare
    OnItemChecked = lvwFilesItemChecked
    OnKeyPress = lvwFilesKeyPress
................................................................................
    EdgeBorders = []
    EdgeInner = esNone
    EdgeOuter = esNone
    Images = modMain.imlMain
    TabOrder = 1
    object chkAll: TCheckBox
      Left = 1
      Height = 21
      Top = 0
      Width = 21
      OnChange = chkAllChange
      State = cbGrayed
      TabOrder = 0
    end
    object btnSep1: TToolButton
      Left = 22
      Top = 0
      Width = 5
      Style = tbsDivider
    end
    object btnStatus: TToolButton
      Left = 27
      Top = 0
      AllowAllUp = True
      Caption = 'Status'
      DropdownMenu = pumStatus
      ImageIndex = 7
      OnClick = btnStatusClick
      ShowCaption = False
      Style = tbsDropDown
    end
    object btnSep3: TToolButton
      Left = 220
      Top = 0
      Width = 5
      Style = tbsDivider
    end
    object btnRefresh: TToolButton
      Left = 225
      Hint = 'Refresh'
      Top = 0
      Caption = 'Refresh'
      ImageIndex = 6
      OnClick = btnRefreshClick
    end
    object edtFilter: TEdit
      AnchorSideRight.Control = btnSep3
      Left = 67
      Height = 27
      Top = 0
      Width = 153
      OnChange = edtFilterChange
      TabOrder = 1
    end
    object btnSep2: TToolButton
      Left = 62
      Top = 0
      Width = 5
      Caption = 'btnSep2'
      Style = tbsDivider
    end
  end
  object pumStatus: TPopupMenu







>
>
>
>
>





|
<
<
<
<
<
<



|
|
|
|
|
>
|






|







 







|

|





|





|










|





|








|
|






|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36






37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
    Color = clWindow
    Columns = <    
      item
        Caption = 'Name'
        MinWidth = 50
        Width = 150
      end    
      item
        Caption = 'Path'
        ImageIndex = 11
        Width = 150
      end    
      item
        Caption = 'Status'
        Width = 20
      end    
      item
        Caption = 'Type'






      end>
    HideSelection = False
    Items.LazData = {
      DA0000000300000009000000FFFFFFFFFFFFFFFF030000000C000000665F636F
      6D6D69742E6C666D050000007372632F61050000004558545241040000002E6C
      666D02000000FFFFFFFFFFFFFFFF030000000900000050616C656F2E6C706907
      0000007372632F70726A06000000454449544544040000002E6C706909000000
      FFFFFFFFFFFFFFFF030000000C000000665F636F6D6D69742E70617305000000
      7372632F7A050000004558545241040000002E706173FFFFFFFFFFFFFFFFFFFF
      FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
    }
    MultiSelect = True
    ReadOnly = True
    RowSelect = True
    ScrollBars = ssAutoBoth
    SmallImages = modMain.imlFileStatuses
    SortColumn = 1
    SortType = stBoth
    TabOrder = 0
    ViewStyle = vsReport
    OnColumnClick = lvwFilesColumnClick
    OnCompare = lvwFilesCompare
    OnItemChecked = lvwFilesItemChecked
    OnKeyPress = lvwFilesKeyPress
................................................................................
    EdgeBorders = []
    EdgeInner = esNone
    EdgeOuter = esNone
    Images = modMain.imlMain
    TabOrder = 1
    object chkAll: TCheckBox
      Left = 1
      Height = 18
      Top = 0
      Width = 20
      OnChange = chkAllChange
      State = cbGrayed
      TabOrder = 0
    end
    object btnSep1: TToolButton
      Left = 21
      Top = 0
      Width = 5
      Style = tbsDivider
    end
    object btnStatus: TToolButton
      Left = 26
      Top = 0
      AllowAllUp = True
      Caption = 'Status'
      DropdownMenu = pumStatus
      ImageIndex = 7
      OnClick = btnStatusClick
      ShowCaption = False
      Style = tbsDropDown
    end
    object btnSep3: TToolButton
      Left = 219
      Top = 0
      Width = 5
      Style = tbsDivider
    end
    object btnRefresh: TToolButton
      Left = 224
      Hint = 'Refresh'
      Top = 0
      Caption = 'Refresh'
      ImageIndex = 6
      OnClick = btnRefreshClick
    end
    object edtFilter: TEdit
      AnchorSideRight.Control = btnSep3
      Left = 66
      Height = 22
      Top = 0
      Width = 153
      OnChange = edtFilterChange
      TabOrder = 1
    end
    object btnSep2: TToolButton
      Left = 61
      Top = 0
      Width = 5
      Caption = 'btnSep2'
      Style = tbsDivider
    end
  end
  object pumStatus: TPopupMenu

Changes to src/a_filelist.pas.

71
72
73
74
75
76
77

78
79
80
81
82
83
84
..
90
91
92
93
94
95
96





97
98
99
100
101
102
103
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
...
176
177
178
179
180
181
182

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
...
201
202
203
204
205
206
207
208
209

210
211
212
213
214
215
216
...
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283








284
285
286
287
288
289
290
    procedure LoadCheckedFiles(const Files: TFossilFileList);

    property DisplayStatuses: TFileStatuses read FDisplayStatuses write SetStatuses;
    property Revision: TFossilRevision      read FRevision        write SetRevision;
  published
    property OnSelectionChanged: TFileSelectionEvent  read FOnSelectionChanged  write FOnSelectionChanged;
  end;


implementation
uses
  Graphics, Math, StrUtils;

{$R *.lfm}

................................................................................
  cSortDescending: string = '▲';
  cSortDirection: array[TSortDirection] of string = ('▼', '▲');
  {$ELSE}
  cSortAscending: string = '▾';
  cSortDescending: string = '▴';
  cSortDirection: array[TSortDirection] of string = ('▾', '▴');
  {$ENDIF}






{ TfraFileList }

constructor TfraFileList.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FCompareFileNames := cFileNameComparer[FileNameCaseSensitive];
................................................................................
begin
  inherited Destroy;
end;

procedure TfraFileList.PopulateList(ForceReload: Boolean = False);
const
  {$IFDEF MSWINDOWS}
  ResizableCols: set of Byte = [0,2]; // don't resize the status column; that's an icon
  ExtraColWidths: array[0..2] of Byte = (20 + 20, 0, 0);
  {$ELSE}
  ResizableCols: set of Byte = [0,1,2]; // other platforms don't show the icon
  ExtraColWidths: array[0..2] of Byte = (20, 20, 0);
  {$ENDIF}
var
  PrevStates: TFossilFileStates;
  Item: TListItem;
  FocusedFile: string;
  Checked, Unchecked: Boolean;
  SelectedFiles: TStringList;
  i: Integer;
  oFile: TFileVersion;
  Bmp: TBitmap;
  ColWidths: array of Integer;
begin
  Bmp := TBitmap.Create;
  try
    Bmp.Canvas.Font.Assign(lvwFiles.Font);
................................................................................
        // Repopulate the listview
        for i := 0 to FRevision.Files.Count - 1 do begin
          oFile := FRevision.Files[i];
          if DoFilter(oFile) then begin
            Item := lvwFiles.Items.Add;
            Item.Data := Pointer(oFile);
            Item.Caption := oFile.Filename;

            {$IFDEF MSWINDOWS}
            Item.ImageIndex := -1; // TODO: add file type icon to image list, and use that
            Item.SubItemImages[
              Item.SubItems.Add(oFile.Status)
            ] := modMain.ImageIndexFromStatuses(oFile.Statuses);
            {$ELSE}
            Item.ImageIndex := modMain.ImageIndexFromStatuses(oFile.Statuses);
            Item.SubItems.Add(oFile.Status);
            {$ENDIF}
            Item.SubItems.Add(oFile.Path);

            if SelectedFiles.IndexOf(oFile.FullName) > -1 then begin
              Item.Selected := True;
              // TODO: test if the event triggers or not, otherwise trigger it ourselves
            end;
            if oFile.Selected then begin
              Item.Checked := True;
................................................................................
            end else begin
              Unchecked := True;
            end;
            if SameFileName(oFile.FullName, FocusedFile) then
              lvwFiles.ItemFocused := Item;

            ColWidths[0] := Max(ColWidths[0], Bmp.Canvas.TextWidth(Item.Caption));
            ColWidths[1] := Max(ColWidths[1], Bmp.Canvas.TextWidth(Item.SubItems[0]));
            ColWidths[2] := Max(ColWidths[2], Bmp.Canvas.TextWidth(Item.SubItems[1]));

          end;
        end {for};

        for i := 0 to lvwFiles.ColumnCount - 1 do begin
          if i in ResizableCols then begin
            if i = 0 then // that column also harbours the icon and the checkbox
              lvwFiles.Column[i].Width := ColWidths[i] + 20 + 20 + 4
................................................................................
  end else if Item2.Data = nil then begin
    Compare := 1;
    Exit;
  end;
  File1 := TFileVersion(Item1.Data);
  File2 := TFileVersion(Item2.Data);
  case lvwFiles.SortColumn of
    0: begin
      Compare := FCompareFileNames(File1.Filename, File2.Filename);
    end;
    1: begin // file status
      Compare := CompareStr(File1.Status, File2.Status);
    end;
    2: begin // path (+ name)
      Compare := FCompareFileNames(File1.Path, File2.Path);
      if Compare = 0 then
         Compare := FCompareFileNames(File1.Filename, File2.Filename);








    end;
  end;
  if lvwFiles.SortDirection = sdDescending then
     Compare := -Compare;
end;

procedure TfraFileList.lvwFilesItemChecked(Sender: TObject; Item: TListItem);







>







 







>
>
>
>
>







 







|
<

|
<







|







 







>









<







 







|
|
>







 







|


|


|



>
>
>
>
>
>
>
>







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
114
115
116
117
118
119
120
121

122
123

124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

197
198
199
200
201
202
203
...
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
...
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
    procedure LoadCheckedFiles(const Files: TFossilFileList);

    property DisplayStatuses: TFileStatuses read FDisplayStatuses write SetStatuses;
    property Revision: TFossilRevision      read FRevision        write SetRevision;
  published
    property OnSelectionChanged: TFileSelectionEvent  read FOnSelectionChanged  write FOnSelectionChanged;
  end;


implementation
uses
  Graphics, Math, StrUtils;

{$R *.lfm}

................................................................................
  cSortDescending: string = '▲';
  cSortDirection: array[TSortDirection] of string = ('▼', '▲');
  {$ELSE}
  cSortAscending: string = '▾';
  cSortDescending: string = '▴';
  cSortDirection: array[TSortDirection] of string = ('▾', '▴');
  {$ENDIF}

  cColFilename = 0;
  cColPath = 1;
  cColStatus = 2;
  cColType = 3;

{ TfraFileList }

constructor TfraFileList.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FCompareFileNames := cFileNameComparer[FileNameCaseSensitive];
................................................................................
begin
  inherited Destroy;
end;

procedure TfraFileList.PopulateList(ForceReload: Boolean = False);
const
  {$IFDEF MSWINDOWS}
  ResizableCols: set of Byte = [cColFilename,cColPath,cColType]; // don't resize the status column; that's an icon

  {$ELSE}
  ResizableCols: set of Byte = [cColFilename,cColPath,cColStatus, cColType]; // other platforms don't show the icon

  {$ENDIF}
var
  PrevStates: TFossilFileStates;
  Item: TListItem;
  FocusedFile: string;
  Checked, Unchecked: Boolean;
  SelectedFiles: TStringList;
  i, ci: Integer;
  oFile: TFileVersion;
  Bmp: TBitmap;
  ColWidths: array of Integer;
begin
  Bmp := TBitmap.Create;
  try
    Bmp.Canvas.Font.Assign(lvwFiles.Font);
................................................................................
        // Repopulate the listview
        for i := 0 to FRevision.Files.Count - 1 do begin
          oFile := FRevision.Files[i];
          if DoFilter(oFile) then begin
            Item := lvwFiles.Items.Add;
            Item.Data := Pointer(oFile);
            Item.Caption := oFile.Filename;
            Item.SubItems.Add(oFile.Path);
            {$IFDEF MSWINDOWS}
            Item.ImageIndex := -1; // TODO: add file type icon to image list, and use that
            Item.SubItemImages[
              Item.SubItems.Add(oFile.Status)
            ] := modMain.ImageIndexFromStatuses(oFile.Statuses);
            {$ELSE}
            Item.ImageIndex := modMain.ImageIndexFromStatuses(oFile.Statuses);
            Item.SubItems.Add(oFile.Status);
            {$ENDIF}


            if SelectedFiles.IndexOf(oFile.FullName) > -1 then begin
              Item.Selected := True;
              // TODO: test if the event triggers or not, otherwise trigger it ourselves
            end;
            if oFile.Selected then begin
              Item.Checked := True;
................................................................................
            end else begin
              Unchecked := True;
            end;
            if SameFileName(oFile.FullName, FocusedFile) then
              lvwFiles.ItemFocused := Item;

            ColWidths[0] := Max(ColWidths[0], Bmp.Canvas.TextWidth(Item.Caption));
            for ci := 1 to High(ColWidths) do begin
              ColWidths[ci] := Max(ColWidths[ci], Bmp.Canvas.TextWidth(Item.SubItems[ci - 1]));
            end;
          end;
        end {for};

        for i := 0 to lvwFiles.ColumnCount - 1 do begin
          if i in ResizableCols then begin
            if i = 0 then // that column also harbours the icon and the checkbox
              lvwFiles.Column[i].Width := ColWidths[i] + 20 + 20 + 4
................................................................................
  end else if Item2.Data = nil then begin
    Compare := 1;
    Exit;
  end;
  File1 := TFileVersion(Item1.Data);
  File2 := TFileVersion(Item2.Data);
  case lvwFiles.SortColumn of
    cColFilename: begin
      Compare := FCompareFileNames(File1.Filename, File2.Filename);
    end;
    cColStatus: begin // file status
      Compare := CompareStr(File1.Status, File2.Status);
    end;
    cColPath: begin // path (+ name)
      Compare := FCompareFileNames(File1.Path, File2.Path);
      if Compare = 0 then
         Compare := FCompareFileNames(File1.Filename, File2.Filename);
    end;
    cColType: begin // extension, then name, then path
      Compare := FCompareFileNames(ExtractFileExt(File1.Filename), ExtractFileExt(File2.Filename));
      if Compare = 0 then begin
        Compare := FCompareFileNames(File1.Filename, File2.Filename);
        if Compare = 0 then
           Compare := FCompareFileNames(File1.Path, File2.Path);
      end;
    end;
  end;
  if lvwFiles.SortDirection = sdDescending then
     Compare := -Compare;
end;

procedure TfraFileList.lvwFilesItemChecked(Sender: TObject; Item: TListItem);

Changes to src/f_commit.lfm.

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
        Width = 250
        Align = alClient
        ClientHeight = 462
        ClientWidth = 250
        inherited lvwFiles: TListView
          Height = 436
          Width = 250
          Columns = <          
            item
              Caption = 'Name'
              MinWidth = 50
              Width = 150
            end          
            item
              Caption = 'Status'
              Width = 20
            end          
            item
              Caption = 'Path'
              ImageIndex = 11
              Width = 80
            end>
        end
        inherited tbrFiles: TToolBar
          Width = 250
          inherited btnStatus: TToolButton
            AllowAllUp = False
          end
        end
      end
    end
    object pssRight: TPairSplitterSide
      Cursor = crArrow
      Left = 255
      Height = 462







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<



<
<
<







33
34
35
36
37
38
39















40
41
42



43
44
45
46
47
48
49
        Width = 250
        Align = alClient
        ClientHeight = 462
        ClientWidth = 250
        inherited lvwFiles: TListView
          Height = 436
          Width = 250















        end
        inherited tbrFiles: TToolBar
          Width = 250



        end
      end
    end
    object pssRight: TPairSplitterSide
      Cursor = crArrow
      Left = 255
      Height = 462