Changeset 14


Ignore:
Timestamp:
Apr 28, 2016, 10:56:31 PM (9 years ago)
Author:
chronos
Message:
  • Added: Window for acronym categories management. There acronyms can be added, modifed and removed.
Location:
trunk
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/AcronymDecoder.lpi

    r13 r14  
    9292      </Item5>
    9393    </RequiredPackages>
    94     <Units Count="7">
     94    <Units Count="8">
    9595      <Unit0>
    9696        <Filename Value="AcronymDecoder.lpr"/>
     
    135135        <ResourceBaseClass Value="Form"/>
    136136      </Unit6>
     137      <Unit7>
     138        <Filename Value="Forms\UFormCategories.pas"/>
     139        <IsPartOfProject Value="True"/>
     140        <ComponentName Value="FormCategories"/>
     141        <ResourceBaseClass Value="Form"/>
     142      </Unit7>
    137143    </Units>
    138144  </ProjectOptions>
  • trunk/AcronymDecoder.lpr

    r13 r14  
    99  Interfaces, // this includes the LCL widgetset
    1010  Forms, UFormMain, UAcronym, synapse, UFormImport, Common, SysUtils, TemplateGenerics,
    11   UFormAcronym, CoolTranslator, UFormSettings, UFormCategorySelect
     11  UFormAcronym, CoolTranslator, UFormSettings, UFormCategorySelect,
     12UFormCategories
    1213  { you can add units after this };
    1314
     
    3536  Application.CreateForm(TFormSettings, FormSettings);
    3637  Application.CreateForm(TFormCategorySelect, FormCategorySelect);
     38  Application.CreateForm(TFormCategories, FormCategories);
    3739  Application.Run;
    3840end.
  • trunk/Example acronyms.adp

    r7 r14  
    1 ACL,"Access Control List",
    2 AJAX,"Asynchronous JavaScript and XML",
    3 AP,"Access Point",
     1ACL,"Access Control List",Chat;Internet
     2AJAX,"Asynchronous JavaScript and XML",Chat
     3AP,"Access Point",Internet
    44API,"Application Programming Interface",
    55AS,"Autonomous System",
  • trunk/Languages/AcronymDecoder.cs.po

    r13 r14  
    5252msgstr "Kategorie:"
    5353
     54#: tformcategories.aadd.caption
     55#, fuzzy
     56msgctxt "tformcategories.aadd.caption"
     57msgid "Add"
     58msgstr "Přidat"
     59
     60#: tformcategories.amodify.caption
     61#, fuzzy
     62msgctxt "tformcategories.amodify.caption"
     63msgid "Modify"
     64msgstr "Upravit"
     65
     66#: tformcategories.aremove.caption
     67#, fuzzy
     68msgctxt "tformcategories.aremove.caption"
     69msgid "Remove"
     70msgstr "Odebrat"
     71
     72#: tformcategories.caption
     73msgid "Acronym categories"
     74msgstr ""
     75
     76#: tformcategories.listviewcategories.columns[0].caption
     77#, fuzzy
     78msgctxt "tformcategories.listviewcategories.columns[0].caption"
     79msgid "Name"
     80msgstr "Název"
     81
     82#: tformcategories.listviewcategories.columns[1].caption
     83msgctxt "tformcategories.listviewcategories.columns[1].caption"
     84msgid "Used count"
     85msgstr ""
     86
    5487#: tformcategoryselect.buttoncancel.caption
    5588msgctxt "tformcategoryselect.buttoncancel.caption"
     
    92125
    93126#: tformmain.aacronymmodify.caption
     127msgctxt "tformmain.aacronymmodify.caption"
    94128msgid "Modify"
    95129msgstr "Upravit"
     
    142176msgstr "Ukázat"
    143177
     178#: tformmain.ashowcategories.caption
     179msgctxt "tformmain.ashowcategories.caption"
     180msgid "Categories"
     181msgstr ""
     182
    144183#: tformmain.caption
    145184msgid "Acronym Decoder"
     
    147186
    148187#: tformmain.listviewacronyms.columns[0].caption
     188msgctxt "tformmain.listviewacronyms.columns[0].caption"
    149189msgid "Name"
    150190msgstr "Název"
     
    155195
    156196#: tformmain.listviewacronyms.columns[2].caption
    157 msgid "Contexts"
     197#, fuzzy
     198#| msgid "Contexts"
     199msgctxt "tformmain.listviewacronyms.columns[2].caption"
     200msgid "Categories"
    158201msgstr "Kontexty"
    159202
     
    165208msgid "Tools"
    166209msgstr "Nástroje"
     210
     211#: tformmain.menuitem20.caption
     212msgid "View"
     213msgstr ""
    167214
    168215#: tformmain.menuitem8.caption
     
    198245
    199246#: uformacronym.scategory
     247msgctxt "uformacronym.scategory"
    200248msgid "Category"
    201249msgstr "Kategorie"
     
    209257msgstr "Opravdu chcete odebrat vybrané kategorie?"
    210258
     259#: uformcategories.scategory
     260#, fuzzy
     261msgctxt "uformcategories.scategory"
     262msgid "Category"
     263msgstr "Kategorie"
     264
     265#: uformcategories.scategoryalreadyexists
     266msgid "Category %s already exists!"
     267msgstr ""
     268
     269#: uformcategories.scategoryquery
     270msgid "Enter name of category"
     271msgstr ""
     272
     273#: uformcategories.sremovecategory
     274msgid "Remove category"
     275msgstr ""
     276
     277#: uformcategories.sremovecategoryquery
     278msgid "Do you really want to remove category?"
     279msgstr ""
     280
    211281#: uformimport.simportednewacronyms
    212282msgid "Imported %d new acronyms."
  • trunk/Languages/AcronymDecoder.po

    r13 r14  
    4242msgstr ""
    4343
     44#: tformcategories.aadd.caption
     45msgctxt "TFORMCATEGORIES.AADD.CAPTION"
     46msgid "Add"
     47msgstr ""
     48
     49#: tformcategories.amodify.caption
     50msgctxt "TFORMCATEGORIES.AMODIFY.CAPTION"
     51msgid "Modify"
     52msgstr ""
     53
     54#: tformcategories.aremove.caption
     55msgctxt "TFORMCATEGORIES.AREMOVE.CAPTION"
     56msgid "Remove"
     57msgstr ""
     58
     59#: tformcategories.caption
     60msgid "Acronym categories"
     61msgstr ""
     62
     63#: tformcategories.listviewcategories.columns[0].caption
     64msgctxt "TFORMCATEGORIES.LISTVIEWCATEGORIES.COLUMNS[0].CAPTION"
     65msgid "Name"
     66msgstr ""
     67
     68#: tformcategories.listviewcategories.columns[1].caption
     69msgctxt "TFORMCATEGORIES.LISTVIEWCATEGORIES.COLUMNS[1].CAPTION"
     70msgid "Used count"
     71msgstr ""
     72
    4473#: tformcategoryselect.buttoncancel.caption
    4574msgctxt "TFORMCATEGORYSELECT.BUTTONCANCEL.CAPTION"
     
    82111
    83112#: tformmain.aacronymmodify.caption
     113msgctxt "tformmain.aacronymmodify.caption"
    84114msgid "Modify"
    85115msgstr ""
     
    132162msgstr ""
    133163
     164#: tformmain.ashowcategories.caption
     165msgctxt "tformmain.ashowcategories.caption"
     166msgid "Categories"
     167msgstr ""
     168
    134169#: tformmain.caption
    135170msgid "Acronym Decoder"
     
    137172
    138173#: tformmain.listviewacronyms.columns[0].caption
     174msgctxt "tformmain.listviewacronyms.columns[0].caption"
    139175msgid "Name"
    140176msgstr ""
     
    145181
    146182#: tformmain.listviewacronyms.columns[2].caption
    147 msgid "Contexts"
     183msgctxt "tformmain.listviewacronyms.columns[2].caption"
     184msgid "Categories"
    148185msgstr ""
    149186
     
    154191#: tformmain.menuitem16.caption
    155192msgid "Tools"
     193msgstr ""
     194
     195#: tformmain.menuitem20.caption
     196msgid "View"
    156197msgstr ""
    157198
     
    188229
    189230#: uformacronym.scategory
     231msgctxt "uformacronym.scategory"
    190232msgid "Category"
    191233msgstr ""
     
    199241msgstr ""
    200242
     243#: uformcategories.scategory
     244msgctxt "uformcategories.scategory"
     245msgid "Category"
     246msgstr ""
     247
     248#: uformcategories.scategoryalreadyexists
     249msgid "Category %s already exists!"
     250msgstr ""
     251
     252#: uformcategories.scategoryquery
     253msgid "Enter name of category"
     254msgstr ""
     255
     256#: uformcategories.sremovecategory
     257msgid "Remove category"
     258msgstr ""
     259
     260#: uformcategories.sremovecategoryquery
     261msgid "Do you really want to remove category?"
     262msgstr ""
     263
    201264#: uformimport.simportednewacronyms
    202265msgid "Imported %d new acronyms."
  • trunk/UAcronym.pas

    r13 r14  
    1515    Name: string;
    1616    URL: string;
     17  end;
     18
     19  TAcronymSources = class(TObjectList)
     20
    1721  end;
    1822
     
    5761  TAcronymCategory = class
    5862    Name: string;
    59     Acronyms: TObjectList; // TObjectList<TAcronym>
     63    AcronymMeanings: TAcronymMeanings;
    6064    constructor Create;
    6165    destructor Destroy; override;
     
    8690  TAcronymDb = class
    8791    FileName: string;
    88     Sources: TObjectList; // TObjectList<TAcronymSource>
     92    Sources: TAcronymSources;
    8993    Acronyms: TAcronyms;
    9094    Categories: TAcronymCategories;
     
    148152
    149153destructor TAcronymMeaning.Destroy;
    150 begin
     154var
     155  I: Integer;
     156begin
     157  for I := 0 to Categories.Count - 1 do
     158    TAcronymCategory(Categories[I]).AcronymMeanings.Remove(Self);
    151159  FreeAndNil(Categories);
    152160  inherited Destroy;
     
    205213begin
    206214  Clear;
    207   for I := 0 to Strings.Count - 1 do
     215  for I := 0 to Strings.Count - 1 do begin
    208216    Add(TAcronymCategory(Strings.Objects[I]));
     217  end;
    209218end;
    210219
     
    227236constructor TAcronymCategory.Create;
    228237begin
    229   Acronyms := TObjectList.Create(False);
     238  AcronymMeanings := TAcronymMeanings.Create(False);
    230239end;
    231240
    232241destructor TAcronymCategory.Destroy;
    233 begin
    234   FreeAndNil(Acronyms);
     242var
     243  I: Integer;
     244begin
     245  for I := 0 to AcronymMeanings.Count - 1 do
     246    TAcronymMeaning(AcronymMeanings[I]).Categories.Remove(Self);
     247  FreeAndNil(AcronymMeanings);
    235248  inherited Destroy;
    236249end;
     
    240253constructor TAcronymDb.Create;
    241254begin
    242   Sources := TObjectList.Create;
     255  Sources := TAcronymSources.Create;
    243256  Acronyms := TAcronyms.Create;
    244257  Categories := TAcronymCategories.Create;
    245   TAcronymCategory(Categories[Categories.Add(TAcronymCategory.Create)]).Name := 'Internet';
    246   TAcronymCategory(Categories[Categories.Add(TAcronymCategory.Create)]).Name := 'Software';
    247   TAcronymCategory(Categories[Categories.Add(TAcronymCategory.Create)]).Name := 'Chat';
    248258end;
    249259
     
    260270  F: TStringList;
    261271  Line: TStringList;
    262   Context: TStringList;
     272  CategoryStrings: TStringList;
    263273  NewAcronym: TAcronym;
    264274  NewMeaning: TAcronymMeaning;
    265275  I: Integer;
    266276  J: Integer;
    267   AcronymContext: TAcronymCategory;
     277  AcronymCategory: TAcronymCategory;
    268278begin
    269279  Self.FileName := FileName;
     
    272282  Line := TStringList.Create;
    273283  Line.StrictDelimiter := True;
    274   Context := TStringList.Create;
    275   Context.Delimiter := ';';
     284  CategoryStrings := TStringList.Create;
     285  CategoryStrings.Delimiter := ';';
    276286  try
    277287    F.LoadFromFile(FileName);
     
    291301        NewAcronym.Meanings.Add(NewMeaning);
    292302      end;
    293       Context.DelimitedText := Line[2];
    294       for J := 0 to Context.Count - 1 do begin
    295         AcronymContext := Categories.SearchByName(Context[J]);
    296         if not Assigned(AcronymContext) then begin
    297           AcronymContext := TAcronymCategory.Create;
    298           AcronymContext.Name := Context[J];
    299           Categories.Add(AcronymContext);
     303      CategoryStrings.DelimitedText := Line[2];
     304      for J := 0 to CategoryStrings.Count - 1 do begin
     305        AcronymCategory := Categories.SearchByName(CategoryStrings[J]);
     306        if not Assigned(AcronymCategory) then begin
     307          AcronymCategory := TAcronymCategory.Create;
     308          AcronymCategory.Name := CategoryStrings[J];
     309          Categories.Add(AcronymCategory);
    300310        end;
    301         NewMeaning.Categories.Add(AcronymContext);
     311        NewMeaning.Categories.Add(AcronymCategory);
     312        AcronymCategory.AcronymMeanings.Add(NewMeaning);
    302313      end;
    303314    end;
     
    305316    F.Free;
    306317    Line.Free;
    307     Context.Free;
     318    CategoryStrings.Free;
    308319  end;
    309320  Modified := False;
  • trunk/UFormMain.lfm

    r13 r14  
    3030      end   
    3131      item
    32         Caption = 'Contexts'
     32        Caption = 'Categories'
    3333        Width = 300
    3434      end>
     
    44204420      OnExecute = ASettingsExecute
    44214421    end
     4422    object AShowCategories: TAction
     4423      Caption = 'Categories'
     4424      OnExecute = AShowCategoriesExecute
     4425    end
    44224426  end
    44234427  object PersistentForm1: TPersistentForm
     
    44734477      end
    44744478    end
     4479    object MenuItem20: TMenuItem
     4480      Caption = 'View'
     4481      object MenuItem21: TMenuItem
     4482        Action = AShowCategories
     4483      end
     4484    end
    44754485    object MenuItem16: TMenuItem
    44764486      Caption = 'Tools'
  • trunk/UFormMain.lrt

    r13 r14  
    22TFORMMAIN.LISTVIEWACRONYMS.COLUMNS[0].CAPTION=Name
    33TFORMMAIN.LISTVIEWACRONYMS.COLUMNS[1].CAPTION=Description
    4 TFORMMAIN.LISTVIEWACRONYMS.COLUMNS[2].CAPTION=Contexts
     4TFORMMAIN.LISTVIEWACRONYMS.COLUMNS[2].CAPTION=Categories
    55TFORMMAIN.AEXIT.CAPTION=Exit
    66TFORMMAIN.ASHOW.CAPTION=Show
     
    1616TFORMMAIN.AFILESAVEAS.CAPTION=Save as...
    1717TFORMMAIN.ASETTINGS.CAPTION=Settings
     18TFORMMAIN.ASHOWCATEGORIES.CAPTION=Categories
    1819TFORMMAIN.MENUITEM8.CAPTION=File
    1920TFORMMAIN.MENUITEMOPENRECENT.CAPTION=Open recent
    2021TFORMMAIN.MENUITEM15.CAPTION=-
     22TFORMMAIN.MENUITEM20.CAPTION=View
    2123TFORMMAIN.MENUITEM16.CAPTION=Tools
  • trunk/UFormMain.pas

    r13 r14  
    1919    AAcronymRemove: TAction;
    2020    AAcronymRemoveAll: TAction;
     21    AShowCategories: TAction;
    2122    ASettings: TAction;
    2223    AFileSaveAs: TAction;
     
    4546    MenuItem18: TMenuItem;
    4647    MenuItem19: TMenuItem;
     48    MenuItem20: TMenuItem;
     49    MenuItem21: TMenuItem;
    4750    MenuItemOpenRecent: TMenuItem;
    4851    MenuItem2: TMenuItem;
     
    7275    procedure AImportExecute(Sender: TObject);
    7376    procedure ASettingsExecute(Sender: TObject);
     77    procedure AShowCategoriesExecute(Sender: TObject);
    7478    procedure AShowExecute(Sender: TObject);
    7579    procedure EditSearchChange(Sender: TObject);
     
    111115
    112116uses
    113   UFormImport, UFormAcronym, UFormSettings;
     117  UFormImport, UFormAcronym, UFormSettings, UFormCategories;
    114118
    115119resourcestring
     
    230234  TempCategories: TStringList;
    231235  Meaning: TAcronymMeaning;
     236  I: Integer;
    232237begin
    233238  if Assigned(ListViewAcronyms.Selected) then
     
    252257        Meaning.Description := TempEntry.Description;
    253258        Meaning.Categories.AssignFromStrings(TempEntry.Categories);
     259        for I := 0 to Meaning.Categories.Count - 1 do
     260          TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.Add(Meaning);
    254261        UpdateAcronymsList;
    255262        UpdateInterface;
     
    289296  TempEntry: TAcronymEntry;
    290297  Meaning: TAcronymMeaning;
     298  I: Integer;
    291299begin
    292300  TempEntry := TAcronymEntry.Create;
     
    300308    Meaning.Description := TempEntry.Description;
    301309    Meaning.Categories.AssignFromStrings(TempEntry.Categories);
     310    for I := 0 to Meaning.Categories.Count - 1 do
     311      TAcronymCategory(Meaning.Categories.Items[I]).AcronymMeanings.Add(Meaning);
    302312    UpdateAcronymsList;
    303313    UpdateInterface;
     
    318328  if FormSettings.ShowModal = mrOk then
    319329    FormSettings.Save;
     330end;
     331
     332procedure TFormMain.AShowCategoriesExecute(Sender: TObject);
     333begin
     334  FormCategories.ShowModal;
    320335end;
    321336
     
    440455  EditSearch.Enabled := Assigned(AcronymDb);
    441456  AImport.Enabled := Assigned(AcronymDb);
     457  AShowCategories.Enabled := Assigned(AcronymDb);
    442458
    443459  Title := Application.Title;
Note: See TracChangeset for help on using the changeset viewer.