summaryrefslogtreecommitdiff
path: root/libopie/tododb.cpp
Unidiff
Diffstat (limited to 'libopie/tododb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/tododb.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index b1b35d0..f9756c6 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -117,48 +117,56 @@ public:
117 //} 117 //}
118 }else { 118 }else {
119 qWarning("could not load" ); 119 qWarning("could not load" );
120 } 120 }
121 delete root; 121 delete root;
122 qWarning("returning" ); 122 qWarning("returning" );
123 return m_todos; 123 return m_todos;
124 } 124 }
125}; 125};
126 126
127} 127}
128 128
129ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){ 129ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){
130 m_fileName = fileName; 130 m_fileName = fileName;
131 if( fileName.isEmpty() && res == 0 ){ 131 if( fileName.isEmpty() && res == 0 ){
132 m_fileName = Global::applicationFileName("todolist","todolist.xml"); 132 m_fileName = Global::applicationFileName("todolist","todolist.xml");
133 res = new FileToDoResource(); 133 res = new FileToDoResource();
134 //qWarning("%s", m_fileName.latin1() ); 134 //qWarning("%s", m_fileName.latin1() );
135 }else if(res == 0 ){ // let's create a ToDoResource for xml 135 }else if(res == 0 ){ // let's create a ToDoResource for xml
136 res = new FileToDoResource(); 136 res = new FileToDoResource();
137 } 137 }
138 m_res = res; 138 m_res = res;
139 load(); 139 load();
140} 140}
141ToDoResource* ToDoDB::resource(){
142 return m_res;
143};
144void ToDoDB::setResource( ToDoResource *res )
145{
146 delete m_res;
147 m_res = res;
148}
141ToDoDB::~ToDoDB() 149ToDoDB::~ToDoDB()
142{ 150{
143 delete m_res; 151 delete m_res;
144} 152}
145QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, 153QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to,
146 bool all ) 154 bool all )
147{ 155{
148 QValueList<ToDoEvent> events; 156 QValueList<ToDoEvent> events;
149 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ 157 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
150 if( (*it).hasDate() ){ 158 if( (*it).hasDate() ){
151 if( (*it).date() >= from && (*it).date() <= to ) 159 if( (*it).date() >= from && (*it).date() <= to )
152 events.append( (*it) ); 160 events.append( (*it) );
153 }else if( all ){ 161 }else if( all ){
154 events.append( (*it) ); 162 events.append( (*it) );
155 } 163 }
156 } 164 }
157 return events; 165 return events;
158} 166}
159QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, 167QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from,
160 bool all) 168 bool all)
161{ 169{
162 return effectiveToDos( from, QDate::currentDate(), all ); 170 return effectiveToDos( from, QDate::currentDate(), all );
163} 171}
164QValueList<ToDoEvent> ToDoDB::overDue() 172QValueList<ToDoEvent> ToDoDB::overDue()