author | zecke <zecke> | 2004-11-18 21:55:17 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-18 21:55:17 (UTC) |
commit | fdef8103e849b674c95d01785259e072bcfb5a4b (patch) (side-by-side diff) | |
tree | 411432edf236f8858094598617383dea95c14c3a | |
parent | c94afa23120bb72709973ae4711106e6e502fe65 (diff) | |
download | opie-fdef8103e849b674c95d01785259e072bcfb5a4b.zip opie-fdef8103e849b674c95d01785259e072bcfb5a4b.tar.gz opie-fdef8103e849b674c95d01785259e072bcfb5a4b.tar.bz2 |
-Kill owarn statements from the code
-Kill magic numbers and use enum values
-rw-r--r-- | core/pim/todo/main.cpp | 1 | ||||
-rw-r--r-- | core/pim/todo/mainwindow.cpp | 16 | ||||
-rw-r--r-- | core/pim/todo/tableview.cpp | 32 | ||||
-rw-r--r-- | core/pim/todo/todomanager.cpp | 7 |
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 @@ -34,13 +34,12 @@ int main( int argc, char **argv ) QPEApplication a( argc, argv ); QTime time; time.start(); Todo::MainWindow mw; int t = time.elapsed(); - Opie::Core::owarn << "QTime " << t/1000 << oendl; mw.setCaption( QObject::tr("Opie Todolist")); QObject::connect( &a, SIGNAL( flush() ), &mw, SLOT( slotFlush() ) ); QObject::connect( &a, SIGNAL( reload() ), &mw, SLOT( slotReload() ) ); a.showMainWidget(&mw); 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 @@ -293,13 +293,12 @@ QPopupMenu* MainWindow::contextMenu( int , bool recur ) { ; // FIXME } return menu; } QPopupMenu* MainWindow::options() { - owarn << "Options" << oendl; return m_options; } QPopupMenu* MainWindow::edit() { return m_edit; } QToolBar* MainWindow::toolbar() { @@ -312,20 +311,18 @@ OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder ) { int cat = 0; if ( m_curCat != QWidget::tr("All Categories") ) cat = currentCatId(); if ( m_curCat == QWidget::tr("Unfiled") ) cat = -1; - owarn << " Category " << cat << " " << m_curCat << oendl; - - int filter = 1; + int filter = OPimTodoAccess::FilterCategory; if (!m_completed ) - filter |= 4; + filter |= OPimTodoAccess::DoNotShowCompleted; if (m_overdue) - filter |= 2; + filter |= OPimTodoAccess::OnlyOverDue; return m_todoMgr.sorted( asc, sortOrder, filter, cat ); } OPimTodoAccess::List MainWindow::sorted( bool asc, int sortOrder, int addFilter) { int cat = 0; if ( m_curCat != QWidget::tr("All Categories") ) @@ -371,13 +368,12 @@ void MainWindow::closeEvent( QCloseEvent* e ) { if (m_syncing ) { e->accept(); return; } bool quit = false; if ( m_todoMgr.saveAll() ){ - owarn << "saved" << oendl; quit = true; }else { if ( QMessageBox::critical( this, QWidget::tr("Out of space"), QWidget::tr("Todo was unable\n" "to save your changes.\n" "Free up some space\n" @@ -534,13 +530,12 @@ void MainWindow::slotEdit() { * set the category */ void MainWindow::setCategory( int c) { if ( c <= 0 ) return; - owarn << "Iterating over cats " << c << oendl; for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) m_catMenu->setItemChecked(i, c == (int)i ); if (c == 1 ) { m_curCat = QString::null; setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); @@ -680,13 +675,12 @@ void MainWindow::slotShowDue(bool ov) { raiseCurrentView(); } void MainWindow::slotShow( int uid ) { if ( uid == 0 ) return; - owarn << "slotShow" << oendl; currentShow()->slotShow( event( uid ) ); m_stack->raiseWidget( currentShow()->widget() ); } void MainWindow::slotShowNext() { int l = currentView()->next(); if (l!=0) @@ -739,13 +733,12 @@ void MainWindow::updateList() { } void MainWindow::setReadAhead( uint count ) { if (m_todoMgr.todoDB() ) m_todoMgr.todoDB()->setReadAhead( count ); } void MainWindow::slotQuickEntered() { - owarn << "entered" << oendl; OPimTodo todo = quickEditor()->todo(); if (todo.isEmpty() ) return; m_todoMgr.add( todo ); currentView()->addEvent( todo ); @@ -786,13 +779,12 @@ void MainWindow::slotComplete( const OPimTodo& todo ) { * if there is a next occurence * from the duedate of the last recurrance */ QDate date; if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { int dayDiff = to.dueDate().daysTo( date ); - owarn << "day diff is " << dayDiff << oendl; QDate inval; /* generate a new uid for the old record */ to.setUid( 1 ); /* add the old one cause it has a new UID here cause it was spin off */ m_todoMgr.add( to ); @@ -950,21 +942,19 @@ namespace { } return nonMatching; } void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { OPimNotifyManager::Alarms::ConstIterator it; for ( it = als.begin(); it != als.end(); ++it ) { - owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl; AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); } } void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { OPimNotifyManager::Alarms::ConstIterator it; for ( it = als.begin(); it != als.end(); ++it ) { - owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl; AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); } } } void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { 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 @@ -135,13 +135,13 @@ TableView::TableView( MainWindow* window, QWidget* wid ) m_enablePaint = true; setUpdatesEnabled( true ); viewport()->setUpdatesEnabled( true ); viewport()->update(); - setSortOrder( 0 ); + setSortOrder( Opie::OPimTodoAccess::Completed ); setAscending( TRUE ); m_first = true; } /* a new day has started @@ -192,13 +192,12 @@ QString TableView::currentRepresentation() { void TableView::showOverDue( bool ) { clear(); updateView(); } void TableView::updateView( ) { - owarn << "update view" << oendl; m_row = false; static int id; id = startTimer(4000 ); /* FIXME we want one page to be read! * * Calculate that screensize @@ -206,13 +205,12 @@ void TableView::updateView( ) { todoWindow()->setReadAhead( 4 ); sort(); OPimTodoAccess::List::Iterator it, end; it = sorted().begin(); end = sorted().end(); - owarn << "setTodos" << oendl; QTime time; time.start(); m_enablePaint = false; setUpdatesEnabled( false ); viewport()->setUpdatesEnabled( false ); @@ -251,18 +249,16 @@ void TableView::replaceEvent( const OPimTodo& ev) { * FIXME: look what performs better * either this or the old align table */ void TableView::removeEvent( int ) { updateView(); } -void TableView::setShowCompleted( bool b) { - owarn << "Show Completed " << b << oendl; +void TableView::setShowCompleted( bool ) { updateView(); } void TableView::setShowDeadline( bool b ) { - owarn << "Show Deadline " << b << oendl; if ( b ) showColumn( 3 ); else hideColumn( 3 ); // Try to intelligently size columns @@ -279,13 +275,12 @@ void TableView::setShowDeadline( bool b ) { setColumnWidth( 3, width ); col2width -= width; } setColumnWidth( 2, col2width ); } void TableView::setShowCategory( const QString& str) { - owarn << "setShowCategory" << oendl; if ( str != m_oleCat || m_first ) updateView(); m_oleCat = str; m_first = false; @@ -344,21 +339,18 @@ void TableView::slotClicked(int row, int col, int, } void TableView::slotPressed(int row, int col, int, const QPoint& point) { - owarn << "pressed row " << row << " col " << col << " x:" << point.x() - << "+y:" << point.y() << oendl; m_prevP = point; /* TextColumn column */ if ( col == 2 && cellGeometry( row, col ).contains( point ) ) m_menuTimer->start( 750, TRUE ); } void TableView::slotValueChanged( int, int ) { - owarn << "Value Changed" << oendl; } void TableView::slotCurrentChanged(int, int ) { m_menuTimer->stop(); } QWidget* TableView::widget() { return this; @@ -368,13 +360,28 @@ QWidget* TableView::widget() { * because we want to sort whole row * based * We event want to set the setOrder * to a sort() and update() */ void TableView::sortColumn( int col, bool asc, bool ) { - owarn << "bool " << asc << oendl; + switch(col) { + case 1: + col = Opie::OPimTodoAccess::Priority; + break; + case 2: + col = Opie::OPimTodoAccess::SortSummary; + break; + case 3: + col = Opie::OPimTodoAccess::Deadline; + break; + case 0: + default: + col = Opie::OPimTodoAccess::Completed; + break; + } + setSortOrder( col ); setAscending( asc ); updateView(); } void TableView::viewportPaintEvent( QPaintEvent* e) { if (m_enablePaint ) @@ -491,13 +498,12 @@ QWidget* TableView::createEditor(int row, int col, bool )const { case 0: default: return 0l; } } void TableView::setCellContentFromEditor(int row, int col ) { - owarn << "set cell content from editor" << oendl; if ( col == 1 ) { QWidget* wid = cellWidget(row, 1 ); if ( wid->inherits("QComboBox") ) { int pri = ((QComboBox*)wid)->currentItem() + 1; OPimTodo todo = sorted()[row]; if ( todo.priority() != pri ) { @@ -527,13 +533,12 @@ void TableView::slotPriority() { * filled enough. * We will try to read ahead 4 items in both ways * up and down. On odd or even we will currentRow()+-4 or +-9 * */ void TableView::timerEvent( QTimerEvent* ) { -// Opie::Core::owarn << "sorted " << sorted().count() << oendl; if (sorted().count() == 0 ) return; int row = currentRow(); if ( m_row ) { int ro = row-4; @@ -575,13 +580,12 @@ void TableView::timerEvent( QTimerEvent* ) { * row and two columns! */ void TableView::contentsMouseReleaseEvent( QMouseEvent* e) { int row = rowAt(m_prevP.y()); int colOld = columnAt(m_prevP.x() ); int colNew = columnAt(e->x() ); - owarn << "colNew: " << colNew << " colOld: " << colOld << oendl; if ( row == rowAt( e->y() ) && row != -1 && colOld != colNew ) { TodoView::complete( sorted()[row] ); return; } QTable::contentsMouseReleaseEvent( e ); 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 @@ -34,35 +34,30 @@ using namespace Todo; TodoManager::TodoManager( QObject *obj ) : QObject( obj ) { m_db = 0l; - QTime time; - time.start(); - int el = time.elapsed(); - owarn << "QTimer for loading " << el/1000 << oendl; } TodoManager::~TodoManager() { delete m_db; } OPimTodo TodoManager::event(int uid ) { return m_db->find( uid ); } void TodoManager::updateList() { - owarn << "update lists" << oendl; m_list = m_db->allRecords(); } OPimTodoAccess::List TodoManager::list() const{ return m_list; } OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) { return m_db->sorted( asc, so, f, cat ); } OPimTodoAccess::List::Iterator TodoManager::overDue() { - int filter = 2 | 1; + int filter = Opie::OPimTodoAccess::FilterCategory | Opie::OPimTodoAccess::OnlyOverDue; m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca ); m_it = m_list.begin(); return m_it; } OPimTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start, const QDate& end ) { |