This commit is contained in:
Patrick Lipka 2021-12-10 09:38:05 +01:00
parent 22f7902b45
commit d19d96b6ee
4 changed files with 4 additions and 33 deletions

View File

@ -109,6 +109,7 @@ void ProjectList::load(std::string file_name){
task.add_time(work_time); task.add_time(work_time);
proj.add_task(task); proj.add_task(task);
} }
// needed to get the active_task pointers right _after_ adding tasks to projetcs
active_task_arr[i] = active_t; active_task_arr[i] = active_t;
add_project(proj); add_project(proj);
} }

View File

@ -26,6 +26,6 @@ void track(Project *proj){
work_h = (worktime % 86400) / 3600; work_h = (worktime % 86400) / 3600;
work_m = (worktime % 3600) / 60; work_m = (worktime % 3600) / 60;
work_s = worktime % 60; work_s = worktime % 60;
// TODO: replace with proper cout call
printf("Time worked on project: %02d:%02d:%02d\n", work_h,work_m,work_s ); printf("Time worked on project: %02d:%02d:%02d\n", work_h,work_m,work_s );
} }

View File

@ -1,7 +1,9 @@
#ifndef TRACK_H #ifndef TRACK_H
#define TRACK_H #define TRACK_H
#include "project.h" #include "project.h"
extern int sigint; extern int sigint;
void handler(int signum); void handler(int signum);
void track (Project *proj); void track (Project *proj);
#endif #endif

View File

@ -9,38 +9,6 @@
int main(){ int main(){
signal(SIGINT, handler); signal(SIGINT, handler);
Task task("Test task");
task.add_time(140);
std::cout << "Task name: " << task.name << ", Work Time: " << task.work_time << std::endl;
Project proj("Test Project");
proj.add_task(task);
std::cout << "Project name: " << proj.name << " No tasks:"<< proj.num_tasks <<" contains task 0: " << proj.tasks[0].name << " with work time " << proj.tasks[0].work_time << std::endl;
/*std::cout << "Removing Task 0 from Project" << std::endl;
proj.remove_task(0);
std::cout << "Number of tasks in project: " << proj.num_tasks << std::endl;
*/
ProjectList proj_list;
proj_list.add_project(proj);
std::cout << "Project List no of projects: " << proj_list.num_projects << " Name of active proj: " << proj_list.projects[proj_list.active_project_id].name << std::endl;
std::cout << "Write Project List to file" << std::endl;
std::cout << "Active Task: " << proj_list.active_project->active_task->name << std::endl;
proj_list.save("test.bin");
std::cout << "Read Project List from file" << std::endl;
ProjectList list2;
list2.load("test.bin");
std::cout << "Project List no of projects: " << list2.num_projects << std::endl;
std::cout << "active Project: " << list2.active_project_id << std::endl;
std::cout << "Name of active proj: " << list2.projects[list2.active_project_id].name << std::endl;
std::cout << list2.active_project->name << std::endl;
std::cout << list2.active_project->active_task->name << std::endl;
std::cout << list2.active_project->active_task->work_time << std::endl;
track(list2.active_project);
return 0; return 0;
} }