~ubuntu-branches/ubuntu/vivid/ddrescueview/vivid-backports

« back to all changes in this revision

Viewing changes to source/BlockInspector.pas

  • Committer: Package Import Robot
  • Author(s): Graham Inggs
  • Date: 2015-06-02 12:30:03 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150602123003-vq5snysd2m5i20ek
Tags: 0.4~alpha2-1
* New upstream release
* Update d/rules, d/watch since upstream now ship an xz-compressed tarball
* Drop d/patches/linker-options.patch included upstream
* Drop manpage, desktop file and xpm icon since these files are now shipped
  by upstream, update d/ddrecueview.install, d/manpages accordingly
* Add build-depends on libgtk2.0-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    BottomPanel: TPanel;
52
52
    TopPanel: TPanel;
53
53
    CloseBIButton: TButton;
54
 
    BlockHeadline: TLabel;
 
54
    lblBlockHeadline: TLabel;
55
55
    LogEntryList: TStringGrid;
56
56
    TrackCurrentCheckBox: TCheckBox;
57
57
    procedure BlockEditChange(Sender: TObject);
 
58
    procedure FormHide(Sender: TObject);
 
59
    procedure FormShow(Sender: TObject);
 
60
    procedure lblBlockHeadlineDblClick(Sender: TObject);
58
61
    procedure LogEntryListHeaderSized(Sender: TObject; IsColumn: Boolean; Index: Integer);
59
62
    procedure CloseBIButtonClick(Sender: TObject);
60
63
    procedure FormCreate(Sender: TObject);
61
64
    procedure FormDestroy(Sender: TObject);
 
65
    procedure TrackCurrentCheckBoxChange(Sender: TObject);
62
66
  private
63
67
    FBlock : integer;
64
68
    FParser : TLogParser;
92
96
  FGridBlockStore:=nil;
93
97
end;
94
98
 
 
99
procedure TBlockForm.TrackCurrentCheckBoxChange(Sender: TObject);
 
100
begin
 
101
  if TrackCurrentCheckBox.Checked then DoUpdate(false);
 
102
end;
 
103
 
95
104
Procedure TBlockForm.FPOObservedChanged(ASender : TObject;
96
105
  Operation : TFPObservedOperation; Data : Pointer);
97
106
begin
100
109
  end;
101
110
end;
102
111
 
 
112
// public method to set the block. Called from the Main GUI.
 
113
// this is not called when the BI is notified.
103
114
procedure TBlockForm.SetBlock(block : integer);
104
115
var
105
 
  activeblock, numBlocks : Longint;
 
116
  numBlocks : Longint;
 
117
  activeblock : Int64;
106
118
begin
107
119
  activeblock := FGridBlockStore.activeBlock();
108
 
  numBlocks := FGridBlockStore.numBlocks;
109
 
  FBlock := max(0, min(block, numBlocks));
110
 
  // Disable Cur. Pos. tracking if requested block is not active block
111
 
  // or is outside of zooming bounds
112
 
  if (FBlock <> activeblock) or (activeblock < 0) or (activeBlock >= numBlocks) then
113
 
     TrackCurrentCheckBox.Checked:=false;
 
120
  numBlocks := FGridBlockStore.NumBlocks;
 
121
  FBlock := max(0, min(block, numBlocks));  // sanitize to bounds
 
122
  // Disable Cur. Pos. tracking if requested, sanitized block is not active block
 
123
  if (FBlock <> activeblock) then TrackCurrentCheckBox.Checked:=false;
114
124
  // update the Form, clear the user's list selection
115
125
  DoUpdate(true);
116
126
end;
121
131
   the first item. *)
122
132
procedure TBlockForm.DoUpdate(clearSel : boolean);
123
133
var
124
 
  imgStartBlock, imgEndBlock, logEntry, logLen, row : Longint;
125
 
  bStart, bEnd, leStart, leEnd, overlap : Int64;
 
134
  logEntry, logLen, row : Longint;
 
135
  actblock, bStart, bEnd, leStart, leEnd, overlap : Int64;
126
136
  rs : TRescueStatus; // only for counting sectors here
127
137
  BlockEditChangeEvent : TNotifyEvent;
128
138
begin
129
139
  with FGridBlockStore do begin
130
140
    // check if file is open
131
 
    if not Assigned(DataSource) or not DataSource.hasFile() then begin
 
141
    if not Assigned(Parser) or not Parser.hasFile() then begin
132
142
      LogEntryList.RowCount:=1; // clear LogEntryList
133
143
      Hide;  // close BI window
134
144
      exit;
135
145
    end;
136
146
 
137
 
    // set the spinEdit bounds
 
147
    FBlock := EnsureRange(block, 0, NumBlocks-1);  // sanitize to bounds
 
148
    // adjust FBlock if current pos tracking is enabled and activeblock is in bounds
 
149
    actblock:=activeBlock();
 
150
    if TrackCurrentCheckBox.Checked and (FBlock <> actblock) and
 
151
      (activeblock >=0) and (activeBlock < NumBlocks) then begin
 
152
      FBlock := actblock;
 
153
      BlockEdit.Value:=FBlock; // calls doUpdate again and updates the MainForm
 
154
      exit;
 
155
    end;
 
156
 
 
157
    // set the spinEdit bounds, deactivate its event while doing so
138
158
    BlockEditChangeEvent:=BlockEdit.OnChange;
139
159
    BlockEdit.OnChange:=nil;
140
160
    BlockEdit.Value:=FBlock;
141
 
    BlockEdit.MaxValue:=numBlocks-1;
 
161
    BlockEdit.MaxValue:=Min(NumBlocks-1, getBlockFromOffset(Parser.rescueStatus.devicesize-1));
142
162
    BlockEdit.OnChange:=BlockEditChangeEvent;
143
163
 
144
 
    // adjust FBlock if curent pos tracking is enabled
145
 
    if TrackCurrentCheckBox.Checked then begin
146
 
      FBlock := activeBlock();
147
 
      BlockEdit.Value:=FBlock; // this also updates the MainForm
148
 
    end;
149
 
 
150
 
 
151
164
    rs:=emptyRescueStatus;
152
165
    bStart := getOffsetFromBlock(FBlock);
153
 
    bEnd := min(DataSource.rescueStatus.deviceSize,
154
 
                getOffsetFromBlock(block+1));
155
 
 
156
 
    EditBlockInfo.Text:='Start: ' + SizeStr(bStart) +
157
 
      '  Size: ' + SizeStr(bEnd-bStart) + ' (' +
158
 
      inttostr((bEnd-bStart) div devBSize) + ' sectors)';
159
 
 
160
 
    with DataSource do begin
 
166
    bEnd := max(bStart, min(Parser.rescueStatus.deviceSize, getOffsetFromBlock(block+1)));
 
167
 
 
168
    EditBlockInfo.Text:='Start: ' + SFORMATS[lblBlockHeadline.Tag]^.SizeStr(bStart) +
 
169
      '  Size: ' + SFORMATS[lblBlockHeadline.Tag]^.SizeStr(bEnd-bStart) +
 
170
      ' (' + SF_SECT.SizeStr(bEnd-bStart) + 'ectors)';
 
171
 
 
172
    with Parser do begin
161
173
      logLen := Length(log);
162
174
      // go through log and make list entries
163
175
      row := 0;
174
186
        // this log block is current rescue pos
175
187
        if (rescueStatus.pos >= leStart) and (rescueStatus.pos < leEnd) then
176
188
          LogEntryList.Cells[0, row]:='> '+LogEntryList.Cells[0, row];
177
 
        LogEntryList.Cells[1, row]:=inttostr(log[logEntry].offset)+' B ('+SizeStr(log[logEntry].offset)+')';
178
 
        LogEntryList.Cells[2, row]:=inttostr(log[logEntry].length)+' B ('+SizeStr(log[logEntry].length)+')';
 
189
        LogEntryList.Cells[1, row]:=SF_HEX.SizeStr(log[logEntry].offset)+
 
190
          ' ('+SF_FLOAT.SizeStr(log[logEntry].offset)+')';
 
191
        LogEntryList.Cells[2, row]:=SF_HEX.SizeStr(log[logEntry].length)+
 
192
          ' ('+SF_FLOAT.SizeStr(log[logEntry].length)+')';
179
193
        overlap:=BlockOverlap(leStart, leEnd, bStart, bEnd);
180
194
        case log[logEntry].status of
181
195
          '?' : inc(rs.nontried, overlap);
187
201
      end;
188
202
      LogEntryList.RowCount:=row+1;
189
203
      if clearSel then LogEntryList.Row:=1;
190
 
    end; // with FParser
191
 
    EditNontriedSectors.Text:=inttostr(rs.nontried div FGridBlockStore.devBSize);
192
 
    EditRescuedSectors.Text:=inttostr(rs.rescued div FGridBlockStore.devBSize);
193
 
    EditNonTrimmedSectors.Text:=inttostr(rs.nontrimmed div FGridBlockStore.devBSize);
194
 
    EditNonScrapedSectors.Text:=inttostr(rs.nonscraped div FGridBlockStore.devBSize);
195
 
    EditBadSectors.Text:=inttostr(rs.bad div FGridBlockStore.devBSize);
 
204
    end; // with Parser
 
205
    EditNontriedSectors.Text:=SF_SECT.SizeStr(rs.nontried);
 
206
    EditRescuedSectors.Text:=SF_SECT.SizeStr(rs.rescued);
 
207
    EditNonTrimmedSectors.Text:=SF_SECT.SizeStr(rs.nontrimmed);
 
208
    EditNonScrapedSectors.Text:=SF_SECT.SizeStr(rs.nonscraped);
 
209
    EditBadSectors.Text:=SF_SECT.SizeStr(rs.bad);
196
210
  end; // with FGridBlockStore
197
211
end;
198
212
 
202
216
  Hide;
203
217
end;
204
218
 
205
 
// The block number in the spind-edit has been changed
 
219
// The block number in the spin-edit has been changed
206
220
procedure TBlockForm.BlockEditChange(Sender: TObject);
207
221
begin
208
 
  if BlockEdit.Value <> FGridBlockStore.activeBlock then TrackCurrentCheckBox.Checked:=false;
209
222
  MainForm.SelectBlock(BlockEdit.Value);
210
223
  SetBlock(BlockEdit.Value);
211
224
end;
212
225
 
 
226
// prevent when hiding the form, unset the mainform's selected block and
 
227
// prevent further trakcing of the active block
 
228
procedure TBlockForm.FormHide(Sender: TObject);
 
229
begin
 
230
  MainForm.SelectBlock(-1);
 
231
  TrackCurrentCheckBox.Checked:=false;
 
232
end;
 
233
 
 
234
procedure TBlockForm.FormShow(Sender: TObject);
 
235
begin
 
236
  self.Position:=poDesigned; // make the form appear at its prev pos when reopened
 
237
end;
 
238
 
 
239
// switch the boundaries line size format
 
240
procedure TBlockForm.lblBlockHeadlineDblClick(Sender: TObject);
 
241
begin
 
242
  lblBlockHeadline.Tag := (lblBlockHeadline.Tag + 1) mod 3;
 
243
  doUpdate(false);
 
244
end;
 
245
 
213
246
// prevent 'Status' column from becoming invisible
214
247
procedure TBlockForm.LogEntryListHeaderSized(Sender: TObject; IsColumn: Boolean;
215
248
  Index: Integer);