Changeset 51 for trunk/Forms


Ignore:
Timestamp:
Dec 3, 2021, 7:44:05 PM (3 years ago)
Author:
chronos
Message:
  • Added: Clone context menu action for list of contacts and contact properties.
Location:
trunk/Forms
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContacts.lfm

    r36 r51  
    1414  object ListView1: TListView
    1515    Left = 0
    16     Height = 810
     16    Height = 801
    1717    Top = 0
    1818    Width = 1210
     
    5858    Left = 0
    5959    Height = 39
    60     Top = 842
     60    Top = 833
    6161    Width = 1210
    6262    Align = alBottom
     
    7777    end
    7878    object ToolButton3: TToolButton
     79      Left = 106
     80      Top = 2
     81      Action = ARemove
     82    end
     83    object ToolButton4: TToolButton
    7984      Left = 71
    8085      Top = 2
    81       Action = ARemove
     86      Action = AClone
    8287    end
    8388  end
     
    8590    Left = 0
    8691    Height = 32
    87     Top = 810
     92    Top = 801
    8893    Width = 1210
    8994    OnChange = ListViewFilter1Change
     
    9297  object StatusBar1: TStatusBar
    9398    Left = 0
    94     Height = 27
    95     Top = 881
     99    Height = 36
     100    Top = 872
    96101    Width = 1210
    97102    Panels = <   
     
    108113      Action = AAdd
    109114    end
     115    object MenuItem2: TMenuItem
     116      Action = AModify
     117    end
     118    object MenuItem5: TMenuItem
     119      Action = AClone
     120    end
    110121    object MenuItem3: TMenuItem
    111122      Action = ARemove
    112     end
    113     object MenuItem2: TMenuItem
    114       Action = AModify
    115123    end
    116124    object MenuItem4: TMenuItem
     
    145153      ShortCut = 16449
    146154    end
     155    object AClone: TAction
     156      Caption = 'Clone'
     157      ImageIndex = 11
     158      OnExecute = ACloneExecute
     159    end
    147160  end
    148161  object ListViewSort1: TListViewSort
  • trunk/Forms/UFormContacts.lrj

    r21 r51  
    1010{"hash":88453081,"name":"tformcontacts.amodify.caption","sourcebytes":[77,111,100,105,102,121],"value":"Modify"},
    1111{"hash":93079237,"name":"tformcontacts.aremove.caption","sourcebytes":[82,101,109,111,118,101],"value":"Remove"},
    12 {"hash":195296268,"name":"tformcontacts.aselectall.caption","sourcebytes":[83,101,108,101,99,116,32,97,108,108],"value":"Select all"}
     12{"hash":195296268,"name":"tformcontacts.aselectall.caption","sourcebytes":[83,101,108,101,99,116,32,97,108,108],"value":"Select all"},
     13{"hash":4863557,"name":"tformcontacts.aclone.caption","sourcebytes":[67,108,111,110,101],"value":"Clone"}
    1314]}
  • trunk/Forms/UFormContacts.pas

    r43 r51  
    1515  TFormContacts = class(TForm)
    1616    AAdd: TAction;
     17    AClone: TAction;
    1718    ASelectAll: TAction;
    1819    ARemove: TAction;
     
    2627    MenuItem3: TMenuItem;
    2728    MenuItem4: TMenuItem;
     29    MenuItem5: TMenuItem;
    2830    PopupMenuContact: TPopupMenu;
    2931    StatusBar1: TStatusBar;
     
    3234    ToolButton2: TToolButton;
    3335    ToolButton3: TToolButton;
     36    ToolButton4: TToolButton;
    3437    procedure AAddExecute(Sender: TObject);
     38    procedure ACloneExecute(Sender: TObject);
    3539    procedure AModifyExecute(Sender: TObject);
    3640    procedure ARemoveExecute(Sender: TObject);
     
    8084
    8185procedure TFormContacts.ListView1Data(Sender: TObject; Item: TListItem);
     86
     87  procedure AddItem(Text: string; IsCaption: Boolean = False);
     88  begin
     89    if IsCaption then begin
     90      if Text <> '' then Item.Caption := Text
     91        else Item.Caption := ' ';
     92    end else begin
     93      if Text <> '' then Item.SubItems.Add(Text)
     94        else Item.SubItems.Add(' ');
     95    end;
     96  end;
     97
    8298begin
    8399  if Item.Index < ListViewSort1.List.Count then
    84100  with TContact(ListViewSort1.List[Item.Index]) do begin
    85     Item.Caption := Fields[cfFullName];
    86     Item.SubItems.Add(Fields[cfFirstName]);
    87     Item.SubItems.Add(Fields[cfMiddleName]);
    88     Item.SubItems.Add(Fields[cfLastName]);
    89     Item.SubItems.Add(Fields[cfTelCell]);
    90     Item.SubItems.Add(Fields[cfTelHome]);
     101
     102    AddItem(Fields[cfFullName], True);
     103    AddItem(Fields[cfFirstName]);
     104    AddItem(Fields[cfMiddleName]);
     105    AddItem(Fields[cfLastName]);
     106    AddItem(Fields[cfTelCell]);
     107    AddItem(Fields[cfTelHome]);
    91108    Item.Data := ListViewSort1.List[Item.Index];
    92109  end;
     
    228245      if FormContact.ShowModal = mrOK then begin
    229246        Contacts.Add(Contact);
     247        Core.DataFile.Modified := True;
     248        ReloadList;
     249        UpdateInterface;
     250        Contact := nil;
     251      end;
     252    finally
     253      if Assigned(Contact) then
     254        Contact.Free;
     255    end;
     256  finally
     257    FormContact.Free;
     258  end;
     259end;
     260
     261procedure TFormContacts.ACloneExecute(Sender: TObject);
     262var
     263  FormContact: TFormContact;
     264  Contact: TContact;
     265begin
     266  FormContact := TFormContact.Create(nil);
     267  try
     268    Contact := TContact.Create;
     269    try
     270      Contact.Assign(TContact(ListView1.Selected.Data));
     271      FormContact.Contact := Contact;
     272      FormContact.OnPrevious := FormContactPrevious;
     273      FormContact.OnNext := FormContactNext;
     274      if FormContact.ShowModal = mrOK then begin
     275        Contacts.Add(Contact);
    230276        Contact := nil;
    231277        Core.DataFile.Modified := True;
     
    250296  try
    251297    Contact := TContact.Create;
    252     Contact.Assign(TContact(ListView1.Selected.Data));
    253     FormContact.Contact := Contact;
    254     FormContact.OnPrevious := FormContactPrevious;
    255     FormContact.OnNext := FormContactNext;
    256298    try
     299      Contact.Assign(TContact(ListView1.Selected.Data));
     300      FormContact.Contact := Contact;
     301      FormContact.OnPrevious := FormContactPrevious;
     302      FormContact.OnNext := FormContactNext;
    257303      if FormContact.ShowModal = mrOK then begin
    258304        TContact(ListView1.Selected.Data).Assign(Contact);
  • trunk/Forms/UFormProperties.lfm

    r39 r51  
    1414  object ListView1: TListView
    1515    Left = 0
    16     Height = 810
     16    Height = 801
    1717    Top = 0
    1818    Width = 1210
     
    4646    Left = 0
    4747    Height = 39
    48     Top = 842
     48    Top = 833
    4949    Width = 1210
    5050    Align = alBottom
     
    7373    Left = 0
    7474    Height = 32
    75     Top = 810
     75    Top = 801
    7676    Width = 1210
    7777    OnChange = ListViewFilter1Change
     
    8080  object StatusBar1: TStatusBar
    8181    Left = 0
    82     Height = 27
    83     Top = 881
     82    Height = 36
     83    Top = 872
    8484    Width = 1210
    8585    Panels = <   
     
    9696      Action = AAdd
    9797    end
     98    object MenuItem2: TMenuItem
     99      Action = AModify
     100    end
     101    object MenuItem5: TMenuItem
     102      Action = AClone
     103    end
    98104    object MenuItem3: TMenuItem
    99105      Action = ARemove
    100     end
    101     object MenuItem2: TMenuItem
    102       Action = AModify
    103106    end
    104107    object MenuItem4: TMenuItem
     
    133136      ShortCut = 16449
    134137    end
     138    object AClone: TAction
     139      Caption = 'Clone'
     140      ImageIndex = 11
     141      OnExecute = ACloneExecute
     142    end
    135143  end
    136144  object ListViewSort1: TListViewSort
  • trunk/Forms/UFormProperties.lrj

    r39 r51  
    77{"hash":88453081,"name":"tformproperties.amodify.caption","sourcebytes":[77,111,100,105,102,121],"value":"Modify"},
    88{"hash":93079237,"name":"tformproperties.aremove.caption","sourcebytes":[82,101,109,111,118,101],"value":"Remove"},
    9 {"hash":195296268,"name":"tformproperties.aselectall.caption","sourcebytes":[83,101,108,101,99,116,32,97,108,108],"value":"Select all"}
     9{"hash":195296268,"name":"tformproperties.aselectall.caption","sourcebytes":[83,101,108,101,99,116,32,97,108,108],"value":"Select all"},
     10{"hash":4863557,"name":"tformproperties.aclone.caption","sourcebytes":[67,108,111,110,101],"value":"Clone"}
    1011]}
  • trunk/Forms/UFormProperties.pas

    r42 r51  
    1515  TFormProperties = class(TForm)
    1616    AAdd: TAction;
     17    AClone: TAction;
    1718    ASelectAll: TAction;
    1819    ARemove: TAction;
     
    2627    MenuItem3: TMenuItem;
    2728    MenuItem4: TMenuItem;
     29    MenuItem5: TMenuItem;
    2830    PopupMenuField: TPopupMenu;
    2931    StatusBar1: TStatusBar;
     
    3335    ToolButton3: TToolButton;
    3436    procedure AAddExecute(Sender: TObject);
     37    procedure ACloneExecute(Sender: TObject);
    3538    procedure AModifyExecute(Sender: TObject);
    3639    procedure ARemoveExecute(Sender: TObject);
     
    7881
    7982procedure TFormProperties.ListView1Data(Sender: TObject; Item: TListItem);
     83
     84  procedure AddItem(Text: string; IsCaption: Boolean = False);
     85  begin
     86    if IsCaption then begin
     87      if Text <> '' then Item.Caption := Text
     88        else Item.Caption := ' ';
     89    end else begin
     90      if Text <> '' then Item.SubItems.Add(Text)
     91        else Item.SubItems.Add(' ');
     92    end;
     93  end;
     94
    8095begin
    8196  if Item.Index < ListViewSort1.List.Count then
    8297  with TContactProperty(ListViewSort1.List[Item.Index]) do begin
    83     Item.Caption := Name;
    84     Item.SubItems.Add(Attributes.DelimitedText);
    85     Item.SubItems.Add(Value);
     98    AddItem(Name, True);
     99    AddItem(Attributes.DelimitedText);
     100    AddItem(Value);
    86101    Item.Data := ListViewSort1.List[Item.Index];
    87102  end;
     
    204219end;
    205220
     221procedure TFormProperties.ACloneExecute(Sender: TObject);
     222var
     223  FormProperty: TFormProperty;
     224  ContactProperty: TContactProperty;
     225begin
     226  FormProperty := TFormProperty.Create(nil);
     227  try
     228    ContactProperty := TContactProperty.Create;
     229    ContactProperty.Assign(TContactProperty(ListView1.Selected.Data));
     230    FormProperty.ContactProperty := ContactProperty;
     231    try
     232      if FormProperty.ShowModal = mrOK then begin
     233        Properties.Add(ContactProperty);
     234        ContactProperty := nil;
     235        Core.DataFile.Modified := True;
     236        ReloadList;
     237        UpdateInterface;
     238      end;
     239    finally
     240      if Assigned(ContactProperty) then
     241        ContactProperty.Free;
     242    end;
     243  finally
     244    FormProperty.Free;
     245  end;
     246end;
     247
    206248procedure TFormProperties.AModifyExecute(Sender: TObject);
    207249var
Note: See TracChangeset for help on using the changeset viewer.