Changeset 104 for trunk


Ignore:
Timestamp:
Feb 9, 2022, 5:07:14 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Updated speed of loading of big number of contacts.
  • Added: Contact field indexes cache for faster reverse search of contact fields by its index.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.pas

    r103 r104  
    685685  if EditHomeAddressCity.Text <> '' then Address := Address + ' ' + EditHomeAddressCity.Text;
    686686  if EditHomeAddressCountry.Text <> '' then Address := Address + ' ' + EditHomeAddressCountry.Text;
    687   OpenURL(Core.MapUrl + URLEncode(Trim(Address)));
     687  if Trim(Address) <> '' then
     688    OpenURL(Core.MapUrl + URLEncode(Trim(Address)));
    688689end;
    689690
     
    704705  if EditWorkAddressCity.Text <> '' then Address := Address + ' ' + EditWorkAddressCity.Text;
    705706  if EditWorkAddressCountry.Text <> '' then Address := Address + ' ' + EditWorkAddressCountry.Text;
    706   OpenURL(Core.MapUrl + URLEncode(Trim(Address)));
     707  if Trim(Address) <> '' then
     708    OpenURL(Core.MapUrl + URLEncode(Trim(Address)));
    707709end;
    708710
  • trunk/Forms/UFormContacts.pas

    r103 r104  
    258258  Text: string;
    259259  SelectedCount: Integer;
    260 begin
     260  Selected: Boolean;
     261begin
     262  Selected := Assigned(ListView1.Selected);
    261263  AAdd.Enabled := Assigned(Contacts);
    262   AModify.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    263   ARemove.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
     264  AModify.Enabled := Assigned(Contacts) and Selected;
     265  ARemove.Enabled := Assigned(Contacts) and Selected;
     266  AAdd.Enabled := Assigned(Contacts);
     267  AModify.Enabled := Assigned(Contacts) and Selected;
     268  AClone.Enabled := Assigned(Contacts) and Selected;
     269  ARemove.Enabled := Assigned(Contacts) and Selected;
     270  ASelectAll.Enabled := ListView1.Items.Count > 0;
     271  ALoadFromFile.Enabled := Assigned(Contacts) and Selected;
     272  ASaveToFile.Enabled := Assigned(Contacts) and Selected;
     273  ACopy.Enabled := Assigned(Contacts) and Selected;
     274  ACut.Enabled := Assigned(Contacts) and Selected;
     275  APaste.Enabled := Assigned(Contacts) and (Clipboard.AsText <> '');
    264276
    265277  Text := '';
     
    273285  end;
    274286  StatusBar1.Panels[0].Text := Text;
     287
     288  UpdateColumns;
    275289end;
    276290
     
    613627begin
    614628  if FUpdateCount = 0 then DoUpdateInterface;
    615   AAdd.Enabled := Assigned(Contacts);
    616   AModify.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    617   AClone.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    618   ARemove.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    619   ASelectAll.Enabled := ListView1.Items.Count > 0;
    620   ALoadFromFile.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    621   ASaveToFile.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    622   ACopy.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    623   ACut.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    624   APaste.Enabled := Assigned(Contacts) and (Clipboard.AsText <> '');
    625 
    626   UpdateColumns;
    627629end;
    628630
  • trunk/Forms/UFormProperties.pas

    r103 r104  
    369369  Text: string;
    370370  SelectedCount: Integer;
    371 begin
     371  Selected: Boolean;
     372begin
     373  Selected := Assigned(ListView1.Selected);
    372374  AAdd.Enabled := Assigned(Properties);
    373   AModify.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
    374   AClone.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);;
    375   ARemove.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
    376   ALoadValueFromFile.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
    377   ASaveValueToFile.Enabled := Assigned(Properties) and Assigned(ListView1.Selected);
     375  AModify.Enabled := Assigned(Properties) and Selected;
     376  AClone.Enabled := Assigned(Properties) and Selected;
     377  ARemove.Enabled := Assigned(Properties) and Selected;
     378  ALoadValueFromFile.Enabled := Assigned(Properties) and Selected;
     379  ASaveValueToFile.Enabled := Assigned(Properties) and Selected;
    378380  ASelectAll.Enabled := ListView1.Items.Count > 0;
    379381
  • trunk/Forms/UFormTest.pas

    r103 r104  
    7676
    7777procedure TFormTest.UpdateInterface;
    78 begin
    79   ARun.Enabled := Assigned(ListViewTestCases.Selected);
    80   AShow.Enabled := Assigned(ListViewTestCases.Selected);
     78var
     79  Selected: Boolean;
     80begin
     81  Selected := Assigned(ListViewTestCases.Selected);
     82  ARun.Enabled := Selected;
     83  AShow.Enabled := Selected;
    8184end;
    8285
  • trunk/Languages/vCardStudio.cs.po

    r103 r104  
    10111011msgstr "Index pole nenalezen"
    10121012
     1013#: ucontact.sfieldindexredefined
     1014#, object-pascal-format
     1015msgid "Field index %d redefined"
     1016msgstr "Index pole %d předefinován"
     1017
    10131018#: ucontact.sfirstname
    10141019msgid "First Name"
  • trunk/Languages/vCardStudio.pot

    r103 r104  
    985985msgstr ""
    986986
     987#: ucontact.sfieldindexredefined
     988#, object-pascal-format
     989msgid "Field index %d redefined"
     990msgstr ""
     991
    987992#: ucontact.sfirstname
    988993msgid "First Name"
  • trunk/UContact.pas

    r103 r104  
    7171
    7272  TContactFields = class(TFPGObjectList<TContactField>)
     73  private
     74    Indexes: array[TContactFieldIndex] of TContactField;
     75    IndexesUpdated: Boolean;
     76  public
     77    procedure UpdateIndexes;
    7378    function AddNew(Name: string; Groups: array of string; NoGroups: array of string;
    7479      Title: string; Index: TContactFieldIndex; DataType:
     
    209214resourcestring
    210215  SVCardFile = 'vCard file';
     216  SFieldIndexRedefined = 'Field index %d redefined';
    211217  SExpectedVCardBegin = 'Expected vCard begin';
    212218  SFieldIndexNotDefined = 'Field index not defined';
     
    779785{ TContactFields }
    780786
     787procedure TContactFields.UpdateIndexes;
     788var
     789  I: Integer;
     790  Index: TContactFieldIndex;
     791begin
     792  for Index := Low(TContactFieldIndex) to High(TContactFieldIndex) do
     793    Indexes[Index] := nil;
     794  for I := 0 to Count - 1 do
     795    if not Assigned(Indexes[Items[I].Index]) then Indexes[Items[I].Index] := Items[I]
     796      else raise Exception.Create(Format(SFieldIndexRedefined, [Integer(Items[I].Index)]));
     797  IndexesUpdated := True;
     798end;
     799
    781800function TContactFields.AddNew(Name: string; Groups: array of string;
    782801  NoGroups: array of string; Title: string; Index: TContactFieldIndex;
     
    798817  Result.DataType := DataType;
    799818  Add(Result);
     819  IndexesUpdated := False;
    800820end;
    801821
     
    825845  I: Integer;
    826846begin
    827   I := 0;
    828   while (I < Count) and (Items[I].Index <> Index) do Inc(I);
    829   if I < Count then Result := Items[I]
    830     else Result := nil;
     847  if IndexesUpdated then Result := Indexes[Index]
     848  else begin
     849    I := 0;
     850    while (I < Count) and (Items[I].Index <> Index) do Inc(I);
     851    if I < Count then Result := Items[I]
     852      else Result := nil;
     853  end;
    831854end;
    832855
     
    958981    with AddNew('X-MYSPACE', [], [], SMySpace, cfMySpace, dtString) do
    959982      AddAlternative('X-SOCIALPROFILE', ['MYSPACE'], []);
     983    UpdateIndexes;
    960984    end;
    961985  end;
Note: See TracChangeset for help on using the changeset viewer.