author | zecke <zecke> | 2004-11-18 21:49:23 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-18 21:49:23 (UTC) |
commit | 1e7f8f22fc10e3ed85b6563332ddc348c95792d0 (patch) (side-by-side diff) | |
tree | 59498ba1d4a7dbff05228c09bebcf0c849e916be /libopie2/opiepim/backend/otodoaccessbackend.cpp | |
parent | 41fa1c196965f17f9748f835d90c307b7e594883 (diff) | |
download | opie-1e7f8f22fc10e3ed85b6563332ddc348c95792d0.zip opie-1e7f8f22fc10e3ed85b6563332ddc348c95792d0.tar.gz opie-1e7f8f22fc10e3ed85b6563332ddc348c95792d0.tar.bz2 |
Backend Changes:
Each Backend can:
-Sort and Filter a set of Records/AllRecords (which can be filtered again)
-QueryByExample by every Backend
-Occurrences for a period of time and a QDateTime
-More common implementation
-OPimBackendOccurrence with common splitting to OPimOccurrence
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessbackend.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessbackend.cpp | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp index 790a764..5f86be9 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.cpp +++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp @@ -19,23 +19,137 @@ ..}^=.= = ; 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 <opie2/otodoaccessbackend.h> +#include <opie2/private/opimtodosortvector.h> +#include <opie2/otodoaccess.h> + +#include <qintdict.h> namespace Opie { OPimTodoAccessBackend::OPimTodoAccessBackend() : OPimAccessBackend<OPimTodo>() { } OPimTodoAccessBackend::~OPimTodoAccessBackend() { } +UIDArray OPimTodoAccessBackend::queryByExample( const OPimTodo&, int settings, + const QDateTime& d)const { + return UIDArray(); +} + +UIDArray OPimTodoAccessBackend::sorted( const UIDArray& events, bool asc, + int sortOrder, int sortFilter, + const QArray<int>& categories )const { + odebug << "Using Unaccelerated TodoList sorted Implementation" << oendl; + Internal::OPimTodoSortVector vector(events.count(), asc,sortOrder ); + int item = 0; + + bool bCat = sortFilter & OPimTodoAccess::FilterCategory ? true : false; + bool bOnly = sortFilter & OPimTodoAccess::OnlyOverDue ? true : false; + bool comp = sortFilter & OPimTodoAccess::DoNotShowCompleted ? true : false; + bool catPassed = false; + int cat; + + for ( uint i = 0; i < events.count(); ++i ) { + OPimTodo todo = find( events[i], events, i, Frontend::Forward ); + if ( todo.isEmpty() ) + continue; + + /* show category */ + /* -1 == unfiled */ + catPassed = false; + for ( uint cat_nu = 0; cat_nu < categories.count(); ++cat_nu ) { + cat = categories[cat_nu]; + if ( bCat && cat == -1 ) { + if(!todo.categories().isEmpty() ) + continue; + } else if ( bCat && cat != 0) + if (!todo.categories().contains( cat ) ) + continue; + catPassed = true; + break; + } + + /* + * If none of the Categories matched + * continue + */ + if ( !catPassed ) + continue; + if ( !todo.isOverdue() && bOnly ) + continue; + if (todo.isCompleted() && comp ) + continue; + + vector.insert(item++, todo ); + } + + vector.resize( item ); + /* sort it now */ + vector.sort(); + /* now get the uids */ + UIDArray array( vector.count() ); + for (uint i= 0; i < vector.count(); i++ ) + array[i] = vector.uidAt( i ); + + return array; +} + +OPimBackendOccurrence::List OPimTodoAccessBackend::occurrences( const QDate& start, + const QDate& end )const { + OPimBackendOccurrence::List lst; + UIDArray effective = effectiveToDos( start, end, false ); + UIDArray overdue = overDue(); + uint count = effective.count(); + int uid; + QIntDict<int> hash; + hash.setAutoDelete( true ); + OPimTodo todo; + + for ( uint i = 0; i < count; ++i ) { + uid = effective[i]; + todo = find( uid, effective, i, Frontend::Forward ); + /* + * If isOverdue but in the 'normal' range we will fill + * the hash so we won't have duplicates in OPimBackendOccurrence + */ + if ( todo.isOverdue() ) + hash.insert( uid, new int(6) ); + OPimBackendOccurrence oc = todo.hasStartDate() ? + OPimBackendOccurrence( todo.startDate(), + todo.dueDate(), uid ) : + OPimBackendOccurrence( todo.dueDate(), uid, QString::null ); + oc.setSummary( todo.summary() ); + lst.append( oc ); + } + + /* + * Create the OverDue items but skip + * the already handled Records + */ + if ( !overdue.isEmpty() ) { + QDate today = QDate::currentDate(); + QDate dueDate = (start >= today && today <= end ) ? today : start; + count = overdue.count(); + for ( uint i = 0; i < count; ++i ) { + uid = overdue[i]; + if (!hash.find( uid ) ) + continue; + todo = find( uid, overdue, i, Frontend::Forward ); + lst.append( OPimBackendOccurrence(dueDate, uid, todo.summary() ) ); + } + } + + return lst; +} } |