Changeset 2 for trunk/Forms


Ignore:
Timestamp:
Jan 26, 2018, 11:23:26 PM (6 years ago)
Author:
chronos
Message:
  • Added: Contact edit form.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      *.lrj
      heaptrclog.trc
      lib
      vCardStudio
      *.lps
      *.res
  • trunk/Forms

    • Property svn:ignore set to
      *.lrj
  • trunk/Forms/UFormContacts.lfm

    r1 r2  
    77  ClientHeight = 605
    88  ClientWidth = 807
     9  OnClose = FormClose
    910  OnShow = FormShow
    1011  LCLVersion = '1.8.0.4'
    1112  object ListView1: TListView
    1213    Left = 0
    13     Height = 605
     14    Height = 579
    1415    Top = 0
    1516    Width = 807
     
    2122      end>
    2223    OwnerData = True
     24    PopupMenu = PopupMenuContact
    2325    ReadOnly = True
    2426    RowSelect = True
     
    2628    ViewStyle = vsReport
    2729    OnData = ListView1Data
     30    OnDblClick = ListView1DblClick
     31    OnSelectItem = ListView1SelectItem
     32  end
     33  object ToolBar1: TToolBar
     34    Left = 0
     35    Height = 26
     36    Top = 579
     37    Width = 807
     38    Align = alBottom
     39    Caption = 'ToolBar1'
     40    Images = Core.ImageList1
     41    TabOrder = 1
     42    object ToolButton1: TToolButton
     43      Left = 1
     44      Top = 2
     45      Action = AAdd
     46    end
     47    object ToolButton2: TToolButton
     48      Left = 24
     49      Top = 2
     50      Action = AModify
     51    end
     52    object ToolButton3: TToolButton
     53      Left = 47
     54      Top = 2
     55      Action = ARemove
     56    end
     57  end
     58  object PopupMenuContact: TPopupMenu
     59    Images = Core.ImageList1
     60    left = 290
     61    top = 175
     62    object MenuItem1: TMenuItem
     63      Action = AAdd
     64    end
     65    object MenuItem2: TMenuItem
     66      Action = AModify
     67    end
     68    object MenuItem3: TMenuItem
     69      Action = ARemove
     70    end
     71  end
     72  object ActionList1: TActionList
     73    Images = Core.ImageList1
     74    left = 488
     75    top = 171
     76    object AAdd: TAction
     77      Caption = 'Add'
     78      ImageIndex = 9
     79      OnExecute = AAddExecute
     80      ShortCut = 45
     81    end
     82    object AModify: TAction
     83      Caption = 'Modify'
     84      ImageIndex = 6
     85      OnExecute = AModifyExecute
     86      ShortCut = 13
     87    end
     88    object ARemove: TAction
     89      Caption = 'Remove'
     90      ImageIndex = 10
     91      OnExecute = ARemoveExecute
     92      ShortCut = 46
     93    end
    2894  end
    2995end
  • trunk/Forms/UFormContacts.pas

    r1 r2  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ComCtrls, UContact;
     9  ComCtrls, Menus, ActnList, UContact;
    1010
    1111type
     
    1414
    1515  TFormContacts = class(TForm)
     16    AAdd: TAction;
     17    ARemove: TAction;
     18    AModify: TAction;
     19    ActionList1: TActionList;
    1620    ListView1: TListView;
     21    MenuItem1: TMenuItem;
     22    MenuItem2: TMenuItem;
     23    MenuItem3: TMenuItem;
     24    PopupMenuContact: TPopupMenu;
     25    ToolBar1: TToolBar;
     26    ToolButton1: TToolButton;
     27    ToolButton2: TToolButton;
     28    ToolButton3: TToolButton;
     29    procedure AAddExecute(Sender: TObject);
     30    procedure AModifyExecute(Sender: TObject);
     31    procedure ARemoveExecute(Sender: TObject);
     32    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    1733    procedure FormShow(Sender: TObject);
    1834    procedure ListView1Data(Sender: TObject; Item: TListItem);
     35    procedure ListView1DblClick(Sender: TObject);
     36    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
     37      Selected: Boolean);
    1938  private
    2039
     
    2241    Contacts: TContacts;
    2342    procedure ReloadList;
     43    procedure UpdateInterface;
    2444  end;
    2545
     
    2747  FormContacts: TFormContacts;
    2848
     49
    2950implementation
    3051
    3152{$R *.lfm}
     53
     54uses
     55  UFormContact, UCore;
    3256
    3357{ TFormContacts }
     
    4266end;
    4367
     68procedure TFormContacts.ListView1DblClick(Sender: TObject);
     69begin
     70  AModify.Execute;
     71end;
     72
     73procedure TFormContacts.ListView1SelectItem(Sender: TObject; Item: TListItem;
     74  Selected: Boolean);
     75begin
     76  UpdateInterface;
     77end;
     78
    4479procedure TFormContacts.FormShow(Sender: TObject);
    4580begin
     81  Core.PersistentForm1.Load(Self);
    4682  ReloadList;
     83  UpdateInterface;
     84end;
     85
     86procedure TFormContacts.AAddExecute(Sender: TObject);
     87var
     88  FormContact: TFormContact;
     89begin
     90  FormContact := TFormContact.Create(nil);
     91  if FormContact.ShowModal = mrOK then begin
     92    FormContact.SaveData(TContact(ListView1.Selected.Data));
     93    ReloadList;
     94    UpdateInterface;
     95  end;
     96  FormContact.Free;
     97end;
     98
     99procedure TFormContacts.AModifyExecute(Sender: TObject);
     100var
     101  FormContact: TFormContact;
     102begin
     103  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;
     109  end;
     110  FormContact.Free;
     111end;
     112
     113procedure TFormContacts.ARemoveExecute(Sender: TObject);
     114var
     115  I: Integer;
     116begin
     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;
     122end;
     123
     124procedure TFormContacts.FormClose(Sender: TObject; var CloseAction: TCloseAction
     125  );
     126begin
     127  Core.PersistentForm1.Save(Self);
    47128end;
    48129
     
    55136end;
    56137
     138procedure TFormContacts.UpdateInterface;
     139begin
     140  AModify.Enabled := Assigned(ListView1.Selected);
     141  ARemove.Enabled := Assigned(ListView1.Selected);
     142end;
     143
    57144end.
    58145
Note: See TracChangeset for help on using the changeset viewer.