Changeset 3 for trunk/Forms


Ignore:
Timestamp:
Jan 29, 2018, 10:54:40 AM (6 years ago)
Author:
chronos
Message:
  • Added: Allow to edit more contacts fields.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        55*.lps
        66*.res
         7vCardStudio.exe
  • trunk/Forms/UFormContact.lfm

    r2 r3  
    11object FormContact: TFormContact
    2   Left = 595
     2  Left = 423
    33  Height = 490
    4   Top = 541
     4  Top = 271
    55  Width = 762
    66  Caption = 'Contact'
    77  ClientHeight = 490
    88  ClientWidth = 762
    9   LCLVersion = '1.8.0.4'
     9  DesignTimePPI = 120
     10  LCLVersion = '1.8.0.6'
    1011  object PageControlContact: TPageControl
    1112    Left = 8
     
    1920    object TabSheetGeneral: TTabSheet
    2021      Caption = 'General'
    21       ClientHeight = 380
    22       ClientWidth = 738
     22      ClientHeight = 391
     23      ClientWidth = 736
    2324      object Label1: TLabel
    2425        Left = 13
    25         Height = 26
     26        Height = 20
    2627        Top = 13
    27         Width = 56
     28        Width = 43
    2829        Caption = 'Name:'
    2930        ParentColor = False
     
    3132      object EditName: TEdit
    3233        Left = 100
    33         Height = 36
     34        Height = 28
    3435        Top = 15
    3536        Width = 212
    3637        TabOrder = 0
     38      end
     39      object Label2: TLabel
     40        Left = 13
     41        Height = 20
     42        Top = 47
     43        Width = 74
     44        Caption = 'Cell phone:'
     45        ParentColor = False
     46      end
     47      object EditCellPhone: TEdit
     48        Left = 100
     49        Height = 28
     50        Top = 49
     51        Width = 212
     52        TabOrder = 1
     53      end
     54      object EditPhone: TEdit
     55        Left = 100
     56        Height = 28
     57        Top = 83
     58        Width = 212
     59        TabOrder = 2
     60      end
     61      object Label3: TLabel
     62        Left = 13
     63        Height = 20
     64        Top = 81
     65        Width = 44
     66        Caption = 'Phone:'
     67        ParentColor = False
     68      end
     69      object EditEmail: TEdit
     70        Left = 479
     71        Height = 28
     72        Top = 49
     73        Width = 212
     74        TabOrder = 3
     75      end
     76      object Label4: TLabel
     77        Left = 392
     78        Height = 20
     79        Top = 47
     80        Width = 46
     81        Caption = 'E-mail:'
     82        ParentColor = False
     83      end
     84      object EditSurname: TEdit
     85        Left = 479
     86        Height = 28
     87        Top = 15
     88        Width = 212
     89        TabOrder = 4
     90      end
     91      object Label5: TLabel
     92        Left = 392
     93        Height = 20
     94        Top = 13
     95        Width = 61
     96        Caption = 'Surname:'
     97        ParentColor = False
     98      end
     99      object MemoNotes: TMemo
     100        Left = 13
     101        Height = 225
     102        Top = 152
     103        Width = 708
     104        Anchors = [akTop, akLeft, akRight, akBottom]
     105        TabOrder = 5
     106      end
     107      object Label6: TLabel
     108        Left = 12
     109        Height = 20
     110        Top = 126
     111        Width = 42
     112        Caption = 'Notes:'
     113        ParentColor = False
    37114      end
    38115    end
     
    42119    object TabSheetAll: TTabSheet
    43120      Caption = 'All fields'
     121      ClientHeight = 391
     122      ClientWidth = 736
     123      object ListView1: TListView
     124        Left = 8
     125        Height = 344
     126        Top = 16
     127        Width = 721
     128        Anchors = [akTop, akLeft, akRight, akBottom]
     129        Columns = <       
     130          item
     131            Caption = 'Item'
     132            Width = 200
     133          end       
     134          item
     135            Caption = 'Value'
     136            Width = 200
     137          end>
     138        ReadOnly = True
     139        RowSelect = True
     140        TabOrder = 0
     141        ViewStyle = vsReport
     142      end
    44143    end
    45144  end
  • trunk/Forms/UFormContact.pas

    r2 r3  
    1616    ButtonCancel: TButton;
    1717    ButtonOk: TButton;
     18    EditSurname: TEdit;
     19    EditEmail: TEdit;
     20    EditPhone: TEdit;
    1821    EditName: TEdit;
     22    EditCellPhone: TEdit;
    1923    Label1: TLabel;
     24    Label2: TLabel;
     25    Label3: TLabel;
     26    Label4: TLabel;
     27    Label5: TLabel;
     28    Label6: TLabel;
     29    ListView1: TListView;
     30    MemoNotes: TMemo;
    2031    PageControlContact: TPageControl;
    2132    TabSheetGeneral: TTabSheet;
     
    4152begin
    4253  EditName.Text := Contact.FirstName;
     54  EditSurname.Text := Contact.LastName;
     55  EditCellPhone.Text := Contact.TelCell;
     56  EditPhone.Text := Contact.TelHome;
     57  EditEmail.Text := Contact.EmailHome;
     58  MemoNotes.Lines.Text := Contact.Note;
    4359end;
    4460
     
    4662begin
    4763  Contact.FirstName := EditName.Text;
     64  Contact.LastName := EditSurname.Text;
     65  Contact.TelCell := EditCellPhone.Text;
     66  Contact.TelHome := EditPhone.Text;
     67  Contact.EmailHome := EditEmail.Text;
     68  Contact.Note := MemoNotes.Lines.Text;
    4869end;
    4970
  • trunk/Forms/UFormContacts.lfm

    r2 r3  
    77  ClientHeight = 605
    88  ClientWidth = 807
     9  DesignTimePPI = 120
    910  OnClose = FormClose
     11  OnCreate = FormCreate
    1012  OnShow = FormShow
    11   LCLVersion = '1.8.0.4'
     13  LCLVersion = '1.8.0.6'
    1214  object ListView1: TListView
    1315    Left = 0
     
    1820    Columns = <   
    1921      item
    20         Caption = 'Name'
    21         Width = 787
     22        Caption = 'First name'
     23        Width = 100
     24      end   
     25      item
     26        Caption = 'Middle name'
     27        Width = 100
     28      end   
     29      item
     30        Caption = 'Last Name'
     31        Width = 100
    2232      end>
    2333    OwnerData = True
  • trunk/Forms/UFormContacts.pas

    r2 r3  
    3131    procedure ARemoveExecute(Sender: TObject);
    3232    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     33    procedure FormCreate(Sender: TObject);
    3334    procedure FormShow(Sender: TObject);
    3435    procedure ListView1Data(Sender: TObject; Item: TListItem);
     
    3738      Selected: Boolean);
    3839  private
     40    FContacts: TContacts;
     41    procedure SetContacts(AValue: TContacts);
    3942
    4043  public
    41     Contacts: TContacts;
     44    property Contacts: TContacts read FContacts write SetContacts;
    4245    procedure ReloadList;
    4346    procedure UpdateInterface;
     
    5558  UFormContact, UCore;
    5659
     60resourcestring
     61  SRemoveContacts = 'Remove contacts';
     62  SRemoveContactsQuery = 'Do you want to remove selected contacts?';
     63
    5764{ TFormContacts }
    5865
     
    6168  if Assigned(Contacts) and (Item.Index < Contacts.Count) then
    6269  with TContact(Contacts[Item.Index]) do begin
    63     Item.Caption := FullName;
     70    Item.Caption := FirstName;
     71    Item.SubItems.Add(MiddleName);
     72    Item.SubItems.Add(LastName);
    6473    Item.Data := Contacts[Item.Index];
    6574  end;
     
    7786end;
    7887
     88procedure TFormContacts.SetContacts(AValue: TContacts);
     89begin
     90  if FContacts = AValue then Exit;
     91  FContacts := AValue;
     92  ReloadList;
     93  UpdateInterface;
     94end;
     95
    7996procedure TFormContacts.FormShow(Sender: TObject);
    8097begin
     
    87104var
    88105  FormContact: TFormContact;
     106  Contact: TContact;
    89107begin
    90108  FormContact := TFormContact.Create(nil);
     109  try
    91110  if FormContact.ShowModal = mrOK then begin
    92     FormContact.SaveData(TContact(ListView1.Selected.Data));
     111    Contact := TContact.Create;
     112    FormContact.SaveData(Contact);
     113    Contacts.Add(Contact);
     114    Core.DataFile.Modified := True;
    93115    ReloadList;
    94116    UpdateInterface;
    95117  end;
    96   FormContact.Free;
     118  finally
     119    FormContact.Free;
     120  end;
    97121end;
    98122
     
    102126begin
    103127  FormContact := TFormContact.Create(nil);
    104   FormContact.LoadData(TContact(ListView1.Selected.Data));
    105   if FormContact.ShowModal = mrOK then begin
    106     FormContact.SaveData(TContact(ListView1.Selected.Data));
    107     ReloadList;
    108     UpdateInterface;
     128  try
     129    FormContact.LoadData(TContact(ListView1.Selected.Data));
     130    if FormContact.ShowModal = mrOK then begin
     131      FormContact.SaveData(TContact(ListView1.Selected.Data));
     132      Core.DataFile.Modified := True;
     133      ReloadList;
     134      UpdateInterface;
     135    end;
     136  finally
     137    FormContact.Free;
    109138  end;
    110   FormContact.Free;
    111139end;
    112140
     
    115143  I: Integer;
    116144begin
    117   for I := ListView1.Items.Count - 1 downto 0 do
    118     if ListView1.Items[I].Selected then begin
    119       Contacts.Delete(I);
    120     end;
    121   UpdateInterface;
     145  if Assigned(ListView1.Selected) then
     146  if MessageDlg(SRemoveContacts, SRemoveContactsQuery,
     147    TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
     148    for I := ListView1.Items.Count - 1 downto 0 do
     149      if ListView1.Items[I].Selected then begin
     150        Contacts.Delete(I);
     151      end;
     152    Core.DataFile.Modified := True;
     153    ReloadList;
     154    UpdateInterface;
     155  end;
    122156end;
    123157
     
    126160begin
    127161  Core.PersistentForm1.Save(Self);
     162end;
     163
     164procedure TFormContacts.FormCreate(Sender: TObject);
     165begin
     166  FContacts := nil;
    128167end;
    129168
     
    138177procedure TFormContacts.UpdateInterface;
    139178begin
    140   AModify.Enabled := Assigned(ListView1.Selected);
    141   ARemove.Enabled := Assigned(ListView1.Selected);
     179  AAdd.Enabled := Assigned(Contacts);
     180  AModify.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
     181  ARemove.Enabled := Assigned(Contacts) and Assigned(ListView1.Selected);
    142182end;
    143183
Note: See TracChangeset for help on using the changeset viewer.