Changeset 168 for trunk/Forms/FormExport.pas
- Timestamp:
- Jul 1, 2023, 8:17:50 PM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/FormExport.pas
r167 r168 36 36 Table: TTable; 37 37 RedrawPending: Boolean; 38 procedure PrepareTable;39 38 procedure UpdateFileNameExt; 40 39 procedure LoadConfig; … … 62 61 begin 63 62 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); 65 65 end; 66 66 … … 118 118 begin 119 119 if RedrawPending then begin 120 PrepareTable; 120 TVCardFile(Core.Core.DataFile).VCard.ExportToTable(Table, 121 CheckBoxHumanReadableHeader.Checked); 121 122 Table.GetOutputListView(ListView1); 122 123 RedrawPending := False; 123 end;124 end;125 126 procedure TFormExport.PrepareTable;127 var128 Row: TRow;129 I: Integer;130 J: Integer;131 Values: TStringList;132 Index: Integer;133 Fields: TContactFields;134 Field: TContactField;135 Columns: TStringList;136 begin137 Fields := TContact.GetFields;138 Table.Clear;139 140 Values := TStringList.Create;141 Columns := TStringList.Create;142 try143 with TVCardFile(Core.Core.DataFile), VCard do begin144 Table.Title := ExtractFileNameWithoutExt(FileName);145 146 // Get all properties types147 for I := 0 to Contacts.Count - 1 do begin148 for J := 0 to Contacts[I].Properties.Count - 1 do149 if not Contacts[I].Properties[J].Name.StartsWith('PHOTO') and150 (Table.Columns.IndexOf(Contacts[I].Properties[J].Name) = -1) then begin151 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 begin157 for I := 0 to Table.Columns.Count - 1 do begin158 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 begin164 Values.Clear;165 for J := 0 to Columns.Count - 1 do166 Values.Add('');167 for J := 0 to Contacts[I].Properties.Count - 1 do begin168 Index := Columns.IndexOf(Contacts[I].Properties[J].Name);169 if Index <> -1 then170 Values[Index] := Contacts[I].Properties[J].Value;171 end;172 173 Row := Table.AddRow;174 for J := 0 to Values.Count - 1 do175 Row.Cells.Add(Values[J]);176 end;177 end;178 finally179 Values.Free;180 Columns.Free;181 124 end; 182 125 end;
Note:
See TracChangeset
for help on using the changeset viewer.