Changeset 230 for trunk/Forms


Ignore:
Timestamp:
Jan 24, 2025, 11:42:58 PM (4 weeks ago)
Author:
chronos
Message:
  • Modified: Fixed Import sources modification.
  • Modified: Catogires don't have direct object references to import sources and acronym meanings.
  • Modified: Updated acronyms example file.
Location:
trunk/Forms
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/FormAcronyms.lfm

    r221 r230  
    88  ClientWidth = 888
    99  DesignTimePPI = 144
     10  OnActivate = FormActivate
    1011  OnCreate = FormCreate
    1112  OnShow = FormShow
     
    138139  end
    139140  object PopupMenuAcronym: TPopupMenu
     141    Images = Core.ImageListSmall
    140142    Left = 298
    141143    Top = 355
  • trunk/Forms/FormAcronyms.pas

    r227 r230  
    3535    procedure ARemoveExecute(Sender: TObject);
    3636    procedure ASelectAllExecute(Sender: TObject);
     37    procedure FormActivate(Sender: TObject);
    3738    procedure FormCreate(Sender: TObject);
    3839    procedure FormShow(Sender: TObject);
     
    103104procedure TFormAcronyms.ListViewAcronymsResize(Sender: TObject);
    104105begin
    105   //ListViewFilter1.UpdateFromListView(ListViewAcronyms);
     106  ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    106107end;
    107108
     
    116117  I: Integer;
    117118begin
    118   ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    119119  UpdateAcronymsList;
    120120  ScaleDPI.ScaleControl(ToolBar1, ScaleDPI.DesignDPI);
     
    166166      Meaning.Description := TempEntry.Description;
    167167      Meaning.Categories.AssignFromStrings(TempEntry.Categories);
    168 
    169       // Update reverse references
    170       for I := 0 to Meaning.Categories.Count - 1 do
    171         if TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.IndexOf(Meaning) = -1 then
    172           TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.Add(Meaning);
    173168
    174169      Acronyms.Db.Update;
     
    216211          Meaning.Categories.AssignFromStrings(TempEntry.Categories);
    217212
    218           // Update reverse references
    219           for I := 0 to Meaning.Categories.Count - 1 do
    220             if Meaning.Categories.Items[I].AcronymMeanings.IndexOf(Meaning) = -1 then
    221               Meaning.Categories.Items[I].AcronymMeanings.Add(Meaning);
    222213          Acronyms.Db.Update;
    223214          UpdateAcronymsList;
     
    259250  for I := 0 to ListViewAcronyms.Items.Count - 1 do
    260251    ListViewAcronyms.Items[I].Selected := True;
     252end;
     253
     254procedure TFormAcronyms.FormActivate(Sender: TObject);
     255begin
     256  ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    261257end;
    262258
  • trunk/Forms/FormCategories.lfm

    r221 r230  
    2626      end   
    2727      item
    28         Caption = 'Used count'
     28        Caption = 'Acronym meanings'
    2929        Width = 556
     30      end   
     31      item
     32        Caption = 'Import sources'
    3033      end>
    3134    MultiSelect = True
     
    6972  end
    7073  object ActionList1: TActionList
     74    Images = Core.ImageListSmall
    7175    Left = 456
    7276    Top = 235
     
    104108  end
    105109  object PopupMenuCategory: TPopupMenu
     110    Images = Core.ImageListSmall
    106111    Left = 143
    107112    Top = 230
  • trunk/Forms/FormCategories.lrj

    r219 r230  
    22{"hash":6979891,"name":"tformcategories.caption","sourcebytes":[65,99,114,111,110,121,109,32,99,97,116,101,103,111,114,105,101,115],"value":"Acronym categories"},
    33{"hash":346165,"name":"tformcategories.listviewcategories.columns[0].caption","sourcebytes":[78,97,109,101],"value":"Name"},
    4 {"hash":107848676,"name":"tformcategories.listviewcategories.columns[1].caption","sourcebytes":[85,115,101,100,32,99,111,117,110,116],"value":"Used count"},
     4{"hash":222267715,"name":"tformcategories.listviewcategories.columns[1].caption","sourcebytes":[65,99,114,111,110,121,109,32,109,101,97,110,105,110,103,115],"value":"Acronym meanings"},
     5{"hash":236591795,"name":"tformcategories.listviewcategories.columns[2].caption","sourcebytes":[73,109,112,111,114,116,32,115,111,117,114,99,101,115],"value":"Import sources"},
    56{"hash":18340,"name":"tformcategories.aadd.caption","sourcebytes":[65,100,100],"value":"Add"},
    67{"hash":93079237,"name":"tformcategories.aremove.caption","sourcebytes":[82,101,109,111,118,101],"value":"Remove"},
  • trunk/Forms/FormCategories.pas

    r227 r230  
    181181    Item.Caption := Name;
    182182    Item.Data := ListViewSort1.List[Item.Index];
    183     Item.SubItems.Add(IntToStr(AcronymMeanings.Count));
     183    Item.SubItems.Add(IntToStr(GetAcronymMeaningsCount));
     184    Item.SubItems.Add(IntToStr(GetImportSourcesCount));
    184185    Item.Checked := Enabled;
    185186  end;
     
    211212    case Column of
    212213      0: Result := CompareString(TAcronymCategory(Item1).Name, TAcronymCategory(Item2).Name);
    213       1: Result := CompareInteger(TAcronymCategory(Item1).AcronymMeanings.Count, TAcronymCategory(Item2).AcronymMeanings.Count);
     214      1: Result := CompareInteger(TAcronymCategory(Item1).GetAcronymMeaningsCount,
     215        TAcronymCategory(Item2).GetAcronymMeaningsCount);
     216      2: Result := CompareInteger(TAcronymCategory(Item1).GetImportSourcesCount,
     217        TAcronymCategory(Item2).GetImportSourcesCount);
    214218    end;
    215219    if ListViewSort1.Order = soDown then Result := -Result;
  • trunk/Forms/FormCategorySelect.pas

    r227 r230  
    1616    ListBox1: TListBox;
    1717    procedure ListBox1DblClick(Sender: TObject);
    18     procedure ListBox1KeyPress(Sender: TObject; var Key: char);
     18    procedure ListBox1KeyPress(Sender: TObject; var Key: Char);
    1919  public
    2020    AcronymDb: TAcronymDb;
     
    3939end;
    4040
    41 procedure TFormCategorySelect.ListBox1KeyPress(Sender: TObject; var Key: char);
     41procedure TFormCategorySelect.ListBox1KeyPress(Sender: TObject; var Key: Char);
    4242begin
    4343  if Key = #13 then ButtonOk.Click;
  • trunk/Forms/FormImportFormats.lfm

    r221 r230  
    6565  end
    6666  object ActionList1: TActionList
     67    Images = Core.ImageListSmall
    6768    Left = 612
    6869    Top = 336
     
    8788  end
    8889  object PopupMenuImportSource: TPopupMenu
     90    Images = Core.ImageListSmall
    8991    Left = 221
    9092    Top = 330
  • trunk/Forms/FormImportSources.lfm

    r227 r230  
    88  ClientWidth = 974
    99  DesignTimePPI = 144
     10  OnActivate = FormActivate
    1011  OnCreate = FormCreate
    1112  OnShow = FormShow
     
    4344      Action = AProcess
    4445    end
     46    object ToolButton5: TToolButton
     47      Left = 141
     48      Top = 2
     49      Action = APreview
     50    end
    4551  end
    4652  object ListView1: TListView
     
    7379      item
    7480        Caption = 'Date'
    75         Width = 145
     81        Width = 120
     82      end   
     83      item
     84        Caption = 'Format'
     85        Width = 150
    7686      end>
    7787    MultiSelect = True
     
    101111  end
    102112  object ActionList1: TActionList
     113    Images = Core.ImageListSmall
    103114    Left = 490
    104115    Top = 269
     
    134145      OnExecute = ADisableExecute
    135146    end
     147    object APreview: TAction
     148      Caption = 'Preview'
     149      ImageIndex = 13
     150      OnExecute = APreviewExecute
     151    end
    136152  end
    137153  object PopupMenuImportSource: TPopupMenu
     154    Images = Core.ImageListSmall
    138155    Left = 176
    139156    Top = 264
     
    149166    object MenuItem4: TMenuItem
    150167      Action = AProcess
     168    end
     169    object MenuItem8: TMenuItem
     170      Action = APreview
    151171    end
    152172    object MenuItem7: TMenuItem
  • trunk/Forms/FormImportSources.lrj

    r219 r230  
    77{"hash":4877396,"name":"tformimportsources.listview1.columns[3].caption","sourcebytes":[67,111,117,110,116],"value":"Count"},
    88{"hash":305317,"name":"tformimportsources.listview1.columns[4].caption","sourcebytes":[68,97,116,101],"value":"Date"},
     9{"hash":81171332,"name":"tformimportsources.listview1.columns[5].caption","sourcebytes":[70,111,114,109,97,116],"value":"Format"},
    910{"hash":18340,"name":"tformimportsources.aadd.caption","sourcebytes":[65,100,100],"value":"Add"},
    1011{"hash":93079237,"name":"tformimportsources.aremove.caption","sourcebytes":[82,101,109,111,118,101],"value":"Remove"},
     
    1213{"hash":127245555,"name":"tformimportsources.aprocess.caption","sourcebytes":[80,114,111,99,101,115,115],"value":"Process"},
    1314{"hash":79984933,"name":"tformimportsources.aenable.caption","sourcebytes":[69,110,97,98,108,101],"value":"Enable"},
    14 {"hash":185170277,"name":"tformimportsources.adisable.caption","sourcebytes":[68,105,115,97,98,108,101],"value":"Disable"}
     15{"hash":185170277,"name":"tformimportsources.adisable.caption","sourcebytes":[68,105,115,97,98,108,101],"value":"Disable"},
     16{"hash":126668695,"name":"tformimportsources.apreview.caption","sourcebytes":[80,114,101,118,105,101,119],"value":"Preview"}
    1517]}
  • trunk/Forms/FormImportSources.pas

    r227 r230  
    1414  TFormImportSources = class(TFormEx)
    1515    AAdd: TAction;
     16    APreview: TAction;
    1617    AEnable: TAction;
    1718    ADisable: TAction;
     
    3132    MenuItem6: TMenuItem;
    3233    MenuItem7: TMenuItem;
     34    MenuItem8: TMenuItem;
    3335    PopupMenuImportSource: TPopupMenu;
    3436    ToolBar1: TToolBar;
     
    3739    ToolButton3: TToolButton;
    3840    ToolButton4: TToolButton;
     41    ToolButton5: TToolButton;
    3942    procedure AAddExecute(Sender: TObject);
    4043    procedure ADisableExecute(Sender: TObject);
    4144    procedure AEnableExecute(Sender: TObject);
    4245    procedure AModifyExecute(Sender: TObject);
     46    procedure APreviewExecute(Sender: TObject);
    4347    procedure AProcessExecute(Sender: TObject);
    4448    procedure ARemoveExecute(Sender: TObject);
     49    procedure FormActivate(Sender: TObject);
    4550    procedure FormCreate(Sender: TObject);
    4651    procedure FormShow(Sender: TObject);
     
    5863    procedure ListViewSort1Filter(ListViewSort: TListViewSort);
    5964  private
     65    PreviewAcronymDb: TAcronymDb;
    6066    procedure ProcessImportJob(Job: TJob);
     67    procedure PreviewImportJob(Job: TJob);
    6168    procedure FilterList(List: TObjectList<TObject>);
    6269  public
     
    7380
    7481uses
    75   FormMain, FormImportSource;
     82  FormMain, FormImportSource, FormAcronyms;
    7683
    7784resourcestring
     
    8087  SImportSourceAlreadyExists = 'Import source %s already exists!';
    8188  SProcessSelectedSource = 'Process selected import source';
     89  SPreviewSelectedSource = 'Preview selected import source';
    8290
    8391
     
    96104      Item.SubItems.Add(DateToStr(LastImportTime))
    97105      else Item.SubItems.Add('');
     106    Item.SubItems.Add(Format.Name);
    98107    Item.Checked := Enabled;
    99108  end;
     
    133142function TFormImportSources.ListViewSort1CompareItem(Item1, Item2: TObject
    134143  ): Integer;
    135 begin
     144var
     145  ImportSource1, ImportSource2: TImportSource;
     146begin
     147  ImportSource1 := TImportSource(Item1);
     148  ImportSource2 := TImportSource(Item2);
    136149  Result := 0;
    137150  if Assigned(Item1) and Assigned(Item2) and (ListViewSort1.Order <> soNone) then begin
    138151    with ListViewSort1 do
    139152    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);
    145159    end;
    146160    if ListViewSort1.Order = soDown then Result := -Result;
     
    164178  ARemove.Enabled := Assigned(ListView1.Selected);
    165179  AModify.Enabled := Assigned(ListView1.Selected);
     180  AProcess.Enabled := Assigned(ListView1.Selected);
     181  APreview.Enabled := Assigned(ListView1.Selected);
    166182end;
    167183
     
    185201  NewImportSource: TImportSource;
    186202  FormImportSource: TFormImportSource;
    187   I: Integer;
    188203begin
    189204  NewImportSource := TImportSource.Create;
     
    197212      if not Assigned(ImportSources.SearchByName(NewImportSource.Name)) then begin;
    198213        ImportSources.Add(NewImportSource);
    199 
    200         // Update reverse references
    201         for I := 0 to NewImportSource.Categories.Count - 1 do
    202           if NewImportSource.Categories.Items[I].ImportSources.IndexOf(NewImportSource) = -1 then
    203             NewImportSource.Categories.Items[I].ImportSources.Add(NewImportSource);
    204214
    205215        NewImportSource := nil;
     
    262272        end;
    263273
    264         // Update reverse references
    265         TImportSource(ListView1.Selected.Data).Categories.UpdateLinkImportSources(TImportSource(ListView1.Selected.Data));
    266 
    267274        UpdateList;
    268275      end;
     
    270277    finally
    271278      FreeAndNil(FormImportSource);
     279    end;
     280  end;
     281end;
     282
     283procedure TFormImportSources.APreviewExecute(Sender: TObject);
     284var
     285  FormAcronyms: TFormAcronyms;
     286begin
     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);
    272302    end;
    273303  end;
     
    287317procedure TFormImportSources.ProcessImportJob(Job: TJob);
    288318begin
    289   TImportSource(ListView1.Selected.Data).Process;
     319  TImportSource(ListView1.Selected.Data).Process(AcronymDb);
     320end;
     321
     322procedure TFormImportSources.PreviewImportJob(Job: TJob);
     323begin
     324  TImportSource(ListView1.Selected.Data).Process(PreviewAcronymDb);
    290325end;
    291326
     
    313348           if Pos(UTF8LowerCase(StringGrid.Cells[4, 0]),
    314349             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);
    315352           if FoundCount <> EnteredCount then List.Delete(I);
    316353         end;
     
    338375end;
    339376
     377procedure TFormImportSources.FormActivate(Sender: TObject);
     378begin
     379  ListViewFilter1.UpdateFromListView(ListView1);
     380end;
     381
    340382procedure TFormImportSources.FormCreate(Sender: TObject);
    341383var
  • trunk/Forms/FormMain.lfm

    r227 r230  
    99  DesignTimePPI = 144
    1010  Menu = MainMenu1
     11  OnActivate = FormActivate
    1112  OnClose = FormClose
    1213  OnCloseQuery = FormCloseQuery
  • trunk/Forms/FormMain.pas

    r227 r230  
    136136    procedure AShowImportSourcesExecute(Sender: TObject);
    137137    procedure EditSearchChange(Sender: TObject);
     138    procedure FormActivate(Sender: TObject);
    138139    procedure FormDestroy(Sender: TObject);
    139140    procedure FormHide(Sender: TObject);
     
    234235end;
    235236
     237procedure TFormMain.FormActivate(Sender: TObject);
     238begin
     239  ListViewFilter1.UpdateFromListView(ListViewAcronyms);
     240end;
     241
    236242procedure TFormMain.FormDestroy(Sender: TObject);
    237243begin
     
    455461  with Core.Core.AcronymDb.ImportSources[I] do
    456462  if Enabled then begin
    457     Process;
     463    Process(Core.Core.AcronymDb);
    458464    ImportTotalItemCount := ImportTotalItemCount + ItemCount;
    459465    Job.Progress.Max := Core.Core.AcronymDb.ImportSources.Count;
     
    568574
    569575  if Visible then begin
    570     ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    571576    UpdateInterface;
    572577    ListViewFilter1.StringGrid.Col := 1;
     
    575580    ListViewFilter1.StringGrid.SetFocus;
    576581  end;
    577   Core.Core.ScaleDPI1.ScaleControl(CoolBar1, Core.Core.ScaleDPI1.DesignDPI);
     582  ScaleDPI.ScaleControl(CoolBar1, ScaleDPI.DesignDPI);
    578583  CoolBar1.AutosizeBands;
    579584end;
Note: See TracChangeset for help on using the changeset viewer.