Changeset 167 for trunk/Forms/FormExport.pas
- Timestamp:
- Jul 1, 2023, 11:54:02 AM (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/FormExport.pas
r162 r167 5 5 uses 6 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, 7 Table, LazFileUtils, FormEx;7 ExtCtrls, Table, LazFileUtils, FormEx; 8 8 9 9 type … … 15 15 ButtonCancel: TButton; 16 16 ButtonExport: TButton; 17 CheckBoxHumanReadableHeader: TCheckBox; 17 18 ComboBoxOutputFormat: TComboBox; 18 19 EditOutputFile: TEdit; … … 22 23 SaveDialog1: TSaveDialog; 23 24 ScrollBox1: TScrollBox; 25 TimerRedraw: TTimer; 24 26 procedure ButtonBrowseClick(Sender: TObject); 25 27 procedure ButtonExportClick(Sender: TObject); 28 procedure CheckBoxHumanReadableHeaderChange(Sender: TObject); 26 29 procedure ComboBoxOutputFormatChange(Sender: TObject); 27 30 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); … … 29 32 procedure FormDestroy(Sender: TObject); 30 33 procedure FormShow(Sender: TObject); 34 procedure TimerRedrawTimer(Sender: TObject); 31 35 private 32 36 Table: TTable; 37 RedrawPending: Boolean; 33 38 procedure PrepareTable; 34 39 procedure UpdateFileNameExt; … … 43 48 44 49 uses 45 Core, Common, RegistryEx, VCardFile ;50 Core, Common, RegistryEx, VCardFile, VCard; 46 51 47 52 { TFormExport } … … 58 63 TableFormat := TTableFormat(ComboBoxOutputFormat.Items.Objects[ComboBoxOutputFormat.ItemIndex]); 59 64 SaveStringToFile(Table.GetOutput(TableFormat), EditOutputFile.Text); 65 end; 66 67 procedure TFormExport.CheckBoxHumanReadableHeaderChange(Sender: TObject); 68 begin 69 RedrawPending := True; 60 70 end; 61 71 … … 102 112 procedure TFormExport.FormShow(Sender: TObject); 103 113 begin 104 PrepareTable; 105 Table.GetOutputListView(ListView1); 114 RedrawPending := True; 115 end; 116 117 procedure TFormExport.TimerRedrawTimer(Sender: TObject); 118 begin 119 if RedrawPending then begin 120 PrepareTable; 121 Table.GetOutputListView(ListView1); 122 RedrawPending := False; 123 end; 106 124 end; 107 125 … … 113 131 Values: TStringList; 114 132 Index: Integer; 115 begin 133 Fields: TContactFields; 134 Field: TContactField; 135 Columns: TStringList; 136 begin 137 Fields := TContact.GetFields; 138 Table.Clear; 139 116 140 Values := TStringList.Create; 141 Columns := TStringList.Create; 117 142 try 118 143 with TVCardFile(Core.Core.DataFile), VCard do begin … … 123 148 for J := 0 to Contacts[I].Properties.Count - 1 do 124 149 if not Contacts[I].Properties[J].Name.StartsWith('PHOTO') and 125 (Table.Columns.IndexOf(Contacts[I].Properties[J].Name) = -1) then 126 Table.Columns.Add(Contacts[I].Properties[J].Name); 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; 127 161 end; 128 162 129 163 for I := 0 to Contacts.Count - 1 do begin 130 164 Values.Clear; 131 for J := 0 to Table.Columns.Count - 1 do165 for J := 0 to Columns.Count - 1 do 132 166 Values.Add(''); 133 167 for J := 0 to Contacts[I].Properties.Count - 1 do begin 134 Index := Table.Columns.IndexOf(Contacts[I].Properties[J].Name);168 Index := Columns.IndexOf(Contacts[I].Properties[J].Name); 135 169 if Index <> -1 then 136 170 Values[Index] := Contacts[I].Properties[J].Value; … … 144 178 finally 145 179 Values.Free; 180 Columns.Free; 146 181 end; 147 182 end; … … 163 198 try 164 199 CurrentContext := Core.Core.ApplicationInfo1.GetRegistryContext; 165 EditOutputFile.Text := ReadStringWithDefault('LastExportFileName', 'Export.txt'); 166 TableFormat := TTableFormat(ReadIntegerWithDefault('TableFormat', Integer(tfCsv))); 200 EditOutputFile.Text := ReadStringWithDefault('ExportFileName', 'Export.txt'); 201 TableFormat := TTableFormat(ReadIntegerWithDefault('ExportTableFormat', Integer(tfCsv))); 202 CheckBoxHumanReadableHeader.Checked := ReadBoolWithDefault('ExportHumanReadableColumns', CheckBoxHumanReadableHeader.Checked); 167 203 ComboBoxOutputFormat.ItemIndex := ComboBoxOutputFormat.Items.IndexOfObject(TObject(TableFormat)); 168 204 finally … … 176 212 try 177 213 CurrentContext := Core.Core.ApplicationInfo1.GetRegistryContext; 178 WriteString('LastExportFileName', EditOutputFile.Text); 179 WriteInteger('TableFormat', Integer(ComboBoxOutputFormat.Items.Objects[ComboBoxOutputFormat.ItemIndex])); 214 WriteString('ExportFileName', EditOutputFile.Text); 215 WriteInteger('ExportTableFormat', Integer(ComboBoxOutputFormat.Items.Objects[ComboBoxOutputFormat.ItemIndex])); 216 WriteBool('ExportHumanReadableColumns', CheckBoxHumanReadableHeader.Checked); 180 217 finally 181 218 Free;
Note:
See TracChangeset
for help on using the changeset viewer.