From 80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6 Mon Sep 17 00:00:00 2001 From: tille Date: Thu, 15 May 2003 13:55:07 +0000 Subject: owait and settings for search group: - hide completed todos - show only later events - do not display hits in datebook dated --- (limited to 'core/pim/osearch/todosearch.cpp') diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp index c9fa61a..08bbe93 100644 --- a/core/pim/osearch/todosearch.cpp +++ b/core/pim/osearch/todosearch.cpp @@ -14,23 +14,35 @@ #include #include -#include #include +#include +#include +#include +#include #include "todoitem.h" TodoSearch::TodoSearch(QListView* parent, QString name) -: SearchGroup(parent, name) +: SearchGroup(parent, name), _todos(0), _popupMenu(0) { - _todos = 0; // AppLnkSet als(QPEApplication::qpeDir()); // setPixmap( 0, als.findExec("todolist")->pixmap() ); QIconSet is = Resource::loadIconSet( "todo/TodoList" ); setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); + actionShowCompleted = new QAction( QObject::tr("show completed tasks"),QString::null, 0, 0, 0, true ); + Config cfg( "osearch", Config::User ); + cfg.setGroup( "todo_settings" ); + actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) ); + } TodoSearch::~TodoSearch() { + Config cfg( "osearch", Config::User ); + cfg.setGroup( "todo_settings" ); + cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() ); + delete _popupMenu; + delete actionShowCompleted; delete _todos; } @@ -45,11 +57,24 @@ int TodoSearch::search() { ORecordList results = _todos->matchRegexp(_search); for (uint i = 0; i < results.count(); i++) - new TodoItem( this, new OTodo( results[i] )); - return results.count(); + insertItem( new OTodo( results[i] )); + return _resultCount; } -void TodoSearch::insertItem( void* ) +void TodoSearch::insertItem( void *rec ) { + OTodo *todo = (OTodo*)rec; + if (!actionShowCompleted->isOn() && + todo->isCompleted() ) return; + new TodoItem( this, todo ); + _resultCount++; +} +QPopupMenu* TodoSearch::popupMenu() +{ + if (!_popupMenu){ + _popupMenu = new QPopupMenu( 0 ); + actionShowCompleted->addTo( _popupMenu ); + } + return _popupMenu; } -- cgit v0.9.0.2