tvplanit: Lots of cosmetic changes

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4771 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-18 21:03:53 +00:00
parent a089da3b74
commit 1e89c2e60f
8 changed files with 673 additions and 702 deletions

View File

@ -159,6 +159,10 @@ msgctxt "vpsr.rscalendartoday"
msgid "Today" msgid "Today"
msgstr "Heute" msgstr "Heute"
#: vpsr.rscalendarweekabbr
msgid "CW"
msgstr "KW"
#: vpsr.rscancelbtn #: vpsr.rscancelbtn
msgid "Cancel" msgid "Cancel"
msgstr "Abbrechen" msgstr "Abbrechen"

View File

@ -149,6 +149,10 @@ msgctxt "vpsr.rscalendartoday"
msgid "Today" msgid "Today"
msgstr "" msgstr ""
#: vpsr.rscalendarweekabbr
msgid "CW"
msgstr ""
#: vpsr.rscancelbtn #: vpsr.rscancelbtn
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""

View File

@ -113,10 +113,10 @@ type
procedure DisplayCurrentCountry; procedure DisplayCurrentCountry;
procedure ResizeControls; procedure ResizeControls;
public public
Resource : TVpResource; Resource: TVpResource;
Contact : TVpContact; Contact: TVpContact;
ReturnCode : TVpEditorReturnCode; ReturnCode: TVpEditorReturnCode;
ControlLink : TVpControlLink; ControlLink: TVpControlLink;
procedure PopulateSelf; procedure PopulateSelf;
procedure DePopulateSelf; procedure DePopulateSelf;
procedure ArrangeControls; procedure ArrangeControls;
@ -124,9 +124,9 @@ type
TVpContactEditDialog = class(TVpBaseDialog) TVpContactEditDialog = class(TVpBaseDialog)
protected {private} protected {private}
ceEditDlg : TContactEditForm; ceEditDlg: TContactEditForm;
ceContact : TVpContact; ceContact: TVpContact;
ceResource : TVpResource; ceResource: TVpResource;
public public
function Execute(Contact: TVpContact): Boolean; reintroduce; function Execute(Contact: TVpContact): Boolean; reintroduce;
function AddNewContact: Boolean; function AddNewContact: Boolean;
@ -150,7 +150,7 @@ uses
{== Utility functions ===================================} {== Utility functions ===================================}
function Max(const a, b : Integer) : Integer; function Max(const a, b: Integer): Integer;
begin begin
if a >= b then if a >= b then
Result := a Result := a
@ -254,9 +254,9 @@ end;
procedure TContactEditForm.PopulateSelf; procedure TContactEditForm.PopulateSelf;
var var
CurCountry : Integer; CurCountry: Integer;
i : TVpPhoneType; pt: TVpPhoneType;
j : TVpCategoryType; ct: TVpCategoryType;
begin begin
NameEdit.Text := AssembleName(Contact); NameEdit.Text := AssembleName(Contact);
@ -296,12 +296,12 @@ begin
cboxState.Text := Contact.State; cboxState.Text := Contact.State;
for i := Low (TVpPhoneType) to High (TVpPhoneType) do begin for pt := Low (TVpPhoneType) to High (TVpPhoneType) do begin
cboxPhoneLbl1.Items.Add (PhoneLabel (i)); cboxPhoneLbl1.Items.Add(PhoneLabel(pt));
cboxPhoneLbl2.Items.Add (PhoneLabel (i)); cboxPhoneLbl2.Items.Add(PhoneLabel(pt));
cboxPhoneLbl3.Items.Add (PhoneLabel (i)); cboxPhoneLbl3.Items.Add(PhoneLabel(pt));
cboxPhoneLbl4.Items.Add (PhoneLabel (i)); cboxPhoneLbl4.Items.Add(PhoneLabel(pt));
cboxPhoneLbl5.Items.Add (PhoneLabel (i)); cboxPhoneLbl5.Items.Add(PhoneLabel(pt));
end; end;
cboxPhoneLbl1.ItemIndex := Contact.PhoneType1; cboxPhoneLbl1.ItemIndex := Contact.PhoneType1;
cboxPhoneLbl2.ItemIndex := Contact.PhoneType2; cboxPhoneLbl2.ItemIndex := Contact.PhoneType2;
@ -309,8 +309,8 @@ begin
cboxPhoneLbl4.ItemIndex := Contact.PhoneType4; cboxPhoneLbl4.ItemIndex := Contact.PhoneType4;
cboxPhoneLbl5.ItemIndex := Contact.PhoneType5; cboxPhoneLbl5.ItemIndex := Contact.PhoneType5;
for j := Low (TVpCategoryType) to High (TVpCategoryType) do for ct := Low (TVpCategoryType) to High (TVpCategoryType) do
cboxCategory.Items.Add (CategoryLabel (j)); cboxCategory.Items.Add(CategoryLabel(ct));
cboxCategory.ItemIndex := Contact.Category; cboxCategory.ItemIndex := Contact.Category;
DisplayCurrentCountry; DisplayCurrentCountry;
@ -346,7 +346,7 @@ begin
cboxState.Visible := False; cboxState.Visible := False;
end end
else begin else begin
ControlLink.Localization.CountriesToTStrings (cboxCountry.Items); ControlLink.Localization.CountriesToTStrings(cboxCountry.Items);
CountryLbl.FocusControl := cboxCountry; CountryLbl.FocusControl := cboxCountry;
cboxCountry.Visible := True; cboxCountry.Visible := True;
edtCountry.Visible := False; edtCountry.Visible := False;
@ -372,14 +372,13 @@ type
TLabelArray = array[0..9] of TLabel; TLabelArray = array[0..9] of TLabel;
var var
Labels : TLabelArray; Labels: TLabelArray;
LargestLabel : Integer; LargestLabel: Integer;
WidestField : Integer; WidestField: Integer;
i : Integer; i, j: Integer;
j : Integer; OldFont: TFont;
OldFont : TFont; FieldTop: Integer;
FieldTop : Integer; delta: Integer;
delta : Integer;
begin begin
{ Note: The resizing algorithm is dependent upon the labels having their { Note: The resizing algorithm is dependent upon the labels having their
@ -414,20 +413,21 @@ begin
Canvas.Font.Assign (cboxCountry.Font); Canvas.Font.Assign (cboxCountry.Font);
try try
for j := 0 to cboxCountry.Items.Count - 1 do begin for j := 0 to cboxCountry.Items.Count - 1 do begin
i := Canvas.TextWidth (cboxCountry.Items[j]); i := Canvas.TextWidth(cboxCountry.Items[j]);
if i > WidestField then if i > WidestField then
WidestField := i; WidestField := i;
end; end;
WidestField := WidestField + ComboArrowWidth; WidestField := WidestField + ComboArrowWidth;
cboxCountry.Width := WidestField; cboxCountry.Width := WidestField;
finally finally
Canvas.Font.Assign (OldFont); Canvas.Font.Assign(OldFont);
end; end;
finally finally
OldFont.Free; OldFont.Free;
end; end;
if (cboxCountry.Left + cboxCountry.Width + FormRightBorder > MinFormWidth) and if (cboxCountry.Left + cboxCountry.Width + FormRightBorder > MinFormWidth) and
(not cboxState.Visible) then (not cboxState.Visible)
then
Width := cboxCountry.Left + cboxCountry.Width + FormRightBorder Width := cboxCountry.Left + cboxCountry.Width + FormRightBorder
else else
Width := MinFormWidth; Width := MinFormWidth;
@ -438,23 +438,24 @@ begin
OldFont := TFont.Create; OldFont := TFont.Create;
try try
OldFont.Assign(Canvas.Font); OldFont.Assign(Canvas.Font);
Canvas.Font.Assign (cboxCountry.Font); Canvas.Font.Assign(cboxCountry.Font);
try try
for j := 0 to cboxState.Items.Count - 1 do begin for j := 0 to cboxState.Items.Count - 1 do begin
i := Canvas.TextWidth (cboxState.Items[j]); i := Canvas.TextWidth(cboxState.Items[j]);
if i > WidestField then if i > WidestField then
WidestField := i; WidestField := i;
end; end;
WidestField := WidestField + ComboArrowWidth; WidestField := WidestField + ComboArrowWidth;
cboxState.Width := WidestField; cboxState.Width := WidestField;
finally finally
Canvas.Font.Assign (OldFont); Canvas.Font.Assign(OldFont);
end; end;
finally finally
OldFont.Free; OldFont.Free;
end; end;
if (cboxState.Left + cboxState.Width + FormRightBorder > MinFormWidth) and if (cboxState.Left + cboxState.Width + FormRightBorder > MinFormWidth) and
(not cboxCountry.Visible) then (not cboxCountry.Visible)
then
Width := cboxState.Left + cboxState.Width + FormRightBorder Width := cboxState.Left + cboxState.Width + FormRightBorder
else else
Width := MinFormWidth; Width := MinFormWidth;
@ -502,14 +503,13 @@ end;
procedure TContactEditForm.DisplayCurrentCountry; procedure TContactEditForm.DisplayCurrentCountry;
var var
Idx : Integer; Idx : Integer;
begin begin
if not Assigned (ControlLink) then if not Assigned(ControlLink) then
Exit; Exit;
Idx := ControlLink.Localization.CountryNameToIndex (cboxCountry.Text); Idx := ControlLink.Localization.CountryNameToIndex(cboxCountry.Text);
if Idx > -1 then begin if Idx > -1 then begin
ControlLink.Localization.StatesToTStrings (Idx, cboxState.Items); ControlLink.Localization.StatesToTStrings(Idx, cboxState.Items);
if ControlLink.Localization.Countries.Items[Idx].Address1Visible then begin if ControlLink.Localization.Countries.Items[Idx].Address1Visible then begin
AddrLbl.Visible := True; AddrLbl.Visible := True;

View File

@ -1085,7 +1085,8 @@ begin
with ContactsTable do begin with ContactsTable do begin
SetFilterCriteria(ContactsTable, False, SetFilterCriteria(ContactsTable, False,
ResourceTable.FieldByName('ResourceID').AsInteger, ResourceTable.FieldByName('ResourceID').AsInteger,
0, 0); 0, 0
);
First; First;
while not EOF do begin while not EOF do begin
Contact := Resource.Contacts.AddContact(GetNextID(ContactsTableName)); Contact := Resource.Contacts.AddContact(GetNextID(ContactsTableName));
@ -1147,7 +1148,8 @@ begin
with TasksTable do begin with TasksTable do begin
SetFilterCriteria(TasksTable, False, SetFilterCriteria(TasksTable, False,
ResourceTable.FieldByName('ResourceID').AsInteger, ResourceTable.FieldByName('ResourceID').AsInteger,
0, 0); 0, 0
);
First; First;
while not EOF do begin while not EOF do begin
Task := Resource.Tasks.AddTask(GetNextID(TasksTableName)); Task := Resource.Tasks.AddTask(GetNextID(TasksTableName));
@ -1187,8 +1189,7 @@ begin
if (Resource <> nil) and Resource.ContactsDirty then begin if (Resource <> nil) and Resource.ContactsDirty then begin
{ Dump this resource's dirty contacts to the DB } { Dump this resource's dirty contacts to the DB }
if ResourceTable.Locate('ResourceID', Resource.ResourceID, []) then begin if ResourceTable.Locate('ResourceID', Resource.ResourceID, []) then begin
SetFilterCriteria(ContactsTable, False, Resource.ResourceID, SetFilterCriteria(ContactsTable, False, Resource.ResourceID, 0, 0);
0, 0);
for I := pred(Resource.Contacts.Count) downto 0 do begin for I := pred(Resource.Contacts.Count) downto 0 do begin
Contact := Resource.Contacts.GetContact(I); Contact := Resource.Contacts.GetContact(I);
@ -1296,8 +1297,7 @@ begin
{ Dump this resource's dirty events to the DB } { Dump this resource's dirty events to the DB }
if ResourceTable.Locate('ResourceID', Resource.ResourceID, []) if ResourceTable.Locate('ResourceID', Resource.ResourceID, [])
then begin then begin
SetFilterCriteria(EventsTable, False, Resource.ResourceID, SetFilterCriteria(EventsTable, False, Resource.ResourceID, 0, 0);
0, 0);
for J := pred(Resource.Schedule.EventCount) downto 0 do begin for J := pred(Resource.Schedule.EventCount) downto 0 do begin
Event := Resource.Schedule.GetEvent(J); Event := Resource.Schedule.GetEvent(J);
@ -1388,8 +1388,7 @@ begin
{ Dump this resource's dirty contacts to the DB } { Dump this resource's dirty contacts to the DB }
if ResourceTable.Locate('ResourceID', Resource.ResourceID, []) if ResourceTable.Locate('ResourceID', Resource.ResourceID, [])
then begin then begin
SetFilterCriteria(TasksTable, False, Resource.ResourceID, SetFilterCriteria(TasksTable, False, Resource.ResourceID, 0, 0);
0, 0);
for I := pred(Resource.Tasks.Count) downto 0 do begin for I := pred(Resource.Tasks.Count) downto 0 do begin
Task := Resource.Tasks.GetTask(I); Task := Resource.Tasks.GetTask(I);
@ -1406,8 +1405,7 @@ begin
if Task.Changed then begin if Task.Changed then begin
if TasksTable.Locate('RecordID', Task.RecordID, []) if TasksTable.Locate('RecordID', Task.RecordID, [])
then then
{ this event already exists in the database so } { this event already exists in the database so update it }
{ update it }
TasksTable.Edit TasksTable.Edit
else else
{ this record doesn't exist in the database, so } { this record doesn't exist in the database, so }
@ -1603,8 +1601,7 @@ begin
SetFilterCriteria(ContactsTable, False, Resource.ResourceID, 0, 0); SetFilterCriteria(ContactsTable, False, Resource.ResourceID, 0, 0);
First; First;
while not EOF do begin while not EOF do begin
Contact := Resource.Contacts.AddContact( Contact := Resource.Contacts.AddContact(FieldByName('RecordID').AsInteger);
FieldByName('RecordID').AsInteger);
Contact.Loading := true; Contact.Loading := true;
// Contact.RecordID := FieldByName('RecordID').AsInteger; // Contact.RecordID := FieldByName('RecordID').AsInteger;
Contact.FirstName := FieldByName('FirstName').AsString; Contact.FirstName := FieldByName('FirstName').AsString;
@ -1668,9 +1665,7 @@ begin
{ Load this resource's events into memory } { Load this resource's events into memory }
with EventsTable do begin with EventsTable do begin
SetFilterCriteria(EventsTable, True, Resource.ResourceID, SetFilterCriteria(EventsTable, True, Resource.ResourceID, TimeRange.StartTime, TimeRange.EndTime);
TimeRange.StartTime,
TimeRange.EndTime);
First; First;
while not EventsTable.EOF do while not EventsTable.EOF do
@ -1678,7 +1673,8 @@ begin
Event := Resource.Schedule.AddEvent( Event := Resource.Schedule.AddEvent(
FieldByName('RecordID').AsInteger, FieldByName('RecordID').AsInteger,
FieldByName('StartTime').AsDateTime, FieldByName('StartTime').AsDateTime,
FieldByName('EndTime').AsDateTime); FieldByName('EndTime').AsDateTime
);
if Event <> nil then begin if Event <> nil then begin
Event.Loading := true; {prevents the events changed flag from being set} Event.Loading := true; {prevents the events changed flag from being set}
// Event.RecordID := FieldByName('RecordID').AsInteger; // Event.RecordID := FieldByName('RecordID').AsInteger;
@ -1729,8 +1725,7 @@ begin
SetFilterCriteria(TasksTable, False, Resource.ResourceID, 0, 0); SetFilterCriteria(TasksTable, False, Resource.ResourceID, 0, 0);
First; First;
while not EOF do begin while not EOF do begin
Task := Resource.Tasks.AddTask( Task := Resource.Tasks.AddTask(FieldByName('RecordID').AsInteger);
FieldByName('RecordID').AsInteger);
Task.Loading := true; Task.Loading := true;
// Task.RecordID := FieldByName('RecordID').AsInteger; // Task.RecordID := FieldByName('RecordID').AsInteger;
Task.Complete := FieldByName('Complete').AsBoolean; Task.Complete := FieldByName('Complete').AsBoolean;

View File

@ -116,6 +116,7 @@ type
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure StartTimeExit(Sender: TObject); procedure StartTimeExit(Sender: TObject);
procedure EndTimeExit(Sender: TObject); procedure EndTimeExit(Sender: TObject);
private { Private declarations } private { Private declarations }
{$IFDEF LCL} {$IFDEF LCL}
StartTime: TTimeEdit; StartTime: TTimeEdit;
@ -132,8 +133,10 @@ type
procedure PopLists; procedure PopLists;
procedure LoadCaptions; procedure LoadCaptions;
procedure DoPlaySound(Sender: TObject; const AWavFile: String; AMode: TVpPlaySoundMode); procedure DoPlaySound(Sender: TObject; const AWavFile: String; AMode: TVpPlaySoundMode);
protected protected
property Datastore: TVpCustomDatastore read FDatastore write FDatastore; property Datastore: TVpCustomDatastore read FDatastore write FDatastore;
public { Public declarations } public { Public declarations }
Event: TVpEvent; Event: TVpEvent;
CatColorMap: TVpCategoryColorMap; CatColorMap: TVpCategoryColorMap;
@ -461,7 +464,6 @@ procedure TDlgEventEdit.EndTimeChange(Sender: TObject);
var var
ET: TDateTime; ET: TDateTime;
begin begin
{ Verify the value is valid } { Verify the value is valid }
try try
@ -643,7 +645,6 @@ begin
if Visible then if Visible then
FCustomInterval.SetFocus; FCustomInterval.SetFocus;
end; end;
end; end;
{=====} {=====}
@ -746,7 +747,9 @@ begin
Result := false; Result := false;
if DataStore <> nil then begin if DataStore <> nil then begin
ceEvent := DataStore.Resource.Schedule.AddEvent( ceEvent := DataStore.Resource.Schedule.AddEvent(
DataStore.GetNextID(EventsTableName), StartTime, EndTime); DataStore.GetNextID(EventsTableName),
StartTime, EndTime
);
if ceEvent <> nil then begin if ceEvent <> nil then begin
Result := Execute(ceEvent); Result := Execute(ceEvent);
if (not Result) or (ceEvent = nil) then if (not Result) or (ceEvent = nil) then

View File

@ -123,6 +123,7 @@ resourcestring
RSMinutes = 'Minutes'; RSMinutes = 'Minutes';
RSHours = 'Hours'; RSHours = 'Hours';
RSDays = 'Days'; RSDays = 'Days';
RSCalendarWeekAbbr = 'CW'; // Abbreviation of "calendar week"
{WARNINGS} {WARNINGS}
RSPermanent = 'This operation cannot be undone!'; RSPermanent = 'This operation cannot be undone!';

View File

@ -90,10 +90,10 @@ type
TVpTaskEditDialog = class(TVpBaseDialog) TVpTaskEditDialog = class(TVpBaseDialog)
protected {private} protected {private}
teEditDlg : TTaskEditForm; teEditDlg: TTaskEditForm;
teTask : TVpTask; teTask: TVpTask;
public public
constructor Create(AOwner : TComponent); override; constructor Create(AOwner: TComponent); override;
function Execute(Task: TVpTask): Boolean; reintroduce; function Execute(Task: TVpTask): Boolean; reintroduce;
function AddNewTask: Boolean; function AddNewTask: Boolean;
published published
@ -145,13 +145,11 @@ begin
DetailsMemo.Text := Task.Details; DetailsMemo.Text := Task.Details;
CompleteCB.Checked := Task.Complete; CompleteCB.Checked := Task.Complete;
if Task.CompletedOn <> 0 then if Task.CompletedOn <> 0 then
CompletedOnLbl.Caption := RSCompletedOn + ' ' + CompletedOnLbl.Caption := RSCompletedOn + ' ' + FormatDateTime(ShortDateFormat, Task.CompletedOn)
FormatDateTime(ShortDateFormat, Task.CompletedOn)
else else
CompletedOnLbl.Visible := False; CompletedOnLbl.Visible := False;
CompletedOnLbl.Visible := CompleteCB.Checked; CompletedOnLbl.Visible := CompleteCB.Checked;
CreatedOnLbl.Caption := RSCreatedOn + ' ' + CreatedOnLbl.Caption := RSCreatedOn + ' ' + FormatDateTime(ShortDateFormat, Task.CreatedOn);
FormatDateTime(ShortDateFormat, Task.CreatedOn);
DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + 8; DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + 8;
end; end;
@ -198,8 +196,8 @@ var
begin begin
Result := false; Result := false;
teTask := Task; teTask := Task;
if (teTask <> nil) and (DataStore <> nil) and if (teTask <> nil) and (DataStore <> nil) and (DataStore.Resource <> nil) then
(DataStore.Resource <> nil) then begin begin
Application.CreateForm(TTaskEditForm, TaskEditForm); Application.CreateForm(TTaskEditForm, TaskEditForm);
try try
DoFormPlacement(TaskEditForm); DoFormPlacement(TaskEditForm);

File diff suppressed because it is too large Load Diff