summaryrefslogtreecommitdiff
authorzecke <zecke>2004-11-18 21:55:17 (UTC)
committer zecke <zecke>2004-11-18 21:55:17 (UTC)
commitfdef8103e849b674c95d01785259e072bcfb5a4b (patch) (unidiff)
tree411432edf236f8858094598617383dea95c14c3a
parentc94afa23120bb72709973ae4711106e6e502fe65 (diff)
downloadopie-fdef8103e849b674c95d01785259e072bcfb5a4b.zip
opie-fdef8103e849b674c95d01785259e072bcfb5a4b.tar.gz
opie-fdef8103e849b674c95d01785259e072bcfb5a4b.tar.bz2
-Kill owarn statements from the code
-Kill magic numbers and use enum values
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/main.cpp1
-rw-r--r--core/pim/todo/mainwindow.cpp16
-rw-r--r--core/pim/todo/tableview.cpp32
-rw-r--r--core/pim/todo/todomanager.cpp7
4 files changed, 22 insertions, 34 deletions
diff --git a/core/pim/todo/main.cpp b/core/pim/todo/main.cpp
index d070ff8..a336ba3 100644
--- a/core/pim/todo/main.cpp
+++ b/core/pim/todo/main.cpp
@@ -36,9 +36,8 @@ int main( int argc, char **argv )
36 QTime time; 36 QTime time;
37 time.start(); 37 time.start();
38 Todo::MainWindow mw; 38 Todo::MainWindow mw;
39 int t = time.elapsed(); 39 int t = time.elapsed();
40 Opie::Core::owarn << "QTime " << t/1000 << oendl;
41 mw.setCaption( QObject::tr("Opie Todolist")); 40 mw.setCaption( QObject::tr("Opie Todolist"));
42 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); 41 QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) );
43 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); 42 QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) );
44 43
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp
index 2002e87..9424c23 100644
--- a/core/pim/todo/mainwindow.cpp
+++ b/core/pim/todo/mainwindow.cpp
@@ -295,9 +295,8 @@ QPopupMenu* MainWindow::contextMenu( int , bool recur ) {
295 295
296 return menu; 296 return menu;
297} 297}
298QPopupMenu* MainWindow::options() { 298QPopupMenu* MainWindow::options() {
299 owarn << "Options" << oendl;
300 return m_options; 299 return m_options;
301} 300}
302QPopupMenu* MainWindow::edit() { 301QPopupMenu* MainWindow::edit() {
303 return m_edit; 302 return m_edit;
@@ -314,16 +313,14 @@ OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) {
314 cat = currentCatId(); 313 cat = currentCatId();
315 if ( m_curCat == QWidget::tr("Unfiled") ) 314 if ( m_curCat == QWidget::tr("Unfiled") )
316 cat = -1; 315 cat = -1;
317 316
318 owarn << " Category " << cat << " " << m_curCat << oendl; 317 int filter = OPimTodoAccess::FilterCategory;
319
320 int filter = 1;
321 318
322 if (!m_completed ) 319 if (!m_completed )
323 filter |= 4; 320 filter |= OPimTodoAccess::DoNotShowCompleted;
324 if (m_overdue) 321 if (m_overdue)
325 filter |= 2; 322 filter |= OPimTodoAccess::OnlyOverDue;
326 323
327 return m_todoMgr.sorted( asc, sortOrder, filter, cat ); 324 return m_todoMgr.sorted( asc, sortOrder, filter, cat );
328} 325}
329OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { 326OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) {
@@ -373,9 +370,8 @@ void MainWindow::closeEvent( QCloseEvent* e ) {
373 return; 370 return;
374 } 371 }
375 bool quit = false; 372 bool quit = false;
376 if ( m_todoMgr.saveAll() ){ 373 if ( m_todoMgr.saveAll() ){
377 owarn << "saved" << oendl;
378 quit = true; 374 quit = true;
379 }else { 375 }else {
380 if ( QMessageBox::critical( this, QWidget::tr("Out of space"), 376 if ( QMessageBox::critical( this, QWidget::tr("Out of space"),
381 QWidget::tr("Todo was unable\n" 377 QWidget::tr("Todo was unable\n"
@@ -536,9 +532,8 @@ void MainWindow::slotEdit() {
536void MainWindow::setCategory( int c) { 532void MainWindow::setCategory( int c) {
537 if ( c <= 0 ) return; 533 if ( c <= 0 ) return;
538 534
539 535
540 owarn << "Iterating over cats " << c << oendl;
541 for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) 536 for ( unsigned int i = 1; i < m_catMenu->count(); i++ )
542 m_catMenu->setItemChecked(i, c == (int)i ); 537 m_catMenu->setItemChecked(i, c == (int)i );
543 538
544 if (c == 1 ) { 539 if (c == 1 ) {
@@ -682,9 +677,8 @@ void MainWindow::slotShowDue(bool ov) {
682void MainWindow::slotShow( int uid ) { 677void MainWindow::slotShow( int uid ) {
683 if ( uid == 0 ) return; 678 if ( uid == 0 ) return;
684 679
685 680
686 owarn << "slotShow" << oendl;
687 currentShow()->slotShow( event( uid ) ); 681 currentShow()->slotShow( event( uid ) );
688 m_stack->raiseWidget( currentShow()->widget() ); 682 m_stack->raiseWidget( currentShow()->widget() );
689} 683}
690void MainWindow::slotShowNext() { 684void MainWindow::slotShowNext() {
@@ -741,9 +735,8 @@ void MainWindow::setReadAhead( uint count ) {
741 if (m_todoMgr.todoDB() ) 735 if (m_todoMgr.todoDB() )
742 m_todoMgr.todoDB()->setReadAhead( count ); 736 m_todoMgr.todoDB()->setReadAhead( count );
743} 737}
744void MainWindow::slotQuickEntered() { 738void MainWindow::slotQuickEntered() {
745 owarn << "entered" << oendl;
746 OPimTodo todo = quickEditor()->todo(); 739 OPimTodo todo = quickEditor()->todo();
747 if (todo.isEmpty() ) 740 if (todo.isEmpty() )
748 return; 741 return;
749 742
@@ -788,9 +781,8 @@ void MainWindow::slotComplete( const OPimTodo& todo ) {
788 */ 781 */
789 QDate date; 782 QDate date;
790 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { 783 if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) {
791 int dayDiff = to.dueDate().daysTo( date ); 784 int dayDiff = to.dueDate().daysTo( date );
792 owarn << "day diff is " << dayDiff << oendl;
793 QDate inval; 785 QDate inval;
794 /* generate a new uid for the old record */ 786 /* generate a new uid for the old record */
795 to.setUid( 1 ); 787 to.setUid( 1 );
796 788
@@ -952,17 +944,15 @@ namespace {
952 } 944 }
953 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 945 void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
954 OPimNotifyManager::Alarms::ConstIterator it; 946 OPimNotifyManager::Alarms::ConstIterator it;
955 for ( it = als.begin(); it != als.end(); ++it ) { 947 for ( it = als.begin(); it != als.end(); ++it ) {
956 owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl;
957 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 948 AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
958 } 949 }
959 950
960 } 951 }
961 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { 952 void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) {
962 OPimNotifyManager::Alarms::ConstIterator it; 953 OPimNotifyManager::Alarms::ConstIterator it;
963 for ( it = als.begin(); it != als.end(); ++it ) { 954 for ( it = als.begin(); it != als.end(); ++it ) {
964 owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl;
965 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); 955 AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid );
966 } 956 }
967 } 957 }
968} 958}
diff --git a/core/pim/todo/tableview.cpp b/core/pim/todo/tableview.cpp
index b7458d8..221faca 100644
--- a/core/pim/todo/tableview.cpp
+++ b/core/pim/todo/tableview.cpp
@@ -137,9 +137,9 @@ TableView::TableView( MainWindow* window, QWidget* wid )
137 m_enablePaint = true; 137 m_enablePaint = true;
138 setUpdatesEnabled( true ); 138 setUpdatesEnabled( true );
139 viewport()->setUpdatesEnabled( true ); 139 viewport()->setUpdatesEnabled( true );
140 viewport()->update(); 140 viewport()->update();
141 setSortOrder( 0 ); 141 setSortOrder( Opie::OPimTodoAccess::Completed );
142 setAscending( TRUE ); 142 setAscending( TRUE );
143 m_first = true; 143 m_first = true;
144 144
145 145
@@ -194,9 +194,8 @@ void TableView::showOverDue( bool ) {
194 updateView(); 194 updateView();
195} 195}
196 196
197void TableView::updateView( ) { 197void TableView::updateView( ) {
198 owarn << "update view" << oendl;
199 m_row = false; 198 m_row = false;
200 static int id; 199 static int id;
201 id = startTimer(4000 ); 200 id = startTimer(4000 );
202 /* FIXME we want one page to be read! 201 /* FIXME we want one page to be read!
@@ -208,9 +207,8 @@ void TableView::updateView( ) {
208 OPimTodoAccess::List::Iterator it, end; 207 OPimTodoAccess::List::Iterator it, end;
209 it = sorted().begin(); 208 it = sorted().begin();
210 end = sorted().end(); 209 end = sorted().end();
211 210
212 owarn << "setTodos" << oendl;
213 QTime time; 211 QTime time;
214 time.start(); 212 time.start();
215 m_enablePaint = false; 213 m_enablePaint = false;
216 setUpdatesEnabled( false ); 214 setUpdatesEnabled( false );
@@ -253,14 +251,12 @@ void TableView::replaceEvent( const OPimTodo& ev) {
253 */ 251 */
254void TableView::removeEvent( int ) { 252void TableView::removeEvent( int ) {
255 updateView(); 253 updateView();
256} 254}
257void TableView::setShowCompleted( bool b) { 255void TableView::setShowCompleted( bool ) {
258 owarn << "Show Completed " << b << oendl;
259 updateView(); 256 updateView();
260} 257}
261void TableView::setShowDeadline( bool b ) { 258void TableView::setShowDeadline( bool b ) {
262 owarn << "Show Deadline " << b << oendl;
263 if ( b ) 259 if ( b )
264 showColumn( 3 ); 260 showColumn( 3 );
265 else 261 else
266 hideColumn( 3 ); 262 hideColumn( 3 );
@@ -281,9 +277,8 @@ void TableView::setShowDeadline( bool b ) {
281 } 277 }
282 setColumnWidth( 2, col2width ); 278 setColumnWidth( 2, col2width );
283} 279}
284void TableView::setShowCategory( const QString& str) { 280void TableView::setShowCategory( const QString& str) {
285 owarn << "setShowCategory" << oendl;
286 if ( str != m_oleCat || m_first ) 281 if ( str != m_oleCat || m_first )
287 updateView(); 282 updateView();
288 283
289 m_oleCat = str; 284 m_oleCat = str;
@@ -346,17 +341,14 @@ void TableView::slotClicked(int row, int col, int,
346} 341}
347void TableView::slotPressed(int row, int col, int, 342void TableView::slotPressed(int row, int col, int,
348 const QPoint& point) { 343 const QPoint& point) {
349 344
350 owarn << "pressed row " << row << " col " << col << " x:" << point.x()
351 << "+y:" << point.y() << oendl;
352 m_prevP = point; 345 m_prevP = point;
353 /* TextColumn column */ 346 /* TextColumn column */
354 if ( col == 2 && cellGeometry( row, col ).contains( point ) ) 347 if ( col == 2 && cellGeometry( row, col ).contains( point ) )
355 m_menuTimer->start( 750, TRUE ); 348 m_menuTimer->start( 750, TRUE );
356} 349}
357void TableView::slotValueChanged( int, int ) { 350void TableView::slotValueChanged( int, int ) {
358 owarn << "Value Changed" << oendl;
359} 351}
360void TableView::slotCurrentChanged(int, int ) { 352void TableView::slotCurrentChanged(int, int ) {
361 m_menuTimer->stop(); 353 m_menuTimer->stop();
362} 354}
@@ -370,9 +362,24 @@ QWidget* TableView::widget() {
370 * We event want to set the setOrder 362 * We event want to set the setOrder
371 * to a sort() and update() 363 * to a sort() and update()
372 */ 364 */
373void TableView::sortColumn( int col, bool asc, bool ) { 365void TableView::sortColumn( int col, bool asc, bool ) {
374 owarn << "bool " << asc << oendl; 366 switch(col) {
367 case 1:
368 col = Opie::OPimTodoAccess::Priority;
369 break;
370 case 2:
371 col = Opie::OPimTodoAccess::SortSummary;
372 break;
373 case 3:
374 col = Opie::OPimTodoAccess::Deadline;
375 break;
376 case 0:
377 default:
378 col = Opie::OPimTodoAccess::Completed;
379 break;
380 }
381
375 setSortOrder( col ); 382 setSortOrder( col );
376 setAscending( asc ); 383 setAscending( asc );
377 updateView(); 384 updateView();
378} 385}
@@ -493,9 +500,8 @@ QWidget* TableView::createEditor(int row, int col, bool )const {
493 return 0l; 500 return 0l;
494 } 501 }
495} 502}
496void TableView::setCellContentFromEditor(int row, int col ) { 503void TableView::setCellContentFromEditor(int row, int col ) {
497 owarn << "set cell content from editor" << oendl;
498 if ( col == 1 ) { 504 if ( col == 1 ) {
499 QWidget* wid = cellWidget(row, 1 ); 505 QWidget* wid = cellWidget(row, 1 );
500 if ( wid->inherits("QComboBox") ) { 506 if ( wid->inherits("QComboBox") ) {
501 int pri = ((QComboBox*)wid)->currentItem() + 1; 507 int pri = ((QComboBox*)wid)->currentItem() + 1;
@@ -529,9 +535,8 @@ void TableView::slotPriority() {
529 * up and down. On odd or even we will currentRow()+-4 or +-9 535 * up and down. On odd or even we will currentRow()+-4 or +-9
530 * 536 *
531 */ 537 */
532void TableView::timerEvent( QTimerEvent* ) { 538void TableView::timerEvent( QTimerEvent* ) {
533// Opie::Core::owarn << "sorted " << sorted().count() << oendl;
534 if (sorted().count() == 0 ) 539 if (sorted().count() == 0 )
535 return; 540 return;
536 541
537 int row = currentRow(); 542 int row = currentRow();
@@ -577,9 +582,8 @@ void TableView::timerEvent( QTimerEvent* ) {
577void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { 582void TableView::contentsMouseReleaseEvent( QMouseEvent* e) {
578 int row = rowAt(m_prevP.y()); 583 int row = rowAt(m_prevP.y());
579 int colOld = columnAt(m_prevP.x() ); 584 int colOld = columnAt(m_prevP.x() );
580 int colNew = columnAt(e->x() ); 585 int colNew = columnAt(e->x() );
581 owarn << "colNew: " << colNew << " colOld: " << colOld << oendl;
582 if ( row == rowAt( e->y() ) && row != -1 && 586 if ( row == rowAt( e->y() ) && row != -1 &&
583 colOld != colNew ) { 587 colOld != colNew ) {
584 TodoView::complete( sorted()[row] ); 588 TodoView::complete( sorted()[row] );
585 return; 589 return;
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
index c4b8fbc..7136f9a 100644
--- a/core/pim/todo/todomanager.cpp
+++ b/core/pim/todo/todomanager.cpp
@@ -36,21 +36,16 @@ using namespace Todo;
36 36
37TodoManager::TodoManager( QObject *obj ) 37TodoManager::TodoManager( QObject *obj )
38 : QObject( obj ) { 38 : QObject( obj ) {
39 m_db = 0l; 39 m_db = 0l;
40 QTime time;
41 time.start();
42 int el = time.elapsed();
43 owarn << "QTimer for loading " << el/1000 << oendl;
44} 40}
45TodoManager::~TodoManager() { 41TodoManager::~TodoManager() {
46 delete m_db; 42 delete m_db;
47} 43}
48OPimTodo TodoManager::event(int uid ) { 44OPimTodo TodoManager::event(int uid ) {
49 return m_db->find( uid ); 45 return m_db->find( uid );
50} 46}
51void TodoManager::updateList() { 47void TodoManager::updateList() {
52 owarn << "update lists" << oendl;
53 m_list = m_db->allRecords(); 48 m_list = m_db->allRecords();
54} 49}
55OPimTodoAccess::List TodoManager::list() const{ 50OPimTodoAccess::List TodoManager::list() const{
56 return m_list; 51 return m_list;
@@ -58,9 +53,9 @@ OPimTodoAccess::List TodoManager::list() const{
58OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { 53OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
59 return m_db->sorted( asc, so, f, cat ); 54 return m_db->sorted( asc, so, f, cat );
60} 55}
61OPimTodoAccess::List::Iterator TodoManager::overDue() { 56OPimTodoAccess::List::Iterator TodoManager::overDue() {
62 int filter = 2 | 1; 57 int filter = Opie::OPimTodoAccess::FilterCategory | Opie::OPimTodoAccess::OnlyOverDue;
63 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); 58 m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
64 m_it = m_list.begin(); 59 m_it = m_list.begin();
65 return m_it; 60 return m_it;
66} 61}