-rw-r--r-- | core/pim/todo/tableview.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp index d980a24..5bbf880 100644 --- a/core/pim/todo/tableview.cpp +++ b/core/pim/todo/tableview.cpp | |||
@@ -16,49 +16,49 @@ | |||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <cmath> | 29 | #include <cmath> |
30 | #include <cctype> | 30 | #include <cctype> |
31 | 31 | ||
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | 36 | ||
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <opie/orecur.h> | 40 | #include <opie2/opimrecurrence.h> |
41 | 41 | ||
42 | #include "mainwindow.h" | 42 | #include "mainwindow.h" |
43 | //#include "tableitems.h" | 43 | //#include "tableitems.h" |
44 | #include "tableview.h" | 44 | #include "tableview.h" |
45 | 45 | ||
46 | using namespace Todo; | 46 | using namespace Todo; |
47 | 47 | ||
48 | namespace { | 48 | namespace { |
49 | static const int BoxSize = 14; | 49 | static const int BoxSize = 14; |
50 | static const int RowHeight = 20; | 50 | static const int RowHeight = 20; |
51 | } | 51 | } |
52 | 52 | ||
53 | TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { | 53 | TableView::EditorWidget::EditorWidget() : m_wid(0l), m_row(-1), m_col(-1) { |
54 | } | 54 | } |
55 | void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { | 55 | void TableView::EditorWidget::setCellWidget(QWidget* wid, int row, int col ) { |
56 | m_wid = wid; | 56 | m_wid = wid; |
57 | m_row = row; | 57 | m_row = row; |
58 | m_col = col; | 58 | m_col = col; |
59 | } | 59 | } |
60 | void TableView::EditorWidget::releaseCellWidget() { | 60 | void TableView::EditorWidget::releaseCellWidget() { |
61 | m_wid = 0; | 61 | m_wid = 0; |
62 | m_row = m_col = -1; | 62 | m_row = m_col = -1; |
63 | } | 63 | } |
64 | QWidget* TableView::EditorWidget::cellWidget()const { | 64 | QWidget* TableView::EditorWidget::cellWidget()const { |
@@ -163,107 +163,107 @@ void TableView::slotShowMenu() { | |||
163 | } | 163 | } |
164 | QString TableView::type() const { | 164 | QString TableView::type() const { |
165 | return QString::fromLatin1( tr("Table View") ); | 165 | return QString::fromLatin1( tr("Table View") ); |
166 | } | 166 | } |
167 | int TableView::current() { | 167 | int TableView::current() { |
168 | if (numRows() == 0 ) return 0; | 168 | if (numRows() == 0 ) return 0; |
169 | int uid = sorted().uidAt(currentRow() ); | 169 | int uid = sorted().uidAt(currentRow() ); |
170 | 170 | ||
171 | return uid; | 171 | return uid; |
172 | } | 172 | } |
173 | int TableView::next() { | 173 | int TableView::next() { |
174 | if ( numRows() == 0 ) return 0; | 174 | if ( numRows() == 0 ) return 0; |
175 | if ( currentRow() + 1 >= numRows() ) return 0; | 175 | if ( currentRow() + 1 >= numRows() ) return 0; |
176 | setCurrentCell( currentRow() +1, currentColumn() ); | 176 | setCurrentCell( currentRow() +1, currentColumn() ); |
177 | return sorted().uidAt( currentRow() ); | 177 | return sorted().uidAt( currentRow() ); |
178 | } | 178 | } |
179 | int TableView::prev() { | 179 | int TableView::prev() { |
180 | if ( numRows() == 0 ) return 0; | 180 | if ( numRows() == 0 ) return 0; |
181 | if ( currentRow() - 1 < 0 ) return 0; | 181 | if ( currentRow() - 1 < 0 ) return 0; |
182 | setCurrentCell( currentRow() -1, currentColumn() ); | 182 | setCurrentCell( currentRow() -1, currentColumn() ); |
183 | return sorted().uidAt( currentRow() ); | 183 | return sorted().uidAt( currentRow() ); |
184 | 184 | ||
185 | } | 185 | } |
186 | QString TableView::currentRepresentation() { | 186 | QString TableView::currentRepresentation() { |
187 | OTodo to = sorted()[currentRow()]; | 187 | OPimTodo to = sorted()[currentRow()]; |
188 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; | 188 | return to.summary().isEmpty() ? to.description().left(20) : to.summary() ; |
189 | } | 189 | } |
190 | /* show overdue */ | 190 | /* show overdue */ |
191 | void TableView::showOverDue( bool ) { | 191 | void TableView::showOverDue( bool ) { |
192 | clear(); | 192 | clear(); |
193 | updateView(); | 193 | updateView(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void TableView::updateView( ) { | 196 | void TableView::updateView( ) { |
197 | qWarning("update view"); | 197 | qWarning("update view"); |
198 | m_row = false; | 198 | m_row = false; |
199 | static int id; | 199 | static int id; |
200 | id = startTimer(4000 ); | 200 | id = startTimer(4000 ); |
201 | /* FIXME we want one page to be read! | 201 | /* FIXME we want one page to be read! |
202 | * | 202 | * |
203 | * Calculate that screensize | 203 | * Calculate that screensize |
204 | */ | 204 | */ |
205 | todoWindow()->setReadAhead( 4 ); | 205 | todoWindow()->setReadAhead( 4 ); |
206 | sort(); | 206 | sort(); |
207 | OTodoAccess::List::Iterator it, end; | 207 | OPimTodoAccess::List::Iterator it, end; |
208 | it = sorted().begin(); | 208 | it = sorted().begin(); |
209 | end = sorted().end(); | 209 | end = sorted().end(); |
210 | 210 | ||
211 | qWarning("setTodos"); | 211 | qWarning("setTodos"); |
212 | QTime time; | 212 | QTime time; |
213 | time.start(); | 213 | time.start(); |
214 | m_enablePaint = false; | 214 | m_enablePaint = false; |
215 | setUpdatesEnabled( false ); | 215 | setUpdatesEnabled( false ); |
216 | viewport()->setUpdatesEnabled( false ); | 216 | viewport()->setUpdatesEnabled( false ); |
217 | 217 | ||
218 | setNumRows( it.count() ); | 218 | setNumRows( it.count() ); |
219 | if ( it.count() == 0 ) | 219 | if ( it.count() == 0 ) |
220 | killTimer(id); | 220 | killTimer(id); |
221 | 221 | ||
222 | // int elc = time.elapsed(); | 222 | // int elc = time.elapsed(); |
223 | setUpdatesEnabled( true ); | 223 | setUpdatesEnabled( true ); |
224 | viewport()->setUpdatesEnabled( true ); | 224 | viewport()->setUpdatesEnabled( true ); |
225 | viewport()->update(); | 225 | viewport()->update(); |
226 | 226 | ||
227 | m_enablePaint = true; | 227 | m_enablePaint = true; |
228 | // int el = time.elapsed(); | 228 | // int el = time.elapsed(); |
229 | } | 229 | } |
230 | void TableView::setTodo( int, const OTodo&) { | 230 | void TableView::setTodo( int, const OPimTodo&) { |
231 | sort(); | 231 | sort(); |
232 | 232 | ||
233 | /* repaint */ | 233 | /* repaint */ |
234 | repaint(); | 234 | repaint(); |
235 | } | 235 | } |
236 | void TableView::addEvent( const OTodo&) { | 236 | void TableView::addEvent( const OPimTodo&) { |
237 | 237 | ||
238 | /* fix problems of not showing the 'Haken' */ | 238 | /* fix problems of not showing the 'Haken' */ |
239 | updateView(); | 239 | updateView(); |
240 | } | 240 | } |
241 | /* | 241 | /* |
242 | * find the event | 242 | * find the event |
243 | * and then replace the complete row | 243 | * and then replace the complete row |
244 | */ | 244 | */ |
245 | void TableView::replaceEvent( const OTodo& ev) { | 245 | void TableView::replaceEvent( const OPimTodo& ev) { |
246 | addEvent( ev ); | 246 | addEvent( ev ); |
247 | } | 247 | } |
248 | /* | 248 | /* |
249 | * re aligning table can be slow too | 249 | * re aligning table can be slow too |
250 | * FIXME: look what performs better | 250 | * FIXME: look what performs better |
251 | * either this or the old align table | 251 | * either this or the old align table |
252 | */ | 252 | */ |
253 | void TableView::removeEvent( int ) { | 253 | void TableView::removeEvent( int ) { |
254 | updateView(); | 254 | updateView(); |
255 | } | 255 | } |
256 | void TableView::setShowCompleted( bool b) { | 256 | void TableView::setShowCompleted( bool b) { |
257 | qWarning("Show Completed %d" , b ); | 257 | qWarning("Show Completed %d" , b ); |
258 | updateView(); | 258 | updateView(); |
259 | } | 259 | } |
260 | void TableView::setShowDeadline( bool b ) { | 260 | void TableView::setShowDeadline( bool b ) { |
261 | qWarning( "Show DeadLine %d" , b ); | 261 | qWarning( "Show DeadLine %d" , b ); |
262 | if ( b ) | 262 | if ( b ) |
263 | showColumn( 3 ); | 263 | showColumn( 3 ); |
264 | else | 264 | else |
265 | hideColumn( 3 ); | 265 | hideColumn( 3 ); |
266 | 266 | ||
267 | // Try to intelligently size columns | 267 | // Try to intelligently size columns |
268 | // TODO - would use width() below, but doesn't have valid value at time of c'tor | 268 | // TODO - would use width() below, but doesn't have valid value at time of c'tor |
269 | int col2width = 238; | 269 | int col2width = 238; |
@@ -367,49 +367,49 @@ QWidget* TableView::widget() { | |||
367 | * based | 367 | * based |
368 | * We event want to set the setOrder | 368 | * We event want to set the setOrder |
369 | * to a sort() and update() | 369 | * to a sort() and update() |
370 | */ | 370 | */ |
371 | void TableView::sortColumn( int col, bool asc, bool ) { | 371 | void TableView::sortColumn( int col, bool asc, bool ) { |
372 | qWarning("bool %d", asc ); | 372 | qWarning("bool %d", asc ); |
373 | setSortOrder( col ); | 373 | setSortOrder( col ); |
374 | setAscending( asc ); | 374 | setAscending( asc ); |
375 | updateView(); | 375 | updateView(); |
376 | } | 376 | } |
377 | void TableView::viewportPaintEvent( QPaintEvent* e) { | 377 | void TableView::viewportPaintEvent( QPaintEvent* e) { |
378 | if (m_enablePaint ) | 378 | if (m_enablePaint ) |
379 | QTable::viewportPaintEvent( e ); | 379 | QTable::viewportPaintEvent( e ); |
380 | } | 380 | } |
381 | /* | 381 | /* |
382 | * This segment is copyrighted by TT | 382 | * This segment is copyrighted by TT |
383 | * it was taken from their todolist | 383 | * it was taken from their todolist |
384 | * application this code is GPL | 384 | * application this code is GPL |
385 | */ | 385 | */ |
386 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { | 386 | void TableView::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) { |
387 | const QColorGroup &cg = colorGroup(); | 387 | const QColorGroup &cg = colorGroup(); |
388 | 388 | ||
389 | p->save(); | 389 | p->save(); |
390 | 390 | ||
391 | OTodo task = sorted()[row]; | 391 | OPimTodo task = sorted()[row]; |
392 | 392 | ||
393 | // TODO - give user option for grid or bars? | 393 | // TODO - give user option for grid or bars? |
394 | 394 | ||
395 | // Paint alternating background bars | 395 | // Paint alternating background bars |
396 | if ( (row % 2 ) == 0 ) { | 396 | if ( (row % 2 ) == 0 ) { |
397 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 397 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
398 | p->setPen( QPen( cg.text() ) ); | 398 | p->setPen( QPen( cg.text() ) ); |
399 | } | 399 | } |
400 | else { | 400 | else { |
401 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); | 401 | p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) ); |
402 | p->setPen( QPen( cg.buttonText() ) ); | 402 | p->setPen( QPen( cg.buttonText() ) ); |
403 | } | 403 | } |
404 | 404 | ||
405 | // Paint grid | 405 | // Paint grid |
406 | //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); | 406 | //p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) ); |
407 | //QPen op = p->pen(); | 407 | //QPen op = p->pen(); |
408 | //p->setPen(cg.mid()); | 408 | //p->setPen(cg.mid()); |
409 | //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); | 409 | //p->drawLine( 0, cr.height() - 1, cr.width() - 1, cr.height() - 1 ); |
410 | //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); | 410 | //p->drawLine( cr.width() - 1, 0, cr.width() - 1, cr.height() - 1 ); |
411 | //p->setPen(op); | 411 | //p->setPen(op); |
412 | 412 | ||
413 | QFont f = p->font(); | 413 | QFont f = p->font(); |
414 | QFontMetrics fm(f); | 414 | QFontMetrics fm(f); |
415 | 415 | ||
@@ -476,60 +476,60 @@ QWidget* TableView::createEditor(int row, int col, bool )const { | |||
476 | QComboBox* combo = new QComboBox( viewport() ); | 476 | QComboBox* combo = new QComboBox( viewport() ); |
477 | for ( int i = 0; i < 5; i++ ) { | 477 | for ( int i = 0; i < 5; i++ ) { |
478 | combo->insertItem( m_pic_priority[ i ] ); | 478 | combo->insertItem( m_pic_priority[ i ] ); |
479 | } | 479 | } |
480 | combo->setCurrentItem( sorted()[row].priority()-1 ); | 480 | combo->setCurrentItem( sorted()[row].priority()-1 ); |
481 | return combo; | 481 | return combo; |
482 | } | 482 | } |
483 | /* summary */ | 483 | /* summary */ |
484 | case 2:{ | 484 | case 2:{ |
485 | QLineEdit* edit = new QLineEdit( viewport() ); | 485 | QLineEdit* edit = new QLineEdit( viewport() ); |
486 | edit->setText( sorted()[row].summary() ); | 486 | edit->setText( sorted()[row].summary() ); |
487 | return edit; | 487 | return edit; |
488 | } | 488 | } |
489 | case 0: | 489 | case 0: |
490 | default: | 490 | default: |
491 | return 0l; | 491 | return 0l; |
492 | } | 492 | } |
493 | } | 493 | } |
494 | void TableView::setCellContentFromEditor(int row, int col ) { | 494 | void TableView::setCellContentFromEditor(int row, int col ) { |
495 | qWarning("set cell content from editor"); | 495 | qWarning("set cell content from editor"); |
496 | if ( col == 1 ) { | 496 | if ( col == 1 ) { |
497 | QWidget* wid = cellWidget(row, 1 ); | 497 | QWidget* wid = cellWidget(row, 1 ); |
498 | if ( wid->inherits("QComboBox") ) { | 498 | if ( wid->inherits("QComboBox") ) { |
499 | int pri = ((QComboBox*)wid)->currentItem() + 1; | 499 | int pri = ((QComboBox*)wid)->currentItem() + 1; |
500 | OTodo todo = sorted()[row]; | 500 | OPimTodo todo = sorted()[row]; |
501 | if ( todo.priority() != pri ) { | 501 | if ( todo.priority() != pri ) { |
502 | todo.setPriority( pri ); | 502 | todo.setPriority( pri ); |
503 | TodoView::update( todo.uid(), todo ); | 503 | TodoView::update( todo.uid(), todo ); |
504 | updateView(); | 504 | updateView(); |
505 | } | 505 | } |
506 | } | 506 | } |
507 | }else if ( col == 2) { | 507 | }else if ( col == 2) { |
508 | QWidget* wid = cellWidget(row, 2); | 508 | QWidget* wid = cellWidget(row, 2); |
509 | if ( wid->inherits("QLineEdit") ) { | 509 | if ( wid->inherits("QLineEdit") ) { |
510 | QString text = ((QLineEdit*)wid)->text(); | 510 | QString text = ((QLineEdit*)wid)->text(); |
511 | OTodo todo = sorted()[row]; | 511 | OPimTodo todo = sorted()[row]; |
512 | if ( todo.summary() != text ) { | 512 | if ( todo.summary() != text ) { |
513 | todo.setSummary( text ); | 513 | todo.setSummary( text ); |
514 | TodoView::update( todo.uid(), todo ); | 514 | TodoView::update( todo.uid(), todo ); |
515 | updateView(); | 515 | updateView(); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | } | 518 | } |
519 | } | 519 | } |
520 | void TableView::slotPriority() { | 520 | void TableView::slotPriority() { |
521 | setCellContentFromEditor( currentRow(), currentColumn() ); | 521 | setCellContentFromEditor( currentRow(), currentColumn() ); |
522 | } | 522 | } |
523 | /* | 523 | /* |
524 | * We'll use the TimerEvent to read ahead or to keep the cahce always | 524 | * We'll use the TimerEvent to read ahead or to keep the cahce always |
525 | * filled enough. | 525 | * filled enough. |
526 | * We will try to read ahead 4 items in both ways | 526 | * We will try to read ahead 4 items in both ways |
527 | * up and down. On odd or even we will currentRow()+-4 or +-9 | 527 | * up and down. On odd or even we will currentRow()+-4 or +-9 |
528 | * | 528 | * |
529 | */ | 529 | */ |
530 | void TableView::timerEvent( QTimerEvent* ) { | 530 | void TableView::timerEvent( QTimerEvent* ) { |
531 | // qWarning("sorted %d", sorted().count() ); | 531 | // qWarning("sorted %d", sorted().count() ); |
532 | if (sorted().count() == 0 ) | 532 | if (sorted().count() == 0 ) |
533 | return; | 533 | return; |
534 | 534 | ||
535 | int row = currentRow(); | 535 | int row = currentRow(); |