Diffstat (limited to 'core/pim/today/plugins/todolist/todopluginwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/today/plugins/todolist/todopluginwidget.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/core/pim/today/plugins/todolist/todopluginwidget.cpp b/core/pim/today/plugins/todolist/todopluginwidget.cpp index 320969e..773e5cf 100644 --- a/core/pim/today/plugins/todolist/todopluginwidget.cpp +++ b/core/pim/today/plugins/todolist/todopluginwidget.cpp @@ -27,25 +27,27 @@ #include <qpe/timestring.h> #include <qpe/qcopenvelope_qws.h> TodolistPluginWidget::TodolistPluginWidget( QWidget *parent, const char* name ) : QWidget( parent, name ) { todoLabel = 0l; todo = 0l; if ( todo ) { delete todo; } - todo = new ToDoDB(); + + todo = new OTodoAccess(); + todo->load(); readConfig(); getTodo(); } TodolistPluginWidget::~TodolistPluginWidget() { delete todo; } void TodolistPluginWidget::readConfig() { Config cfg( "todaytodoplugin" ); @@ -58,67 +60,61 @@ void TodolistPluginWidget::readConfig() { /** * Get the todos */ void TodolistPluginWidget::getTodo() { QVBoxLayout* layoutTodo = new QVBoxLayout( this ); if ( todoLabel ) { delete todoLabel; } todoLabel = new OClickableLabel( this ); - todoLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); connect( todoLabel, SIGNAL( clicked() ), this, SLOT( startTodolist() ) ); QString output; QString tmpout; int count = 0; int ammount = 0; // get overdue todos first - QValueList<ToDoEvent> overDueList = todo->overDue(); - qBubbleSort( overDueList ); - for ( QValueList<ToDoEvent>::Iterator it = overDueList.begin(); - it != overDueList.end(); ++it ) { - if (!(*it).isCompleted() && ( ammount < m_maxLinesTask ) ) { - QString desc = (*it).summary(); + m_list = todo->overDue(); + + for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { + if (!(*m_it).isCompleted() && ( ammount < m_maxLinesTask ) ) { + QString desc = (*m_it).summary(); if( desc.isEmpty() ) { - desc = (*it).description(); + desc = (*m_it).description(); } tmpout += "<font color=#e00000><b>-" + desc.mid( 0, m_maxCharClip ) + "</b></font><br>"; ammount++; } } // get total number of still open todos - QValueList<ToDoEvent> openTodo = todo->rawToDos(); - qBubbleSort( openTodo ); - for ( QValueList<ToDoEvent>::Iterator it = openTodo.begin(); - it != openTodo.end(); ++it ) { - if ( !(*it).isCompleted() ){ + m_list = todo->sorted( true, 1, 4, 1); + + for ( m_it = m_list.begin(); m_it != m_list.end(); ++m_it ) { count +=1; // not the overdues, we allready got them, and not if we are // over the maxlines - if ( !(*it).isOverdue() && ( ammount < m_maxLinesTask ) ) { - QString desc = (*it).summary(); + if ( !(*m_it).isOverdue() && ( ammount < m_maxLinesTask ) ) { + QString desc = (*m_it).summary(); if( desc.isEmpty() ) { - desc = (*it).description(); + desc = (*m_it).description(); } tmpout += "<b>-</b>" + desc.mid( 0, m_maxCharClip ) + "<br>"; ammount++; } } - } - if ( count > 0 ) { if( count == 1 ) { output += QObject::tr( "There is <b> 1</b> active task: <br>" ); } else { output += QObject::tr( "There are <b> %1</b> active tasks: <br>" ).arg( count ); } output += tmpout; } else { output = QObject::tr( "No active tasks" ); } todoLabel->setText( output ); |