Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

todosearch.cpp

Go to the documentation of this file.
00001 //
00002 //
00003 // C++ Implementation: $MODULE$
00004 //
00005 // Description:
00006 //
00007 //
00008 // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003
00009 //
00010 // Copyright: See COPYING file that comes with this distribution
00011 //
00012 //
00013 #include "todosearch.h"
00014 #include "todoitem.h"
00015 
00016 #include <opie2/oresource.h>
00017 
00018 #include <qpe/config.h>
00019 
00020 #include <qaction.h>
00021 #include <qpopupmenu.h>
00022 
00023 using namespace Opie;
00024 TodoSearch::TodoSearch(QListView* parent, QString name)
00025 : SearchGroup(parent, name), _todos(0), _popupMenu(0)
00026 {
00027 //      AppLnkSet als(QPEApplication::qpeDir());
00028 //      setPixmap( 0, als.findExec("todolist")->pixmap() );
00029     setPixmap( 0, Opie::Core::OResource::loadPixmap( "todo/TodoList", Opie::Core::OResource::SmallIcon ) );
00030 
00031         actionShowCompleted = new QAction( QObject::tr("Show completed tasks"),QString::null,  0, 0, 0, true );
00032         Config cfg( "osearch", Config::User );
00033         cfg.setGroup( "todo_settings" );
00034         actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) );
00035 
00036 }
00037 
00038 
00039 TodoSearch::~TodoSearch()
00040 {
00041         Config cfg( "osearch", Config::User );
00042         cfg.setGroup( "todo_settings" );
00043         cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() );
00044         delete _popupMenu;
00045         delete actionShowCompleted;
00046         delete _todos;
00047 }
00048 
00049 
00050 void TodoSearch::load()
00051 {
00052          _todos = new OPimTodoAccess();
00053          _todos->load();
00054 }
00055 
00056 int TodoSearch::search()
00057 {
00058         OPimRecordList<OPimTodo> results = _todos->matchRegexp(_search);
00059         for (uint i = 0; i < results.count(); i++)
00060                 insertItem( new OPimTodo( results[i] ));
00061         return _resultCount;
00062 }
00063 
00064 void TodoSearch::insertItem( void *rec )
00065 {
00066         OPimTodo *todo = (OPimTodo*)rec;
00067         if (!actionShowCompleted->isOn() &&
00068                 todo->isCompleted() ) return;
00069         (void)new TodoItem( this, todo );
00070         _resultCount++;
00071 }
00072 
00073 QPopupMenu* TodoSearch::popupMenu()
00074 {
00075         if (!_popupMenu){
00076                 _popupMenu = new QPopupMenu( 0 );
00077                 actionShowCompleted->addTo( _popupMenu );
00078         }
00079         return _popupMenu;
00080 }

Generated on Sat Nov 5 16:15:54 2005 for OPIE by  doxygen 1.4.2