- Timestamp:
- Feb 11, 2022, 11:31:42 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormContact.lfm
r103 r108 43 43 Top = 75 44 44 Width = 161 45 OnChange = NamePartChange 45 46 ParentFont = False 46 47 TabOrder = 1 … … 95 96 end 96 97 object EditLastName: TEdit 97 Left = 69998 Left = 700 98 99 Height = 43 99 100 Top = 75 100 101 Width = 161 102 OnChange = NamePartChange 101 103 ParentFont = False 102 104 TabOrder = 2 … … 167 169 Top = 125 168 170 Width = 161 171 OnChange = NamePartChange 169 172 ParentFont = False 170 173 TabOrder = 4 … … 179 182 end 180 183 object EditTitleBefore: TEdit 181 Left = 37 5184 Left = 376 182 185 Height = 43 183 186 Top = 175 184 187 Width = 161 188 OnChange = NamePartChange 185 189 ParentFont = False 186 190 TabOrder = 5 … … 199 203 Top = 175 200 204 Width = 161 205 OnChange = NamePartChange 201 206 ParentFont = False 202 207 TabOrder = 6 … … 699 704 Width = 920 700 705 Caption = 'Address' 701 ClientHeight = 2 55706 ClientHeight = 281 702 707 ClientWidth = 918 703 708 TabOrder = 9 -
trunk/Forms/UFormContact.pas
r104 r108 205 205 procedure ButtonWorkAddressShowClick(Sender: TObject); 206 206 procedure EditFullNameChange(Sender: TObject); 207 procedure NamePartChange(Sender: TObject); 207 208 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 208 209 procedure FormCreate(Sender: TObject); … … 315 316 {$ENDIF} 316 317 Core.PersistentForm1.Load(Self); 317 318 FormProperties.ManualDock(TabSheetAll, nil, alClient);319 FormProperties.Align := alClient;320 FormProperties.Show;321 322 318 PhotoChange(nil); 323 319 324 PageControlContact.TabIndex := Core.LastContactTabIndex; 325 UpdateInterface; 320 FormProperties.BeginUpdate; 321 try 322 323 FormProperties.ManualDock(TabSheetAll, nil, alClient); 324 FormProperties.Align := alClient; 325 FormProperties.Show; 326 327 PageControlContact.TabIndex := Core.LastContactTabIndex; 328 UpdateInterface; 329 finally 330 FormProperties.EndUpdate; 331 end; 326 332 end; 327 333 … … 385 391 procedure TFormContact.TabSheetAllShow(Sender: TObject); 386 392 begin 387 FormProperties.Properties := Contact.Properties; 388 FormProperties.ReloadList; 389 FormProperties.UpdateInterface; 393 FormProperties.BeginUpdate; 394 try 395 FormProperties.Properties := Contact.Properties; 396 FormProperties.ReloadList; 397 FormProperties.UpdateInterface; 398 FormProperties.Show; 399 finally 400 FormProperties.EndUpdate; 401 end; 390 402 end; 391 403 … … 709 721 end; 710 722 723 procedure UpdateEditNoOnChange(Edit: TEdit; Text: string); 724 var 725 LastHandler: TNotifyEvent; 726 begin 727 LastHandler := Edit.OnChange; 728 Edit.OnChange := nil; 729 try 730 Edit.Text := Text; 731 finally 732 Edit.OnChange := LastHandler; 733 end; 734 end; 735 711 736 procedure TFormContact.EditFullNameChange(Sender: TObject); 712 begin 737 var 738 739 Before, First, Middle, Last, After: string; 740 begin 741 Contact.FullNameToNameParts(EditFullName.Text, Before, First, Middle, Last, After); 742 UpdateEditNoOnChange(EditTitleBefore, Before); 743 UpdateEditNoOnChange(EditFirstName, First); 744 UpdateEditNoOnChange(EditMiddleName, Middle); 745 UpdateEditNoOnChange(EditLastName, Last); 746 UpdateEditNoOnChange(EditTitleAfter, After); 713 747 UpdateInterface; 748 end; 749 750 procedure TFormContact.NamePartChange(Sender: TObject); 751 begin 752 UpdateEditNoOnChange(EditFullName, Contact.NamePartsToFullName(EditTitleBefore.Text, 753 EditFirstName.Text, EditMiddleName.Text, EditLastName.Text, EditTitleAfter.Text)); 714 754 end; 715 755 … … 732 772 733 773 procedure TFormContact.UpdateInterface; 734 begin 735 Caption := EditFullName.Text + ' - ' + SContact; 774 var 775 Title: string; 776 begin 777 Title := SContact; 778 if EditFullName.Text <> '' then Title := EditFullName.Text + ' - ' + Title 779 else 780 if EditOrganization.Text <> '' then Title := EditOrganization.Text + ' - ' + Title; 781 Caption := Title; 736 782 APhotoSave.Enabled := FPhoto.Used; 737 783 APhotoClear.Enabled := FPhoto.Used; -
trunk/Forms/UFormContacts.pas
r104 r108 260 260 Selected: Boolean; 261 261 begin 262 if not ListView1.HandleAllocated then Exit; 263 262 264 Selected := Assigned(ListView1.Selected); 263 265 AAdd.Enabled := Assigned(Contacts); -
trunk/Forms/UFormMain.lfm
r90 r108 1 1 object FormMain: TFormMain 2 Left = 6012 Left = 553 3 3 Height = 829 4 Top = 4 474 Top = 401 5 5 Width = 1227 6 6 Caption = 'vCard Studio' -
trunk/Forms/UFormProperties.pas
r104 r108 65 65 private 66 66 FProperties: TContactProperties; 67 FUpdateCount: Integer; 67 68 procedure FilterList(List: TFPGObjectList<TObject>); 68 69 procedure SetProperties(AValue: TContactProperties); 70 procedure DoUpdateInterface; 69 71 public 70 72 property Properties: TContactProperties read FProperties write SetProperties; 71 73 procedure ReloadList; 74 procedure BeginUpdate; 75 procedure EndUpdate; 72 76 procedure UpdateInterface; 73 77 end; … … 93 97 STextFiles = 'Text files'; 94 98 SValue = 'Value'; 99 SEndUpdateTooLow = 'Update counter error'; 95 100 96 101 const … … 365 370 end; 366 371 367 procedure TFormProperties.UpdateInterface; 372 procedure TFormProperties.BeginUpdate; 373 begin 374 Inc(FUpdateCount); 375 end; 376 377 procedure TFormProperties.EndUpdate; 378 begin 379 if FUpdateCount <= 0 then raise Exception(SEndUpdateTooLow); 380 Dec(FUpdateCount); 381 if FUpdateCount = 0 then DoUpdateInterface; 382 end; 383 384 procedure TFormProperties.DoUpdateInterface; 368 385 var 369 386 Text: string; … … 371 388 Selected: Boolean; 372 389 begin 390 if not ListView1.HandleAllocated then Exit; 391 373 392 Selected := Assigned(ListView1.Selected); 374 393 AAdd.Enabled := Assigned(Properties); … … 392 411 end; 393 412 413 procedure TFormProperties.UpdateInterface; 414 begin 415 if FUpdateCount = 0 then DoUpdateInterface; 416 end; 417 394 418 end. 395 419 -
trunk/Languages/vCardStudio.cs.po
r104 r108 1379 1379 1380 1380 #: uformcontacts.sendupdatetoolow 1381 msgctxt "uformcontacts.sendupdatetoolow" 1381 1382 msgid "Update counter error" 1382 1383 msgstr "Chyba čítače aktualizací" … … 1418 1419 msgstr "Všechny soubory" 1419 1420 1421 #: uformproperties.sendupdatetoolow 1422 msgctxt "uformproperties.sendupdatetoolow" 1423 msgid "Update counter error" 1424 msgstr "Chyba čítače aktualizací" 1425 1420 1426 #: uformproperties.sfiltered 1421 1427 msgctxt "uformproperties.sfiltered" -
trunk/Languages/vCardStudio.pot
r104 r108 1351 1351 1352 1352 #: uformcontacts.sendupdatetoolow 1353 msgctxt "uformcontacts.sendupdatetoolow" 1353 1354 msgid "Update counter error" 1354 1355 msgstr "" … … 1390 1391 msgstr "" 1391 1392 1393 #: uformproperties.sendupdatetoolow 1394 msgctxt "uformproperties.sendupdatetoolow" 1395 msgid "Update counter error" 1396 msgstr "" 1397 1392 1398 #: uformproperties.sfiltered 1393 1399 msgctxt "uformproperties.sfiltered" -
trunk/Packages/Common/UCommon.pas
r98 r108 13 13 type 14 14 TArrayOfByte = array of Byte; 15 TArrayOfString = array of string;16 15 TExceptionEvent = procedure(Sender: TObject; E: Exception) of object; 17 16 … … 51 50 function ComputerName: string; 52 51 procedure DeleteFiles(APath, AFileSpec: string); 52 function Explode(Separator: Char; Data: string): TStringArray; 53 53 procedure ExecuteProgram(Executable: string; Parameters: array of string); 54 54 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog); … … 65 65 function LoadFileToStr(const FileName: TFileName): AnsiString; 66 66 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 67 function MergeArray(A, B: array of string): T ArrayOfString;67 function MergeArray(A, B: array of string): TStringArray; 68 68 function OccurenceOfChar(What: Char; Where: string): Integer; 69 69 procedure OpenWebPage(URL: string); … … 291 291 end; 292 292 293 function Explode(Separator: char; Data: string): TArrayOfString; 294 begin 295 Result := nil; 296 SetLength(Result, 0); 297 while Pos(Separator, Data) > 0 do begin 298 SetLength(Result, Length(Result) + 1); 299 Result[High(Result)] := Copy(Data, 1, Pos(Separator, Data) - 1); 300 Delete(Data, 1, Pos(Separator, Data)); 301 end; 293 function Explode(Separator: Char; Data: string): TStringArray; 294 var 295 Index: Integer; 296 begin 297 Result := Default(TStringArray); 298 repeat 299 Index := Pos(Separator, Data); 300 if Index > 0 then begin 301 SetLength(Result, Length(Result) + 1); 302 Result[High(Result)] := Copy(Data, 1, Index - 1); 303 Delete(Data, 1, Index); 304 end else Break; 305 until False; 302 306 SetLength(Result, Length(Result) + 1); 303 307 Result[High(Result)] := Data; … … 509 513 end; 510 514 511 function MergeArray(A, B: array of string): T ArrayOfString;512 var 513 I: Integer; 514 begin 515 Result := Default(T ArrayOfString);515 function MergeArray(A, B: array of string): TStringArray; 516 var 517 I: Integer; 518 begin 519 Result := Default(TStringArray); 516 520 SetLength(Result, Length(A) + Length(B)); 517 521 for I := 0 to Length(A) - 1 do -
trunk/UContact.pas
r104 r108 141 141 function GetProperty(Field: TContactField): TContactProperty; overload; 142 142 function GetProperty(FieldIndex: TContactFieldIndex): TContactProperty; overload; 143 procedure FullNameToNameParts(FullName: string; out Before, First, Middle, 144 Last, After: string); 145 function NamePartsToFullName(Before, First, Middle, Last, After: string): string; 143 146 procedure Assign(Source: TContact); 144 147 function UpdateFrom(Source: TContact): Boolean; … … 1116 1119 end; 1117 1120 1121 function IsNumber(Text: string): Boolean; 1122 var 1123 Value: Integer; 1124 begin 1125 Result := TryStrToInt(Text, Value); 1126 end; 1127 1128 function IsRomanNumber(Text: string): Boolean; 1129 var 1130 I: Integer; 1131 begin 1132 Result := True; 1133 for I := 1 to Length(Text) do 1134 if not (Text[I] in ['I', 'V', 'X', 'L', 'C', 'D', 'M']) then begin 1135 Result := False; 1136 Break; 1137 end; 1138 end; 1139 1140 procedure TContact.FullNameToNameParts(FullName: string; out Before, First, 1141 Middle, Last, After: string); 1142 var 1143 Parts: TStringArray; 1144 I, J: Integer; 1145 begin 1146 Before := ''; 1147 First := ''; 1148 Middle := ''; 1149 Last := ''; 1150 After := ''; 1151 while Pos(' ', FullName) > 0 do 1152 FullName := StringReplace(FullName, ' ', ' ', [rfReplaceAll]); 1153 Parts := Explode(' ', Trim(FullName)); 1154 1155 // Title before 1156 while (Length(Parts) > 0) and EndsWith(Parts[0], '.') do begin 1157 Before := Trim(Before + ' ' + Parts[0]); 1158 Delete(Parts, 0, 1); 1159 end; 1160 1161 // Title after 1162 for I := 0 to High(Parts) do 1163 if (Pos('.', Parts[I]) > 0) or IsNumber(Parts[I]) or IsRomanNumber(Parts[I]) then begin 1164 for J := I to High(Parts) do 1165 After := Trim(After + ' ' + Parts[J]); 1166 SetLength(Parts, I); 1167 Break; 1168 end; 1169 1170 if Length(Parts) = 0 then begin 1171 end else 1172 if Length(Parts) = 1 then begin 1173 First := Parts[0]; 1174 end else 1175 if Length(Parts) = 2 then begin 1176 First := Parts[0]; 1177 Last := Parts[1]; 1178 end else begin 1179 First := Parts[0]; 1180 for I := 0 to Length(Parts) - 3 do 1181 Middle := Trim(Middle + ' ' + Parts[I + 1]); 1182 Last := Parts[High(Parts)]; 1183 end; 1184 end; 1185 1186 function TContact.NamePartsToFullName(Before, First, Middle, Last, After: string 1187 ): string; 1188 begin 1189 Result := ''; 1190 if Before <> '' then Result := Result + ' ' + Before; 1191 if First <> '' then Result := Result + ' ' + First; 1192 if Middle <> '' then Result := Result + ' ' + Middle; 1193 if Last <> '' then Result := Result + ' ' + Last; 1194 if After <> '' then Result := Result + ' ' + After; 1195 Result := Trim(Result); 1196 end; 1197 1118 1198 procedure TContact.Assign(Source: TContact); 1119 1199 begin -
trunk/UContactImage.pas
r103 r108 9 9 10 10 type 11 TContactImageFormat = (if Bmp, ifJpeg, ifPng, ifGif);11 TContactImageFormat = (ifNone, ifBmp, ifJpeg, ifPng, ifGif); 12 12 13 13 { TContactImage } … … 64 64 (ContactProperty.Attributes.IndexOf('png') <> -1) then Result := ifPng 65 65 else 66 Result := ifBmp; 66 if (ContactProperty.Attributes.IndexOf('BMP') <> -1) or 67 (ContactProperty.Attributes.IndexOf('bmp') <> -1) then Result := ifBmp 68 else 69 Result := ifNone; 67 70 end; 68 71 … … 134 137 GifImage.Free; 135 138 end; 139 end else 140 if ImageFormat = ifBmp then begin 141 try 142 Bitmap.SaveToStream(Stream); 143 except 144 end; 136 145 end else begin 137 // Bmp 138 try 139 Bitmap.SaveToStream(Stream); 140 except 141 end; 146 // Use default type 147 SaveImageToStream(ifJpeg, Stream); 142 148 end; 143 149 end; … … 149 155 PngImage: TPortableNetworkGraphic; 150 156 GifImage: TGIFImage; 157 BmpImage: TBitmap; 151 158 begin 152 159 if ImageFormat = ifJpeg then begin 153 JpegImage := TJPEGImage.Create;154 try160 try 161 JpegImage := TJPEGImage.Create; 155 162 try 156 163 JpegImage.LoadFromStream(Stream); … … 160 167 Canvas.Draw(0, 0, JpegImage); 161 168 end; 162 Used := True;163 except164 Used := False;165 end;166 finally167 JpegImage.Free;169 finally 170 JpegImage.Free; 171 end; 172 Used := True; 173 except 174 Used := False; 168 175 end; 169 176 end else 170 177 if ImageFormat = ifPng then begin 171 PngImage := TPortableNetworkGraphic.Create;172 try178 try 179 PngImage := TPortableNetworkGraphic.Create; 173 180 try 174 181 PngImage.LoadFromStream(Stream); … … 178 185 Canvas.Draw(0, 0, PngImage); 179 186 end; 180 Used := True;181 except182 Used := False;183 end;184 finally185 PngImage.Free;187 finally 188 PngImage.Free; 189 end; 190 Used := True; 191 except 192 Used := False; 186 193 end; 187 194 end else 188 195 if ImageFormat = ifGif then begin 189 GifImage := TGIFImage.Create;190 try196 try 197 GifImage := TGIFImage.Create; 191 198 try 192 199 GifImage.LoadFromStream(Stream); … … 196 203 Canvas.Draw(0, 0, GifImage); 197 204 end; 198 Used := True; 199 except 200 Used := False; 201 end; 202 finally 203 GifImage.Free; 205 finally 206 GifImage.Free; 207 end; 208 Used := True; 209 except 210 Used := False; 211 end; 212 end else 213 if ImageFormat = ifBmp then begin 214 try 215 BmpImage := TBitmap.Create; 216 try 217 BmpImage.LoadFromStream(Stream); 218 with Bitmap do begin 219 PixelFormat := pf24bit; 220 SetSize(BmpImage.Width, BmpImage.Height); 221 Canvas.Draw(0, 0, BmpImage); 222 end; 223 finally 224 BmpImage.Free; 225 end; 226 Used := True; 227 except 228 Used := False; 204 229 end; 205 230 end else begin 206 // Bmp207 with TImage.Create(nil) do208 try231 // Unknown image type, let TPicture guess what it is 232 try 233 with TImage.Create(nil) do 209 234 try 210 235 Picture.LoadFromStream(Stream); 211 Canvas.Draw(0, 0, Picture.Bitmap); 212 Used := True; 213 except 214 Used := False; 215 end; 216 finally 217 Free; 236 with Bitmap do begin 237 PixelFormat := pf24bit; 238 SetSize(Picture.Bitmap.Width, Picture.Bitmap.Height); 239 Canvas.Draw(0, 0, Picture.Bitmap); 240 end; 241 finally 242 Free; 243 end; 244 Used := True; 245 except 246 Used := False; 218 247 end; 219 248 end;
Note:
See TracChangeset
for help on using the changeset viewer.