summaryrefslogtreecommitdiff
path: root/src/taskmanager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/taskmanager.h')
-rw-r--r--src/taskmanager.h169
1 files changed, 89 insertions, 80 deletions
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 <list>
#include <string>
@@ -38,36 +37,37 @@
typedef std::pair<TaskIdList, TaskIdList> 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<task_t> 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<task_t>{
+class TaskList
+ : public std::list<task_t>
+{
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<task_t>::push_front(t);
- return;
- }
-
- std::list<task_t>::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<task_t>::insert(++it, t);
-
-// std::list<task_t>::push_back(t);
-// std::list<task_t>::sort(CompareByParentid());
-
- }
-
- void move(task_t t) {
- std::list<task_t>::iterator it;
- for(it = begin(); it != end(); it++) {
- if(t.id == it->id) {
- break;
- }
- }
- assert(it != end());
- // if(it != end()) {
- std::list<task_t>::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<task_t>::push_front(t);
+ return;
+ }
+
+ std::list<task_t>::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<task_t>::insert(++it, t);
+
+ //std::list<task_t>::push_back(t);
+ //std::list<task_t>::sort(CompareByParentid());
+ }
+
+ void move(task_t t)
+ {
+ std::list<task_t>::iterator it;
+ for(it = begin(); it != end(); it++)
+ {
+ if(t.id == it->id)
+ {
+ break;
+ }
+ }
+ assert(it != end());
+ //if(it != end())
+ //{
+ std::list<task_t>::erase(it);
+ //}
+ insert(t);
+ }
+
+ void push_back(task_t t)
+ {
+ insert(t);
+ }
private:
- std::list<task_t> list;
+ std::list<task_t> list;
};
@@ -195,11 +207,8 @@ extern TaskList tasklist;
//typedef std::priority_queue<task_t, std::vector<task_t>, 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*/