Check-in [73d0f24a3d]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Updated dislpay of duration.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:73d0f24a3d3638660a967ad9ba68825811c0b812
User & Date: MCO 2014-07-28 14:49:20
Context
2014-07-28
15:48
dmMain now sports a few Select-functions. check-in: 101b3773b8 user: MCO tags: trunk
14:49
Updated dislpay of duration. check-in: 73d0f24a3d user: MCO tags: trunk
14:24
Added activity form, including attachment handling. Added date range selection to list of activities. Renamed controls to English. Added button on projects list to view activities and reports. Disabled platform warnings. check-in: c6e0ad17ef user: MCO tags: trunk
Changes

Changes to Olam/src/F_Activity.dfm.

991
992
993
994
995
996
997

998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008

1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019

1020
1021
1022
1023
1024
1025
1026
....
1027
1028
1029
1030
1031
1032
1033

1034
1035
1036
1037
1038
1039
1040
    Left = 84
    Top = 247
    Width = 93
    Height = 21
    Date = 41848.000000000000000000
    Time = 41848.000000000000000000
    TabOrder = 7

  end
  object dtpFromTime: TDateTimePicker
    Left = 183
    Top = 247
    Width = 59
    Height = 21
    Date = 36892.568868645830000000
    Format = 'H:mm'
    Time = 36892.568868645830000000
    Kind = dtkTime
    TabOrder = 8

  end
  object dtpUntilDate: TDateTimePicker
    Left = 264
    Top = 247
    Width = 117
    Height = 21
    Date = 41848.000000000000000000
    Time = 41848.000000000000000000
    ShowCheckbox = True
    TabOrder = 9
    OnClick = dtpUntilDateClick

    OnEnter = dtpUntilDateEnter
  end
  object dtpUntilTime: TDateTimePicker
    Left = 387
    Top = 247
    Width = 62
    Height = 21
................................................................................
    Date = 36892.568868645830000000
    Format = 'H:mm'
    Time = 36892.568868645830000000
    Checked = False
    Enabled = False
    Kind = dtkTime
    TabOrder = 10

  end
  object edtDuration: TEdit
    Left = 84
    Top = 274
    Width = 158
    Height = 21
    Color = clBtnFace







>











>











>







 







>







991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
....
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
    Left = 84
    Top = 247
    Width = 93
    Height = 21
    Date = 41848.000000000000000000
    Time = 41848.000000000000000000
    TabOrder = 7
    OnChange = dtpFromDateChange
  end
  object dtpFromTime: TDateTimePicker
    Left = 183
    Top = 247
    Width = 59
    Height = 21
    Date = 36892.568868645830000000
    Format = 'H:mm'
    Time = 36892.568868645830000000
    Kind = dtkTime
    TabOrder = 8
    OnChange = dtpFromTimeChange
  end
  object dtpUntilDate: TDateTimePicker
    Left = 264
    Top = 247
    Width = 117
    Height = 21
    Date = 41848.000000000000000000
    Time = 41848.000000000000000000
    ShowCheckbox = True
    TabOrder = 9
    OnClick = dtpUntilDateClick
    OnChange = dtpUntilDateChange
    OnEnter = dtpUntilDateEnter
  end
  object dtpUntilTime: TDateTimePicker
    Left = 387
    Top = 247
    Width = 62
    Height = 21
................................................................................
    Date = 36892.568868645830000000
    Format = 'H:mm'
    Time = 36892.568868645830000000
    Checked = False
    Enabled = False
    Kind = dtkTime
    TabOrder = 10
    OnChange = dtpUntilTimeChange
  end
  object edtDuration: TEdit
    Left = 84
    Top = 274
    Width = 158
    Height = 21
    Color = clBtnFace

Changes to Olam/src/F_Activity.pas.

57
58
59
60
61
62
63




64
65
66
67
68
69
70
..
85
86
87
88
89
90
91

92
93
94
95
96
97
98
...
114
115
116
117
118
119
120
















121
122
123
124
125


126
127
128
129
130
131
132

133

















134
135
136
137
138
139
140
...
226
227
228
229
230
231
232


















233
234
235
236
237
238
239
240
241
242
243
244
245






246
    procedure actSelectAllUpdate(Sender: TObject);
    procedure actOpenAttachmentUpdate(Sender: TObject);
    procedure actRemoveAttachmentUpdate(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
    procedure FormHide(Sender: TObject);
    procedure dtpUntilDateEnter(Sender: TObject);
    procedure tmrDurationTimer(Sender: TObject);




  private
    { Private declarations }
  public
    { Public declarations }
    procedure UpdateDuration;
  end;

................................................................................
  actAddFile.ShortCut := VK_INSERT;
  actRemoveAttachment.ShortCut := VK_DELETE;
  dtpFromDate.Date := Date;
  dtpFromTime.Time := Now;
  dtpUntilDate.Date := Date;
  dtpUntilDate.Checked := False;
  dtpUntilTime.Time := Now;

end {TfrmActivity.FormCreate};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.FormHide(Sender: TObject);
begin
  BalloonHint.HideHint;
end {TfrmActivity.FormHide};
................................................................................
end {TfrmActivity.lvwAttachmentsDeletion};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.tmrDurationTimer(Sender: TObject);
begin
  UpdateDuration;
end;

















{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.UpdateDuration;
var
  dtStart, dtStop: TDateTime;


begin
  dtStart := Trunc(dtpFromDate.Date) + Frac(dtpFromTime.Time);
  if not dtpUntilDate.Checked then begin
    dtStop := Now;
  end else begin
    dtStop := Trunc(dtpUntilDate.Date) + Frac(dtpUntilTime.Time);
  end;

  edtDuration.Text := IntToStr(MinutesBetween(dtStop, dtStart));

















end {TfrmActivity.UpdateDuration};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.actAddFileExecute(Sender: TObject);
var
  FileName: string;
  Item: TListItem;
................................................................................
    BalloonHint.Delay := 0;
    BalloonHint.ShowHint(ErrorControl);
    ModalResult := mrNone;
  end else begin
    ModalResult := mrOk;
  end;
end {TfrmActivity.btnOKClick};



















{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpUntilDateClick(Sender: TObject);
begin
  dtpUntilTime.Enabled := dtpUntilDate.Checked;
end {TfrmActivity.dtpUntilDateClick};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpUntilDateEnter(Sender: TObject);
begin
  dtpUntilDate.MinDate := dtpFromDate.Date;
end {TfrmActivity.dtpUntilDateEnter};







end.







>
>
>
>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





>
>







>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













>
>
>
>
>
>

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
    procedure actSelectAllUpdate(Sender: TObject);
    procedure actOpenAttachmentUpdate(Sender: TObject);
    procedure actRemoveAttachmentUpdate(Sender: TObject);
    procedure btnOKClick(Sender: TObject);
    procedure FormHide(Sender: TObject);
    procedure dtpUntilDateEnter(Sender: TObject);
    procedure tmrDurationTimer(Sender: TObject);
    procedure dtpFromDateChange(Sender: TObject);
    procedure dtpFromTimeChange(Sender: TObject);
    procedure dtpUntilDateChange(Sender: TObject);
    procedure dtpUntilTimeChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure UpdateDuration;
  end;

................................................................................
  actAddFile.ShortCut := VK_INSERT;
  actRemoveAttachment.ShortCut := VK_DELETE;
  dtpFromDate.Date := Date;
  dtpFromTime.Time := Now;
  dtpUntilDate.Date := Date;
  dtpUntilDate.Checked := False;
  dtpUntilTime.Time := Now;
  UpdateDuration;
end {TfrmActivity.FormCreate};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.FormHide(Sender: TObject);
begin
  BalloonHint.HideHint;
end {TfrmActivity.FormHide};
................................................................................
end {TfrmActivity.lvwAttachmentsDeletion};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.tmrDurationTimer(Sender: TObject);
begin
  UpdateDuration;
end;

{ ---------------------------------------------------------------------------- }
function Pluralize(const Value: Int64; const None, Singular, Plural: string): string; overload; inline;
begin
  case Value of
    0:    Result := None;
    1:    Result := Singular;
    else  Result := Plural;
  end;
  Result := Format(Result, [Value]);
end {Pluralize};
{ ---------------------------------------------------------------------------- }
function Pluralize(const Value: Int64; const Singular, Plural: string): string; overload; inline;
begin
  Result := Pluralize(Value, Plural, Singular, Plural);
end {Pluralize};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.UpdateDuration;
var
  dtStart, dtStop: TDateTime;
  Remainder: Int64;
  Duration: string;
begin
  dtStart := Trunc(dtpFromDate.Date) + Frac(dtpFromTime.Time);
  if not dtpUntilDate.Checked then begin
    dtStop := Now;
  end else begin
    dtStop := Trunc(dtpUntilDate.Date) + Frac(dtpUntilTime.Time);
  end;

  Remainder := MinutesBetween(dtStop, dtStart);
  if Remainder > MinsPerDay then begin
    Duration := Pluralize(Remainder div MinsPerDay, '%d day', '%d days');
    Remainder := Remainder mod MinsPerDay;
  end;
  if (Duration = '') or (Remainder <> 0)  then begin
    if Duration <> '' then
      Duration := Duration + ', ';
    if Remainder > MinsPerHour then begin
      Duration := Duration + Format('%.2d', [Remainder div MinsPerHour]);
      Remainder := Remainder mod MinsPerHour;
    end else begin
      Duration := Duration + '00';
    end;
    Duration := Duration + Format(':%.2d', [Remainder]);
  end;

  edtDuration.Text := Duration;
end {TfrmActivity.UpdateDuration};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.actAddFileExecute(Sender: TObject);
var
  FileName: string;
  Item: TListItem;
................................................................................
    BalloonHint.Delay := 0;
    BalloonHint.ShowHint(ErrorControl);
    ModalResult := mrNone;
  end else begin
    ModalResult := mrOk;
  end;
end {TfrmActivity.btnOKClick};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpFromDateChange(Sender: TObject);
begin
  UpdateDuration;
end;

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpFromTimeChange(Sender: TObject);
begin
  UpdateDuration;
end;

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpUntilDateChange(Sender: TObject);
begin
  UpdateDuration;
end;

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpUntilDateClick(Sender: TObject);
begin
  dtpUntilTime.Enabled := dtpUntilDate.Checked;
end {TfrmActivity.dtpUntilDateClick};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpUntilDateEnter(Sender: TObject);
begin
  dtpUntilDate.MinDate := dtpFromDate.Date;
end {TfrmActivity.dtpUntilDateEnter};

{ ---------------------------------------------------------------------------- }
procedure TfrmActivity.dtpUntilTimeChange(Sender: TObject);
begin
  UpdateDuration;
end;

end.