summaryrefslogtreecommitdiff
path: root/libopie/tododb.cpp
authorzecke <zecke>2002-03-20 21:45:51 (UTC)
committer zecke <zecke>2002-03-20 21:45:51 (UTC)
commite9189f8d0cc46b0532fdcbcb2377ae3d108666d5 (patch) (unidiff)
tree20af6104c262510595b82e619ee69b0958596ddd /libopie/tododb.cpp
parent0b39bb8d62f67a86128a6bd16afbd2aae004637c (diff)
downloadopie-e9189f8d0cc46b0532fdcbcb2377ae3d108666d5.zip
opie-e9189f8d0cc46b0532fdcbcb2377ae3d108666d5.tar.gz
opie-e9189f8d0cc46b0532fdcbcb2377ae3d108666d5.tar.bz2
vCal Resource for the tododb
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
@@ -93,96 +93,104 @@ public:
93 event.setDate( date); 93 event.setDate( date);
94 } 94 }
95 dummy = element->attribute("Priority" ); 95 dummy = element->attribute("Priority" );
96 dumInt = dummy.toInt(&ok ); 96 dumInt = dummy.toInt(&ok );
97 if(!ok ) dumInt = ToDoEvent::NORMAL; 97 if(!ok ) dumInt = ToDoEvent::NORMAL;
98 event.setPriority( dumInt ); 98 event.setPriority( dumInt );
99 //description 99 //description
100 dummy = element->attribute("Description" ); 100 dummy = element->attribute("Description" );
101 event.setDescription( dummy ); 101 event.setDescription( dummy );
102 // category 102 // category
103 dummy = element->attribute("Categories" ); 103 dummy = element->attribute("Categories" );
104 dumInt = dummy.toInt(&ok ); 104 dumInt = dummy.toInt(&ok );
105 if(ok ) { 105 if(ok ) {
106 QArray<int> arrat(1); 106 QArray<int> arrat(1);
107 arrat[0] = dumInt; 107 arrat[0] = dumInt;
108 event.setCategory( Qtopia::Record::idsToString( arrat ) ); 108 event.setCategory( Qtopia::Record::idsToString( arrat ) );
109 } 109 }
110 //uid 110 //uid
111 dummy = element->attribute("Uid" ); 111 dummy = element->attribute("Uid" );
112 dumInt = dummy.toInt(&ok ); 112 dumInt = dummy.toInt(&ok );
113 if(ok ) event.setUid( dumInt ); 113 if(ok ) event.setUid( dumInt );
114 m_todos.append( event ); 114 m_todos.append( event );
115 element = element->nextChild(); // next element 115 element = element->nextChild(); // next element
116 } 116 }
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()
165{ 173{
166 QValueList<ToDoEvent> events; 174 QValueList<ToDoEvent> events;
167 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ 175 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
168 if( (*it).isOverdue() ) 176 if( (*it).isOverdue() )
169 events.append((*it) ); 177 events.append((*it) );
170 } 178 }
171 return events; 179 return events;
172} 180}
173QValueList<ToDoEvent> ToDoDB::rawToDos() 181QValueList<ToDoEvent> ToDoDB::rawToDos()
174{ 182{
175 return m_todos; 183 return m_todos;
176} 184}
177void ToDoDB::addEvent( const ToDoEvent &event ) 185void ToDoDB::addEvent( const ToDoEvent &event )
178{ 186{
179 m_todos.append( event ); 187 m_todos.append( event );
180} 188}
181void ToDoDB::editEvent( const ToDoEvent &event ) 189void ToDoDB::editEvent( const ToDoEvent &event )
182{ 190{
183 m_todos.remove( event ); 191 m_todos.remove( event );
184 m_todos.append( event ); 192 m_todos.append( event );
185} 193}
186void ToDoDB::removeEvent( const ToDoEvent &event ) 194void ToDoDB::removeEvent( const ToDoEvent &event )
187{ 195{
188 m_todos.remove( event ); 196 m_todos.remove( event );