Changeset 13 for trunk/UFormMain.pas


Ignore:
Timestamp:
Apr 28, 2016, 10:09:02 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Acronym meaning context items renamed to categories.
  • Added: Ability to select categories for meanings.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UFormMain.pas

    r12 r13  
    8888  private
    8989    FAlwaysOnTop: Boolean;
     90    function CompareStrings(Strings1, Strings2: TStrings): Boolean;
    9091    procedure SetAlwaysOnTop(AValue: Boolean);
    9192  private
     
    227228var
    228229  TempEntry: TAcronymEntry;
     230  TempCategories: TStringList;
    229231  Meaning: TAcronymMeaning;
    230232begin
     
    235237    TempEntry.Meaning := Name;
    236238    TempEntry.Description := Description;
     239    Categories.AssignToStrings(TempEntry.Categories);
     240    TempCategories := TStringList.Create;
     241    TempCategories.Assign(TempEntry.Categories);
    237242    FormAcronym.Load(TempEntry);
    238243    if FormAcronym.ShowModal = mrOk then begin
     
    240245      if (TempEntry.Name <> Acronym.Name) or
    241246      (TempEntry.Meaning <> Name) or
    242       (TempEntry.Description <> Description) then begin
     247      (TempEntry.Description <> Description) or
     248      not CompareStrings(TempEntry.Categories, TempCategories) then begin
    243249        // TODO: Update item inplace if possible
    244250        AcronymDb.RemoveAcronym(Acronym.Name, Name);
    245251        Meaning := AcronymDb.AddAcronym(TempEntry.Name, TempEntry.Meaning);
    246252        Meaning.Description := TempEntry.Description;
     253        Meaning.Categories.AssignFromStrings(TempEntry.Categories);
    247254        UpdateAcronymsList;
    248255        UpdateInterface;
    249256      end;
    250257    end;
     258    TempEntry.Free;
     259    TempCategories.Free;
    251260  end;
    252261end;
     
    290299    Meaning := AcronymDb.AddAcronym(TempEntry.Name, TempEntry.Meaning);
    291300    Meaning.Description := TempEntry.Description;
     301    Meaning.Categories.AssignFromStrings(TempEntry.Categories);
    292302    UpdateAcronymsList;
    293303    UpdateInterface;
    294   end else TempEntry.Free;
     304  end;
     305  TempEntry.Free;
    295306end;
    296307
     
    347358    Item.Data := TAcronymMeaning(FoundAcronyms[Item.Index]);
    348359    ContextCombined := '';
    349     for I := 0 to Contexts.Count - 1 do
    350       ContextCombined := ContextCombined + TAcronymContext(Contexts[I]).Name + ',';
     360    for I := 0 to Categories.Count - 1 do
     361      ContextCombined := ContextCombined + TAcronymCategory(Categories[I]).Name + ',';
    351362    Delete(ContextCombined, Length(ContextCombined), 1);
    352363    Item.SubItems.Add(ContextCombined);
     
    372383begin
    373384  Visible := not Visible;
     385end;
     386
     387function TFormMain.CompareStrings(Strings1, Strings2: TStrings): Boolean;
     388var
     389  I: Integer;
     390begin
     391  Result := Strings1.Count = Strings2.Count;
     392  if not Result then Exit;
     393  for I := 0 to Strings1.Count - 1 do
     394    if (Strings1[I] <> Strings2[I]) or (Strings1.Objects[I] <> Strings2.Objects[I]) then begin
     395      Result := False;
     396      Exit;
     397    end;
    374398end;
    375399
Note: See TracChangeset for help on using the changeset viewer.