//------------------------------------------------------------------ // //------------------------------------------------------------------ procedure TMainboard.ExItems(Left, Right: TListItem); var
Cap: String;
j, k, diff: integer;
TA: arrayofstring; begin if left <> right thenbegin
Cap := Left.Caption;
Left.Caption := Right.Caption;
Right.Caption := Cap; //save left line for k := 0 to left.SubItems.Count - 1 dobegin
setlength(TA, k + 1);
TA[k] := Left.SubItems[k]; end; //
diff := Right.SubItems.Count - Left.SubItems.Count; for j := 1 to diff do
Left.SubItems.add(''); // for k := 0 to Right.SubItems.Count - 1 do
Left.SubItems[k] := Right.SubItems[k]; // for j := 1 to diff do
Right.SubItems.Delete(Right.SubItems.Count - 1); // for k := 0 to Right.SubItems.Count - 1 do
Right.SubItems[k] := TA[k]; end; end;
procedure Changer(left: boolean); var
i, ll, le, ri, lex, rix, fnd: integer; begin
i := 0;
ll := length(Matches);
fnd := 0; while (i < ll) dobegin if Matches[i].valid thenbegin
le := Matches[i].leftline;
ri := Matches[i].rightline; if left thenbegin
lex := finditem(ListView1, le); with ListView1 do
ExItems(Items[fnd], Items[lex]);
Inc(fnd) end elsebegin
rix := finditem(ListView2, ri); with ListView2 do
ExItems(Items[fnd], Items[rix]);
Inc(fnd) end; end;
Inc(i) end; end;
begin //
changer(true); //
changer(false); // end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.removefromMatches(mat: integer); var
i, ll: integer;
oneleft: boolean; begin
Matches[mat].valid := false;
oneleft := false;
ll := Length(Matches); for i := 0 to ll - 1 do
oneleft := oneleft or matches[i].valid; ifnot oneleft then
ResetMatching(nil); end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.Abgleichen(Sender: TObject); var
i, j, ll, mi, mj, sb, ten: integer;
Sim: String; begin
screen.Cursor := crHourGlass;
Sim := trans(70, 'Fortschritt') + ' ';
sb := max(ListView1.Items.Count, ListView2.Items.Count);
ten := ((sb div 10) * 8) div 10;
ll := 0;
SetLength(Matches, ll); // for j := 1 to 2 do for i := 0 to Length(Pivot[j]) - 1 do
Pivot[j][i] := 0; //
i := 0; while i < ListView1.Items.Count dobegin
j := 0; while (j < ListView2.Items.Count) dobegin
mi := isinmatches(i, -1);
mj := isinMatches(-1, j); if (mi < 0) and (mj < 0) thenbegin
ActMatch := hasMatch(ListView1.Items[i], ListView2.Items[j]); if (ActMatch <> nil) then if (isinMatches(i, -1) < 0) and (isinMatches(-1, j) < 0) then
addtoMatches(false, i, j); end;
Inc(j) end;
Inc(i); if (ten > 0) and (i mod (2 * ten) = 0) thenbegin
Sim := Sim + '***';
StatusBar1.SimpleText := inttostr((100 * i) div ((sb * 12) div 10)) + '% ' + Sim; end end; //
getmatchingColumns(); //
setPivotOnly(); //
ExchangeMatches(); ifnot Abgeglichen then
errorn(45, 'keine Übereinstimmung gefunden');
screen.Cursor := crDefault;
showStatus(); //
Clearselected(ListView1);
Clearselected(ListView2); //
Reset1.enabled := Abgeglichen;
Abgleich1.Enabled := not Abgeglichen;
Speichern1.Enabled := Abgeglichen;
Manuell.Enabled := Abgeglichen;
newselect[1].y := -1;
newselect[2].y := -1;
ListView1.Repaint;
ListView2.Repaint; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.Beenden1Click(Sender: TObject); begin
Close() end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.Ende1Click(Sender: TObject); begin
Close end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.Ergebnis1Click(Sender: TObject); var
done: integer; begin if Abgeglichen thenbegin repeat
opt.R.ergfile := getfilename(opt.R.ergfile, false);
done := exportfile(opt.R.ergfile, ListView1, ListView2, opt.R.leftkeys,
opt.R.rightkeys, opt.R.recordnumbersonly); until (exportcancel = mrcancel) or (done > 0); if done > 0 thenbegin
StatusBar1.SimpleText := IntToStr(done) + ' ' +
Trans(63, 'Sätze geschrieben');
gesichert := true; end; end else
errorn(43, 'kein Abgleich erfolgt, Ergebnis ist leer'); end;
//------------------------------------------------------- // //------------------------------------------------------- function TMainboard.getfilename(ini: String; isinput: boolean): String; var
res, ext: String; begin
res := ini; if ini > ''then
ini := ExtractFilePath(ini) else
ini := Opt.getSamplesDir(Title); if isinput then with OpenDialog1 dobegin
InitialDir := ini;
Options := [];
Options := Options - [ofNoDereferenceLinks]; if isinput then
Options := Options + [ofReadOnly, ofFileMustExist] else
Options := Options + [ofOverwritePrompt, ofPathMustExist];
Filter := trans(7, 'Komma separierte Dateien') + '|*.csv';
FileName := ''; if Execute() then
res := OpenDialog1.FileName; end else with SaveDialog1 dobegin
InitialDir := ini;
Options := [];
Options := Options - [ofNoDereferenceLinks]; if isinput then
Options := Options + [ofReadOnly, ofFileMustExist] else
Options := Options + [ofOverwritePrompt, ofPathMustExist];
Filter := trans(7, 'Komma separierte Dateien') + '|*.csv';
FileName := opt.r.ergfile; if Execute() then
res := FileName; end;
ext := ExtractFileExt(res); if (ext = '') and (res <> '') then
res := res + '.csv';
result := res end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.showstatus(); var
l, r, f: String; begin
l := trans(3, 'linke');
r := trans(4, 'rechte');
f := ' ' + trans(5, 'Datei') + ' = '; if (opt.R.leftfile > '') and (opt.R.rightfile > '') then
StatusBar1.SimpleText := l + f + ExtractFileName(opt.R.leftfile) + '(' +
IntToStr(ListView1.Items.Count) + ')' + ' --- ' + r + f +
ExtractFileName(opt.R.rightfile) + '(' +
IntToStr(ListView2.Items.Count) + ')' elseif (opt.R.leftfile > '') then
StatusBar1.SimpleText := l + f + ExtractFileName(opt.R.leftfile) + '(' +
IntToStr(ListView1.Items.Count) + ')' elseif (opt.R.rightfile > '') then
StatusBar1.SimpleText := r + f + ExtractFileName(opt.R.rightfile) + '(' +
IntToStr(ListView2.Items.Count) + ')' else
StatusBar1.SimpleText := trans(2, 'Keine Datei geladen'); if Abgeglichen then
StatusBar1.SimpleText := StatusBar1.SimpleText + ' * ' +
trans(53, 'Anzahl Paare = ') + IntToStr(Length(Matches)); end;
//------------------------------------------------------- // //------------------------------------------------------- procedure sizeit(LV: TListView); var
lw, j, rat: integer; begin
lw := 0; for j := 0 to LV.Columns.Count - 1 do
lw := lw + LV.Columns[j].Width; if lw > 0 thenbegin
rat := (LV.Width * 100) div lw; for j := 0 to LV.Columns.Count - 1 do
LV.Columns[j].Width := (LV.Columns[j].Width * rat) div 100; end; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.scrollin(LV: TListView; x: integer); var
cnt, sign: integer; //-------------------------------------------------- function isgoodvis(): boolean; begin with LV do
result := (x >= TopItem.Index) and (x < TopItem.Index + visibleRowCount) end;
begin
cnt := 0; if x >= 0 then with LV dobegin
sign := 1; if x < LV.TopItem.Index then
sign := -1; whilenot isgoodvis() dobegin
Scroll(0, sign * 10);
Inc(cnt); if cnt > 1000 then
ShowMessage('hi'); end end;
LV.Items[x].Selected := true; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.Suchen1Click(Sender: TObject); var
fund: TPoint; //-------------------------------------------------- function findin(LV: TListView; lf: TPoint): TPoint; var
i, j, anf: integer;
res: TPoint; begin
res.x := -1;
res.y := -1; with LV do if Searcher.Search > ''thenbegin
anf := lf.Y + 1;
i := lf.x + 1; while (res.x < 0) and (i < Items.Count) do with Items[i] dobegin
j := anf; while (res.x < 0) and (j < SubItems.Count) dobegin if pos(Searcher.Search, SubItems[j]) > 0 thenbegin
res.x := i;
res.y := j end;
Inc(j); end;
anf := 1;
Inc(i) end; end;
result := res end;
begin //if (searcher.lastlist=2) and (searcher.lastfund.x<0) then if sender = Suchen1 thenbegin
Clearselected(ListView1);
Clearselected(ListView2); with searcher dobegin
lastlist := 1;
lastfund.x := -1;
lastfund.y := -1; end;
searcher.ShowModal();
opt.R.searchstring := searcher.Search; end; // if searcher.lastlist = 1 thenbegin
fund := findin(ListView1, searcher.lastfund); if fund.X < 0 thenbegin
searcher.lastfund.X := 0;
searcher.lastfund.Y := 0;
searcher.lastlist := 2;
fund := findin(ListView2, searcher.lastfund); end end else
fund := findin(ListView2, searcher.lastfund); // if fund.X >= 0 thenbegin if searcher.lastlist = 1 then
scrollin(ListView1, fund.X) elseif searcher.lastlist = 2 then
scrollin(ListView2, fund.X); end elsebegin
ShowMessage(trans(62, 'Nicht gefunden')); with searcher dobegin
lastlist := 1;
lastfund.x := -1;
lastfund.y := -1; end; end;
searcher.lastfund := fund; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.clearMatches(); var
i: integer; begin with ListView1 dobegin for i := 0 to Items.Count - 1 do
Items[i].Selected := false; end; with ListView2 dobegin for i := 0 to Items.Count - 1 do
Items[i].Selected := false; end; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.getColumnwidths(LV: TListView; inx: integer); var
j, ll: integer; begin
ll := LV.Columns.Count - 1; with LV do for j := 0 to ll do
opt.R.Colwidths[inx, j] := Columns[j].Width; if lv = ListView1 then
opt.R.Colleftfile := opt.R.leftfile; if lv = ListView2 then
opt.R.Colrightfile := opt.R.rightfile; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.initColumnwidths(LV: TListView; inx: integer); var
j, ll: integer; begin
ll := LV.Columns.Count - 1; with LV do for j := 0 to ll do
Columns[j].Width := LV.Width div (Columns.Count + 1) end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.setColumnwidths(LV: TListView; inx: integer); var
j, ll, lw: integer; begin
ll := LV.Columns.Count - 1; if opt.R.leftfile = opt.R.Colleftfile then with LV do for j := 0 to ll dobegin if opt.R.Colwidths[inx, j] = 0 then
Columns[j].Width := LV.Width div (Columns.Count + 1) else
Columns[j].Width := opt.R.Colwidths[inx, j]; end else
initColumnwidths(LV, inx); //measure total width
lw := 0; for j := 0 to LV.Columns.Count - 1 do
lw := lw + LV.Columns[j].Width; if abs(lw - LV.Width) > 10 then
sizeit(LV); end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.ManuellClick(Sender: TObject); begin if (newselect[1].y >= 0) and (newselect[2].y >= 0) then
addtomatches(true, newselect[1].y, newselect[2].y) elseif (newselect[1].y < 0) then
ShowMessage(trans(77, 'Bitte linken Satz auswählen')) elseif (newselect[2].y < 0) then
ShowMessage(trans(78, 'Bitte rechten Satz auswählen'));
showStatus(); end;
//--------------------------------------------------------------- //Mouse over Control? //--------------------------------------------------------------- function TMainboard.MouseOver(var Obj: TListView): boolean; var
MP, OP: TPoint;
isit, c1, c2: boolean; begin
MP := Mouse.CursorPos;
OP := ScreentoClient(MP);
c1 := (OP.x >= Obj.left) and (OP.x <= Obj.left + Obj.Width);
c2 := (OP.y >= Obj.top) and (OP.y <= Obj.top + Obj.Height);
isit := c1 and c2;
Result := isit end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); begin if MouseOver(Listview1) then
ListView1.Scroll(0, -WheelDelta) elseif MouseOver(Listview2) then
ListView2.Scroll(0, -WheelDelta); end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.FormResize(Sender: TObject); begin
sizeit(ListView1);
sizeit(ListView2); if ListView1.Width < width div 4 then
ListView1.Width := width div 4; if ListView2.Width < width div 4 then
ListView2.Width := width div 4; //
Panelbuttons.Left := width div 2 - Panelbuttons.Width div 2; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.Clearselected(LV: TCustomListView); var
ix: integer; begin for ix := 0 to LV.Items.Count - 1 do with LV.items[ix] dobegin
Selected := false;
Checked := false;
Canvas.Font.Color := clBlack;
Canvas.Font.Style := [] end; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.CustomDrawSubItem(Sender: TCustomListView; Item: TListItem;
SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean); var
six, ile, iri: integer; begin
six := StrToInt(Item.Caption);
Sender.Canvas.Font.Color := clBlack;
Sender.Canvas.Font.Style := []; if (Sender = ListView1) thenbegin
ile := isinMatches(six, -1); if (ile >= 0) and Matches[ile].valid thenbegin if (SubItem = Matches[ile].leftcol + 1) thenbegin
Sender.Canvas.Font.Color := clBlue;
Sender.Canvas.Font.Style := [fsBold] end else
Sender.Canvas.Font.Color := clBlack; end else
Sender.Canvas.Font.Color := clBlack; end elseif (Sender = ListView2) thenbegin
iri := isinMatches(-1, six); if (iri >= 0) and Matches[iri].valid thenbegin if (SubItem = Matches[iri].rightcol + 1) thenbegin
Sender.Canvas.Font.Color := clRed;
Sender.Canvas.Font.Style := [fsBold] end else
Sender.Canvas.Font.Color := clBlack; end else
Sender.Canvas.Font.Color := clBlack; end;
Sender.Repaint; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.ListView1Click(Sender: TObject); var
LI: TListItem;
LV: TListView;
Tex: String;
inx, cap: integer;
MP, CP: TPoint;
hittestinfo: TLVHitTestInfo;
subit: integer; procedure AbgleichFrage(inx: integer); var
re: Cardinal;
mat: integer;
cap1, cap2: String; begin
cap := StrToInt(LI.Caption); if inx = 1 then
mat := isinMatches(cap, -1) else
mat := isinMatches(-1, cap); if mat >= 0 thenbegin
re := ask(79, 'Soll das Paar aus dem Abgleich entfernt werden?', ' ',
[mbYes, mbNo]); if re = mrYes then
removefromMatches(mat) end elseif Abgeglichen thenbegin if (inx = 2) and (newselect[1].y >= 0) and (newselect[1].x <> subit) then
ShowMessage(trans(82, 'Linke und rechte Spalte müssen gleich sein')) elseif (inx = 1) and (newselect[2].y >= 0) and
(newselect[2].x <> subit) then
ShowMessage(trans(82, 'Linke und rechte Spalte müssen gleich sein')) elsebegin
newselect[inx].x := subit;
newselect[inx].y := LI.Index; if (newselect[1].y >= 0) and (newselect[2].y >= 0) thenbegin
cap1 := ListView1.Items[newselect[1].y].Caption;
cap2 := ListView2.Items[newselect[2].y].Caption;
StatusBar1.SimpleText := trans(80, 'Neues Paar') + ' <' + cap1 + ',' +
cap2 + '> ' + trans(81, 'Zum Hinzufügen Manuell drücken'); end end; end;
LI.Selected := Abgeglichen; end;
begin
LV := (Sender as TListView);
MP := mouse.CursorPos;
CP := ScreenToClient(MP); with CP do
LI := LV.GetItemAt(x, y); if LI <> nilthenbegin
FillChar(hittestinfo, sizeof(hittestinfo), 0);
hittestinfo.pt := CP;
LV.perform(LVM_SUBITEMHITTEST, 0, lparam(@hittestinfo));
subit := hittestinfo.iSubItem; if LV=ListView2 then Dec(subit,2); if lv = ListView1 then
abgleichFrage(1) else
abgleichFrage(2);
Tex := ListRec(LV, LI.Index, LV = ListView1);
LV.Hint := Tex; if (LV = ListView1) thenbegin
cap := StrToInt(LI.Caption);
inx := isinMatches(cap, -1); if inx >= 0 then
scrollin(ListView2, finditem(ListView2, matches[inx].rightline)); end elseif (LV = ListView2) thenbegin
cap := StrToInt(LI.Caption);
inx := isinMatches(-1, cap); if inx >= 0 then
scrollin(ListView1, matches[inx].leftline); end; end; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.ListViewColumnClick(Sender: TObject; Column: TListColumn); var
LV: TListView; begin
LV := (Sender as TListView);
LV.Hint := trans(68, 'Spalte') + '=' + IntToStr(Column.Index); end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.ListMouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer); var
LV: TListView;
LI: TListItem; begin
LV := (Sender as TListView);
LI := LV.GetItemAt(x, y); if (LI <> nil) and (LV.Selected <> nil) and (LI <> LV.Selected) then
LV.Hint := ''; end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.LoadBoth(); begin
setmatchbounds(opt.R.lineseparator, opt.R.recordseparator,
opt.R.fielddelimiter, opt.R.escapecharacter); if opt.R.leftfile > ''then
importfile(1, opt.R.leftfile, ListView1, opt.R.firstlinenames); if opt.R.rightfile > ''then
importfile(2, opt.R.rightfile, ListView2, opt.R.firstlinenames);
showstatus(); end;
//------------------------------------------------------- // //------------------------------------------------------- procedure TMainboard.FormShow(Sender: TObject); begin if opt.R.splitterleft < Width div 5 then
opt.R.splitterleft := Width div 5;
Width := opt.R.Width;
Height := opt.R.Height;
Top := opt.R.top;
Left := opt.R.left;
LoadBoth();
setColumnwidths(ListView1, 1);
setColumnwidths(ListView2, 2);
ListView1.Width := opt.R.splitterleft;
Abgeglichen := false;
Gesichert := true;
switchLanguage();
Screen.Cursor := crDefault;
Speichern1.Enabled := Abgeglichen;
Lizenz1.Checklicense(); end;
//------------------------------------------------------------------ //- - //------------------------------------------------------------------ procedure TMainboard.SortLV(LV: TListView); var
i, j, ll, ca1, ca2: integer; begin
ll := lV.Items.Count; for i := 0 to ll - 1 do for j := i + 1 to ll - 1 dobegin
ca1 := StrToInt(LV.Items[i].Caption);
ca2 := StrToInt(LV.Items[j].Caption); if ca1 > ca2 then
ExItems(LV.Items[i], LV.Items[j]); end; end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.