Changeset 73 for trunk/Forms


Ignore:
Timestamp:
Dec 13, 2021, 11:33:11 PM (3 years ago)
Author:
chronos
Message:
  • Added: Copy, cut and paste context menu action in contacts list.
  • Modified: Merge multiple files action replaced by Combine action. During Combine action files are simply added into final contacts list even with duplicate contacts.
  • Modified: Added Merge button into Find duplicate window to merge contacts by selected contact field.
  • Modified: Show only used contact fields in Find duplicates window.
  • Fixed: Wrong items were removed if contacts and properties lists were in filtered state.
Location:
trunk/Forms
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.lfm

    r71 r73  
    429429        Anchors = [akTop, akLeft, akRight]
    430430        Caption = 'Address'
    431         ClientHeight = 215
    432         ClientWidth = 920
     431        ClientHeight = 212
     432        ClientWidth = 918
    433433        TabOrder = 6
    434434        object Label36: TLabel
     
    573573    object TabSheetWork: TTabSheet
    574574      Caption = 'Work'
    575       ClientHeight = 628
    576       ClientWidth = 959
     575      ClientHeight = 630
     576      ClientWidth = 961
    577577      OnHide = TabSheetWorkHide
    578578      OnShow = TabSheetWorkShow
    579579      object EditOrganization: TEdit
    580580        Left = 173
    581         Height = 42
     581        Height = 33
    582582        Top = 64
    583583        Width = 254
     
    587587      object LabelOrganization: TLabel
    588588        Left = 10
    589         Height = 24
     589        Height = 25
    590590        Top = 70
    591         Width = 114
     591        Width = 106
    592592        Caption = 'Organization:'
    593593        ParentColor = False
     
    596596      object LabelOrganization1: TLabel
    597597        Left = 451
    598         Height = 24
     598        Height = 25
    599599        Top = 24
    600         Width = 106
     600        Width = 99
    601601        Caption = 'Department:'
    602602        ParentColor = False
     
    605605      object EditDepartment: TEdit
    606606        Left = 608
    607         Height = 42
     607        Height = 33
    608608        Top = 20
    609609        Width = 254
     
    613613      object Label18: TLabel
    614614        Left = 10
    615         Height = 24
     615        Height = 25
    616616        Top = 20
    617         Width = 41
     617        Width = 36
    618618        Caption = 'Title:'
    619619        ParentColor = False
     
    622622      object EditTitle: TEdit
    623623        Left = 173
    624         Height = 42
     624        Height = 33
    625625        Top = 16
    626626        Width = 254
     
    630630      object EditWorkWeb: TEdit
    631631        Left = 173
    632         Height = 42
     632        Height = 33
    633633        Top = 256
    634634        Width = 683
     
    638638      object Label32: TLabel
    639639        Left = 10
    640         Height = 24
     640        Height = 25
    641641        Top = 264
    642         Width = 114
     642        Width = 107
    643643        Caption = 'Web address:'
    644644        ParentColor = False
     
    651651        Width = 911
    652652        Caption = 'Address'
    653         ClientHeight = 220
    654         ClientWidth = 909
     653        ClientHeight = 217
     654        ClientWidth = 907
    655655        TabOrder = 4
    656656        object Label31: TLabel
    657657          Left = 10
    658           Height = 24
     658          Height = 25
    659659          Top = 160
    660           Width = 71
     660          Width = 67
    661661          Caption = 'Country:'
    662662          ParentColor = False
     
    665665        object EditAddressWorkCountry: TEdit
    666666          Left = 173
    667           Height = 42
     667          Height = 33
    668668          Top = 160
    669669          Width = 254
     
    673673        object EditAddressWorkRegion: TEdit
    674674          Left = 173
    675           Height = 42
     675          Height = 33
    676676          Top = 112
    677677          Width = 254
     
    681681        object Label30: TLabel
    682682          Left = 10
    683           Height = 24
     683          Height = 25
    684684          Top = 112
    685           Width = 64
     685          Width = 59
    686686          Caption = 'Region:'
    687687          ParentColor = False
     
    690690        object Label35: TLabel
    691691          Left = 10
    692           Height = 24
     692          Height = 25
    693693          Top = 66
    694           Width = 137
     694          Width = 126
    695695          Caption = 'Extended street:'
    696696          ParentColor = False
     
    699699        object EditAddressWorkStreetExtended: TEdit
    700700          Left = 173
    701           Height = 42
     701          Height = 33
    702702          Top = 64
    703703          Width = 254
     
    707707        object Label28: TLabel
    708708          Left = 10
    709           Height = 24
     709          Height = 25
    710710          Top = 18
    711           Width = 54
     711          Width = 49
    712712          Caption = 'Street:'
    713713          ParentColor = False
     
    716716        object EditAddressWorkStreet: TEdit
    717717          Left = 173
    718           Height = 42
     718          Height = 33
    719719          Top = 8
    720720          Width = 254
     
    724724        object Label34: TLabel
    725725          Left = 451
    726           Height = 24
     726          Height = 25
    727727          Top = 18
    728           Width = 131
     728          Width = 122
    729729          Caption = 'Post office box:'
    730730          ParentColor = False
     
    733733        object EditAddressWorkPostOfficeBox: TEdit
    734734          Left = 608
    735           Height = 42
     735          Height = 33
    736736          Top = 8
    737737          Width = 254
     
    741741        object EditAddressWorkCity: TEdit
    742742          Left = 608
    743           Height = 42
     743          Height = 33
    744744          Top = 56
    745745          Width = 254
     
    749749        object Label29: TLabel
    750750          Left = 451
    751           Height = 24
     751          Height = 25
    752752          Top = 64
    753           Width = 36
     753          Width = 34
    754754          Caption = 'City:'
    755755          ParentColor = False
     
    758758        object EditAddressWorkPostalCode: TEdit
    759759          Left = 608
    760           Height = 42
     760          Height = 33
    761761          Top = 142
    762762          Width = 254
     
    766766        object Label33: TLabel
    767767          Left = 451
    768           Height = 24
     768          Height = 25
    769769          Top = 150
    770           Width = 103
     770          Width = 95
    771771          Caption = 'Postal code:'
    772772          ParentColor = False
     
    776776      object Label15: TLabel
    777777        Left = 10
    778         Height = 24
     778        Height = 25
    779779        Top = 116
    780         Width = 59
     780        Width = 54
    781781        Caption = 'Phone:'
    782782        ParentColor = False
     
    785785      object EditWorkPhone: TEdit
    786786        Left = 173
    787         Height = 42
     787        Height = 33
    788788        Top = 112
    789789        Width = 254
     
    793793      object Label16: TLabel
    794794        Left = 451
    795         Height = 24
     795        Height = 25
    796796        Top = 112
    797         Width = 34
     797        Width = 29
    798798        Caption = 'Fax:'
    799799        ParentColor = False
     
    802802      object EditWorkFax: TEdit
    803803        Left = 608
    804         Height = 42
     804        Height = 33
    805805        Top = 112
    806806        Width = 254
     
    810810      object EditWorkPager: TEdit
    811811        Left = 608
    812         Height = 42
     812        Height = 33
    813813        Top = 156
    814814        Width = 254
     
    818818      object Label17: TLabel
    819819        Left = 448
    820         Height = 24
     820        Height = 25
    821821        Top = 160
    822         Width = 54
     822        Width = 48
    823823        Caption = 'Pager:'
    824824        ParentColor = False
     
    827827      object EditWorkMobile: TEdit
    828828        Left = 173
    829         Height = 42
     829        Height = 33
    830830        Top = 160
    831831        Width = 254
     
    835835      object Label19: TLabel
    836836        Left = 10
    837         Height = 24
     837        Height = 25
    838838        Top = 160
    839         Width = 63
     839        Width = 59
    840840        Caption = 'Mobile:'
    841841        ParentColor = False
     
    844844      object Label8: TLabel
    845845        Left = 10
    846         Height = 24
     846        Height = 25
    847847        Top = 210
    848         Width = 58
     848        Width = 53
    849849        Caption = 'E-mail:'
    850850        ParentColor = False
     
    853853      object EditWorkEmail: TEdit
    854854        Left = 173
    855         Height = 42
     855        Height = 33
    856856        Top = 210
    857857        Width = 254
  • trunk/Forms/UFormContacts.lfm

    r72 r73  
    149149      Action = ASelectAll
    150150    end
     151    object MenuItem12: TMenuItem
     152      Caption = '-'
     153    end
     154    object MenuItem9: TMenuItem
     155      Action = ACut
     156    end
     157    object MenuItem10: TMenuItem
     158      Action = ACopy
     159    end
     160    object MenuItem11: TMenuItem
     161      Action = APaste
     162    end
    151163    object MenuItem6: TMenuItem
    152164      Caption = '-'
     
    201213      OnExecute = ASaveToFileExecute
    202214    end
     215    object ACopy: TAction
     216      Caption = 'Copy'
     217      ImageIndex = 11
     218      OnExecute = ACopyExecute
     219      ShortCut = 16451
     220    end
     221    object ACut: TAction
     222      Caption = 'Cut'
     223      ImageIndex = 12
     224      OnExecute = ACutExecute
     225      ShortCut = 16472
     226    end
     227    object APaste: TAction
     228      Caption = 'Paste'
     229      ImageIndex = 13
     230      OnExecute = APasteExecute
     231      ShortCut = 16470
     232    end
    203233  end
    204234  object ListViewSort1: TListViewSort
  • trunk/Forms/UFormContacts.lrj

    r72 r73  
    1515{"hash":4863557,"name":"tformcontacts.aclone.caption","sourcebytes":[67,108,111,110,101],"value":"Clone"},
    1616{"hash":177113358,"name":"tformcontacts.aloadfromfile.caption","sourcebytes":[76,111,97,100,32,102,114,111,109,32,102,105,108,101,46,46,46],"value":"Load from file..."},
    17 {"hash":10127854,"name":"tformcontacts.asavetofile.caption","sourcebytes":[83,97,118,101,32,116,111,32,102,105,108,101,46,46,46],"value":"Save to file..."}
     17{"hash":10127854,"name":"tformcontacts.asavetofile.caption","sourcebytes":[83,97,118,101,32,116,111,32,102,105,108,101,46,46,46],"value":"Save to file..."},
     18{"hash":304761,"name":"tformcontacts.acopy.caption","sourcebytes":[67,111,112,121],"value":"Copy"},
     19{"hash":19140,"name":"tformcontacts.acut.caption","sourcebytes":[67,117,116],"value":"Cut"},
     20{"hash":5671589,"name":"tformcontacts.apaste.caption","sourcebytes":[80,97,115,116,101],"value":"Paste"}
    1821]}
  • trunk/Forms/UFormContacts.pas

    r72 r73  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, Menus, ActnList, UContact, UListViewSort, fgl, LazUTF8;
     9  ComCtrls, Menus, ActnList, UContact, UListViewSort, fgl, LazUTF8, Clipbrd;
    1010
    1111type
     
    1616    AAdd: TAction;
    1717    AClone: TAction;
     18    ACopy: TAction;
     19    ACut: TAction;
     20    APaste: TAction;
    1821    ALoadFromFile: TAction;
    1922    ASaveToFile: TAction;
     
    2629    ListViewSort1: TListViewSort;
    2730    MenuItem1: TMenuItem;
     31    MenuItem10: TMenuItem;
     32    MenuItem11: TMenuItem;
     33    MenuItem12: TMenuItem;
    2834    MenuItem2: TMenuItem;
    2935    MenuItem3: TMenuItem;
     
    3339    MenuItem7: TMenuItem;
    3440    MenuItem8: TMenuItem;
     41    MenuItem9: TMenuItem;
    3542    OpenDialog1: TOpenDialog;
    3643    PopupMenuContact: TPopupMenu;
     
    4754    procedure AAddExecute(Sender: TObject);
    4855    procedure ACloneExecute(Sender: TObject);
     56    procedure ACopyExecute(Sender: TObject);
     57    procedure ACutExecute(Sender: TObject);
    4958    procedure ALoadFromFileExecute(Sender: TObject);
    5059    procedure AModifyExecute(Sender: TObject);
     60    procedure APasteExecute(Sender: TObject);
    5161    procedure ARemoveExecute(Sender: TObject);
    5262    procedure ASaveToFileExecute(Sender: TObject);
     
    334344end;
    335345
     346procedure TFormContacts.ACopyExecute(Sender: TObject);
     347var
     348  Text: string;
     349  Strings: TStringList;
     350  I: Integer;
     351begin
     352  Strings := TStringList.Create;
     353  try
     354  Text := '';
     355  for I := 0 to ListView1.Items.Count - 1 do
     356    if ListView1.Items[I].Selected then begin
     357      TContact(ListView1.Items[I].Data).SaveToStrings(Strings);
     358      Text := Text + Strings.Text;
     359    end;
     360    Clipboard.AsText := Text;
     361  finally
     362    Strings.Free;
     363  end;
     364end;
     365
     366procedure TFormContacts.ACutExecute(Sender: TObject);
     367var
     368  Text: string;
     369  Strings: TStringList;
     370  I: Integer;
     371begin
     372  Strings := TStringList.Create;
     373  try
     374    Text := '';
     375    for I := 0 to ListView1.Items.Count - 1 do
     376      if ListView1.Items[I].Selected then begin
     377        TContact(ListView1.Items[I].Data).SaveToStrings(Strings);
     378        Text := Text + Strings.Text;
     379      end;
     380    Clipboard.AsText := Text;
     381    for I := 0 to ListView1.Items.Count - 1 do
     382      if ListView1.Items[I].Selected then begin
     383        Contacts.Delete(Contacts.IndexOf(ListView1.Items[I].Data));
     384      end;
     385    ReloadList;
     386    ListView1.ClearSelection;
     387    UpdateInterface;
     388  finally
     389    Strings.Free;
     390  end;
     391end;
     392
    336393procedure TFormContacts.ALoadFromFileExecute(Sender: TObject);
    337394var
     
    384441end;
    385442
     443procedure TFormContacts.APasteExecute(Sender: TObject);
     444var
     445  PasteContacts: TContactsFile;
     446  Lines: TStringList;
     447begin
     448  PasteContacts := TContactsFile.Create;
     449  Lines := TStringList.Create;
     450  try
     451    Lines.Text := Clipboard.AsText;
     452    PasteContacts.LoadFromStrings(Lines);
     453    if PasteContacts.Contacts.Count > 0 then begin
     454      if Assigned(ListView1.Selected) then begin
     455        Contacts.InsertContacts(Contacts.IndexOf(ListView1.Selected.Data),
     456          PasteContacts.Contacts);
     457      end else Contacts.AddContacts(PasteContacts.Contacts);
     458      Core.DataFile.Modified := True;
     459      ReloadList;
     460      UpdateInterface;
     461    end;
     462  finally
     463    Lines.Free;
     464    PasteContacts.Free;
     465  end;
     466end;
     467
    386468procedure TFormContacts.ARemoveExecute(Sender: TObject);
    387469var
     
    393475    for I := ListView1.Items.Count - 1 downto 0 do
    394476      if ListView1.Items[I].Selected then begin
    395         Contacts.Delete(I);
     477        Contacts.Delete(Contacts.IndexOf(ListView1.Items[I].Data));
    396478      end;
    397479    Core.DataFile.Modified := True;
  • trunk/Forms/UFormFindDuplicity.lfm

    r23 r73  
    11object FormFindDuplicity: TFormFindDuplicity
    22  Left = 455
    3   Height = 481
    4   Top = 397
    5   Width = 701
     3  Height = 523
     4  Top = 355
     5  Width = 807
    66  Caption = 'Find duplicities'
    7   ClientHeight = 481
    8   ClientWidth = 701
     7  ClientHeight = 523
     8  ClientWidth = 807
    99  DesignTimePPI = 144
    1010  OnClose = FormClose
     
    1515  object ListView1: TListView
    1616    Left = 5
    17     Height = 413
     17    Height = 455
    1818    Top = 63
    19     Width = 691
     19    Width = 797
    2020    Align = alClient
    2121    BorderSpacing.Around = 5
     
    4747    Height = 58
    4848    Top = 0
    49     Width = 701
     49    Width = 807
    5050    Align = alTop
    5151    BevelOuter = bvNone
    5252    ClientHeight = 58
    53     ClientWidth = 701
     53    ClientWidth = 807
    5454    ParentFont = False
    5555    TabOrder = 1
    5656    object ComboBoxField: TComboBox
    57       Left = 173
    58       Height = 41
    59       Top = 14
     57      Left = 160
     58      Height = 33
     59      Top = 16
    6060      Width = 326
    61       ItemHeight = 0
     61      ItemHeight = 25
    6262      OnChange = ComboBoxFieldChange
    6363      ParentFont = False
     
    6767    object Label1: TLabel
    6868      Left = 13
    69       Height = 24
     69      Height = 25
    7070      Top = 19
    71       Width = 111
    72       Caption = 'Contact field:'
     71      Width = 125
     72      Caption = 'By contact field:'
    7373      ParentColor = False
    7474      ParentFont = False
     75    end
     76    object ButtonMerge: TButton
     77      Left = 496
     78      Height = 38
     79      Top = 14
     80      Width = 113
     81      Caption = 'Merge'
     82      OnClick = ButtonMergeClick
     83      TabOrder = 1
    7584    end
    7685  end
  • trunk/Forms/UFormFindDuplicity.lrj

    r21 r73  
    44{"hash":106593811,"name":"tformfindduplicity.listview1.columns[1].caption","sourcebytes":[67,111,110,116,97,99,116,115],"value":"Contacts"},
    55{"hash":4877396,"name":"tformfindduplicity.listview1.columns[2].caption","sourcebytes":[67,111,117,110,116],"value":"Count"},
    6 {"hash":9821370,"name":"tformfindduplicity.label1.caption","sourcebytes":[67,111,110,116,97,99,116,32,102,105,101,108,100,58],"value":"Contact field:"},
     6{"hash":14454458,"name":"tformfindduplicity.label1.caption","sourcebytes":[66,121,32,99,111,110,116,97,99,116,32,102,105,101,108,100,58],"value":"By contact field:"},
     7{"hash":5490901,"name":"tformfindduplicity.buttonmerge.caption","sourcebytes":[77,101,114,103,101],"value":"Merge"},
    78{"hash":229436515,"name":"tformfindduplicity.ashowcontacts.caption","sourcebytes":[83,104,111,119,32,99,111,110,116,97,99,116,115],"value":"Show contacts"}
    89]}
  • trunk/Forms/UFormFindDuplicity.pas

    r68 r73  
    3131    AShowContacts: TAction;
    3232    ActionList1: TActionList;
     33    ButtonMerge: TButton;
    3334    ComboBoxField: TComboBox;
    3435    Label1: TLabel;
     
    3839    PopupMenu1: TPopupMenu;
    3940    procedure AShowContactsExecute(Sender: TObject);
     41    procedure ButtonMergeClick(Sender: TObject);
    4042    procedure ComboBoxFieldChange(Sender: TObject);
    4143    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     
    109111var
    110112  ContactField: TContactField;
     113  Items: TStringList;
     114  I: Integer;
    111115begin
    112116  if FContacts = AValue then Exit;
    113117  FContacts := AValue;
    114118  if Assigned(FContacts) then begin
    115     Contacts.ContactsFile.Fields.LoadToStrings(ComboBoxField.Items);
     119    Items := TStringList.Create;
     120    try
     121      Contacts.ContactsFile.Fields.LoadToStrings(Items);
     122
     123      // Remove fields which are not used in contacts
     124      for I := Items.Count - 1 downto 0 do
     125        if Contacts.CountByField(TContactField(Items.Objects[I]).Index) = 0 then
     126          Items.Delete(I);
     127
     128      ComboBoxField.Items.Assign(Items);
     129    finally
     130      Items.Free;
     131    end;
    116132    ContactField := Contacts.ContactsFile.Fields.GetByIndex(ContactFieldIndex);
    117133    ComboBoxField.ItemIndex := ComboBoxField.Items.IndexOfObject(ContactField);
     
    156172  Core.Translator.TranslateComponentRecursive(Self);
    157173  Core.ThemeManager1.UseTheme(Self);
    158   ContactFieldIndex := cfTelCell;
     174  ContactFieldIndex := cfFullName;
    159175end;
    160176
     
    203219end;
    204220
     221procedure TFormFindDuplicity.ButtonMergeClick(Sender: TObject);
     222var
     223  TempContacts: TContactsFile;
     224  I: Integer;
     225begin
     226  TempContacts := TContactsFile.Create;
     227  try
     228    for I := 0 to Contacts.Count - 1 do
     229      TempContacts.Contacts.Merge(Contacts[I], TContactField(ComboBoxField.Items.Objects[ComboBoxField.ItemIndex]).Index);
     230    Contacts.Assign(TempContacts.Contacts);
     231    Find;
     232  finally
     233    TempContacts.Free;
     234  end;
     235end;
     236
    205237procedure TFormFindDuplicity.FormClose(Sender: TObject;
    206238  var CloseAction: TCloseAction);
  • trunk/Forms/UFormMain.lfm

    r62 r73  
    136136      end
    137137      object MenuItem3: TMenuItem
    138         Action = Core.AFileMerge
     138        Action = Core.AFileCombine
    139139      end
    140140      object MenuItem6: TMenuItem
  • trunk/Forms/UFormProperties.pas

    r72 r73  
    314314    for I := ListView1.Items.Count - 1 downto 0 do
    315315      if ListView1.Items[I].Selected then begin
    316         Properties.Delete(I);
     316        Properties.Delete(Properties.IndexOf(ListView1.Items[I].Data));
    317317      end;
    318318    Core.DataFile.Modified := True;
Note: See TracChangeset for help on using the changeset viewer.