Skip to content

Commit a361de3

Browse files
committed
DataBloky: show '---' in all irrelevant columns.
1 parent afc7f57 commit a361de3

1 file changed

Lines changed: 13 additions & 58 deletions

File tree

src/tables/DataBloky.pas

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
unit DataBloky;
22

3-
// TBlkTableData - trida resici zobrazovani tavulky bloku
3+
// TBlocksTablePainter - trida resici zobrazovani tavulky bloku
44

55
interface
66

@@ -17,16 +17,17 @@ TBlocksTablePainter = class
1717
_LVI_NOTE = 5;
1818
_LVI_LOCKOUT = 6;
1919
_LVI_TRAIN_PREDICT = 7;
20+
_LVS_IRRELEVANT = '---';
2021

2122
private
2223
LV: TListView;
23-
2424
changed: array of Boolean;
2525

2626
public
27-
2827
reload: Boolean;
2928

29+
constructor Create(LV: TListView);
30+
3031
procedure LoadTable();
3132
procedure UpdateTable();
3233
procedure UpdateLine(line: Integer);
@@ -37,7 +38,6 @@ TBlocksTablePainter = class
3738

3839
procedure BlkMove(source, target: Integer);
3940

40-
constructor Create(LV: TListView);
4141
end;
4242

4343
var
@@ -67,9 +67,9 @@ procedure TBlocksTablePainter.LoadTable();
6767
for var i := 0 to Blocks.count - 1 do
6868
begin
6969
var LI: TListItem := Self.LV.Items.Add;
70-
LI.Caption := '---';
70+
LI.Caption := _LVS_IRRELEVANT;
7171
for var j := 0 to Self.LV.Columns.count - 2 do
72-
LI.SubItems.Add('---');
72+
LI.SubItems.Add(_LVS_IRRELEVANT);
7373
end;
7474

7575
Self.reload := true;
@@ -83,12 +83,14 @@ procedure TBlocksTablePainter.UpdateTable();
8383
F_Main.L_BlkPocet.Caption := 'Celkem ' + IntToStr(Blocks.count) + ' bloků';
8484

8585
for var i := 0 to Blocks.count - 1 do
86+
begin
8687
if ((Self.changed[i]) or (Self.reload)) then
8788
begin
8889
Self.UpdateLine(i);
8990
Self.changed[i] := false;
9091
Self.LV.UpdateItems(i, i);
9192
end;
93+
end;
9294

9395
Self.reload := false;
9496
end;
@@ -138,7 +140,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
138140

139141
Self.LV.Items[line].SubItems[_LVI_NOTE] := (blk as TBlkTurnout).note;
140142
Self.LV.Items[line].SubItems[_LVI_LOCKOUT] := (blk as TBlkTurnout).lockout;
141-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
142143
end;
143144

144145
/// //////////////////////////////////////////////////
@@ -173,7 +174,7 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
173174
if ((blk as TBlkTrack).trainPredict <> nil) then
174175
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := (blk as TBlkTrack).trainPredict.name
175176
else
176-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '--#--';
177+
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '';
177178
end;
178179

179180
/// //////////////////////////////////////////////////
@@ -182,8 +183,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
182183
Self.LV.Items[line].ImageIndex := 4;
183184
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'IR';
184185

185-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
186-
187186
case ((blk as TBlkIR).occupied) of
188187
TIROccupationState.disabled:
189188
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
@@ -194,11 +193,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
194193
TIROccupationState.occupied:
195194
Self.LV.Items[line].SubItems[_LVI_STATE] := '+++';
196195
end; // case
197-
198-
Self.LV.Items[line].SubItems[_LVI_AREA] := '---';
199-
Self.LV.Items[line].SubItems[_LVI_NOTE] := '---';
200-
Self.LV.Items[line].SubItems[_LVI_LOCKOUT] := '---';
201-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
202196
end;
203197

204198
/// //////////////////////////////////////////////////
@@ -211,13 +205,7 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
211205
else
212206
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Návěstidlo';
213207

214-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
215-
216208
Self.LV.Items[line].SubItems[_LVI_STATE] := TBlkSignal.SignalToString((blk as TBlkSignal).signal);
217-
218-
Self.LV.Items[line].SubItems[_LVI_NOTE] := '---';
219-
Self.LV.Items[line].SubItems[_LVI_LOCKOUT] := '---';
220-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
221209
end;
222210

223211
/// //////////////////////////////////////////////////
@@ -226,8 +214,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
226214
Self.LV.Items[line].ImageIndex := 7;
227215
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Přejezd';
228216

229-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
230-
231217
case ((blk as TBlkCrossing).state) of
232218
TBlkCrossingBasicState.disabled:
233219
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
@@ -247,8 +233,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
247233

248234
Self.LV.Items[line].SubItems[_LVI_NOTE] := (Blk as TBlkCrossing).note;
249235
Self.LV.Items[line].SubItems[_LVI_LOCKOUT] := '';
250-
251-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
252236
end;
253237

254238
/// //////////////////////////////////////////////////
@@ -257,8 +241,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
257241
Self.LV.Items[line].ImageIndex := 8;
258242
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Trať';
259243

260-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
261-
262244
if ((blk as TBlkRailway).occupied) then
263245
begin
264246
Self.LV.Items[line].SubItems[_LVI_STATE] := 'obsazeno';
@@ -295,7 +277,7 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
295277
if (Assigned((blk as TBlkRailway).trainPredict)) then
296278
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := (blk as TBlkRailway).trainPredict.train.name
297279
else
298-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '--#--';
280+
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '';
299281
end;
300282

301283
/// //////////////////////////////////////////////////
@@ -304,15 +286,12 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
304286
Self.LV.Items[line].ImageIndex := 9;
305287
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Úvazka';
306288

307-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
308-
309289
if ((blk as TBlkLinker).enabled) then
310290
Self.LV.Items[line].SubItems[_LVI_STATE] := 'enabled'
311291
else
312292
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
313293

314294
Self.LV.Items[line].SubItems[_LVI_NOTE] := (blk as TBlkLinker).note;
315-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
316295
end;
317296

318297
/// //////////////////////////////////////////////////
@@ -321,8 +300,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
321300
Self.LV.Items[line].ImageIndex := 10;
322301
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Zámek';
323302

324-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
325-
326303
if ((blk as TBlkLock).state.enabled) then
327304
begin
328305
if ((blk as TBlkLock).keyReleased) then
@@ -334,7 +311,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
334311
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
335312

336313
Self.LV.Items[line].SubItems[_LVI_NOTE] := (blk as TBlkLock).note;
337-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
338314
end;
339315

340316
/// //////////////////////////////////////////////////
@@ -343,8 +319,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
343319
Self.LV.Items[line].ImageIndex := 11;
344320
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Rozpojovač';
345321

346-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
347-
348322
case ((blk as TBlkDisconnector).state) of
349323
TBlkDiscBasicState.disabled:
350324
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
@@ -355,7 +329,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
355329
end; // case
356330

357331
Self.LV.Items[line].SubItems[_LVI_NOTE] := (blk as TBlkDisconnector).note;
358-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
359332
end;
360333

361334
/// //////////////////////////////////////////////////
@@ -386,7 +359,7 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
386359
if ((blk as TBlkTrack).trainPredict <> nil) then
387360
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := (blk as TBlkTrack).trainPredict.name
388361
else
389-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '--#--';
362+
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '';
390363
end;
391364

392365
/// //////////////////////////////////////////////////
@@ -395,17 +368,13 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
395368
Self.LV.Items[line].ImageIndex := 12;
396369
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'IO';
397370

398-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
399-
400371
if (TBlkIO(Blk).enabled) then
401372
Self.LV.Items[line].SubItems[_LVI_STATE] := 'I: ' + ownConvert.BoolToYesNo(TBlkIO(Blk).activeInput) + ', O: ' +
402373
ownConvert.BoolToYesNo(TBlkIO(blk).activeOutput)
403374
else
404375
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
405376

406377
Self.LV.Items[line].SubItems[_LVI_NOTE] := (blk as TBlkIO).note;
407-
Self.LV.Items[line].SubItems[_LVI_LOCKOUT] := '---';
408-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
409378
end;
410379

411380
/// //////////////////////////////////////////////////
@@ -414,15 +383,10 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
414383
Self.LV.Items[line].ImageIndex := -1;
415384
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Součtová hláska';
416385

417-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
418-
419386
if ((blk as TBlkSummary).enabled) then
420387
Self.LV.Items[line].SubItems[_LVI_STATE] := 'ok'
421388
else
422389
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
423-
424-
Self.LV.Items[line].SubItems[_LVI_NOTE] := '';
425-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
426390
end;
427391

428392
/// //////////////////////////////////////////////////
@@ -431,8 +395,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
431395
Self.LV.Items[line].ImageIndex := -1;
432396
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'AC';
433397

434-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
435-
436398
if (TBlkAC(blk).enabled) then
437399
begin
438400
case (TBlkAC(blk).acState) of
@@ -451,16 +413,12 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
451413
end
452414
else
453415
Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
454-
455-
Self.LV.Items[line].SubItems[_LVI_NOTE] := '---';
456-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
457416
end;
458417

459418
btPst:
460419
begin
461420
Self.LV.Items[line].ImageIndex := -1;
462421
Self.LV.Items[line].SubItems[_LVI_TYPE] := 'Pomocné stavědlo';
463-
Self.LV.Items[line].SubItems[_LVI_TRAIN] := '---';
464422

465423
case (TBlkPst(blk).status) of
466424
pstDisabled: Self.LV.Items[line].SubItems[_LVI_STATE] := 'disabled';
@@ -469,9 +427,6 @@ procedure TBlocksTablePainter.UpdateLine(line: Integer);
469427
pstRefuging: Self.LV.Items[line].SubItems[_LVI_STATE] := 'nastavování boční ochrany...';
470428
pstActive: Self.LV.Items[line].SubItems[_LVI_STATE] := 'aktivní';
471429
end;
472-
473-
Self.LV.Items[line].SubItems[_LVI_NOTE] := '---';
474-
Self.LV.Items[line].SubItems[_LVI_TRAIN_PREDICT] := '---';
475430
end;
476431

477432
end;
@@ -499,9 +454,9 @@ procedure TBlocksTablePainter.BlkAdd(index: Integer);
499454
SetLength(changed, Length(changed) + 1);
500455

501456
var LI: TListItem := Self.LV.Items.Insert(index);
502-
LI.Caption := '---';
457+
LI.Caption := _LVS_IRRELEVANT;
503458
for var j := 0 to Self.LV.Columns.count - 2 do
504-
LI.SubItems.Add('---');
459+
LI.SubItems.Add(_LVS_IRRELEVANT);
505460
Self.UpdateLine(index);
506461

507462
F_Main.L_BlkPocet.Caption := 'Pocet bloku : ' + IntToStr(Blocks.count);

0 commit comments

Comments
 (0)