From 85af6345aa2650580a48b502069f8f80bcaba066 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 10 Jan 2019 10:10:16 +0000 Subject: [PATCH] tvplanit: Improved name extraction from vcards. Some improvements in the demos. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6788 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/datastores/sqlite3/project1.lpi | 14 ++++------ .../examples/datastores/sqlite3/unit1.lfm | 26 +++++++++---------- .../examples/datastores/sqlite3/unit1.pas | 6 +++++ .../examples/datastores/xml/unit1.lfm | 8 +++--- .../tvplanit/source/vpbasedatafiles.pas | 4 +-- components/tvplanit/source/vpvcard.pas | 10 +++++-- 6 files changed, 38 insertions(+), 30 deletions(-) diff --git a/components/tvplanit/examples/datastores/sqlite3/project1.lpi b/components/tvplanit/examples/datastores/sqlite3/project1.lpi index f043343da..96c35799b 100644 --- a/components/tvplanit/examples/datastores/sqlite3/project1.lpi +++ b/components/tvplanit/examples/datastores/sqlite3/project1.lpi @@ -1,7 +1,7 @@ - + @@ -17,9 +17,10 @@ - - - + + + + @@ -64,11 +65,6 @@ - - - - - diff --git a/components/tvplanit/examples/datastores/sqlite3/unit1.lfm b/components/tvplanit/examples/datastores/sqlite3/unit1.lfm index ccefe1b4b..a05b9d6bc 100644 --- a/components/tvplanit/examples/datastores/sqlite3/unit1.lfm +++ b/components/tvplanit/examples/datastores/sqlite3/unit1.lfm @@ -7,7 +7,7 @@ object Form1: TForm1 ClientHeight = 686 ClientWidth = 980 OnCreate = FormCreate - LCLVersion = '1.6.4.0' + LCLVersion = '2.1.0.0' object Panel1: TPanel Left = 0 Height = 33 @@ -67,9 +67,9 @@ object Form1: TForm1 Height = 653 Top = 33 Width = 980 - ActivePage = TabSheet3 + ActivePage = TabSheet2 Align = alClient - TabIndex = 2 + TabIndex = 1 TabOrder = 1 OnChange = PageControl1Change object TabSheet1: TTabSheet @@ -161,7 +161,6 @@ object Form1: TForm1 Align = alBottom TabStop = True TabOrder = 1 - KBNavigation = True DateLabelFormat = 'mmmm yyyy' DayHeadAttributes.Font.Height = -13 DayHeadAttributes.Font.Name = 'Tahoma' @@ -170,6 +169,7 @@ object Form1: TForm1 DrawingStyle = dsFlat EventDayStyle = [] HeadAttributes.Color = clBtnFace + KBNavigation = True OffDayColor = clSilver SelectedDayColor = clRed ShowEvents = True @@ -233,22 +233,24 @@ object Form1: TForm1 end object TabSheet2: TTabSheet Caption = 'Contacts' - ClientHeight = 594 - ClientWidth = 928 + ClientHeight = 625 + ClientWidth = 972 object VpContactButtonBar1: TVpContactButtonBar Left = 0 - Height = 594 + Height = 625 Top = 0 Width = 40 + ContactGrid = VpContactGrid1 DrawingStyle = dsFlat - RadioStyle = False + OnContactNotFound = VpContactButtonBar1ContactNotFound + RadioStyle = True Align = alLeft end object VpContactGrid1: TVpContactGrid Left = 40 - Height = 594 + Height = 625 Top = 0 - Width = 888 + Width = 932 DataStore = VpSqlite3Datastore1 ControlLink = VpControlLink1 Color = clWindow @@ -356,7 +358,7 @@ object Form1: TForm1 top = 264 end object VpResourceEditDialog1: TVpResourceEditDialog - Version = 'v1.05' + Version = 'v1.12' DataStore = VpSqlite3Datastore1 Options = [] Placement.Position = mpCenter @@ -404,7 +406,6 @@ object Form1: TForm1 LoginPrompt = False KeepConnection = False Transaction = SQLTransaction1 - Options = [] left = 136 top = 120 end @@ -412,7 +413,6 @@ object Form1: TForm1 Active = False Action = caCommitRetaining Database = SQLite3Connection1 - Options = [] left = 256 top = 120 end diff --git a/components/tvplanit/examples/datastores/sqlite3/unit1.pas b/components/tvplanit/examples/datastores/sqlite3/unit1.pas index 69476821a..638116ace 100644 --- a/components/tvplanit/examples/datastores/sqlite3/unit1.pas +++ b/components/tvplanit/examples/datastores/sqlite3/unit1.pas @@ -58,6 +58,7 @@ type procedure QryGridAfterEdit(DataSet: TDataSet); procedure QryGridAfterPost(DataSet: TDataSet); procedure TabControl1Change(Sender: TObject); + procedure VpContactButtonBar1ContactNotFound(Sender: TObject); private { private declarations } public @@ -186,5 +187,10 @@ begin Grid.Columns[i].Width := 100;; end; +procedure TForm1.VpContactButtonBar1ContactNotFound(Sender: TObject); +begin + MessageDlg('No matching contact found.', mtInformation, [mbOK], 0); +end; + end. diff --git a/components/tvplanit/examples/datastores/xml/unit1.lfm b/components/tvplanit/examples/datastores/xml/unit1.lfm index 7da67e7d5..5d243a53a 100644 --- a/components/tvplanit/examples/datastores/xml/unit1.lfm +++ b/components/tvplanit/examples/datastores/xml/unit1.lfm @@ -7,7 +7,7 @@ object Form1: TForm1 ClientHeight = 686 ClientWidth = 980 OnCreate = FormCreate - LCLVersion = '1.8.4.0' + LCLVersion = '2.1.0.0' object Panel1: TPanel Left = 0 Height = 33 @@ -67,9 +67,9 @@ object Form1: TForm1 Height = 653 Top = 33 Width = 980 - ActivePage = TabSheet1 + ActivePage = TabSheet2 Align = alClient - TabIndex = 0 + TabIndex = 1 TabOrder = 1 object TabSheet1: TTabSheet Caption = 'Events and tasks' @@ -270,7 +270,7 @@ object Form1: TForm1 Align = alClient TabStop = True TabOrder = 1 - AllowInPlaceEditing = True + AllowInPlaceEditing = False BarWidth = 3 BarColor = clSilver ColumnWidth = 200 diff --git a/components/tvplanit/source/vpbasedatafiles.pas b/components/tvplanit/source/vpbasedatafiles.pas index 57ea7ea57..e41e432b5 100644 --- a/components/tvplanit/source/vpbasedatafiles.pas +++ b/components/tvplanit/source/vpbasedatafiles.pas @@ -38,7 +38,7 @@ type FItemClass: TVpFileItemClass; function GetValue(const AKey, Attributes: String): String; protected - FItems: TObjectList; + FItems: TFPObjectList; public constructor Create(AClass: TVpFileItemClass); destructor Destroy; override; @@ -231,7 +231,7 @@ end; constructor TVpFileBlock.Create(AClass: TVpFileItemClass); begin inherited Create; - FItems := TObjectList.Create; + FItems := TFPObjectList.Create; FItemClass := AClass; end; diff --git a/components/tvplanit/source/vpvcard.pas b/components/tvplanit/source/vpvcard.pas index 57aa72b6f..a12695c72 100644 --- a/components/tvplanit/source/vpvcard.pas +++ b/components/tvplanit/source/vpvcard.pas @@ -192,6 +192,7 @@ procedure TVpVCard.Analyze; var i: Integer; item: TVpVCardItem; + fn, ln, t: String; begin inherited; @@ -200,8 +201,13 @@ begin case item.Key of 'VERSION': FVersion := item.Value; - 'FN': - VCardName(item.Value, FLastName, FFirstName, FTitle); + 'FN', 'N': + begin + VCardName(item.Value, ln, fn, t); + if FLastName = '' then FLastName := ln; + if FFirstName = '' then FFirstName := fn; + if FTitle = '' then FTitle := t; + end; 'ORG': FCompany := item.Value; 'ADR':