Changeset 8


Ignore:
Timestamp:
Feb 1, 2018, 12:51:32 PM (7 years ago)
Author:
chronos
Message:
  • Added: Show all fields tab in contact form.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormContact.lfm

    r7 r8  
    77  ClientHeight = 490
    88  ClientWidth = 762
     9  DesignTimePPI = 120
    910  OnClose = FormClose
    1011  OnCreate = FormCreate
    1112  OnShow = FormShow
    12   LCLVersion = '1.8.0.4'
     13  LCLVersion = '1.8.0.6'
    1314  object PageControlContact: TPageControl
    1415    Left = 8
     
    1617    Top = 8
    1718    Width = 744
    18     ActivePage = TabSheetGeneral
     19    ActivePage = TabSheetAll
    1920    Anchors = [akTop, akLeft, akRight, akBottom]
    20     TabIndex = 0
     21    TabIndex = 2
    2122    TabOrder = 0
    2223    object TabSheetGeneral: TTabSheet
    2324      Caption = 'General'
    24       ClientHeight = 380
    25       ClientWidth = 738
     25      ClientHeight = 391
     26      ClientWidth = 736
    2627      object Label1: TLabel
    2728        Left = 13
    28         Height = 26
     29        Height = 20
    2930        Top = 13
    30         Width = 56
     31        Width = 43
    3132        Caption = 'Name:'
    3233        ParentColor = False
     
    3435      object EditName: TEdit
    3536        Left = 100
    36         Height = 36
     37        Height = 28
    3738        Top = 15
    3839        Width = 212
     
    4142      object Label2: TLabel
    4243        Left = 13
    43         Height = 26
     44        Height = 20
    4445        Top = 47
    45         Width = 95
     46        Width = 74
    4647        Caption = 'Cell phone:'
    4748        ParentColor = False
     
    4950      object EditCellPhone: TEdit
    5051        Left = 100
    51         Height = 36
     52        Height = 28
    5253        Top = 49
    5354        Width = 212
     
    5657      object EditPhone: TEdit
    5758        Left = 100
    58         Height = 36
     59        Height = 28
    5960        Top = 83
    6061        Width = 212
     
    6364      object Label3: TLabel
    6465        Left = 13
    65         Height = 26
     66        Height = 20
    6667        Top = 81
    67         Width = 59
     68        Width = 44
    6869        Caption = 'Phone:'
    6970        ParentColor = False
     
    7172      object EditEmail: TEdit
    7273        Left = 479
    73         Height = 36
     74        Height = 28
    7475        Top = 49
    7576        Width = 212
     
    7879      object Label4: TLabel
    7980        Left = 392
    80         Height = 26
     81        Height = 20
    8182        Top = 47
    82         Width = 58
     83        Width = 46
    8384        Caption = 'E-mail:'
    8485        ParentColor = False
     
    8687      object EditSurname: TEdit
    8788        Left = 479
    88         Height = 36
     89        Height = 28
    8990        Top = 15
    9091        Width = 212
     
    9394      object Label5: TLabel
    9495        Left = 392
    95         Height = 26
     96        Height = 20
    9697        Top = 13
    97         Width = 81
     98        Width = 61
    9899        Caption = 'Surname:'
    99100        ParentColor = False
     
    101102      object MemoNotes: TMemo
    102103        Left = 13
    103         Height = 214
     104        Height = 225
    104105        Top = 152
    105         Width = 710
     106        Width = 708
    106107        Anchors = [akTop, akLeft, akRight, akBottom]
    107108        TabOrder = 5
     
    109110      object Label6: TLabel
    110111        Left = 12
    111         Height = 26
     112        Height = 20
    112113        Top = 126
    113         Width = 56
     114        Width = 42
    114115        Caption = 'Notes:'
    115116        ParentColor = False
     
    121122    object TabSheetAll: TTabSheet
    122123      Caption = 'All fields'
    123       ClientHeight = 380
    124       ClientWidth = 738
     124      ClientHeight = 391
     125      ClientWidth = 736
    125126      object ListView1: TListView
    126127        Left = 8
    127         Height = 344
     128        Height = 368
    128129        Top = 16
    129130        Width = 721
     
    136137          item
    137138            Caption = 'Value'
    138             Width = 501
     139            Width = 200
    139140          end>
    140141        ReadOnly = True
     
    142143        TabOrder = 0
    143144        ViewStyle = vsReport
     145        OnData = ListView1Data
    144146      end
    145147    end
  • trunk/Forms/UFormContact.pas

    r7 r8  
    3636    procedure FormCreate(Sender: TObject);
    3737    procedure FormShow(Sender: TObject);
     38    procedure ListView1Data(Sender: TObject; Item: TListItem);
    3839  private
    39 
     40    Contact: TContact;
    4041  public
     42    procedure ReloadFields;
    4143    procedure LoadData(Contact: TContact);
    4244    procedure SaveData(Contact: TContact);
     
    5860begin
    5961  Core.PersistentForm1.Load(Self);
     62  PageControlContact.TabIndex := 0;
     63  ReloadFields;
     64end;
     65
     66procedure TFormContact.ListView1Data(Sender: TObject; Item: TListItem);
     67begin
     68  if Item.Index < Contact.Parent.Fields.Count then
     69  with TContactField(Contact.Parent.Fields[Item.Index]) do begin
     70    Item.Caption := Name;
     71    Item.SubItems.Add(Contact.Fields[Index]);
     72  end;
     73end;
     74
     75procedure TFormContact.ReloadFields;
     76begin
     77  if Assigned(Contact) then begin
     78    ListView1.Items.Count := Contact.Parent.Fields.Count;
     79  end else ListView1.Items.Count := 0;
     80  ListView1.Refresh;
    6081end;
    6182
     
    6990begin
    7091  Core.CoolTranslator1.TranslateComponentRecursive(Self);
     92  Contact := nil;
    7193end;
    7294
    7395procedure TFormContact.LoadData(Contact: TContact);
    7496begin
     97  Self.Contact := Contact;
     98  ReloadFields;
    7599  EditName.Text := Contact.FirstName;
    76100  EditSurname.Text := Contact.LastName;
  • trunk/Forms/UFormContacts.lfm

    r7 r8  
    11object FormContacts: TFormContacts
    2   Left = 536
     2  Left = 400
    33  Height = 605
    4   Top = 418
     4  Top = 212
    55  Width = 807
    66  Caption = 'Contacts'
    77  ClientHeight = 605
    88  ClientWidth = 807
     9  DesignTimePPI = 120
    910  OnClose = FormClose
    1011  OnCreate = FormCreate
    1112  OnShow = FormShow
    12   LCLVersion = '1.8.0.4'
     13  LCLVersion = '1.8.0.6'
    1314  object ListView1: TListView
    1415    Left = 0
     
    2829      item
    2930        Caption = 'Last Name'
    30         Width = 587
     31        Width = 100
    3132      end>
    3233    OwnerData = True
  • trunk/Forms/UFormContacts.pas

    r3 r8  
    110110  if FormContact.ShowModal = mrOK then begin
    111111    Contact := TContact.Create;
     112    Contact.Parent := Contacts.ContactsFile;
    112113    FormContact.SaveData(Contact);
    113114    Contacts.Add(Contact);
     
    171172  if Assigned(Contacts) then
    172173    ListView1.Items.Count := Contacts.Count
    173     else ListView1.Clear;
     174    else ListView1.Items.Count := 0;
    174175  ListView1.Refresh;
    175176end;
  • trunk/Forms/UFormMain.lfm

    r7 r8  
    55  Width = 785
    66  Caption = 'FormMain'
    7   ClientHeight = 497
     7  ClientHeight = 506
    88  ClientWidth = 785
     9  DesignTimePPI = 120
    910  Menu = MainMenu1
    1011  OnClose = FormClose
     
    1213  OnCreate = FormCreate
    1314  OnShow = FormShow
    14   LCLVersion = '1.8.0.4'
     15  LCLVersion = '1.8.0.6'
    1516  object CoolBar1: TCoolBar
    1617    Left = 0
    17     Height = 38
     18    Height = 32
    1819    Top = 0
    1920    Width = 785
  • trunk/Forms/UFormMain.pas

    r1 r8  
    7474procedure TFormMain.FormCloseQuery(Sender: TObject; var CanClose: boolean);
    7575begin
    76   Core.FileClose;
     76  Core.AFileClose.Execute;
    7777  CanClose := Core.FileClosed;
    7878end;
  • trunk/Languages/vCardStudio.cs.po

    r7 r8  
    1010"Content-Transfer-Encoding: 8bit\n"
    1111"Language: cs\n"
    12 "X-Generator: Poedit 2.0.4\n"
     12"X-Generator: Poedit 1.8.8\n"
    1313
    1414#: tcore.aabout.caption
     
    238238msgstr "Soubor byl upraven. Chcete jej uložit před ukončením?"
    239239
     240#: ucore.sfilenotfound
     241msgid "File '%s' not found."
     242msgstr "Soubor '%s' nenalezen."
     243
    240244#: udatafile.sallfiles
    241245msgid "All files"
  • trunk/Languages/vCardStudio.po

    r7 r8  
    226226msgstr ""
    227227
     228#: ucore.sfilenotfound
     229msgid "File '%s' not found."
     230msgstr ""
     231
    228232#: udatafile.sallfiles
    229233msgid "All files"
  • trunk/UContact.pas

    r3 r8  
    99
    1010type
     11  TContactsFile = class;
     12
    1113  TStringEvent = procedure (Text: string) of object;
    1214
     15  TDataType = (dtString, dtInteger, dtDate, dtDateTime, dtImage);
     16
     17  TContactFieldIndex = (cfFirstName, cfMiddleName, cfLastName);
     18
     19  TContactField = class
     20    Name: string;
     21    Index: TContactFieldIndex;
     22    DataType: TDataType;
     23  end;
     24
     25  { TContactFields }
     26
     27  TContactFields = class(TObjectList)
     28    function AddNew(Name: string; Index: TContactFieldIndex; DataType:
     29      TDataType): TContactField;
     30  end;
     31
     32  { TContact }
     33
    1334  TContact = class
     35  private
     36    function GetField(Index: TContactFieldIndex): string;
     37    procedure SetField(Index: TContactFieldIndex; AValue: string);
     38  public
     39    Parent: TContactsFile;
    1440    Version: string;
    1541    FirstName: string;
     
    4470    Photo: string;
    4571    XJabber: string;
     72    property Fields[Index: TContactFieldIndex]: string read GetField write SetField;
    4673  end;
    4774
    4875  TContacts = class(TObjectList)
    49 
     76    ContactsFile: TContactsFile;
    5077  end;
    5178
     
    5683    FOnError: TStringEvent;
    5784    function GetNext(var Text: string; Separator: string): string;
     85    procedure InitFields;
    5886  public
     87    Fields: TContactFields;
    5988    Contacts: TContacts;
    6089    function GetFileName: string; override;
     
    75104  SUnknownCommand = 'Unknown command: %s';
    76105
     106{ TContactFields }
     107
     108function TContactFields.AddNew(Name: string; Index: TContactFieldIndex;
     109  DataType: TDataType): TContactField;
     110begin
     111  Result := TContactField.Create;
     112  Result.Name := Name;
     113  Result.Index := Index;
     114  Result.DataType := DataType;
     115  Add(Result);
     116end;
     117
     118{ TContact }
     119
     120function TContact.GetField(Index: TContactFieldIndex): string;
     121begin
     122  case Index of
     123    cfFirstName: Result := FirstName;
     124    cfMiddleName: Result := MiddleName;
     125    cfLastName: Result := LastName;
     126  end;
     127end;
     128
     129procedure TContact.SetField(Index: TContactFieldIndex; AValue: string);
     130begin
     131  case Index of
     132    cfFirstName: FirstName := AValue;
     133    cfMiddleName: MiddleName := AValue;
     134    cfLastName: LastName := AValue;
     135  end;
     136end;
     137
    77138{ TContactsFile }
    78139
     
    85146    Result := Text;
    86147    Text := '';
     148  end;
     149end;
     150
     151procedure TContactsFile.InitFields;
     152begin
     153  with Fields do begin
     154    AddNew('First Name', cfFirstName, dtString);
     155    AddNew('Middle Name', cfMiddleName, dtString);
     156    AddNew('Last Name', cfLastName, dtString);
    87157  end;
    88158end;
     
    118188        Add('N:' + LastName + ';' + FirstName + ';' + MiddleName + ';' + TitleBefore + ';' + TitleAfter);
    119189      if FullName <> '' then Add('FN:' + FullName);
    120       if TelCell <> '' then Add('TEL;PREF;CELL:' + TelPrefCell);
     190      if TelPrefCell <> '' then Add('TEL;PREF;CELL:' + TelPrefCell);
    121191      if TelCell <> '' then Add('TEL;CELL:' + TelCell);
    122192      if TelHome <> '' then Add('TEL;HOME:' + TelHome);
     
    157227  NewRecord: TContact;
    158228  Command: string;
    159   CommandParam: string;
    160229  CommandPart: string;
    161230  Charset: string;
     
    175244      if Line = 'BEGIN:VCARD' then begin
    176245        NewRecord := TContact.Create;
     246        NewRecord.Parent := Self;
    177247      end else
    178248      if Line = 'END:VCARD' then begin
     
    244314  inherited;
    245315  Contacts := TContacts.Create;
     316  Contacts.ContactsFile := Self;
     317  Fields := TContactFields.Create;
     318  InitFields;
    246319end;
    247320
    248321destructor TContactsFile.Destroy;
    249322begin
    250   Contacts.Free;
     323  FreeAndNil(Fields);
     324  FreeAndNil(Contacts);
    251325  inherited;
    252326end;
  • trunk/UCore.lfm

    r7 r8  
    77  VerticalOffset = 428
    88  Width = 1020
     9  PPI = 120
    910  object ImageList1: TImageList
    1011    left = 200
  • trunk/UCore.pas

    r3 r8  
    8282  SAppExit = 'Application exit';
    8383  SAppExitQuery = 'File was modified. Do you want to save it before exit?';
     84  SFileNotFound = 'File ''%s'' not found.';
    8485
    8586{ TCore }
     
    188189procedure TCore.DataModuleDestroy(Sender: TObject);
    189190begin
     191  FileClose;
    190192  SaveConfig;
    191193end;
     
    204206procedure TCore.FileOpen(FileName: string);
    205207begin
    206   FileClose;
    207   if FileClosed then begin
    208     FileNew;
    209     DataFile.LoadFromFile(FileName);
    210     LastOpenedList1.AddItem(FileName);
    211   end;
     208  if FileExists(FileName) then begin
     209    FileClose;
     210    if FileClosed then begin
     211      FileNew;
     212      DataFile.LoadFromFile(FileName);
     213      LastOpenedList1.AddItem(FileName);
     214    end;
     215  end else ShowMessage(Format(SFileNotFound, [FileName]));
    212216end;
    213217
     
    232236  end else DoClose := True;
    233237  if DoClose then begin
    234     FreeAndNil(DataFile);
     238    if Assigned(DataFile) then FreeAndNil(DataFile);
    235239    FileClosed := True;
    236240  end;
Note: See TracChangeset for help on using the changeset viewer.