summaryrefslogtreecommitdiff
path: root/core/pim/todo/todomanager.cpp
authorzecke <zecke>2002-10-07 11:39:30 (UTC)
committer zecke <zecke>2002-10-07 11:39:30 (UTC)
commitf11d4bda64b58abfebf77485d5d77143a10dc8c9 (patch) (side-by-side diff)
treea4e80550c4abe867303553de608316941dd943f1 /core/pim/todo/todomanager.cpp
parentc2cd5470fa3ec69394fa65ad16ab29a6cadab56f (diff)
downloadopie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.zip
opie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.tar.gz
opie-f11d4bda64b58abfebf77485d5d77143a10dc8c9.tar.bz2
Re add files
for todo
Diffstat (limited to 'core/pim/todo/todomanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/todo/todomanager.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/core/pim/todo/todomanager.cpp b/core/pim/todo/todomanager.cpp
new file mode 100644
index 0000000..8e3fa88
--- a/dev/null
+++ b/core/pim/todo/todomanager.cpp
@@ -0,0 +1,125 @@
+/*
+               =. This file is part of the OPIE Project
+             .=l. Copyright (c) 2002 <>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
+#include <qdatetime.h>
+#include <qpe/categoryselect.h>
+
+#include "todomanager.h"
+
+using namespace Todo;
+
+TodoManager::TodoManager( QObject *obj )
+ : QObject( obj ) {
+ m_db = 0l;
+ QTime time;
+ time.start();
+ int el = time.elapsed();
+ qWarning("QTimer for loading %d", el/1000 );
+}
+TodoManager::~TodoManager() {
+ delete m_db;
+}
+OTodo TodoManager::event(int uid ) {
+ return m_db->find( uid );
+}
+void TodoManager::updateList() {
+ m_list = m_db->allRecords();
+}
+OTodoAccess::List::Iterator TodoManager::begin() {
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess::List::Iterator TodoManager::end() {
+ return m_list.end();
+}
+OTodoAccess::List::Iterator TodoManager::overDue() {
+ int filter = 2 & 1;
+ m_list = m_db->sorted(m_asc, m_sortOrder, filter, m_ca );
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess::List::Iterator TodoManager::fromTo( const QDate& start,
+ const QDate& end ) {
+ m_list = m_db->effectiveToDos( start, end );
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess::List::Iterator TodoManager::query( const OTodo& ev, int query ) {
+ m_list = m_db->queryByExample( ev, query );
+ m_it = m_list.begin();
+ return m_it;
+}
+OTodoAccess* TodoManager::todoDB() {
+ return m_db;
+}
+void TodoManager::add( const OTodo& ev ) {
+ m_db->add( ev );
+}
+void TodoManager::update( int, const SmallTodo& ) {
+
+}
+void TodoManager::update( int, const OTodo& ev) {
+ m_db->replace( ev );
+}
+void TodoManager::remove( int uid ) {
+ m_db->remove( uid );
+}
+void TodoManager::removeAll() {
+ m_db->clear();
+}
+void TodoManager::save() {
+ m_db->save();
+}
+bool TodoManager::saveAll() {
+ return m_db->save();
+}
+void TodoManager::reload() {
+ m_db->reload();
+}
+QStringList TodoManager::categories() {
+ m_cat.load(categoryFileName() );
+ return m_cat.labels( "Todo List");
+}
+/*
+ * we rely on load beeing called from populateCategories
+ */
+int TodoManager::catId( const QString& cats ) {
+ return m_cat.id( "Todo List", cats );
+}
+void TodoManager::remove( const QArray<int>& ids) {
+ for (uint i=0; i < ids.size(); i++ )
+ remove( ids[i] );
+}
+bool TodoManager::isLoaded()const {
+ return (m_db == 0 );
+}
+void TodoManager::load() {
+ if (!m_db) {
+ m_db = new OTodoAccess();
+ m_db->load();
+ }
+}