-rw-r--r-- | libopie/tododb.cpp | 8 |
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 | ||
129 | ToDoDB::ToDoDB(const QString &fileName = QString::null, ToDoResource *res ){ | 129 | ToDoDB::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 | } |
141 | ToDoResource* ToDoDB::resource(){ | ||
142 | return m_res; | ||
143 | }; | ||
144 | void ToDoDB::setResource( ToDoResource *res ) | ||
145 | { | ||
146 | delete m_res; | ||
147 | m_res = res; | ||
148 | } | ||
141 | ToDoDB::~ToDoDB() | 149 | ToDoDB::~ToDoDB() |
142 | { | 150 | { |
143 | delete m_res; | 151 | delete m_res; |
144 | } | 152 | } |
145 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, | 153 | QValueList<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 | } |
159 | QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, | 167 | QValueList<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 | } |
164 | QValueList<ToDoEvent> ToDoDB::overDue() | 172 | QValueList<ToDoEvent> ToDoDB::overDue() |