Changeset 3


Ignore:
Timestamp:
Jan 29, 2018, 10:54:40 AM (7 years ago)
Author:
chronos
Message:
  • Added: Allow to edit more contacts fields.
Location:
trunk
Files:
1 added
1 deleted
13 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
  • trunk/Install/win

    • Property svn:ignore set to
      *.exe
  • trunk/Install/win/build.bat

    r1 r3  
    22  set LAZDIR=C:\lazarus
    33)
    4 SET APPNAME=FileMenuProject
     4SET APPNAME=vCardStudio
    55%LAZDIR%\lazbuild.exe --lazarusdir=%LAZDIR% --build-mode="Release" --cpu=i386 --operating-system=Win32 ..\..\%APPNAME%.lpi
    66copy ..\..\%APPNAME%.exe ..\..\lib\i386-win32-Release
     
    88copy ..\..\%APPNAME%.exe ..\..\lib\x86_64-win64-Release
    99
    10 "c:\Program Files (x86)\Inno Setup 5\ISCC.exe" "%APPNAME%.iss"
     10"c:\Program Files (x86)\Inno Setup 5\ISCC.exe" "vCard Studio.iss"
    1111
  • trunk/Languages/vCardStudio.po

    r2 r3  
    6161msgstr ""
    6262
     63#: tformcontact.label2.caption
     64msgid "Cell phone:"
     65msgstr ""
     66
     67#: tformcontact.label3.caption
     68msgid "Phone:"
     69msgstr ""
     70
     71#: tformcontact.label4.caption
     72msgid "E-mail:"
     73msgstr ""
     74
     75#: tformcontact.label5.caption
     76msgid "Surname:"
     77msgstr ""
     78
     79#: tformcontact.label6.caption
     80msgid "Notes:"
     81msgstr ""
     82
     83#: tformcontact.listview1.columns[0].caption
     84msgid "Item"
     85msgstr ""
     86
     87#: tformcontact.listview1.columns[1].caption
     88msgid "Value"
     89msgstr ""
     90
    6391#: tformcontact.tabsheetall.caption
    6492msgid "All fields"
     
    90118
    91119#: tformcontacts.listview1.columns[0].caption
    92 msgid "Name"
     120msgid "First name"
     121msgstr ""
     122
     123#: tformcontacts.listview1.columns[1].caption
     124msgid "Middle name"
     125msgstr ""
     126
     127#: tformcontacts.listview1.columns[2].caption
     128msgid "Last Name"
    93129msgstr ""
    94130
     
    157193msgstr ""
    158194
     195#: ucontact.sunknowncommand
     196msgid "Unknown command: %s"
     197msgstr ""
     198
    159199#: ucontact.svcardfile
    160200msgctxt "ucontact.svcardfile"
     
    191231msgstr ""
    192232
     233#: uformcontacts.sremovecontacts
     234msgid "Remove contacts"
     235msgstr ""
     236
     237#: uformcontacts.sremovecontactsquery
     238msgid "Do you want to remove selected contacts?"
     239msgstr ""
     240
    193241#: uformmain.smodified
    194242msgid "Modified"
  • trunk/UContact.pas

    r1 r3  
    5757    function GetNext(var Text: string; Separator: string): string;
    5858  public
    59     Records: TContacts;
     59    Contacts: TContacts;
    6060    function GetFileName: string; override;
    6161    function GetFileExt: string; override;
     
    7373resourcestring
    7474  SVCardFile = 'vCard file';
     75  SUnknownCommand = 'Unknown command: %s';
    7576
    7677{ TContactsFile }
     
    110111  try
    111112    Output := TStringList.Create;
    112     for I := 0 to Records.Count - 1 do
    113     with TContact(Records[I]), Output do begin
     113    for I := 0 to Contacts.Count - 1 do
     114    with TContact(Contacts[I]), Output do begin
    114115      Add('BEGIN:VCARD');
    115116      if Version <> '' then Add('VERSION:' + Version);
     
    160161  Charset: string;
    161162  Encoding: string;
    162 begin
    163   inherited;
    164   Records.Clear;
     163  CommandItems: TStringList;
     164begin
     165  inherited;
     166  Contacts.Clear;
    165167  Lines := TStringList.Create;
    166168  Lines.LoadFromFile(FileName);
    167169  try
     170    CommandItems := TStringList.Create;
     171    CommandItems.Delimiter := ';';
    168172    I := 0;
    169173    while I < Lines.Count do begin
     
    173177      end else
    174178      if Line = 'END:VCARD' then begin
    175         Records.Add(NewRecord);
     179        Contacts.Add(NewRecord);
    176180        NewRecord := nil;
    177181      end else
    178182      if Pos(':', Line) > 0 then begin
    179183        CommandPart := GetNext(Line, ':');
    180         Command := GetNext(CommandPart, ';');
    181         while CommandPart <> '' do begin
    182           CommandParam := GetNext(CommandPart, ';');
    183           if CommandParam = 'CHARSET' then begin
    184             GetNext(CommandParam, '=');
    185             Charset := CommandParam;
    186           end else
    187           if CommandParam = 'ENCODING' then begin
    188             GetNext(CommandParam, '=');
    189             Encoding := CommandParam;
    190           end else if Assigned(FOnError) then FOnError('Unknown command param: ' + CommandParam);
     184        CommandItems.DelimitedText := CommandPart;
     185        if CommandItems.IndexOfName('CHARSET') >= 0 then begin
     186          Charset := CommandItems.Values['CHARSET'];
     187          CommandItems.Delete(CommandItems.IndexOfName('CHARSET'));
     188        end
     189        else if CommandItems.IndexOfName('ENCODING') >= 0 then begin
     190          Encoding := CommandItems.Values['ENCODING'];
     191          CommandItems.Delete(CommandItems.IndexOfName('ENCODING'));
    191192        end;
     193        Command := CommandItems.DelimitedText;
     194
    192195        if Command = 'FN' then NewRecord.FullName := Line
    193196        else if Command = 'N' then begin
     
    212215        else if Command = 'X-NICKNAME' then NewRecord.NickName := Line
    213216        else if Command = 'EMAIL;HOME' then NewRecord.EmailHome := Line
    214         else if Command = 'EMAIL;INTERNET' then NewRecord.EmailInternet := Line
     217        else if Command = 'EMAIL:INTERNET' then NewRecord.EmailInternet := Line
    215218        else if Command = 'NOTE' then NewRecord.Note := Line
    216219        else if Command = 'ORG' then NewRecord.Organization := Line
     
    231234      Inc(I);
    232235    end;
     236    CommandItems.Free;
    233237  finally
    234238    Lines.Free;
     
    239243begin
    240244  inherited;
    241   Records := TContacts.Create;
     245  Contacts := TContacts.Create;
    242246end;
    243247
    244248destructor TContactsFile.Destroy;
    245249begin
    246   Records.Free;
     250  Contacts.Free;
    247251  inherited;
    248252end;
  • trunk/UCore.lfm

    r2 r3  
    33  OnDestroy = DataModuleDestroy
    44  OldCreateOrder = False
    5   Height = 606
    6   HorizontalOffset = 484
    7   VerticalOffset = 342
    8   Width = 816
     5  Height = 758
     6  HorizontalOffset = 605
     7  VerticalOffset = 428
     8  Width = 1020
     9  PPI = 120
    910  object ImageList1: TImageList
    10     left = 160
    11     top = 231
     11    left = 200
     12    top = 289
    1213    Bitmap = {
    1314      4C690B0000001000000010000000000000000000000000000000000000000000
     
    368369  object ActionList1: TActionList
    369370    Images = ImageList1
    370     left = 340
    371     top = 233
     371    left = 425
     372    top = 291
    372373    object AExit: TAction
    373374      Caption = 'Exit'
     
    432433    MaxCount = 10
    433434    OnChange = LastOpenedList1Change
    434     left = 509
    435     top = 231
     435    left = 636
     436    top = 289
    436437  end
    437438  object OpenDialog1: TOpenDialog
    438     left = 520
    439     top = 322
     439    left = 650
     440    top = 403
    440441  end
    441442  object SaveDialog1: TSaveDialog
    442     left = 375
    443     top = 329
     443    left = 469
     444    top = 411
    444445  end
    445446  object ApplicationInfo1: TApplicationInfo
     
    458459    RegistryRoot = rrKeyCurrentUser
    459460    License = 'CC0'
    460     left = 191
    461     top = 329
     461    left = 239
     462    top = 411
    462463  end
    463464  object PersistentForm1: TPersistentForm
    464465    MinVisiblePart = 50
    465466    EntireVisible = False
    466     left = 520
    467     top = 72
     467    left = 650
     468    top = 90
    468469  end
    469470  object CoolTranslator1: TCoolTranslator
    470471    POFilesFolder = 'Languages'
    471     left = 239
    472     top = 72
     472    left = 299
     473    top = 90
    473474  end
    474475  object ScaleDPI1: TScaleDPI
    475476    AutoDetect = False
    476     left = 376
    477     top = 72
     477    left = 470
     478    top = 90
    478479  end
    479480end
  • trunk/UCore.pas

    r1 r3  
    251251  FormMain.UpdateInterface;
    252252  if Assigned(DataFile) then
    253     FormContacts.Contacts := TContactsFile(DataFile).Records
     253    FormContacts.Contacts := TContactsFile(DataFile).Contacts
    254254    else FormContacts.Contacts := nil;
    255   FormContacts.ReloadList;
    256255end;
    257256
     
    295294procedure TCore.UpdateInterface;
    296295begin
    297   AFileSave.Enabled := Assigned(DataFile);
     296  AFileSave.Enabled := Assigned(DataFile) and DataFile.Modified;
    298297  AFileSaveAs.Enabled := Assigned(DataFile);
    299298  AFileClose.Enabled := Assigned(DataFile);
  • trunk/UDataFile.pas

    r1 r3  
    1818    procedure SetFileName(AValue: string);
    1919    procedure SetModified(AValue: Boolean);
     20    procedure DoOnModify;
    2021  public
    2122    function GetFileExt: string; virtual;
     
    4849  if FModified = AValue then Exit;
    4950  FModified := AValue;
     51  DoOnModify;
     52end;
     53
     54procedure TDataFile.DoOnModify;
     55begin
     56  if Assigned(FOnModify) then FOnModify(Self);
    5057end;
    5158
  • trunk/vCardStudio.lpi

    r2 r3  
    144144        <IsPartOfProject Value="True"/>
    145145        <ComponentName Value="FormContact"/>
     146        <HasResources Value="True"/>
    146147        <ResourceBaseClass Value="Form"/>
    147148      </Unit8>
Note: See TracChangeset for help on using the changeset viewer.