Changeset 230 for trunk/Forms/FormImportSources.pas
- Timestamp:
- Jan 24, 2025, 11:42:58 PM (6 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Forms/FormImportSources.pas ¶
r227 r230 14 14 TFormImportSources = class(TFormEx) 15 15 AAdd: TAction; 16 APreview: TAction; 16 17 AEnable: TAction; 17 18 ADisable: TAction; … … 31 32 MenuItem6: TMenuItem; 32 33 MenuItem7: TMenuItem; 34 MenuItem8: TMenuItem; 33 35 PopupMenuImportSource: TPopupMenu; 34 36 ToolBar1: TToolBar; … … 37 39 ToolButton3: TToolButton; 38 40 ToolButton4: TToolButton; 41 ToolButton5: TToolButton; 39 42 procedure AAddExecute(Sender: TObject); 40 43 procedure ADisableExecute(Sender: TObject); 41 44 procedure AEnableExecute(Sender: TObject); 42 45 procedure AModifyExecute(Sender: TObject); 46 procedure APreviewExecute(Sender: TObject); 43 47 procedure AProcessExecute(Sender: TObject); 44 48 procedure ARemoveExecute(Sender: TObject); 49 procedure FormActivate(Sender: TObject); 45 50 procedure FormCreate(Sender: TObject); 46 51 procedure FormShow(Sender: TObject); … … 58 63 procedure ListViewSort1Filter(ListViewSort: TListViewSort); 59 64 private 65 PreviewAcronymDb: TAcronymDb; 60 66 procedure ProcessImportJob(Job: TJob); 67 procedure PreviewImportJob(Job: TJob); 61 68 procedure FilterList(List: TObjectList<TObject>); 62 69 public … … 73 80 74 81 uses 75 FormMain, FormImportSource ;82 FormMain, FormImportSource, FormAcronyms; 76 83 77 84 resourcestring … … 80 87 SImportSourceAlreadyExists = 'Import source %s already exists!'; 81 88 SProcessSelectedSource = 'Process selected import source'; 89 SPreviewSelectedSource = 'Preview selected import source'; 82 90 83 91 … … 96 104 Item.SubItems.Add(DateToStr(LastImportTime)) 97 105 else Item.SubItems.Add(''); 106 Item.SubItems.Add(Format.Name); 98 107 Item.Checked := Enabled; 99 108 end; … … 133 142 function TFormImportSources.ListViewSort1CompareItem(Item1, Item2: TObject 134 143 ): Integer; 135 begin 144 var 145 ImportSource1, ImportSource2: TImportSource; 146 begin 147 ImportSource1 := TImportSource(Item1); 148 ImportSource2 := TImportSource(Item2); 136 149 Result := 0; 137 150 if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin 138 151 with ListViewSort1 do 139 152 case Column of 140 0: Result := CompareString(TImportSource(Item1).Name, TImportSource(Item2).Name); 141 1: Result := CompareString(TImportSource(Item1).URL, TImportSource(Item2).URL); 142 2: Result := CompareString(TImportSource(Item1).Categories.GetString, TImportSource(Item2).Categories.GetString); 143 3: Result := CompareInteger(TImportSource(Item1).ItemCount, TImportSource(Item2).ItemCount); 144 4: Result := CompareTime(TImportSource(Item1).LastImportTime, TImportSource(Item2).LastImportTime); 153 0: Result := CompareString(ImportSource1.Name, ImportSource2.Name); 154 1: Result := CompareString(ImportSource1.URL, ImportSource2.URL); 155 2: Result := CompareString(ImportSource1.Categories.GetString, ImportSource2.Categories.GetString); 156 3: Result := CompareInteger(ImportSource1.ItemCount, ImportSource2.ItemCount); 157 4: Result := CompareTime(ImportSource1.LastImportTime, ImportSource2.LastImportTime); 158 5: Result := CompareString(ImportSource1.Format.Name, ImportSource2.Format.Name); 145 159 end; 146 160 if ListViewSort1.Order = soDown then Result := -Result; … … 164 178 ARemove.Enabled := Assigned(ListView1.Selected); 165 179 AModify.Enabled := Assigned(ListView1.Selected); 180 AProcess.Enabled := Assigned(ListView1.Selected); 181 APreview.Enabled := Assigned(ListView1.Selected); 166 182 end; 167 183 … … 185 201 NewImportSource: TImportSource; 186 202 FormImportSource: TFormImportSource; 187 I: Integer;188 203 begin 189 204 NewImportSource := TImportSource.Create; … … 197 212 if not Assigned(ImportSources.SearchByName(NewImportSource.Name)) then begin; 198 213 ImportSources.Add(NewImportSource); 199 200 // Update reverse references201 for I := 0 to NewImportSource.Categories.Count - 1 do202 if NewImportSource.Categories.Items[I].ImportSources.IndexOf(NewImportSource) = -1 then203 NewImportSource.Categories.Items[I].ImportSources.Add(NewImportSource);204 214 205 215 NewImportSource := nil; … … 262 272 end; 263 273 264 // Update reverse references265 TImportSource(ListView1.Selected.Data).Categories.UpdateLinkImportSources(TImportSource(ListView1.Selected.Data));266 267 274 UpdateList; 268 275 end; … … 270 277 finally 271 278 FreeAndNil(FormImportSource); 279 end; 280 end; 281 end; 282 283 procedure TFormImportSources.APreviewExecute(Sender: TObject); 284 var 285 FormAcronyms: TFormAcronyms; 286 begin 287 if Assigned(ListView1.Selected) then begin 288 PreviewAcronymDb := TAcronymDb.Create; 289 try 290 JobProgressView1.AddJob(SPreviewSelectedSource, PreviewImportJob); 291 JobProgressView1.Start; 292 FormAcronyms := TFormAcronyms.Create(nil); 293 try 294 FormAcronyms.AcronymDb := PreviewAcronymDb; 295 FormAcronyms.Acronyms := PreviewAcronymDb.Acronyms; 296 FormAcronyms.ShowModal; 297 finally 298 FormAcronyms.Free; 299 end; 300 finally 301 FreeAndNil(PreviewAcronymDb); 272 302 end; 273 303 end; … … 287 317 procedure TFormImportSources.ProcessImportJob(Job: TJob); 288 318 begin 289 TImportSource(ListView1.Selected.Data).Process; 319 TImportSource(ListView1.Selected.Data).Process(AcronymDb); 320 end; 321 322 procedure TFormImportSources.PreviewImportJob(Job: TJob); 323 begin 324 TImportSource(ListView1.Selected.Data).Process(PreviewAcronymDb); 290 325 end; 291 326 … … 313 348 if Pos(UTF8LowerCase(StringGrid.Cells[4, 0]), 314 349 UTF8LowerCase(DateTimeToStr(TImportSource(List.Items[I]).LastImportTime))) > 0 then Inc(FoundCount); 350 if Pos(UTF8LowerCase(StringGrid.Cells[5, 0]), 351 UTF8LowerCase(TImportSource(List.Items[I]).Format.Name)) > 0 then Inc(FoundCount); 315 352 if FoundCount <> EnteredCount then List.Delete(I); 316 353 end; … … 338 375 end; 339 376 377 procedure TFormImportSources.FormActivate(Sender: TObject); 378 begin 379 ListViewFilter1.UpdateFromListView(ListView1); 380 end; 381 340 382 procedure TFormImportSources.FormCreate(Sender: TObject); 341 383 var
Note:
See TracChangeset
for help on using the changeset viewer.