From 1ae51ff94d0f1f27a4e4cc657371578db13c3ca1 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 8 Feb 2019 20:26:14 +0100 Subject: Make code compile again (fix bitrot dating back from 2013). --- src/taskmanager.h | 169 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 89 insertions(+), 80 deletions(-) (limited to 'src/taskmanager.h') diff --git a/src/taskmanager.h b/src/taskmanager.h index 11601a4..99143f5 100644 --- a/src/taskmanager.h +++ b/src/taskmanager.h @@ -25,8 +25,7 @@ * along with Munia; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __MUNIA_TASKMANAGER_H__ -#define __MUNIA_TASKMANAGER_H__ +#pragma once #include #include @@ -38,36 +37,37 @@ typedef std::pair TaskIdListPair; -class TaskManager { +class TaskManager +{ public: - TaskManager(); - ~TaskManager(); + TaskManager(); + ~TaskManager(); - void init(std::string filename); + void init(std::string filename); - TaskIdList createTask(taskid_t parentid, taskid_t *id) throw (std::exception); - TaskIdList updateTask(taskid_t id, const std::string &name, - const std::string &value) throw (std::exception); - TaskIdList removeTask(taskid_t id) throw (std::exception); - - TaskIdListPair moveTask(taskid_t id, taskid_t newParent) throw (std::exception); + TaskIdList createTask(taskid_t parentid, taskid_t *id) throw (std::exception); + TaskIdList updateTask(taskid_t id, const std::string &name, + const std::string &value) throw (std::exception); + TaskIdList removeTask(taskid_t id) throw (std::exception); - TaskIdList subTasks(taskid_t) throw (std::exception); + TaskIdListPair moveTask(taskid_t id, taskid_t newParent) throw (std::exception); - TaskTree tree; + TaskIdList subTasks(taskid_t) throw (std::exception); - task_t task(taskid_t t); + TaskTree tree; - void flushTasks(); + task_t task(taskid_t t); - taskid_t createId(); + void flushTasks(); + + taskid_t createId(); private: - // TaskIdList ancestorList(taskid_t task); - taskid_t idCount; - task_t nextTask(); + // TaskIdList ancestorList(taskid_t task); + taskid_t idCount; + task_t nextTask(); - std::string file; + std::string file; }; #ifndef FOOBAR @@ -128,66 +128,78 @@ protocol: //typedef std::list TaskList; -class CompareByParentid { +class CompareByParentid +{ public: - bool operator()(const task_t &a, const task_t &b) const { - return a.parent_id < b.parent_id; - } + bool operator()(const task_t &a, const task_t &b) const + { + return a.parent_id < b.parent_id; + } }; - - - -class TaskList : public std::list{ +class TaskList + : public std::list +{ public: - TaskList() {} - ~TaskList(){} - - void insert(task_t t) { - if(t.id == t.parent_id) return; - printf("inserting task %d with parent %d\n", t.id, t.parent_id); - - if(t.parent_id == -1) { - std::list::push_front(t); - return; - } - - std::list::iterator it; - for(it = begin(); it != end(); ++it) { - printf("\tcomparing %d and %d\n", t.parent_id, it->id); - if(t.parent_id == it->id) { - break; - } - } - assert(it != end()); - - std::list::insert(++it, t); - -// std::list::push_back(t); -// std::list::sort(CompareByParentid()); - - } - - void move(task_t t) { - std::list::iterator it; - for(it = begin(); it != end(); it++) { - if(t.id == it->id) { - break; - } - } - assert(it != end()); - // if(it != end()) { - std::list::erase(it); - // } - insert(t); - } - - void push_back(task_t t) { - insert(t); - } + TaskList() {} + ~TaskList(){} + + void insert(task_t t) + { + if(t.id == t.parent_id) + { + return; + } + printf("inserting task %d with parent %d\n", t.id, t.parent_id); + + if(t.parent_id == -1) + { + std::list::push_front(t); + return; + } + + std::list::iterator it; + for(it = begin(); it != end(); ++it) + { + printf("\tcomparing %d and %d\n", t.parent_id, it->id); + if(t.parent_id == it->id) + { + break; + } + } + assert(it != end()); + + std::list::insert(++it, t); + + //std::list::push_back(t); + //std::list::sort(CompareByParentid()); + } + + void move(task_t t) + { + std::list::iterator it; + for(it = begin(); it != end(); it++) + { + if(t.id == it->id) + { + break; + } + } + assert(it != end()); + //if(it != end()) + //{ + std::list::erase(it); + //} + insert(t); + } + + void push_back(task_t t) + { + insert(t); + } private: - std::list list; + std::list list; }; @@ -195,11 +207,8 @@ extern TaskList tasklist; //typedef std::priority_queue, CompareByParentid> TaskList; -task_t create_task(std::string title, std::string desc, - /*int x, int y*/ int parent_id); +task_t create_task(std::string title, std::string desc, /*int x, int y*/ int parent_id); TaskList load_tasklist_from_file(std::string file); bool save_tasklist_to_file(TaskList t, std::string file); -#endif - -#endif/*__MUNIA_TASK_H__*/ +#endif/*0*/ -- cgit v1.2.3