-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 | ||||
-rw-r--r-- | core/pim/todo/todotable.cpp | 49 |
2 files changed, 29 insertions, 23 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 5609211..b7b1da0 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -164,192 +164,195 @@ TodoWindow::TodoWindow( QWidget *parent, const char *name, WFlags f ) : | |||
164 | QString::null, 0, this, 0 ); | 164 | QString::null, 0, this, 0 ); |
165 | connect( a, SIGNAL( activated() ), | 165 | connect( a, SIGNAL( activated() ), |
166 | this, SLOT( slotDelete() ) ); | 166 | this, SLOT( slotDelete() ) ); |
167 | a->addTo( bar ); | 167 | a->addTo( bar ); |
168 | a->addTo( edit ); | 168 | a->addTo( edit ); |
169 | a->addTo( contextMenu ); | 169 | a->addTo( contextMenu ); |
170 | a->setEnabled( FALSE ); | 170 | a->setEnabled( FALSE ); |
171 | deleteAction = a; | 171 | deleteAction = a; |
172 | 172 | ||
173 | // delete All in category is missing.... | 173 | // delete All in category is missing.... |
174 | // set All Done | 174 | // set All Done |
175 | // set All Done in category | 175 | // set All Done in category |
176 | 176 | ||
177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); | 177 | a = new QAction( QString::null, tr( "Delete all..."), 0, this, 0 ); |
178 | connect(a, SIGNAL( activated() ), | 178 | connect(a, SIGNAL( activated() ), |
179 | this, SLOT( slotDeleteAll() ) ); | 179 | this, SLOT( slotDeleteAll() ) ); |
180 | a->addTo(edit ); | 180 | a->addTo(edit ); |
181 | a->setEnabled( FALSE ); | 181 | a->setEnabled( FALSE ); |
182 | deleteAllAction = a; | 182 | deleteAllAction = a; |
183 | 183 | ||
184 | edit->insertSeparator(); | 184 | edit->insertSeparator(); |
185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); | 185 | a = new QAction( QString::null, tr("Duplicate" ), 0, this, 0 ); |
186 | connect(a, SIGNAL( activated() ), | 186 | connect(a, SIGNAL( activated() ), |
187 | this, SLOT( slotDuplicate() ) ); | 187 | this, SLOT( slotDuplicate() ) ); |
188 | a->addTo(edit ); | 188 | a->addTo(edit ); |
189 | a->setEnabled( FALSE ); | 189 | a->setEnabled( FALSE ); |
190 | duplicateAction = a; | 190 | duplicateAction = a; |
191 | edit->insertSeparator(); | 191 | edit->insertSeparator(); |
192 | 192 | ||
193 | 193 | ||
194 | 194 | ||
195 | if ( Ir::supported() ) { | 195 | if ( Ir::supported() ) { |
196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), | 196 | a = new QAction( tr( "Beam" ), Resource::loadPixmap( "beam" ), |
197 | QString::null, 0, this, 0 ); | 197 | QString::null, 0, this, 0 ); |
198 | connect( a, SIGNAL( activated() ), | 198 | connect( a, SIGNAL( activated() ), |
199 | this, SLOT( slotBeam() ) ); | 199 | this, SLOT( slotBeam() ) ); |
200 | a->addTo( edit ); | 200 | a->addTo( edit ); |
201 | a->addTo( bar ); | 201 | a->addTo( bar ); |
202 | } | 202 | } |
203 | 203 | ||
204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), | 204 | a = new QAction( tr( "Find" ), Resource::loadIconSet( "mag" ), |
205 | QString::null, 0, this, 0 ); | 205 | QString::null, 0, this, 0 ); |
206 | connect( a, SIGNAL( activated() ), | 206 | connect( a, SIGNAL( activated() ), |
207 | this, SLOT( slotFind() ) ); | 207 | this, SLOT( slotFind() ) ); |
208 | a->addTo( bar ); | 208 | a->addTo( bar ); |
209 | a->addTo( options ); | 209 | a->addTo( options ); |
210 | options->insertSeparator(); | 210 | options->insertSeparator(); |
211 | 211 | ||
212 | if ( table->numRows() ) | 212 | if ( table->numRows() ) |
213 | a->setEnabled( TRUE ); | 213 | a->setEnabled( TRUE ); |
214 | else | 214 | else |
215 | a->setEnabled( FALSE ); | 215 | a->setEnabled( FALSE ); |
216 | 216 | ||
217 | //a->setEnabled( FALSE ); | 217 | //a->setEnabled( FALSE ); |
218 | findAction = a; | 218 | findAction = a; |
219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); | 219 | // qDebug("mainwindow #2: t=%d", t.elapsed() ); |
220 | 220 | ||
221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); | 221 | completedAction = new QAction( QString::null, tr("Completed tasks"), 0, this, 0, TRUE ); |
222 | 222 | ||
223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); | 223 | showdeadlineAction = new QAction( QString::null, tr( "Show Deadline" ), 0, this, 0, TRUE ); |
224 | 224 | ||
225 | catMenu->setCheckable( true ); | 225 | catMenu->setCheckable( true ); |
226 | populateCategories(); | 226 | populateCategories(); |
227 | 227 | ||
228 | 228 | ||
229 | completedAction->addTo( options ); | 229 | completedAction->addTo( options ); |
230 | completedAction->setOn( table->showCompleted() ); | 230 | completedAction->setOn( table->showCompleted() ); |
231 | showdeadlineAction->addTo( options ); | 231 | showdeadlineAction->addTo( options ); |
232 | showdeadlineAction->setOn( table->showDeadline() ); | 232 | showdeadlineAction->setOn( table->showDeadline() ); |
233 | options->insertSeparator( ); | 233 | options->insertSeparator( ); |
234 | QList<QWidget> list; | 234 | QList<QWidget> list; |
235 | list.append(table ); | 235 | list.append(table ); |
236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); | 236 | OFontMenu *menu = new OFontMenu(this, "menu",list ); |
237 | menu->forceSize( table->horizontalHeader(), 10 ); | 237 | menu->forceSize( table->horizontalHeader(), 10 ); |
238 | //catMenu->insertItem(tr("Fonts"), menu ); | 238 | //catMenu->insertItem(tr("Fonts"), menu ); |
239 | list.clear(); | 239 | list.clear(); |
240 | options->insertItem( tr("Fonts"), menu ); | 240 | options->insertItem( tr("Fonts"), menu ); |
241 | 241 | ||
242 | 242 | ||
243 | mb->insertItem( tr( "Data" ), edit ); | 243 | mb->insertItem( tr( "Data" ), edit ); |
244 | mb->insertItem( tr( "Category" ), catMenu ); | 244 | mb->insertItem( tr( "Category" ), catMenu ); |
245 | mb->insertItem( tr( "Options"), options ); | 245 | mb->insertItem( tr( "Options"), options ); |
246 | resize( 200, 300 ); | 246 | resize( 200, 300 ); |
247 | if ( table->numRows() > 0 ) | 247 | if ( table->numRows() > 0 ) |
248 | currentEntryChanged( 0, 0 ); | 248 | currentEntryChanged( 0, 0 ); |
249 | connect( table, SIGNAL( signalEdit() ), | 249 | connect( table, SIGNAL( signalEdit() ), |
250 | this, SLOT( slotEdit() ) ); | 250 | this, SLOT( slotEdit() ) ); |
251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), | 251 | connect( table, SIGNAL(signalShowMenu(const QPoint &)), |
252 | this, SLOT( slotShowPopup(const QPoint &)) ); | 252 | this, SLOT( slotShowPopup(const QPoint &)) ); |
253 | 253 | ||
254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); | 254 | // qDebug("mainwindow #3: t=%d", t.elapsed() ); |
255 | table->updateVisible(); | 255 | table->updateVisible(); |
256 | table->setUpdatesEnabled( TRUE ); | 256 | table->setUpdatesEnabled( TRUE ); |
257 | table->setPaintingEnabled( TRUE ); | 257 | table->setPaintingEnabled( TRUE ); |
258 | table->viewport()->setUpdatesEnabled( TRUE ); | 258 | table->viewport()->setUpdatesEnabled( TRUE ); |
259 | 259 | ||
260 | // Initialize the table | ||
261 | table->updateVisible(); | ||
262 | |||
260 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); | 263 | connect( completedAction, SIGNAL( toggled(bool) ), this, SLOT( showCompleted(bool) ) ); |
261 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); | 264 | connect( showdeadlineAction, SIGNAL( toggled(bool) ), this, SLOT( showDeadline(bool) ) ); |
262 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); | 265 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(setCategory(int)) ); |
263 | connect( table, SIGNAL( currentChanged( int, int ) ), | 266 | connect( table, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( currentEntryChanged( int, int ) ) ); | 267 | this, SLOT( currentEntryChanged( int, int ) ) ); |
265 | 268 | ||
266 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), | 269 | connect( table, SIGNAL(showDetails(const ToDoEvent &) ), |
267 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); | 270 | this, SLOT(slotShowDetails(const ToDoEvent & ) ) ); |
268 | // qDebug("done: t=%d", t.elapsed() ); | 271 | // qDebug("done: t=%d", t.elapsed() ); |
269 | } | 272 | } |
270 | 273 | ||
271 | void TodoWindow::slotNew() | 274 | void TodoWindow::slotNew() |
272 | { | 275 | { |
273 | if(syncing) { | 276 | if(syncing) { |
274 | QMessageBox::warning(this, tr("Todo"), | 277 | QMessageBox::warning(this, tr("Todo"), |
275 | tr("Can not edit data, currently syncing")); | 278 | tr("Can not edit data, currently syncing")); |
276 | return; | 279 | return; |
277 | } | 280 | } |
278 | 281 | ||
279 | int id; | 282 | int id; |
280 | id = -1; | 283 | id = -1; |
281 | QArray<int> ids; | 284 | QArray<int> ids; |
282 | ids = table->currentEntry().categories(); | 285 | ids = table->currentEntry().categories(); |
283 | if ( ids.count() ) | 286 | if ( ids.count() ) |
284 | id = ids[0]; | 287 | id = ids[0]; |
285 | NewTaskDialog e( id, this, 0, TRUE ); | 288 | NewTaskDialog e( id, this, 0, TRUE ); |
286 | 289 | ||
287 | ToDoEvent todo; | 290 | ToDoEvent todo; |
288 | 291 | ||
289 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 292 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
290 | e.showMaximized(); | 293 | e.showMaximized(); |
291 | #endif | 294 | #endif |
292 | int ret = e.exec(); | 295 | int ret = e.exec(); |
293 | // qWarning("finished" ); | 296 | // qWarning("finished" ); |
294 | if ( ret == QDialog::Accepted ) { | 297 | if ( ret == QDialog::Accepted ) { |
295 | table->setPaintingEnabled( false ); | 298 | table->setPaintingEnabled( false ); |
296 | todo = e.todoEntry(); | 299 | todo = e.todoEntry(); |
297 | //todo.assignUid(); | 300 | //todo.assignUid(); |
298 | table->addEntry( todo ); | 301 | table->addEntry( todo ); |
299 | table->setPaintingEnabled( true ); | 302 | table->setPaintingEnabled( true ); |
300 | findAction->setEnabled( TRUE ); | 303 | findAction->setEnabled( TRUE ); |
301 | } | 304 | } |
302 | // I'm afraid we must call this every time now, otherwise | 305 | // I'm afraid we must call this every time now, otherwise |
303 | // spend expensive time comparing all these strings... | 306 | // spend expensive time comparing all these strings... |
304 | populateCategories(); | 307 | populateCategories(); |
305 | mStack->raiseWidget(1 ); | 308 | mStack->raiseWidget(1 ); |
306 | } | 309 | } |
307 | 310 | ||
308 | TodoWindow::~TodoWindow() | 311 | TodoWindow::~TodoWindow() |
309 | { | 312 | { |
310 | } | 313 | } |
311 | 314 | ||
312 | void TodoWindow::slotDelete() | 315 | void TodoWindow::slotDelete() |
313 | { | 316 | { |
314 | if(syncing) { | 317 | if(syncing) { |
315 | QMessageBox::warning(this, tr("Todo"), | 318 | QMessageBox::warning(this, tr("Todo"), |
316 | tr("Can not edit data, currently syncing")); | 319 | tr("Can not edit data, currently syncing")); |
317 | return; | 320 | return; |
318 | } | 321 | } |
319 | 322 | ||
320 | if ( table->currentRow() == -1 ) | 323 | if ( table->currentRow() == -1 ) |
321 | return; | 324 | return; |
322 | 325 | ||
323 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 326 | QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
324 | 327 | ||
325 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) | 328 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), strName ) ) |
326 | return; | 329 | return; |
327 | 330 | ||
328 | 331 | ||
329 | 332 | ||
330 | table->setPaintingEnabled( false ); | 333 | table->setPaintingEnabled( false ); |
331 | table->removeCurrentEntry(); | 334 | table->removeCurrentEntry(); |
332 | table->setPaintingEnabled( true ); | 335 | table->setPaintingEnabled( true ); |
333 | 336 | ||
334 | if ( table->numRows() == 0 ) { | 337 | if ( table->numRows() == 0 ) { |
335 | currentEntryChanged( -1, 0 ); | 338 | currentEntryChanged( -1, 0 ); |
336 | findAction->setEnabled( FALSE ); | 339 | findAction->setEnabled( FALSE ); |
337 | } | 340 | } |
338 | mStack->raiseWidget(1); | 341 | mStack->raiseWidget(1); |
339 | } | 342 | } |
340 | void TodoWindow::slotDeleteAll() | 343 | void TodoWindow::slotDeleteAll() |
341 | { | 344 | { |
342 | if(syncing) { | 345 | if(syncing) { |
343 | QMessageBox::warning(this, tr("Todo"), | 346 | QMessageBox::warning(this, tr("Todo"), |
344 | tr("Can not edit data, currently syncing")); | 347 | tr("Can not edit data, currently syncing")); |
345 | return; | 348 | return; |
346 | } | 349 | } |
347 | 350 | ||
348 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); | 351 | //QString strName = table->text( table->currentRow(), 2 ).left( 30 ); |
349 | 352 | ||
350 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) | 353 | if ( !QPEMessageBox::confirmDelete( this, tr( "Todo" ), tr("Delete all tasks?") ) ) |
351 | return; | 354 | return; |
352 | 355 | ||
353 | 356 | ||
354 | 357 | ||
355 | table->setPaintingEnabled( false ); | 358 | table->setPaintingEnabled( false ); |
diff --git a/core/pim/todo/todotable.cpp b/core/pim/todo/todotable.cpp index 877308a..52a3087 100644 --- a/core/pim/todo/todotable.cpp +++ b/core/pim/todo/todotable.cpp | |||
@@ -213,206 +213,203 @@ void DueTextItem::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bo | |||
213 | }else if( m_off == 0 ){ | 213 | }else if( m_off == 0 ){ |
214 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined | 214 | cg2.setColor(QColorGroup::Text, QColor(yellow) ); // orange isn't predefined |
215 | }else if( m_off > 0){ | 215 | }else if( m_off > 0){ |
216 | cg2.setColor(QColorGroup::Text, QColor(green ) ); | 216 | cg2.setColor(QColorGroup::Text, QColor(green ) ); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | QTableItem::paint(p, cg2, cr, selected ); | 219 | QTableItem::paint(p, cg2, cr, selected ); |
220 | cg2.setColor(QColorGroup::Text, text ); | 220 | cg2.setColor(QColorGroup::Text, text ); |
221 | } | 221 | } |
222 | TodoTable::TodoTable( QWidget *parent, const char *name ) | 222 | TodoTable::TodoTable( QWidget *parent, const char *name ) |
223 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR | 223 | // #ifdef QT_QTABLE_NOHEADER_CONSTRUCTOR |
224 | // : QTable( 0, 3, parent, name, TRUE ), | 224 | // : QTable( 0, 3, parent, name, TRUE ), |
225 | // #else | 225 | // #else |
226 | : QTable( 0, 4, parent, name ), | 226 | : QTable( 0, 4, parent, name ), |
227 | // #endif | 227 | // #endif |
228 | showComp( true ), | 228 | showComp( true ), |
229 | enablePainting( true ), | 229 | enablePainting( true ), |
230 | mCat( 0 ), | 230 | mCat( 0 ), |
231 | currFindRow( -2 ), | 231 | currFindRow( -2 ), |
232 | showDeadl( true) | 232 | showDeadl( true) |
233 | { | 233 | { |
234 | mCat.load( categoryFileName() ); | 234 | mCat.load( categoryFileName() ); |
235 | setSorting( TRUE ); | 235 | setSorting( TRUE ); |
236 | setSelectionMode( NoSelection ); | 236 | setSelectionMode( NoSelection ); |
237 | setColumnStretchable( 2, TRUE ); | 237 | setColumnStretchable( 2, TRUE ); |
238 | setColumnWidth( 0, 20 ); | 238 | setColumnWidth( 0, 20 ); |
239 | setColumnWidth( 1, 35 ); | 239 | setColumnWidth( 1, 35 ); |
240 | 240 | ||
241 | setLeftMargin( 0 ); | 241 | setLeftMargin( 0 ); |
242 | verticalHeader()->hide(); | 242 | verticalHeader()->hide(); |
243 | horizontalHeader()->setLabel( 0, tr( "C." ) ); | 243 | horizontalHeader()->setLabel( 0, tr( "C." ) ); |
244 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); | 244 | horizontalHeader()->setLabel( 1, tr( "Prior." ) ); |
245 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); | 245 | horizontalHeader()->setLabel( 2, tr( "Description" ) ); |
246 | 246 | ||
247 | setColumnStretchable( 3, FALSE ); | 247 | setColumnStretchable( 3, FALSE ); |
248 | setColumnWidth( 3, 20 ); | 248 | setColumnWidth( 3, 20 ); |
249 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); | 249 | horizontalHeader()->setLabel( 3, tr( "Deadline" ) ); |
250 | 250 | ||
251 | if (showDeadl){ | 251 | if (showDeadl){ |
252 | showColumn (3); | 252 | showColumn (3); |
253 | }else{ | 253 | }else{ |
254 | hideColumn (3); | 254 | hideColumn (3); |
255 | } | 255 | } |
256 | 256 | ||
257 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), | 257 | connect( this, SIGNAL( clicked( int, int, int, const QPoint & ) ), |
258 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); | 258 | this, SLOT( slotClicked( int, int, int, const QPoint & ) ) ); |
259 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), | 259 | connect( this, SIGNAL( pressed( int, int, int, const QPoint & ) ), |
260 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); | 260 | this, SLOT( slotPressed( int, int, int, const QPoint & ) ) ); |
261 | connect( this, SIGNAL( valueChanged( int, int ) ), | 261 | connect( this, SIGNAL( valueChanged( int, int ) ), |
262 | this, SLOT( slotCheckPriority( int, int ) ) ); | 262 | this, SLOT( slotCheckPriority( int, int ) ) ); |
263 | connect( this, SIGNAL( currentChanged( int, int ) ), | 263 | connect( this, SIGNAL( currentChanged( int, int ) ), |
264 | this, SLOT( slotCurrentChanged( int, int ) ) ); | 264 | this, SLOT( slotCurrentChanged( int, int ) ) ); |
265 | 265 | ||
266 | menuTimer = new QTimer( this ); | 266 | menuTimer = new QTimer( this ); |
267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); | 267 | connect( menuTimer, SIGNAL(timeout()), this, SLOT(slotShowMenu()) ); |
268 | 268 | ||
269 | mDayTimer = new QTimer( this ); | 269 | mDayTimer = new QTimer( this ); |
270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); | 270 | connect( mDayTimer, SIGNAL(timeout()), this, SLOT(slotCheckDay() ) ); |
271 | mDay = QDate::currentDate(); | 271 | mDay = QDate::currentDate(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void TodoTable::addEntry( const ToDoEvent &todo ) | 274 | void TodoTable::addEntry( const ToDoEvent &todo ) |
275 | { | 275 | { |
276 | int row = numRows(); | 276 | int row = numRows(); |
277 | setNumRows( row + 1 ); | 277 | setNumRows( row + 1 ); |
278 | updateJournal( todo, ACTION_ADD ); | 278 | updateJournal( todo, ACTION_ADD ); |
279 | insertIntoTable( new ToDoEvent(todo), row ); | 279 | insertIntoTable( new ToDoEvent(todo), row ); |
280 | setCurrentCell(row, currentColumn()); | 280 | setCurrentCell(row, currentColumn()); |
281 | updateVisible(); | 281 | updateVisible(); |
282 | } | 282 | } |
283 | 283 | ||
284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) | 284 | void TodoTable::slotClicked( int row, int col, int, const QPoint &pos ) |
285 | { | 285 | { |
286 | if ( !cellGeometry( row, col ).contains(pos) ) | 286 | if ( !cellGeometry( row, col ).contains(pos) ) |
287 | return; | 287 | return; |
288 | // let's switch on the column number... | 288 | // let's switch on the column number... |
289 | switch ( col ) | 289 | switch ( col ) |
290 | { | 290 | { |
291 | case 0: { | 291 | case 0: { |
292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); | 292 | CheckItem *i = static_cast<CheckItem*>(item( row, col )); |
293 | if ( i ) { | 293 | if ( i ) { |
294 | int x = pos.x() - columnPos( col ); | 294 | int x = pos.x() - columnPos( col ); |
295 | int y = pos.y() - rowPos( row ); | 295 | int y = pos.y() - rowPos( row ); |
296 | int w = columnWidth( col ); | 296 | int w = columnWidth( col ); |
297 | int h = rowHeight( row ); | 297 | int h = rowHeight( row ); |
298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && | 298 | if ( i && x >= ( w - BoxSize ) / 2 && x <= ( w - BoxSize ) / 2 + BoxSize && |
299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { | 299 | y >= ( h - BoxSize ) / 2 && y <= ( h - BoxSize ) / 2 + BoxSize ) { |
300 | i->toggle(); | 300 | i->toggle(); |
301 | } | 301 | } |
302 | emit signalDoneChanged( i->isChecked() ); | 302 | emit signalDoneChanged( i->isChecked() ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | break; | 305 | break; |
306 | case 1: | 306 | case 1: |
307 | break; | 307 | break; |
308 | case 2: | 308 | case 2: |
309 | // may as well edit it... | ||
310 | // menuTimer->stop(); | ||
311 | // emit signalEdit(); | ||
312 | // Show detailed view of the selected entry | 309 | // Show detailed view of the selected entry |
313 | { | 310 | { |
314 | menuTimer->stop(); | 311 | menuTimer->stop(); |
315 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; | 312 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(row, 0))]; |
316 | emit showDetails( *todo ); | 313 | emit showDetails( *todo ); |
317 | } | 314 | } |
318 | break; | 315 | break; |
319 | case 3: | 316 | case 3: |
320 | // may as well edit it... | 317 | // may as well edit it... |
321 | menuTimer->stop(); | 318 | menuTimer->stop(); |
322 | // emit signalEdit(); | 319 | emit signalEdit(); |
323 | break; | 320 | break; |
324 | } | 321 | } |
325 | } | 322 | } |
326 | 323 | ||
327 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) | 324 | void TodoTable::slotPressed( int row, int col, int, const QPoint &pos ) |
328 | { | 325 | { |
329 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) | 326 | if ( col == 2 && cellGeometry( row, col ).contains(pos) ) |
330 | menuTimer->start( 750, TRUE ); | 327 | menuTimer->start( 750, TRUE ); |
331 | } | 328 | } |
332 | 329 | ||
333 | void TodoTable::slotShowMenu() | 330 | void TodoTable::slotShowMenu() |
334 | { | 331 | { |
335 | emit signalShowMenu( QCursor::pos() ); | 332 | emit signalShowMenu( QCursor::pos() ); |
336 | } | 333 | } |
337 | 334 | ||
338 | void TodoTable::slotCurrentChanged( int, int ) | 335 | void TodoTable::slotCurrentChanged( int, int ) |
339 | { | 336 | { |
340 | menuTimer->stop(); | 337 | menuTimer->stop(); |
341 | } | 338 | } |
342 | 339 | ||
343 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) | 340 | void TodoTable::internalAddEntries( QList<ToDoEvent> &list ) |
344 | { | 341 | { |
345 | setNumRows( list.count() ); | 342 | setNumRows( list.count() ); |
346 | int row = 0; | 343 | int row = 0; |
347 | ToDoEvent *it; | 344 | ToDoEvent *it; |
348 | for ( it = list.first(); it; it = list.next() ) | 345 | for ( it = list.first(); it; it = list.next() ) |
349 | insertIntoTable( it, row++ ); | 346 | insertIntoTable( it, row++ ); |
350 | } | 347 | } |
351 | 348 | ||
352 | 349 | ||
353 | ToDoEvent TodoTable::currentEntry() const | 350 | ToDoEvent TodoTable::currentEntry() const |
354 | { | 351 | { |
355 | //qWarning ("in currentEntry\n"); | 352 | //qWarning ("in currentEntry\n"); |
356 | 353 | ||
357 | QTableItem *i = item( currentRow(), 0 ); | 354 | QTableItem *i = item( currentRow(), 0 ); |
358 | if ( !i || rowHeight( currentRow() ) <= 0 ) | 355 | if ( !i || rowHeight( currentRow() ) <= 0 ) |
359 | return ToDoEvent(); | 356 | return ToDoEvent(); |
360 | ToDoEvent *todo = todoList[(CheckItem*)i]; | 357 | ToDoEvent *todo = todoList[(CheckItem*)i]; |
361 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); | 358 | todo->setCompleted( ( (CheckItem*)item( currentRow(), 0 ) )->isChecked() ); |
362 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); | 359 | todo->setPriority( ( (ComboItem*)item( currentRow(), 1 ) )->text().toInt() ); |
363 | return *todo; | 360 | return *todo; |
364 | } | 361 | } |
365 | 362 | ||
366 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) | 363 | void TodoTable::replaceCurrentEntry( const ToDoEvent &todo, bool fromTableItem ) |
367 | { | 364 | { |
368 | int row = currentRow(); | 365 | int row = currentRow(); |
369 | updateJournal( todo, ACTION_REPLACE); | 366 | updateJournal( todo, ACTION_REPLACE); |
370 | 367 | ||
371 | if ( !fromTableItem ) { | 368 | if ( !fromTableItem ) { |
372 | journalFreeReplaceEntry( todo, row ); | 369 | journalFreeReplaceEntry( todo, row ); |
373 | updateVisible(); | 370 | updateVisible(); |
374 | } | 371 | } |
375 | } | 372 | } |
376 | 373 | ||
377 | void TodoTable::removeCurrentEntry() | 374 | void TodoTable::removeCurrentEntry() |
378 | { | 375 | { |
379 | ToDoEvent *oldTodo; | 376 | ToDoEvent *oldTodo; |
380 | int row = currentRow(); | 377 | int row = currentRow(); |
381 | CheckItem *chk; | 378 | CheckItem *chk; |
382 | 379 | ||
383 | chk = static_cast<CheckItem*>(item(row, 0 )); | 380 | chk = static_cast<CheckItem*>(item(row, 0 )); |
384 | if ( !chk ) | 381 | if ( !chk ) |
385 | return; | 382 | return; |
386 | oldTodo = todoList[chk]; | 383 | oldTodo = todoList[chk]; |
387 | todoList.remove( chk ); | 384 | todoList.remove( chk ); |
388 | oldTodo->setCompleted( chk->isChecked() ); | 385 | oldTodo->setCompleted( chk->isChecked() ); |
389 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); | 386 | oldTodo->setPriority( static_cast<ComboItem*>(item(row, 1))->text().toInt() ); |
390 | realignTable( row ); | 387 | realignTable( row ); |
391 | updateVisible(); | 388 | updateVisible(); |
392 | updateJournal( *oldTodo, ACTION_REMOVE); | 389 | updateJournal( *oldTodo, ACTION_REMOVE); |
393 | delete oldTodo; | 390 | delete oldTodo; |
394 | } | 391 | } |
395 | 392 | ||
396 | 393 | ||
397 | bool TodoTable::save( const QString &fn ) | 394 | bool TodoTable::save( const QString &fn ) |
398 | { | 395 | { |
399 | QString strNewFile = fn + ".new"; | 396 | QString strNewFile = fn + ".new"; |
400 | QFile::remove( strNewFile ); // just to be sure | 397 | QFile::remove( strNewFile ); // just to be sure |
401 | ToDoDB todoDB( strNewFile ); | 398 | ToDoDB todoDB( strNewFile ); |
402 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); | 399 | for ( QMap<CheckItem*, ToDoEvent *>::Iterator it = todoList.begin(); |
403 | it != todoList.end(); ++it ) { | 400 | it != todoList.end(); ++it ) { |
404 | if ( !item( it.key()->row(), 0 ) ) | 401 | if ( !item( it.key()->row(), 0 ) ) |
405 | continue; | 402 | continue; |
406 | ToDoEvent *todo = *it; | 403 | ToDoEvent *todo = *it; |
407 | // sync item with table | 404 | // sync item with table |
408 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); | 405 | todo->setCompleted( ((CheckItem*)item(it.key()->row(), 0))->isChecked() ); |
409 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); | 406 | todo->setPriority( ((ComboItem*)item( it.key()->row(), 1))->text().toInt() ); |
410 | todoDB.addEvent( *todo ); | 407 | todoDB.addEvent( *todo ); |
411 | } | 408 | } |
412 | if(!todoDB.save() ){ | 409 | if(!todoDB.save() ){ |
413 | QFile::remove( strNewFile ); | 410 | QFile::remove( strNewFile ); |
414 | return false; | 411 | return false; |
415 | }; | 412 | }; |
416 | // now do the rename | 413 | // now do the rename |
417 | if ( ::rename( strNewFile, fn ) < 0 ) | 414 | if ( ::rename( strNewFile, fn ) < 0 ) |
418 | qWarning( "problem renaming file %s to %s errno %d", | 415 | qWarning( "problem renaming file %s to %s errno %d", |
@@ -566,213 +563,219 @@ void TodoTable::updateJournal( const ToDoEvent &todo, journal_action action ) | |||
566 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; | 563 | buf += " Completed=\""+ QString::number((int)todo.isCompleted() ) + "\""; |
567 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; | 564 | buf += " HasDate=\""+ QString::number((int)todo.hasDate() ) +"\""; |
568 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; | 565 | buf += " Priority=\"" + QString::number( todo.priority() ) + "\""; |
569 | QArray<int> arrat = todo.categories(); | 566 | QArray<int> arrat = todo.categories(); |
570 | QString attr; | 567 | QString attr; |
571 | for(uint i=0; i < arrat.count(); i++ ){ | 568 | for(uint i=0; i < arrat.count(); i++ ){ |
572 | attr.append(QString::number(arrat[i])+";" ); | 569 | attr.append(QString::number(arrat[i])+";" ); |
573 | } | 570 | } |
574 | if(!attr.isEmpty() ) // remove the last ; | 571 | if(!attr.isEmpty() ) // remove the last ; |
575 | attr.remove(attr.length()-1, 1 ); | 572 | attr.remove(attr.length()-1, 1 ); |
576 | buf += " Categories=\"" + attr + "\""; | 573 | buf += " Categories=\"" + attr + "\""; |
577 | buf += " Description=\"" + todo.description() + "\""; | 574 | buf += " Description=\"" + todo.description() + "\""; |
578 | if(todo.hasDate() ) { | 575 | if(todo.hasDate() ) { |
579 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; | 576 | buf += " DateYear=\""+QString::number( todo.date().year() ) + "\""; |
580 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; | 577 | buf += " DateMonth=\"" + QString::number( todo.date().month() ) + "\""; |
581 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; | 578 | buf += " DateDay=\"" + QString::number( todo.date().day() ) + "\""; |
582 | } | 579 | } |
583 | buf += "/>\n"; | 580 | buf += "/>\n"; |
584 | str = buf.utf8(); | 581 | str = buf.utf8(); |
585 | f.writeBlock( str.data(), str.length() ); | 582 | f.writeBlock( str.data(), str.length() ); |
586 | f.close(); | 583 | f.close(); |
587 | } | 584 | } |
588 | 585 | ||
589 | void TodoTable::rowHeightChanged( int row ) | 586 | void TodoTable::rowHeightChanged( int row ) |
590 | { | 587 | { |
591 | if ( enablePainting ) | 588 | if ( enablePainting ) |
592 | QTable::rowHeightChanged( row ); | 589 | QTable::rowHeightChanged( row ); |
593 | } | 590 | } |
594 | 591 | ||
595 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) | 592 | void TodoTable::loadFile( const QString &/*we use the standard*/ ) |
596 | { | 593 | { |
597 | 594 | ||
598 | QList<ToDoEvent> list; | 595 | QList<ToDoEvent> list; |
599 | ToDoDB todoDB; | 596 | ToDoDB todoDB; |
600 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); | 597 | QValueList<ToDoEvent> vaList = todoDB.rawToDos(); |
601 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ | 598 | for(QValueList<ToDoEvent>::ConstIterator it = vaList.begin(); it != vaList.end(); ++it ){ |
602 | ToDoEvent *event = new ToDoEvent( (*it) ); | 599 | ToDoEvent *event = new ToDoEvent( (*it) ); |
603 | list.append( event ); | 600 | list.append( event ); |
604 | } | 601 | } |
605 | vaList.clear(); | 602 | vaList.clear(); |
606 | // qDebug("parsing done=%d", t.elapsed() ); | 603 | // qDebug("parsing done=%d", t.elapsed() ); |
607 | if ( list.count() > 0 ) { | 604 | if ( list.count() > 0 ) { |
608 | internalAddEntries( list ); | 605 | internalAddEntries( list ); |
609 | list.clear(); | 606 | list.clear(); |
610 | } | 607 | } |
611 | // qDebug("loading done: t=%d", t.elapsed() ); | 608 | // qDebug("loading done: t=%d", t.elapsed() ); |
612 | } | 609 | } |
613 | 610 | ||
614 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) | 611 | void TodoTable::journalFreeReplaceEntry( const ToDoEvent &todo, int row ) |
615 | { | 612 | { |
616 | QString strTodo; | 613 | QString strTodo; |
617 | strTodo = todo.description().left(40).simplifyWhiteSpace(); | 614 | strTodo = todo.description().left(40).simplifyWhiteSpace(); |
618 | if ( row == -1 ) { | 615 | if ( row == -1 ) { |
619 | QMapIterator<CheckItem*, ToDoEvent *> it; | 616 | QMapIterator<CheckItem*, ToDoEvent *> it; |
620 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { | 617 | for ( it = todoList.begin(); it != todoList.end(); ++it ) { |
621 | if ( *(*it) == todo ) { | 618 | if ( *(*it) == todo ) { |
622 | row = it.key()->row(); | 619 | row = it.key()->row(); |
623 | it.key()->setChecked( todo.isCompleted() ); | 620 | it.key()->setChecked( todo.isCompleted() ); |
624 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 621 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
625 | item( row, 2 )->setText( strTodo ); | 622 | item( row, 2 )->setText( strTodo ); |
626 | 623 | ||
627 | if (showDeadl){ | 624 | if (showDeadl){ |
628 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 625 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
629 | } | 626 | } |
630 | 627 | ||
631 | *(*it) = todo; | 628 | *(*it) = todo; |
632 | } | 629 | } |
633 | } | 630 | } |
634 | } else { | 631 | } else { |
635 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; | 632 | ToDoEvent *t = todoList[static_cast<CheckItem*>(item(row, 0))]; |
636 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); | 633 | todoList.remove( static_cast<CheckItem*>(item(row, 0)) ); |
637 | delete t; | 634 | delete t; |
638 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); | 635 | static_cast<CheckItem*>(item(row, 0))->setChecked( todo.isCompleted() ); |
639 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); | 636 | static_cast<ComboItem*>(item(row, 1))->setText( QString::number(todo.priority()) ); |
640 | item( row, 2 )->setText( strTodo ); | 637 | item( row, 2 )->setText( strTodo ); |
641 | 638 | ||
642 | if (showDeadl){ | 639 | if (showDeadl){ |
643 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); | 640 | static_cast<DueTextItem*>(item(row,3))->setToDoEvent(&todo ); |
644 | } | 641 | } |
645 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); | 642 | todoList.insert( static_cast<CheckItem*>(item(row,0)), new ToDoEvent(todo) ); |
646 | } | 643 | } |
647 | } | 644 | } |
648 | 645 | ||
649 | void TodoTable::journalFreeRemoveEntry( int row ) | 646 | void TodoTable::journalFreeRemoveEntry( int row ) |
650 | { | 647 | { |
651 | CheckItem *chk; | 648 | CheckItem *chk; |
652 | chk = static_cast<CheckItem*>(item(row, 0 )); | 649 | chk = static_cast<CheckItem*>(item(row, 0 )); |
653 | if ( !chk ) | 650 | if ( !chk ) |
654 | return; | 651 | return; |
655 | todoList.remove( chk ); | 652 | todoList.remove( chk ); |
656 | 653 | ||
657 | realignTable( row ); | 654 | realignTable( row ); |
658 | } | 655 | } |
659 | 656 | ||
660 | void TodoTable::keyPressEvent( QKeyEvent *e ) | 657 | void TodoTable::keyPressEvent( QKeyEvent *e ) |
661 | { | 658 | { |
662 | if ( e->key() == Key_Space || e->key() == Key_Return ) { | 659 | if ( e->key() == Key_Space || e->key() == Key_Return ) { |
663 | switch ( currentColumn() ) { | 660 | switch ( currentColumn() ) { |
664 | case 0: { | 661 | case 0: { |
665 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), | 662 | CheckItem *i = static_cast<CheckItem*>(item(currentRow(), |
666 | currentColumn())); | 663 | currentColumn())); |
667 | if ( i ) | 664 | if ( i ) |
668 | i->toggle(); | 665 | i->toggle(); |
669 | break; | 666 | break; |
670 | } | 667 | } |
671 | case 1: | 668 | case 1: |
672 | break; | 669 | break; |
673 | case 2: | 670 | case 2:{ |
674 | emit signalEdit(); | 671 | ToDoEvent *todo = todoList[static_cast<CheckItem*>(item(currentRow(), 0))]; |
675 | default: | 672 | emit showDetails(*todo); |
676 | break; | 673 | break; |
677 | } | 674 | } |
678 | } else { | 675 | case 3: |
679 | QTable::keyPressEvent( e ); | 676 | // Future: Let us change the dueDate directly... |
680 | } | 677 | emit signalEdit(); |
678 | default: | ||
679 | break; | ||
680 | } | ||
681 | } else | ||
682 | QTable::keyPressEvent( e ); | ||
681 | } | 683 | } |
682 | 684 | ||
685 | |||
683 | QStringList TodoTable::categories() | 686 | QStringList TodoTable::categories() |
684 | { | 687 | { |
685 | // This is called seldom, so calling a load in here | 688 | // This is called seldom, so calling a load in here |
686 | // should be fine. | 689 | // should be fine. |
687 | mCat.load( categoryFileName() ); | 690 | mCat.load( categoryFileName() ); |
688 | QStringList categoryList = mCat.labels( "Todo List" ); | 691 | QStringList categoryList = mCat.labels( "Todo List" ); |
689 | return categoryList; | 692 | return categoryList; |
690 | } | 693 | } |
691 | 694 | ||
692 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, | 695 | void TodoTable::slotDoFind( const QString &findString, bool caseSensitive, |
693 | bool backwards, int category ) | 696 | bool backwards, int category ) |
694 | { | 697 | { |
695 | // we have to iterate through the table, this gives the illusion that | 698 | // we have to iterate through the table, this gives the illusion that |
696 | // sorting is actually being used. | 699 | // sorting is actually being used. |
697 | if ( currFindRow < -1 ) | 700 | if ( currFindRow < -1 ) |
698 | currFindRow = currentRow() - 1; | 701 | currFindRow = currentRow() - 1; |
699 | clearSelection( TRUE ); | 702 | clearSelection( TRUE ); |
700 | int rows, | 703 | int rows, |
701 | row; | 704 | row; |
702 | CheckItem *chk; | 705 | CheckItem *chk; |
703 | QRegExp r( findString ); | 706 | QRegExp r( findString ); |
704 | 707 | ||
705 | r.setCaseSensitive( caseSensitive ); | 708 | r.setCaseSensitive( caseSensitive ); |
706 | rows = numRows(); | 709 | rows = numRows(); |
707 | static bool wrapAround = true; | 710 | static bool wrapAround = true; |
708 | 711 | ||
709 | if ( !backwards ) { | 712 | if ( !backwards ) { |
710 | for ( row = currFindRow + 1; row < rows; row++ ) { | 713 | for ( row = currFindRow + 1; row < rows; row++ ) { |
711 | chk = static_cast<CheckItem*>( item(row, 0) ); | 714 | chk = static_cast<CheckItem*>( item(row, 0) ); |
712 | if ( taskCompare(*(todoList[chk]), r, category) ) | 715 | if ( taskCompare(*(todoList[chk]), r, category) ) |
713 | break; | 716 | break; |
714 | } | 717 | } |
715 | } else { | 718 | } else { |
716 | for ( row = currFindRow - 1; row > -1; row-- ) { | 719 | for ( row = currFindRow - 1; row > -1; row-- ) { |
717 | chk = static_cast<CheckItem*>( item(row, 0) ); | 720 | chk = static_cast<CheckItem*>( item(row, 0) ); |
718 | if ( taskCompare(*(todoList[chk]), r, category) ) | 721 | if ( taskCompare(*(todoList[chk]), r, category) ) |
719 | break; | 722 | break; |
720 | } | 723 | } |
721 | } | 724 | } |
722 | if ( row >= rows || row < 0 ) { | 725 | if ( row >= rows || row < 0 ) { |
723 | if ( row < 0 ) | 726 | if ( row < 0 ) |
724 | currFindRow = rows; | 727 | currFindRow = rows; |
725 | else | 728 | else |
726 | currFindRow = -1; | 729 | currFindRow = -1; |
727 | if ( wrapAround ) | 730 | if ( wrapAround ) |
728 | emit signalWrapAround(); | 731 | emit signalWrapAround(); |
729 | else | 732 | else |
730 | emit signalNotFound(); | 733 | emit signalNotFound(); |
731 | wrapAround = !wrapAround; | 734 | wrapAround = !wrapAround; |
732 | } else { | 735 | } else { |
733 | currFindRow = row; | 736 | currFindRow = row; |
734 | QTableSelection foundSelection; | 737 | QTableSelection foundSelection; |
735 | foundSelection.init( currFindRow, 0 ); | 738 | foundSelection.init( currFindRow, 0 ); |
736 | foundSelection.expandTo( currFindRow, numCols() - 1 ); | 739 | foundSelection.expandTo( currFindRow, numCols() - 1 ); |
737 | addSelection( foundSelection ); | 740 | addSelection( foundSelection ); |
738 | setCurrentCell( currFindRow, numCols() - 1 ); | 741 | setCurrentCell( currFindRow, numCols() - 1 ); |
739 | // we should always be able to wrap around and find this again, | 742 | // we should always be able to wrap around and find this again, |
740 | // so don't give confusing not found message... | 743 | // so don't give confusing not found message... |
741 | wrapAround = true; | 744 | wrapAround = true; |
742 | } | 745 | } |
743 | } | 746 | } |
744 | 747 | ||
745 | int TodoTable::showCategoryId() const | 748 | int TodoTable::showCategoryId() const |
746 | { | 749 | { |
747 | int id; | 750 | int id; |
748 | id = -1; | 751 | id = -1; |
749 | // if allcategories are selected, you get unfiled... | 752 | // if allcategories are selected, you get unfiled... |
750 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) | 753 | if ( showCat != tr( "Unfiled" ) && showCat != tr( "All" ) ) |
751 | id = mCat.id( "Todo List", showCat ); | 754 | id = mCat.id( "Todo List", showCat ); |
752 | return id; | 755 | return id; |
753 | } | 756 | } |
754 | void TodoTable::applyJournal() | 757 | void TodoTable::applyJournal() |
755 | { | 758 | { |
756 | // we need to hack | 759 | // we need to hack |
757 | QFile file( journalFileName() ); | 760 | QFile file( journalFileName() ); |
758 | if( file.open(IO_ReadOnly ) ) { | 761 | if( file.open(IO_ReadOnly ) ) { |
759 | QByteArray ar = file.readAll(); | 762 | QByteArray ar = file.readAll(); |
760 | file.close(); | 763 | file.close(); |
761 | QFile file2( journalFileName() + "_new" ); | 764 | QFile file2( journalFileName() + "_new" ); |
762 | if( file2.open(IO_WriteOnly ) ){ | 765 | if( file2.open(IO_WriteOnly ) ){ |
763 | QTextStream str(&file2 ); | 766 | QTextStream str(&file2 ); |
764 | str << QString::fromLatin1("<Tasks>") << endl; | 767 | str << QString::fromLatin1("<Tasks>") << endl; |
765 | str << ar.data(); | 768 | str << ar.data(); |
766 | str << QString::fromLatin1("</Tasks>") << endl; | 769 | str << QString::fromLatin1("</Tasks>") << endl; |
767 | file2.close(); | 770 | file2.close(); |
768 | } | 771 | } |
769 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); | 772 | XMLElement *root = XMLElement::load(journalFileName()+ "_new"); |
770 | XMLElement *el = root->firstChild(); | 773 | XMLElement *el = root->firstChild(); |
771 | el = el->firstChild(); | 774 | el = el->firstChild(); |
772 | ToDoDB tododb; // allready loaded ;) | 775 | ToDoDB tododb; // allready loaded ;) |
773 | bool ok; | 776 | bool ok; |
774 | int action; | 777 | int action; |
775 | QString dummy; | 778 | QString dummy; |
776 | while( el ){ | 779 | while( el ){ |
777 | dummy = el->attribute("Action" ); | 780 | dummy = el->attribute("Action" ); |
778 | action = dummy.toInt(&ok ); | 781 | action = dummy.toInt(&ok ); |