Check-in [25b06ad3a6]
Not logged in

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

Overview
Comment:Added icon, keyboard shortcuts
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 25b06ad3a6d99e2b5e6f2cbd501ae89516a9533d
User & Date: MCO 2011-05-04 13:07:41
Context
2011-05-05
08:59
* If the program is already running, don't launch a second instance but activate the first; * If Shift is pressed during shutdown, no line '(closed)' is added. check-in: 9584fe1b9f user: MCO tags: trunk
2011-05-04
13:07
Added icon, keyboard shortcuts check-in: 25b06ad3a6 user: MCO tags: trunk
11:02
First working version check-in: 19a962fef4 user: MCO tags: trunk
Changes

Changes to src/F_Entry.dfm.

7
8
9
10
11
12
13


14
15

16
17
18
19
20
21
22
..
25
26
27
28
29
30
31


32
33
34
35
36
37
38
39
40

41

42
43

44
45
46
47
48
49
50
..
51
52
53
54
55
56
57

58
59
60
61
62

63
64
65
66
67
68
69
  ClientWidth = 550
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []


  OldCreateOrder = False
  Position = poScreenCenter

  OnCreate = FormCreate
  OnDestroy = FormDestroy
  OnResize = FormResize
  DesignSize = (
    550
    418)
  PixelsPerInch = 96
................................................................................
    Left = 8
    Top = 8
    Width = 137
    Height = 21
    Date = 40667.351732187500000000
    Format = 'd MMMM yyyy'
    Time = 40667.351732187500000000


    TabOrder = 1
    OnChange = dtpDayChange
  end
  object Grid: TStringGrid
    Left = 8
    Top = 35
    Width = 534
    Height = 375
    Anchors = [akLeft, akTop, akRight, akBottom]

    ColCount = 3

    RowCount = 2
    Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goTabs, goAlwaysShowEditor]

    TabOrder = 0
    OnKeyDown = GridKeyDown
    ColWidths = (
      64
      128
      334)
  end
................................................................................
  object tbsWeek: TTabSet
    Left = 151
    Top = 17
    Width = 391
    Height = 21
    Anchors = [akLeft, akTop, akRight]
    DitherBackground = False

    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []

    SoftTop = True
    Style = tsModernTabs
    Tabs.Strings = (
      'Maandag'
      'Dinsdag'
      'Woensdag'
      'Donderdag'







>
>


>







 







>
>









>

>


>







 







>





>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  ClientWidth = 550
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  GlassFrame.Enabled = True
  GlassFrame.SheetOfGlass = True
  OldCreateOrder = False
  Position = poScreenCenter
  OnCloseQuery = FormCloseQuery
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  OnResize = FormResize
  DesignSize = (
    550
    418)
  PixelsPerInch = 96
................................................................................
    Left = 8
    Top = 8
    Width = 137
    Height = 21
    Date = 40667.351732187500000000
    Format = 'd MMMM yyyy'
    Time = 40667.351732187500000000
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 1
    OnChange = dtpDayChange
  end
  object Grid: TStringGrid
    Left = 8
    Top = 35
    Width = 534
    Height = 375
    Anchors = [akLeft, akTop, akRight, akBottom]
    Color = clBtnFace
    ColCount = 3
    DoubleBuffered = True
    RowCount = 2
    Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goTabs, goAlwaysShowEditor]
    ParentDoubleBuffered = False
    TabOrder = 0
    OnKeyDown = GridKeyDown
    ColWidths = (
      64
      128
      334)
  end
................................................................................
  object tbsWeek: TTabSet
    Left = 151
    Top = 17
    Width = 391
    Height = 21
    Anchors = [akLeft, akTop, akRight]
    DitherBackground = False
    DoubleBuffered = True
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentDoubleBuffered = False
    SoftTop = True
    Style = tsModernTabs
    Tabs.Strings = (
      'Maandag'
      'Dinsdag'
      'Woensdag'
      'Donderdag'

Changes to src/F_Entry.pas.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
..
47
48
49
50
51
52
53


54
55
56
57
58
59
60





61
62
63
64















65
66
67
68
69
70
71
..
89
90
91
92
93
94
95







96
97
98
99
100
101
102
...
138
139
140
141
142
143
144

145
146
147
148
149
150
151
...
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213

214
215
216
217
218
219




220
221
222
223
224
225

226
227
228
229
230
231
232
    dtpDay: TDateTimePicker;
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure tbsWeekChange(Sender: TObject; NewTab: Integer; var AllowChange: Boolean);
    procedure dtpDayChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure GridKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);

  private
    { Private declarations }
    FDoneLoading: Boolean;
    FInhibitEvents: boolean;
    FDB: TSQLiteDatabase;
    FActiveDate: TDateTime;
    FLoadQuery: TSQLiteQuery;
................................................................................
uses
  DateUtils;

{$R *.dfm}

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.FormCreate(Sender: TObject);


begin
  try
    dtpDay.MaxDate := dtpDay.Date + 7; // eigenlijk niet verder dan a.s. zondag...
    FillHeaders;
    InitializeDB;

    SetDate(Date);





  finally
    FDoneLoading := True;
  end;
end;















{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FDB);
end;

{ ------------------------------------------------------------------------------------------------ }
................................................................................
        if ssShift in KeyShift then begin
          SetDate(FActiveDate - 1);
        end else begin
          if FActiveDate + 2 < dtpDay.MaxDate then
            SetDate(FActiveDate + 1);
        end{if};
      end{if};







    end;
  end{case};
end{TfrmEntry.GridKeyDown};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.dtpDayChange(Sender: TObject);
begin
................................................................................
    dtpDay.Date := NewDate;
    tbsWeek.TabIndex := (DayOfWeek(NewDate) + 5) mod 7;
  finally
    FInhibitEvents := False;
  end;

  FActiveDate := NewDate;


  // load the new day's data into the grid
  LoadGrid(NewDate);

  if SameDate(NewDate, Date) then begin
    Grid.Row := AddRow(NewDate);
    Grid.Col := 1;
................................................................................
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.SaveGrid(Date: TDateTime);
var
  Row: Integer;
  Timestamp: TDateTime;
  Project, Activity: string;
begin
  // TODO: check the ID (object of the first row); if present then send that along (do an insert or replace)

  FDB.BeginTransaction;
  try
    // First, throw away the existing records for this date
    FClearQuery.Parameters.Add(':Date', SQLDateToStr(Date));
    FDB.Execute(FClearQuery);

    // Next, save all the new records

    for Row := Grid.FixedRows to Grid.RowCount - 1 do begin
      if TryStrToTime(Grid.Cells[0, Row], Timestamp) then begin
        Timestamp := Trunc(Date) + Frac(Timestamp);
        Project := Trim(Grid.Cells[1, Row]);
        Activity := Trim(Grid.Cells[2, Row]);
        if (Length(Project) > 0) or (Length(Activity) > 0) then begin




          with FSaveQuery do begin
            Parameters.Add(':DateTime', SQLDateTimeToStr(Timestamp));
            Parameters.Add(':Project', Project);
            Parameters.Add(':Activity', Activity);
          end;
          FDB.Execute(FSaveQuery);

        end{if};
      end;
    end{for};

    FDB.Commit;
  except
    FDB.Rollback;







>







 







>
>







>
>
>
>
>




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







 







>
>
>
>
>
>
>







 







>







 







|










>






>
>
>
>






>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
..
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
    dtpDay: TDateTimePicker;
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure tbsWeekChange(Sender: TObject; NewTab: Integer; var AllowChange: Boolean);
    procedure dtpDayChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure GridKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
    FDoneLoading: Boolean;
    FInhibitEvents: boolean;
    FDB: TSQLiteDatabase;
    FActiveDate: TDateTime;
    FLoadQuery: TSQLiteQuery;
................................................................................
uses
  DateUtils;

{$R *.dfm}

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.FormCreate(Sender: TObject);
var
  Row: Integer;
begin
  try
    dtpDay.MaxDate := dtpDay.Date + 7; // eigenlijk niet verder dan a.s. zondag...
    FillHeaders;
    InitializeDB;

    SetDate(Date);
    Row := AddRow(FActiveDate);
    if Row = Grid.FixedRows then begin
      Grid.Cells[1, Row] := '(overig)';
      Grid.Cells[2, Row] := 'Opgestart';
    end;
  finally
    FDoneLoading := True;
  end;
end;
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
  Row: Integer;
begin
  if CanClose then begin
    if FDoneLoading then begin
      SetDate(Date);
      Row := AddRow(FActiveDate);
      Grid.Cells[1, Row] := '(overig)';
      Grid.Cells[2, Row] := 'Afgesloten';
      SaveGrid(FActiveDate);
    end;
  end;
end{TfrmEntry.FormCloseQuery};
{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.FormDestroy(Sender: TObject);
begin
  FreeAndNil(FDB);
end;

{ ------------------------------------------------------------------------------------------------ }
................................................................................
        if ssShift in KeyShift then begin
          SetDate(FActiveDate - 1);
        end else begin
          if FActiveDate + 2 < dtpDay.MaxDate then
            SetDate(FActiveDate + 1);
        end{if};
      end{if};
    end;
    VK_F4: begin
      if KeyShift = [] then begin
        dtpDay.SetFocus;
        PostMessage(dtpDay.Handle, WM_KEYDOWN, VK_F4, 0);
        PostMessage(dtpDay.Handle, WM_KEYUP, VK_F4, 0);
      end;
    end;
  end{case};
end{TfrmEntry.GridKeyDown};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.dtpDayChange(Sender: TObject);
begin
................................................................................
    dtpDay.Date := NewDate;
    tbsWeek.TabIndex := (DayOfWeek(NewDate) + 5) mod 7;
  finally
    FInhibitEvents := False;
  end;

  FActiveDate := NewDate;
  Self.Caption := Application.Title + ' - ' + FormatDateTime('dddddd', FActiveDate);

  // load the new day's data into the grid
  LoadGrid(NewDate);

  if SameDate(NewDate, Date) then begin
    Grid.Row := AddRow(NewDate);
    Grid.Col := 1;
................................................................................
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmEntry.SaveGrid(Date: TDateTime);
var
  Row: Integer;
  Timestamp: TDateTime;
  PrevProject, Project, Activity: string;
begin
  // TODO: check the ID (object of the first row); if present then send that along (do an insert or replace)

  FDB.BeginTransaction;
  try
    // First, throw away the existing records for this date
    FClearQuery.Parameters.Add(':Date', SQLDateToStr(Date));
    FDB.Execute(FClearQuery);

    // Next, save all the new records
    PrevProject := '';
    for Row := Grid.FixedRows to Grid.RowCount - 1 do begin
      if TryStrToTime(Grid.Cells[0, Row], Timestamp) then begin
        Timestamp := Trunc(Date) + Frac(Timestamp);
        Project := Trim(Grid.Cells[1, Row]);
        Activity := Trim(Grid.Cells[2, Row]);
        if (Length(Project) > 0) or (Length(Activity) > 0) then begin
          if Length(Project) = 0 then begin
            // If empty, then repeat the preceding project
            Project := PrevProject;
          end;
          with FSaveQuery do begin
            Parameters.Add(':DateTime', SQLDateTimeToStr(Timestamp));
            Parameters.Add(':Project', Project);
            Parameters.Add(':Activity', Activity);
          end;
          FDB.Execute(FSaveQuery);
          PrevProject := Project;
        end{if};
      end;
    end{for};

    FDB.Commit;
  except
    FDB.Rollback;

Changes to src/prj/D2010/Olam.dpr.

5
6
7
8
9
10
11

12
13
14
  F_Entry in '..\..\F_Entry.pas' {frmEntry};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;

  Application.CreateForm(TfrmEntry, frmEntry);
  Application.Run;
end.







>



5
6
7
8
9
10
11
12
13
14
15
  F_Entry in '..\..\F_Entry.pas' {frmEntry};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.Title := 'Olam';
  Application.CreateForm(TfrmEntry, frmEntry);
  Application.Run;
end.

Changes to src/prj/D2010/Olam.dproj.

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112
113
114
					<Parameters>
						<Parameters Name="UseLauncher">False</Parameters>
						<Parameters Name="LoadAllSymbols">True</Parameters>
						<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
					</Parameters>
					<VersionInfo>
						<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
						<VersionInfo Name="AutoIncBuild">False</VersionInfo>
						<VersionInfo Name="MajorVer">1</VersionInfo>
						<VersionInfo Name="MinorVer">0</VersionInfo>
						<VersionInfo Name="Release">0</VersionInfo>
						<VersionInfo Name="Build">0</VersionInfo>
						<VersionInfo Name="Debug">False</VersionInfo>
						<VersionInfo Name="PreRelease">False</VersionInfo>
						<VersionInfo Name="Special">False</VersionInfo>
						<VersionInfo Name="Private">False</VersionInfo>
						<VersionInfo Name="DLL">False</VersionInfo>
						<VersionInfo Name="Locale">1043</VersionInfo>
						<VersionInfo Name="CodePage">1252</VersionInfo>
					</VersionInfo>
					<VersionInfoKeys>
						<VersionInfoKeys Name="CompanyName"/>
						<VersionInfoKeys Name="FileDescription"/>
						<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
						<VersionInfoKeys Name="InternalName"/>
						<VersionInfoKeys Name="LegalCopyright"/>
						<VersionInfoKeys Name="LegalTrademarks"/>
						<VersionInfoKeys Name="OriginalFilename"/>
						<VersionInfoKeys Name="ProductName"/>
						<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
						<VersionInfoKeys Name="Comments"/>

					</VersionInfoKeys>
					<Excluded_Packages>
						<Excluded_Packages Name="$(BDS)\bin\dcloffice2k140.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
						<Excluded_Packages Name="$(BDS)\bin\dclofficexp140.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
					</Excluded_Packages>
				</Delphi.Personality>
			</BorlandProject>
			<ProjectFileVersion>12</ProjectFileVersion>
		</ProjectExtensions>
	</Project>







|



|



|





|
|
|
|






>










74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
					<Parameters>
						<Parameters Name="UseLauncher">False</Parameters>
						<Parameters Name="LoadAllSymbols">True</Parameters>
						<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
					</Parameters>
					<VersionInfo>
						<VersionInfo Name="IncludeVerInfo">True</VersionInfo>
						<VersionInfo Name="AutoIncBuild">True</VersionInfo>
						<VersionInfo Name="MajorVer">1</VersionInfo>
						<VersionInfo Name="MinorVer">0</VersionInfo>
						<VersionInfo Name="Release">0</VersionInfo>
						<VersionInfo Name="Build">2</VersionInfo>
						<VersionInfo Name="Debug">False</VersionInfo>
						<VersionInfo Name="PreRelease">False</VersionInfo>
						<VersionInfo Name="Special">False</VersionInfo>
						<VersionInfo Name="Private">True</VersionInfo>
						<VersionInfo Name="DLL">False</VersionInfo>
						<VersionInfo Name="Locale">1043</VersionInfo>
						<VersionInfo Name="CodePage">1252</VersionInfo>
					</VersionInfo>
					<VersionInfoKeys>
						<VersionInfoKeys Name="CompanyName">Martijn Coppoolse</VersionInfoKeys>
						<VersionInfoKeys Name="FileDescription">Olam Work registration helper</VersionInfoKeys>
						<VersionInfoKeys Name="FileVersion">1.0.0.2</VersionInfoKeys>
						<VersionInfoKeys Name="InternalName">Olam</VersionInfoKeys>
						<VersionInfoKeys Name="LegalCopyright"/>
						<VersionInfoKeys Name="LegalTrademarks"/>
						<VersionInfoKeys Name="OriginalFilename"/>
						<VersionInfoKeys Name="ProductName"/>
						<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
						<VersionInfoKeys Name="Comments"/>
						<VersionInfoKeys Name="PrivateBuild"/>
					</VersionInfoKeys>
					<Excluded_Packages>
						<Excluded_Packages Name="$(BDS)\bin\dcloffice2k140.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
						<Excluded_Packages Name="$(BDS)\bin\dclofficexp140.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
					</Excluded_Packages>
				</Delphi.Personality>
			</BorlandProject>
			<ProjectFileVersion>12</ProjectFileVersion>
		</ProjectExtensions>
	</Project>

Changes to src/prj/D2010/Olam.res.

cannot compute difference between binary files