|
YATISH
Yet Another TIme SHeet
|
Interacts with yatish tables in a SQLite database. More...
#include <yatishDBsqlite.h>


Public Member Functions | |
| yatishDBsqlite () | |
Mainly connects to the yatish.sqlite database. More... | |
| ~yatishDBsqlite () | |
| bool | FillChoice (wxChoice *, tableID) |
Fills a wxChoice. More... | |
| int | ChoiceSelector (tableID, long) |
Finds the proper index for selection in a wxChoice. More... | |
| bool | StartTimeslot (int, int, int) |
| Starts a new row in the timeslot table. More... | |
| bool | StopTimeslot () |
| Stops current timeslot. More... | |
| int | RunningTimeslots () |
| Determines the number n of unfinished timeslots. More... | |
| bool | FillList (wxListCtrl *, tableID) |
| Fills a wxListCtrl. More... | |
| void | AddToFilter (tableID, int) |
| Add a condition to the WHERE clause of FillList(). More... | |
| void | SetLimit (bool b, int i) |
| wxString | FilteredTotal () |
| Writes the total and average durations of currently viewed timeslots. More... | |
| void | ClearFilter () |
| void | SetFirstDay (const wxDateTime &) |
Sets private member firstDay (for future SQL queries). More... | |
| void | SetLastDay (const wxDateTime &) |
Sets private member lastDay (for future SQL queries). More... | |
| wxDateTime | First () |
| Obtains the minimum time in column start from currently selected rows of table yatish_timeslot. More... | |
| wxDateTime | Last () |
| Obtains the maximum time in column start from currently selected rows of table yatish_timeslot. More... | |
| long | LastActivity () |
| Reads the last activity_id in yatish_timeslot. More... | |
| long | Activity (long) |
| Reads the activity_id in a record of yatish_timeslot. More... | |
| bool | Delete (tableID, long) |
| Marks a local record for deletion. More... | |
| wxString | ReadName (tableID, long) |
Reads a wxString from the name column. More... | |
| bool | ReadDates (long, wxDateTime &, wxDateTime &) |
| Reads the start and stop fields of a yatish_timeslot record. More... | |
| bool | RecordName (tableID, long, const wxString &) |
| Modifies or creates a record with only one field (called name). More... | |
| bool | RecordProject (long, const wxString &, int) |
| Modifies or creates a record in the yatish_project table. More... | |
| bool | RecordActivity (long, int, int, int) |
| Modifies or creates a record in the yatish_activity table. More... | |
| bool | RecordTimeslot (long, const wxDateTime &, const wxDateTime &, int, int, int) |
| Modifies or creates a record in the yatish_timeslot table. More... | |
Private Attributes | |
| bool | limitRow |
| int | rowLimit |
| long | currentTimeslotID |
| long | slotCount |
| wxArrayLong | clientIDs |
| wxArrayLong | projectIDs |
| wxArrayLong | taskIDs |
| wxArrayLong | toolIDs |
| wxString | firstDay |
| wxString | lastDay |
| wxString | filter |
| wxTimeSpan | totalSpan |
Additional Inherited Members | |
Static Public Attributes inherited from yatishDB | |
| static const char * | tableName [] |
Must be defined in the same order as enum tableID. More... | |
Protected Member Functions inherited from yatishDB | |
| wxDatabase * | GetDatabase (const wxString &) |
Sets up a (configuration) flux using its argument then calls wxDatabase::GetDatabase(). More... | |
| bool | TablesOk (wxDatabase *) |
Returns false if any of the yatish table is missings. More... | |
Static Protected Attributes inherited from yatishDB | |
| static wxDatabase * | masterDB = nullptr |
Interacts with yatish tables in a SQLite database.
Cf. the application example distributed with the wxDatabase library.
The sync field of each table only exists in the local (SQlite) database, with values among:
date('now'). Such timestamps are stored by SQLite as TEXT fields in the UTC timezone (i.e. we don't use date('now','localtime')).Definition at line 39 of file yatishDBsqlite.h.
| yatishDBsqlite::yatishDBsqlite | ( | ) |
Mainly connects to the yatish.sqlite database.
(initializing protected member yatishDB::masterDB).
Definition at line 17 of file yatishDBsqlite.cpp.
| yatishDBsqlite::~yatishDBsqlite | ( | ) |
Definition at line 50 of file yatishDBsqlite.cpp.
| long yatishDBsqlite::Activity | ( | long | id | ) |
Reads the activity_id in a record of yatish_timeslot.
| id | the record to read |
Definition at line 445 of file yatishDBsqlite.cpp.
| void yatishDBsqlite::AddToFilter | ( | tableID | tid, |
| int | choice | ||
| ) |
Add a condition to the WHERE clause of FillList().
| tid | the table used to build the new condition |
| choice | the item in this table (as returned from a previously filled wxChoice) |
Definition at line 322 of file yatishDBsqlite.cpp.
| int yatishDBsqlite::ChoiceSelector | ( | tableID | tid, |
| long | id | ||
| ) |
Finds the proper index for selection in a wxChoice.
The selection corresponds to a given record in the refering table (cf. foreign keys in the yatish database schema).
| tid | either client_tid, project_tid, task_tid or tool_tid |
| id | of the foreign key to read from the refering table |
wxChoice index (or wxNOT_FOUND in case of problem) Definition at line 109 of file yatishDBsqlite.cpp.
|
inline |
Definition at line 52 of file yatishDBsqlite.h.
| bool yatishDBsqlite::Delete | ( | tableID | tid, |
| long | id | ||
| ) |
Marks a local record for deletion.
Actually deletes it if its sync status was 'I'.
| tid | Which table? |
| id | Which record? |
false if something went wrong or deletion was cancelled Definition at line 462 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::FillChoice | ( | wxChoice * | choices, |
| tableID | tid | ||
| ) |
Fills a wxChoice.
Corresponding values of the SQL id field are stored for future reference.
| choices | the control to fill |
| tid | either client_tid, project_tid, task_tid or tool_tid |
false if something went wrong Definition at line 63 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::FillList | ( | wxListCtrl * | lst, |
| tableID | tid | ||
| ) |
Fills a wxListCtrl.
The SQL id is stored as the row data.
| lst | the control to fill |
| tid | the type of data to fetch |
false if something went wrong Definition at line 220 of file yatishDBsqlite.cpp.
| wxString yatishDBsqlite::FilteredTotal | ( | ) |
Writes the total and average durations of currently viewed timeslots.
One work day amounts to 7 hours.
wxString, or wxEmptyString if the currently viewed table is not yatish_timeslot Definition at line 348 of file yatishDBsqlite.cpp.
| wxDateTime yatishDBsqlite::First | ( | ) |
Obtains the minimum time in column start from currently selected rows of table yatish_timeslot.
This time is provided in the local timezone.
Now() if something went wrong Definition at line 379 of file yatishDBsqlite.cpp.
| wxDateTime yatishDBsqlite::Last | ( | ) |
Obtains the maximum time in column start from currently selected rows of table yatish_timeslot.
This time is provided in the local timezone.
Now() if something went wrong Definition at line 404 of file yatishDBsqlite.cpp.
| long yatishDBsqlite::LastActivity | ( | ) |
Reads the last activity_id in yatish_timeslot.
Definition at line 428 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::ReadDates | ( | long | id, |
| wxDateTime & | dt1, | ||
| wxDateTime & | dt2 | ||
| ) |
Reads the start and stop fields of a yatish_timeslot record.
| id | Which record? |
| dt1 | where to write the start value |
| dt2 | where to write the stop value |
false if something went wrong (or activity still running)N.B. wxWidgets assumes the string from the database is local time which is wrong (it's UTC from SQLite) thus dt1.GetTicks() and dt2.GetTicks() would be biased (by the same offset: no problem when computing their difference). However wxDateTime::MakeFromUTC() appears to reverse the (fake) local->UTC transformation initially applied by the wxDateTime constructor, so that we can get the correct local time afterward (wxWidgets output is always local time). Furthermore GetTicks() is then OK.
However this trick is not satisfying when the Daylight Saving Time changes between (i) writing and (ii) reading a record.
Definition at line 520 of file yatishDBsqlite.cpp.
| wxString yatishDBsqlite::ReadName | ( | tableID | tid, |
| long | id | ||
| ) |
Reads a wxString from the name column.
| tid | Which table? |
| id | Which record? |
Definition at line 492 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::RecordActivity | ( | long | id, |
| int | project, | ||
| int | task, | ||
| int | tool | ||
| ) |
Modifies or creates a record in the yatish_activity table.
| id | Which record? A new record is created if id == wxNOT_FOUND. |
| project,task,tool | indexes selected in previously filled wxChoices |
false if something went wrong Definition at line 604 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::RecordName | ( | tableID | tid, |
| long | id, | ||
| const wxString & | str | ||
| ) |
Modifies or creates a record with only one field (called name).
| tid | Which table? |
| id | Which record? A new record is created if id == wxNOT_FOUND. |
| str | the new name |
false if something went wrong Definition at line 546 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::RecordProject | ( | long | id, |
| const wxString & | str, | ||
| int | client_choice | ||
| ) |
Modifies or creates a record in the yatish_project table.
| id | Which record? A new record is created if id == wxNOT_FOUND. |
| str | the new name |
| client_choice | index selected in a previously filled wxChoice |
false if something went wrong Definition at line 575 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::RecordTimeslot | ( | long | id, |
| const wxDateTime & | dt1, | ||
| const wxDateTime & | dt2, | ||
| int | project, | ||
| int | task, | ||
| int | tool | ||
| ) |
Modifies or creates a record in the yatish_timeslot table.
Also inserts the corresponding row in the activity table, if necessary.
| id | Which record? A new record is created if id == wxNOT_FOUND. |
| dt1,dt2 | the new start and stop |
| project,task,tool | indexes selected in previously filled wxChoices |
false if something went wrong Definition at line 638 of file yatishDBsqlite.cpp.
| int yatishDBsqlite::RunningTimeslots | ( | ) |
Determines the number n of unfinished timeslots.
Definition at line 202 of file yatishDBsqlite.cpp.
| void yatishDBsqlite::SetFirstDay | ( | const wxDateTime & | dt | ) |
Sets private member firstDay (for future SQL queries).
firstDay is a UTC time string in ISO format.
Definition at line 363 of file yatishDBsqlite.cpp.
| void yatishDBsqlite::SetLastDay | ( | const wxDateTime & | dt | ) |
Sets private member lastDay (for future SQL queries).
lastDay is a UTC time string in ISO format.
Definition at line 371 of file yatishDBsqlite.cpp.
|
inline |
Definition at line 50 of file yatishDBsqlite.h.
| bool yatishDBsqlite::StartTimeslot | ( | int | project, |
| int | task, | ||
| int | tool | ||
| ) |
Starts a new row in the timeslot table.
Also inserts the corresponding row in the activity table, if necessary.
| project,task,tool | 0-based index of the item currently selected in panel #1 |
false if something went wrong Definition at line 149 of file yatishDBsqlite.cpp.
| bool yatishDBsqlite::StopTimeslot | ( | ) |
Stops current timeslot.
false if something went wrong Definition at line 187 of file yatishDBsqlite.cpp.
|
private |
Definition at line 70 of file yatishDBsqlite.h.
|
private |
Definition at line 69 of file yatishDBsqlite.h.
|
private |
Definition at line 71 of file yatishDBsqlite.h.
|
private |
Definition at line 71 of file yatishDBsqlite.h.
|
private |
Definition at line 71 of file yatishDBsqlite.h.
|
private |
Definition at line 67 of file yatishDBsqlite.h.
|
private |
Definition at line 70 of file yatishDBsqlite.h.
|
private |
Definition at line 68 of file yatishDBsqlite.h.
|
private |
Definition at line 69 of file yatishDBsqlite.h.
|
private |
Definition at line 70 of file yatishDBsqlite.h.
|
private |
Definition at line 70 of file yatishDBsqlite.h.
|
private |
Definition at line 72 of file yatishDBsqlite.h.
1.8.13