You've already forked lazarus-ccr
tvplanit: Better sorting of contacts. Clean-up.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6484 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -183,9 +183,9 @@ type
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
procedure CreateWnd; override;
|
||||
function GetContactIndexByCoord(Pnt: TPoint): Integer;
|
||||
function GetDisplayEMail(AContact: TVpContact): String;
|
||||
function GetDisplayEMailField(AContact: TVpContact): String;
|
||||
procedure SetDisplayEMail(AContact: TVpContact; AEMail: String);
|
||||
function GetDisplayEMailValue(AContact: TVpContact): String;
|
||||
procedure SetDisplayEMailValue(AContact: TVpContact; AEMail: String);
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
procedure MouseEnter; override;
|
||||
procedure MouseLeave; override;
|
||||
@ -1301,87 +1301,55 @@ begin
|
||||
if field = 'Address' then begin
|
||||
cgInPlaceEditor.Field := 'Address1';
|
||||
cgInPlaceEditor.Move(AddressRect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(AddressRect.Left + TextMargin - 1,
|
||||
AddressRect.Top, AddressRect.Right + 3, AddressRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := FActiveContact.Address1;
|
||||
end;
|
||||
{ edit company }
|
||||
if field = 'Company' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(CompanyRect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(CompanyRect.Left + TextMargin - 1,
|
||||
CompanyRect.Top, CompanyRect.Right + 3, CompanyRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := FActiveContact.Company;
|
||||
end;
|
||||
{ edit CSZ }
|
||||
if field = 'CSZ' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(CSZRect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(CSZRect.Left + TextMargin - 1,
|
||||
CSZRect.Top, CSZRect.Right + 3, CSZRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := FActiveContact.City1 + ', ' + FActiveContact.State1
|
||||
+ ' ' + FActiveContact.Zip1;
|
||||
end;
|
||||
{ edit email }
|
||||
if field = 'EMail' then begin
|
||||
cgInPlaceEditor.Field := GetDisplayEMailField(FActiveContact); //'EMail1';
|
||||
cgInPlaceEditor.Field := GetDisplayEMailField(FActiveContact);
|
||||
cgInPlaceEditor.Move(EMailRect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(EMailRect);
|
||||
// Canvas.DrawFocusRect(Rect(EMailRect.Left - TextMargin,
|
||||
// EMailRect.Top, EMailRect.Right + 3, EMailRect.Bottom + 3));
|
||||
}
|
||||
cgInPlaceEditor.Text := GetDisplayEMail(FActiveContact); //FActiveContact.EMail1;
|
||||
cgInPlaceEditor.Text := GetDisplayEMailValue(FActiveContact);
|
||||
end;
|
||||
{ edit Phone1 }
|
||||
if field = 'Phone1' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone1Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone1Rect.Left - TextMargin,
|
||||
Phone1Rect.Top, Phone1Rect.Right + 3, Phone1Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone1;
|
||||
end;
|
||||
{ edit Phone2 }
|
||||
if field = 'Phone2' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone2Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone2Rect.Left - TextMargin,
|
||||
Phone2Rect.Top, Phone2Rect.Right + 3, Phone2Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone2;
|
||||
end;
|
||||
{ edit Phone3 }
|
||||
if field = 'Phone3' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone3Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone3Rect.Left - TextMargin,
|
||||
Phone3Rect.Top, Phone3Rect.Right + 3, Phone3Rect.Bottom + 3)); }
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone3;
|
||||
end;
|
||||
{ edit Phone4 }
|
||||
if field = 'Phone4' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone4Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone4Rect.Left - TextMargin ,
|
||||
Phone4Rect.Top, Phone4Rect.Right + 3, Phone4Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone4;
|
||||
end;
|
||||
{ edit Phone5 }
|
||||
if field = 'Phone5' then begin
|
||||
cgInPlaceEditor.Field := field;
|
||||
cgInPlaceEditor.Move(Phone5Rect, true);
|
||||
{
|
||||
Canvas.DrawFocusRect(Rect(Phone5Rect.Left - TextMargin,
|
||||
Phone5Rect.Top, Phone5Rect.Right + 3, Phone5Rect.Bottom + 3));}
|
||||
cgInPlaceEditor.Text := FActiveContact.Phone5;
|
||||
end;
|
||||
end;
|
||||
@ -1416,17 +1384,17 @@ begin
|
||||
{EMail}
|
||||
else if cgInPlaceEditor.field = 'EMail' then begin
|
||||
if cgInPlaceEditor.Text <> FActiveContact.EMail1 then begin
|
||||
SetDisplayEMail(FACtiveContact, cgInplaceEditor.Text);
|
||||
// FActiveContact.EMail1 := cgInPlaceEditor.Text;
|
||||
SetDisplayEMailValue(FActiveContact, cgInplaceEditor.Text);
|
||||
FActiveContact.Changed := true;
|
||||
end;
|
||||
end
|
||||
{City, State, Zip}
|
||||
else if cgInPlaceEditor.field = 'CSZ' then begin
|
||||
ParseCSZ(cgInPlaceEditor.Text, City, State, Zip);
|
||||
if (City <> FActiveContact.City1)
|
||||
or (State <> FActiveContact.State1)
|
||||
or (Zip <> FActiveContact.Zip1) then begin
|
||||
if (City <> FActiveContact.City1) or
|
||||
(State <> FActiveContact.State1) or
|
||||
(Zip <> FActiveContact.Zip1) then
|
||||
begin
|
||||
FActiveContact.City1 := City;
|
||||
FActiveContact.State1 := State;
|
||||
FActiveContact.Zip1 := Zip;
|
||||
@ -1607,15 +1575,14 @@ end;
|
||||
|
||||
procedure TVpContactGrid.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
var
|
||||
PopupPoint : TPoint;
|
||||
|
||||
PopupPoint: TPoint;
|
||||
begin
|
||||
case Key of
|
||||
VK_UP :
|
||||
if ContactIndex > 0 then
|
||||
ContactIndex := ContactIndex - 1;
|
||||
VK_DOWN :
|
||||
if ContactIndex < Pred(DataStore.Resource.Contacts.Count) then
|
||||
if ContactIndex < DataStore.Resource.Contacts.Count - 1 then
|
||||
ContactIndex := ContactIndex + 1;
|
||||
VK_HOME :
|
||||
ContactIndex := 0;
|
||||
@ -1624,16 +1591,16 @@ begin
|
||||
ContactIndex := ContactIndex - 1;
|
||||
}
|
||||
VK_END :
|
||||
ContactIndex := Pred(Datastore.Resource.Contacts.Count);
|
||||
ContactIndex := Datastore.Resource.Contacts.Count - 1;
|
||||
{
|
||||
if ContactIndex < Pred(DataStore.Resource.Contacts.Count) then
|
||||
ContactIndex := ContactIndex + 1;
|
||||
}
|
||||
VK_RIGHT :
|
||||
if ContactIndex + cgCol1RecCount <= Pred(DataStore.Resource.Contacts.Count) then
|
||||
if ContactIndex + cgCol1RecCount <= DataStore.Resource.Contacts.Count - 1 then
|
||||
ContactIndex := ContactIndex + cgCol1RecCount
|
||||
else
|
||||
ContactIndex := Pred(DataStore.Resource.Contacts.Count);
|
||||
ContactIndex := DataStore.Resource.Contacts.Count - 1;
|
||||
VK_LEFT :
|
||||
if ContactIndex - cgCol1RecCount <= 0 then
|
||||
ContactIndex := 0
|
||||
@ -1658,8 +1625,13 @@ begin
|
||||
PopupPoint := GetClientOrigin;
|
||||
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
||||
end;
|
||||
else
|
||||
inherited;
|
||||
end;
|
||||
|
||||
Key := 0;
|
||||
Invalidate;
|
||||
inherited;
|
||||
end;
|
||||
{=====}
|
||||
|
||||
@ -1831,7 +1803,7 @@ begin
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
function TVpContactGrid.GetDisplayEMail(AContact: TVpContact): String;
|
||||
function TVpContactGrid.GetDisplayEMailValue(AContact: TVpContact): String;
|
||||
begin
|
||||
if AContact = nil then
|
||||
Result := ''
|
||||
@ -1854,7 +1826,7 @@ begin
|
||||
Result := 'EMail1';
|
||||
end;
|
||||
|
||||
procedure TVpContactGrid.SetDisplayEMail(AContact: TVpContact; AEMail: String);
|
||||
procedure TVpContactGrid.SetDisplayEMailValue(AContact: TVpContact; AEMail: String);
|
||||
begin
|
||||
if (AContact.EMail1 <> '') then
|
||||
AContact.EMail1 := AEMail
|
||||
|
@ -287,7 +287,7 @@ begin
|
||||
TmpBmp.Canvas.FillRect(Rect(0, 0, TmpBmp.Width, TmpBmp.Height));
|
||||
|
||||
{ sort the records }
|
||||
FContactGrid.DataStore.Resource.Contacts.Sort;
|
||||
FContactGrid.DataStore.Resource.Contacts.Sort; // wp: why sort here?
|
||||
|
||||
{ Set the anchor starting point }
|
||||
case Angle of
|
||||
@ -463,7 +463,7 @@ begin
|
||||
DrawContactLine(TmpBmp, TmpCon.Phone5, Str, WholeRect, Phone5Rect);
|
||||
|
||||
{ do EMail }
|
||||
Str := TVpContactGridOpener(FContactGrid).GetDisplayEMail(TmpCon);
|
||||
Str := TVpContactGridOpener(FContactGrid).GetDisplayEMailValue(TmpCon);
|
||||
DrawContactLine(TmpBmp, Str, RSEmail + ': ', WholeRect, EMailRect);
|
||||
|
||||
{ if this record's too big to fit in the remaining area of this }
|
||||
@ -550,67 +550,9 @@ begin
|
||||
cgContactArray[I].Phone3Rect := MoveRect(Phone3Rect, Anchor);
|
||||
cgContactArray[I].Phone4Rect := MoveRect(Phone4Rect, Anchor);
|
||||
cgContactArray[I].Phone5Rect := MoveRect(Phone5Rect, Anchor);
|
||||
(*
|
||||
|
||||
cgContactArray[I].WholeRect.TopLeft := Point(
|
||||
Anchor.X, Anchor.Y + WholeRect.Top);
|
||||
cgContactArray[I].WholeRect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + WholeRect.Bottom);
|
||||
|
||||
cgContactArray[I].HeaderRect.TopLeft := Point(
|
||||
Anchor.X, Anchor.Y + HeadRect.Top);
|
||||
cgContactArray[I].HeaderRect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + HeadRect.Bottom);
|
||||
|
||||
cgContactArray[I].AddressRect.TopLeft := Point(
|
||||
Anchor.X, Anchor.Y + AddrRect.Top);
|
||||
cgContactArray[I].AddressRect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + AddrRect.Bottom);
|
||||
|
||||
cgContactArray[I].CSZRect.TopLeft := Point(
|
||||
Anchor.X, Anchor.Y + CSZRect.Top);
|
||||
cgContactArray[I].CSZRect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + CSZRect.Bottom);
|
||||
|
||||
cgContactArray[I].CompanyRect.TopLeft := Point(
|
||||
Anchor.X, Anchor.Y + CompanyRect.Top);
|
||||
cgContactArray[I].CompanyRect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + CompanyRect.Bottom);
|
||||
|
||||
cgContactArray[I].EMailRect.TopLeft := Point(
|
||||
Anchor.X + EMailRect.Left, Anchor.Y + EMailRect.Top);
|
||||
cgContactArray[I].EMailRect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + EMailRect.Bottom);
|
||||
|
||||
cgContactArray[I].Phone1Rect.TopLeft := Point(
|
||||
Anchor.X + Phone1Rect.Left, Anchor.Y + Phone1Rect.Top);
|
||||
cgContactArray[I].Phone1Rect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + Phone1Rect.Bottom);
|
||||
|
||||
cgContactArray[I].Phone2Rect.TopLeft := Point(
|
||||
Anchor.X + Phone2Rect.Left, Anchor.Y + Phone2Rect.Top);
|
||||
cgContactArray[I].Phone2Rect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + Phone2Rect.Bottom);
|
||||
|
||||
cgContactArray[I].Phone3Rect.TopLeft := Point(
|
||||
Anchor.X + Phone3Rect.Left, Anchor.Y + Phone3Rect.Top);
|
||||
cgContactArray[I].Phone3Rect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + Phone3Rect.Bottom);
|
||||
|
||||
cgContactArray[I].Phone4Rect.TopLeft := Point(
|
||||
Anchor.X + Phone4Rect.Left, Anchor.Y + Phone4Rect.Top);
|
||||
cgContactArray[I].Phone4Rect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + Phone4Rect.Bottom);
|
||||
|
||||
cgContactArray[I].Phone5Rect.TopLeft := Point(
|
||||
Anchor.X + Phone5Rect.Left, Anchor.Y + Phone5Rect.Top);
|
||||
cgContactArray[I].Phone5Rect.BottomRight := Point(
|
||||
Anchor.X + TmpBmp.Width, Anchor.Y + Phone5Rect.Bottom);
|
||||
*)
|
||||
end;
|
||||
|
||||
{ move the drawn record from the bitmap to the component canvas }
|
||||
|
||||
case Angle of
|
||||
ra0 :
|
||||
RenderCanvas.CopyRect (Rect (Anchor.X + WholeRect.Left + RenderIn.Left,
|
||||
|
@ -742,6 +742,21 @@ begin
|
||||
Result := CompareValue(TVpTask(Item1).DueDate, TVpTask(Item2).DueDate);
|
||||
end;
|
||||
|
||||
function CompareContacts_Minors(Item1, Item2: Pointer): Integer;
|
||||
begin
|
||||
Result := CompareText(TVpContact(Item1).Email1, TVpContact(Item2).EMail1);
|
||||
if Result = 0 then
|
||||
Result := CompareText(TVpContact(Item1).Phone1, TVpContact(Item2).Phone1);
|
||||
if Result = 0 then
|
||||
Result := CompareText(TVpContact(Item1).Phone2, TVpContact(Item2).Phone2);
|
||||
if Result = 0 then
|
||||
Result := CompareText(TVpContact(Item1).Phone3, TVpContact(Item2).Phone3);
|
||||
if Result = 0 then
|
||||
Result := CompareText(TVpContact(Item1).Phone4, TVpContact(Item2).Phone4);
|
||||
if Result = 0 then
|
||||
Result := CompareText(TVpContact(Item1).Phone5, TVpContact(Item2).Phone5);
|
||||
end;
|
||||
|
||||
{ Compare function for sorting contacts: Compare the first names of the contacts,
|
||||
if equal compare the last names. }
|
||||
function CompareContacts_FirstLast(Item1, Item2: Pointer): Integer;
|
||||
@ -751,6 +766,8 @@ begin
|
||||
Result := CompareText(TVpContact(Item1).LastName, TVpContact(Item2).LastName);
|
||||
if Result = 0 then
|
||||
Result := CompareText(TVpContact(Item1).Company, TVpContact(Item2).Company);
|
||||
if Result = 0 then
|
||||
Result := CompareContacts_Minors(Item1, Item2);
|
||||
end;
|
||||
|
||||
{ Compare function for sorting contacts: Compare the last names of the contacts,
|
||||
@ -762,6 +779,8 @@ begin
|
||||
Result := CompareText(TVpContact(Item1).FirstName, TVpContact(Item2).FirstName);
|
||||
if Result = 0 then
|
||||
Result := CompareText(TVpContact(Item1).Company, TVpContact(Item2).Company);
|
||||
if Result = 0 then
|
||||
Result := CompareContacts_Minors(Item1, Item2);
|
||||
end;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user