Ignore:
Timestamp:
Jul 1, 2023, 8:17:50 PM (11 months ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormExport.pas

    r167 r168  
    3636    Table: TTable;
    3737    RedrawPending: Boolean;
    38     procedure PrepareTable;
    3938    procedure UpdateFileNameExt;
    4039    procedure LoadConfig;
     
    6261begin
    6362  TableFormat := TTableFormat(ComboBoxOutputFormat.Items.Objects[ComboBoxOutputFormat.ItemIndex]);
    64   SaveStringToFile(Table.GetOutput(TableFormat), EditOutputFile.Text);
     63  TVCardFile(Core.Core.DataFile).VCard.ExportToFile(EditOutputFile.Text, TableFormat,
     64    CheckBoxHumanReadableHeader.Checked);
    6565end;
    6666
     
    118118begin
    119119  if RedrawPending then begin
    120     PrepareTable;
     120    TVCardFile(Core.Core.DataFile).VCard.ExportToTable(Table,
     121      CheckBoxHumanReadableHeader.Checked);
    121122    Table.GetOutputListView(ListView1);
    122123    RedrawPending := False;
    123   end;
    124 end;
    125 
    126 procedure TFormExport.PrepareTable;
    127 var
    128   Row: TRow;
    129   I: Integer;
    130   J: Integer;
    131   Values: TStringList;
    132   Index: Integer;
    133   Fields: TContactFields;
    134   Field: TContactField;
    135   Columns: TStringList;
    136 begin
    137   Fields := TContact.GetFields;
    138   Table.Clear;
    139 
    140   Values := TStringList.Create;
    141   Columns := TStringList.Create;
    142   try
    143     with TVCardFile(Core.Core.DataFile), VCard do begin
    144       Table.Title := ExtractFileNameWithoutExt(FileName);
    145 
    146       // Get all properties types
    147       for I := 0 to Contacts.Count - 1 do begin
    148         for J := 0 to Contacts[I].Properties.Count - 1 do
    149         if not Contacts[I].Properties[J].Name.StartsWith('PHOTO') and
    150           (Table.Columns.IndexOf(Contacts[I].Properties[J].Name) = -1) then begin
    151             Table.Columns.Add(Contacts[I].Properties[J].Name);
    152             Columns.Add(Contacts[I].Properties[J].Name);
    153           end;
    154       end;
    155 
    156       if CheckBoxHumanReadableHeader.Checked then begin
    157         for I := 0 to Table.Columns.Count - 1 do begin
    158           Field := Fields.GetBySysName(Table.Columns[I]);
    159           if Assigned(Field) then Table.Columns[I] := Field.Title;
    160         end;
    161       end;
    162 
    163       for I := 0 to Contacts.Count - 1 do begin
    164         Values.Clear;
    165         for J := 0 to Columns.Count - 1 do
    166           Values.Add('');
    167         for J := 0 to Contacts[I].Properties.Count - 1 do begin
    168           Index := Columns.IndexOf(Contacts[I].Properties[J].Name);
    169           if Index <> -1 then
    170             Values[Index] := Contacts[I].Properties[J].Value;
    171         end;
    172 
    173         Row := Table.AddRow;
    174         for J := 0 to Values.Count - 1 do
    175           Row.Cells.Add(Values[J]);
    176       end;
    177     end;
    178   finally
    179     Values.Free;
    180     Columns.Free;
    181124  end;
    182125end;
Note: See TracChangeset for help on using the changeset viewer.