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

todomanager.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C) Opie Team <opie-devel@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022 :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #include <opie2/odebug.h>
00032 
00033 #include <qpe/categoryselect.h>
00034 
00035 #include "todomanager.h"
00036 
00037 using namespace Todo;
00038 
00039 TodoManager::TodoManager( QObject *obj )
00040     : QObject( obj ) {
00041     m_db = 0l;
00042     m_cat.load( categoryFileName() );
00043 }
00044 TodoManager::~TodoManager() {
00045     delete m_db;
00046 }
00047 OPimTodo TodoManager::event(int uid ) {
00048     return m_db->find( uid );
00049 }
00050 void TodoManager::updateList() {
00051     m_list = m_db->allRecords();
00052 }
00053 OPimTodoAccess::List TodoManager::list() const{
00054     return m_list;
00055 }
00056 OPimTodoAccess::List TodoManager::sorted( bool asc, int so, int f, int cat ) {
00057     return m_db->sorted( asc, so, f, cat );
00058 }
00059 OPimTodoAccess::List::Iterator TodoManager::overDue() {
00060     int filter = Opie::OPimTodoAccess::FilterCategory | Opie::OPimTodoAccess::OnlyOverDue;
00061     m_list = m_db->sorted(m_asc, m_sortOrder, filter,  m_ca );
00062     m_it = m_list.begin();
00063     return m_it;
00064 }
00065 OPimTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
00066                                       const QDate& end ) {
00067     m_list = m_db->effectiveToDos( start, end );
00068     m_it = m_list.begin();
00069     return m_it;
00070 }
00071 OPimTodoAccess::List::Iterator TodoManager::query( const OPimTodo& ev, int query ) {
00072     m_list = m_db->queryByExample( ev, query );
00073     m_it = m_list.begin();
00074     return m_it;
00075 }
00076 OPimTodoAccess* TodoManager::todoDB() {
00077     return m_db;
00078 }
00079 void TodoManager::add( const OPimTodo& ev ) {
00080     m_db->add( ev );
00081 }
00082 void TodoManager::update( int, const SmallTodo& ) {
00083 
00084 }
00085 void TodoManager::update( int, const OPimTodo& ev) {
00086     m_db->replace( ev );
00087 }
00088 bool TodoManager::remove( int uid ) {
00089     return m_db->remove( uid );
00090 }
00091 void TodoManager::removeAll() {
00092     m_db->clear();
00093 }
00094 void TodoManager::removeCompleted() {
00095     m_db->removeAllCompleted();
00096 }
00097 void TodoManager::save() {
00098     m_db->save();
00099 }
00100 bool TodoManager::saveAll() {
00101     return m_db->save();
00102 }
00103 void TodoManager::reload() {
00104     m_db->reload();
00105 }
00106 QStringList TodoManager::categories() {
00107     m_cat.load(categoryFileName() );
00108     return m_cat.labels( "Todo List");
00109 }
00110 /*
00111  * we rely on load beeing called from populateCategories
00112  */
00113 int TodoManager::catId( const QString& cats ) {
00114     return m_cat.id( "Todo List", cats );
00115 }
00116 void TodoManager::remove( const QArray<int>& ids) {
00117     for (uint i=0; i < ids.size(); i++ )
00118         remove( ids[i] );
00119 }
00120 bool TodoManager::isLoaded()const {
00121     return (m_db == 0 );
00122 }
00123 void TodoManager::load() {
00124     if (!m_db) {
00125         m_db = new OPimTodoAccess();
00126         m_db->load();
00127     }
00128 }

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