Diffstat (limited to 'core/pim/osearch/todosearch.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/osearch/todosearch.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
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 | |||
@@ -11,29 +11,41 @@ | |||
11 | // | 11 | // |
12 | // | 12 | // |
13 | #include "todosearch.h" | 13 | #include "todosearch.h" |
14 | 14 | ||
15 | #include <opie/otodoaccess.h> | 15 | #include <opie/otodoaccess.h> |
16 | #include <opie/otodo.h> | 16 | #include <opie/otodo.h> |
17 | #include <qiconset.h> | ||
18 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/config.h> | ||
19 | #include <qiconset.h> | ||
20 | #include <qaction.h> | ||
21 | #include <qpopupmenu.h> | ||
19 | #include "todoitem.h" | 22 | #include "todoitem.h" |
20 | 23 | ||
21 | TodoSearch::TodoSearch(QListView* parent, QString name) | 24 | TodoSearch::TodoSearch(QListView* parent, QString name) |
22 | : SearchGroup(parent, name) | 25 | : SearchGroup(parent, name), _todos(0), _popupMenu(0) |
23 | { | 26 | { |
24 | _todos = 0; | ||
25 | //AppLnkSet als(QPEApplication::qpeDir()); | 27 | //AppLnkSet als(QPEApplication::qpeDir()); |
26 | //setPixmap( 0, als.findExec("todolist")->pixmap() ); | 28 | //setPixmap( 0, als.findExec("todolist")->pixmap() ); |
27 | QIconSet is = Resource::loadIconSet( "todo/TodoList" ); | 29 | QIconSet is = Resource::loadIconSet( "todo/TodoList" ); |
28 | setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); | 30 | setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); |
31 | actionShowCompleted = new QAction( QObject::tr("show completed tasks"),QString::null, 0, 0, 0, true ); | ||
32 | Config cfg( "osearch", Config::User ); | ||
33 | cfg.setGroup( "todo_settings" ); | ||
34 | actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) ); | ||
35 | |||
29 | } | 36 | } |
30 | 37 | ||
31 | 38 | ||
32 | TodoSearch::~TodoSearch() | 39 | TodoSearch::~TodoSearch() |
33 | { | 40 | { |
41 | Config cfg( "osearch", Config::User ); | ||
42 | cfg.setGroup( "todo_settings" ); | ||
43 | cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() ); | ||
44 | delete _popupMenu; | ||
45 | delete actionShowCompleted; | ||
34 | delete _todos; | 46 | delete _todos; |
35 | } | 47 | } |
36 | 48 | ||
37 | 49 | ||
38 | void TodoSearch::load() | 50 | void TodoSearch::load() |
39 | { | 51 | { |
@@ -42,14 +54,27 @@ void TodoSearch::load() | |||
42 | } | 54 | } |
43 | 55 | ||
44 | int TodoSearch::search() | 56 | int TodoSearch::search() |
45 | { | 57 | { |
46 | ORecordList<OTodo> results = _todos->matchRegexp(_search); | 58 | ORecordList<OTodo> results = _todos->matchRegexp(_search); |
47 | for (uint i = 0; i < results.count(); i++) | 59 | for (uint i = 0; i < results.count(); i++) |
48 | new TodoItem( this, new OTodo( results[i] )); | 60 | insertItem( new OTodo( results[i] )); |
49 | return results.count(); | 61 | return _resultCount; |
50 | } | 62 | } |
51 | 63 | ||
52 | void TodoSearch::insertItem( void* ) | 64 | void TodoSearch::insertItem( void *rec ) |
53 | { | 65 | { |
66 | OTodo *todo = (OTodo*)rec; | ||
67 | if (!actionShowCompleted->isOn() && | ||
68 | todo->isCompleted() ) return; | ||
69 | new TodoItem( this, todo ); | ||
70 | _resultCount++; | ||
71 | } | ||
54 | 72 | ||
73 | QPopupMenu* TodoSearch::popupMenu() | ||
74 | { | ||
75 | if (!_popupMenu){ | ||
76 | _popupMenu = new QPopupMenu( 0 ); | ||
77 | actionShowCompleted->addTo( _popupMenu ); | ||
78 | } | ||
79 | return _popupMenu; | ||
55 | } | 80 | } |