// pour le départ de la boucle r2 :=1; G :=0; m :=0;
tot := Form1.Listview4.Items.Count;
// départ boucle 1
for v1 := 0 to tot-1 do
begin
// départ boucle 2
for R1 := r2 to tot-1 do
begin
d := d + 1;
// conditions
if (Form1.ListView4.Items[r1].caption <> Form1.ListView4.Items[v1].caption)
and (Form1.ListView4.Items[r1].SubItems[0] = Form1.ListView4.Items[V1].SubItems[0])
and (Form1.ListView4.Items[r1].SubItems[1] = Form1.ListView4.Items[V1].SubItems[1])
and (Form1.ListView4.Items[r1].SubItems[2] = Form1.ListView4.Items[V1].SubItems[2])
and (Form1.ListView4.Items[v1].SubItems[3] = '0')
then begin
// Place un 1 sur l'items pour ne plus le reprendre
Form1.ListView4.Items[r1].SubItems[3] := '1';
// Un de trouvé création d'un groupe
if (g = 0) then begin
Group := Form1.ListView3.Groups.Add;
Group.Header := 'Nouveau Groupe';
Group.GroupID := m;
Items :=Form1.ListView3.Items.Add;
Items.GroupID := m;
Items.Caption := (Form1.Listview4.items[V1].Caption);
Items.SubItems.Add (Form1.ListView4.Items[V1].SubItems[1]);
Items.SubItems.Add (Form1.ListView4.Items[V1].SubItems[2]);
Items.SubItems.Add (Form1.ListView4.Items[V1].SubItems[3]);
// Mets g à 1 pour ne pas créer un nouveau groupe
g:=1;
//fin création du groupe
end;
// Place le 2emme l'items dans le groupe
Items :=Form1.ListView3.Items.Add;
Items.GroupID := m;
Items.Caption := (Form1.Listview4.items[r1].Caption));
Items.SubItems.Add (Form1.ListView4.Items[r1].SubItems[1]);
Items.SubItems.Add (Form1.ListView4.Items[R1].SubItems[2]);
Items.SubItems.Add (Form1.ListView4.Items[R1].SubItems[3]);
// fin conditions
end;
// fin boucle 2
end;
// préparation pour le prochain tours
// Prochain départ pour la boucle à r2 + 1
r2 := r2 + 1;
// numéro du prochain groupe
m := m + 1;
// prêt pour créer un nouveau groupe
g := 0;
end; // fin de la boucle 1 (enfin)
var
ListItem : TListItem;
I : Integer;
J : Integer;
K : Integer;
SearchS : Boolean;
SearchG : Integer;
begin
for I := 0 to ListView4.Items.Count -1 do
begin
SearchS := False;
SearchG := -1;
for K := 0 to ListView3.Items.Count -1 do
begin
ListItem := ListView3.FindCaption(K, ListView4.Items[I].Caption, False, True, False);
if ListItem <> nil then
begin
SearchG := ListItem.GroupID;
for J := 0 to ListItem.SubItems.Count -1 do
begin
if ListItem.SubItems[J] = ListView4.Items[I].SubItems[J] then
begin
SearchS := True;
end
else
begin
SearchS := False;
Break;
end;
end;
if SearchS then
Break;
end;
end;
if not SearchS then
begin
if SearchG = -1 then
begin
ListView3.Groups.Add;
ListView3.Groups[ListView3.Groups.Count -1].Header := 'Groupe'+IntToStr(ListView3.Groups.Count -1);
SearchG := ListView3.Groups.Count -1;
end;
ListView3.Items.Add;
ListView3.Items[ListView3.Items.Count -1].GroupID := SearchG;
ListView3.Items[ListView3.Items.Count -1].Caption := ListView4.Items[I].Caption;
ListView3.Items[ListView3.Items.Count -1].SubItems.AddStrings(ListView4.Items[I].SubItems);
end;
end;
end;
...
if SearchS then
Break;
end
else
Break;
...
if SearchG = -1 then
begin
ListView3.Groups.Add;
ListView3.Groups[ListView3.Groups.Count -1].Header := 'Groupe'+IntToStr(ListView3.Groups.Count -1);
SearchG := ListView3.Groups.Count -1;
end;