summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
Diffstat (limited to 'libopie') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/otodoaccess.cpp6
-rw-r--r--libopie/pim/otodoaccess.h15
-rw-r--r--libopie/pim/otodoaccessbackend.h3
-rw-r--r--libopie/pim/otodoaccessvcal.cpp20
-rw-r--r--libopie/pim/otodoaccessvcal.h2
-rw-r--r--libopie/pim/otodoaccessxml.cpp16
-rw-r--r--libopie/pim/otodoaccessxml.h2
7 files changed, 63 insertions, 1 deletions
diff --git a/libopie/pim/otodoaccess.cpp b/libopie/pim/otodoaccess.cpp
index 5e89a1b..37f6fbc 100644
--- a/libopie/pim/otodoaccess.cpp
+++ b/libopie/pim/otodoaccess.cpp
@@ -33,24 +33,30 @@ OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
List lis( ints, this );
return lis;
}
OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start,
bool includeNoDates ) {
return effectiveToDos( start, QDate::currentDate(),
includeNoDates );
}
OTodoAccess::List OTodoAccess::overDue() {
List lis( m_todoBackEnd->overDue(), this );
return lis;
}
/* sort order */
OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
filter, cat );
OTodoAccess::List list( ints, this );
return list;
}
void OTodoAccess::removeAllCompleted() {
m_todoBackEnd->removeAllCompleted();
}
+QBitArray OTodoAccess::backendSupport( const QString& ) const{
+ return m_todoBackEnd->supports();
+}
+bool OTodoAccess::backendSupports( int attr, const QString& ar) const{
+ return backendSupport(ar).testBit( attr );
+}
diff --git a/libopie/pim/otodoaccess.h b/libopie/pim/otodoaccess.h
index a626731..916923f 100644
--- a/libopie/pim/otodoaccess.h
+++ b/libopie/pim/otodoaccess.h
@@ -51,40 +51,55 @@ public:
bool includeNoDates = true );
/**
* return overdue OTodos
*/
List overDue();
/**
*
*/
List sorted( bool ascending, int sortOrder, int sortFilter, int cat );
/**
* merge a list of OTodos into
* the resource
*/
void mergeWith( const QValueList<OTodo>& );
/**
* delete all already completed items
*/
void removeAllCompleted();
+ /**
+ * request information about what a backend supports.
+ * Supports in the sense of beeing able to store.
+ * This is related to the enum in OTodo
+ *
+ * @param backend Will be used in the future when we support multiple backend
+ */
+ QBitArray backendSupport( const QString& backend = QString::null )const;
+
+ /**
+ * see above but for a specefic attribute. This method was added for convience
+ * @param attr The attribute to be queried for
+ * @param backend Will be used in the future when we support multiple backends
+ */
+ bool backendSupports( int attr, const QString& backend = QString::null )const;
signals:
/**
* if the OTodoAccess was changed
*/
void changed( const OTodoAccess* );
void changed( const OTodoAccess*, int uid );
void added( const OTodoAccess*, int uid );
void removed( const OTodoAccess*, int uid );
private:
int m_cat;
OTodoAccessBackend* m_todoBackEnd;
class OTodoAccessPrivate;
OTodoAccessPrivate* d;
};
#endif
diff --git a/libopie/pim/otodoaccessbackend.h b/libopie/pim/otodoaccessbackend.h
index 7944a2c..05e8ca9 100644
--- a/libopie/pim/otodoaccessbackend.h
+++ b/libopie/pim/otodoaccessbackend.h
@@ -1,21 +1,24 @@
#ifndef OPIE_TODO_ACCESS_BACKEND_H
#define OPIE_TODO_ACCESS_BACKEND_H
+#include <qbitarray.h>
+
#include "otodo.h"
#include "opimaccessbackend.h"
class OTodoAccessBackend : public OPimAccessBackend<OTodo> {
public:
OTodoAccessBackend();
~OTodoAccessBackend();
virtual QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
bool includeNoDates ) = 0;
virtual QArray<int> overDue() = 0;
virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
int cat ) = 0;
virtual void removeAllCompleted() = 0;
+ virtual QBitArray supports()const = 0;
};
#endif
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp
index 2136283..9bc16c6 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/libopie/pim/otodoaccessvcal.cpp
@@ -178,24 +178,44 @@ QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
QArray<int> OTodoAccessVCal::allRecords()const {
QArray<int> ar( m_map.count() );
QMap<int, OTodo>::ConstIterator it;
int i = 0;
for ( it = m_map.begin(); it != m_map.end(); ++it ) {
ar[i] = it.key();
i++;
}
return ar;
}
QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
QArray<int> ar(0);
return ar;
}
QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
const QDate& ,
bool ) {
QArray<int> ar(0);
return ar;
}
QArray<int> OTodoAccessVCal::overDue() {
QArray<int> ar(0);
return ar;
}
+QBitArray OTodoAccessVCal::supports()const {
+ static QBitArray ar = sup();
+
+ return ar;
+}
+QBitArray OTodoAccessVCal::sup() {
+ QBitArray ar ( OTodo::CompletedDate +1 );
+ ar.fill( true );
+
+ ar[OTodo::CrossReference] = false;
+ ar[OTodo::State ] = false;
+ ar[OTodo::Reminders] = false;
+ ar[OTodo::Notifiers] = false;
+ ar[OTodo::Maintainer] = false;
+ ar[OTodo::Progress] = false;
+ ar[OTodo::Alarms ] = false;
+ ar[OTodo::Recurrence] = false;
+
+ return ar;
+}
diff --git a/libopie/pim/otodoaccessvcal.h b/libopie/pim/otodoaccessvcal.h
index a90ee9c..489416b 100644
--- a/libopie/pim/otodoaccessvcal.h
+++ b/libopie/pim/otodoaccessvcal.h
@@ -6,32 +6,34 @@
class OTodoAccessVCal : public OTodoAccessBackend {
public:
OTodoAccessVCal(const QString& );
~OTodoAccessVCal();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
bool includeNoDates );
QArray<int> overDue();
QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
int cat );
OTodo find(int uid)const;
void clear();
bool add( const OTodo& );
bool remove( int uid );
bool replace( const OTodo& );
void removeAllCompleted();
+ virtual QBitArray supports()const;
private:
+ static QBitArray sup();
bool m_dirty : 1;
QString m_file;
QMap<int, OTodo> m_map;
};
#endif
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp
index 71e8787..55f268b 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/libopie/pim/otodoaccessxml.cpp
@@ -643,33 +643,47 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
qWarning("item is not overdue but bOnly checked");
continue;
}
if ((*it).isCompleted() && comp ) {
qWarning("completed continue!");
continue;
}
OTodoXMLContainer* con = new OTodoXMLContainer();
con->todo = (*it);
vector.insert(item, con );
item++;
}
qWarning("XXX %d Items added", item);
vector.resize( item );
/* sort it now */
vector.sort();
/* now get the uids */
QArray<int> array( vector.count() );
for (uint i= 0; i < vector.count(); i++ ) {
array[i] = ( vector.at(i) )->todo.uid();
}
- qWarning("array count = %d %d", array.count(), vector.count() );
return array;
};
void OTodoAccessXML::removeAllCompleted() {
for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
if ( (*it).isCompleted() )
m_events.remove( it );
}
}
+QBitArray OTodoAccessXML::supports()const {
+ static QBitArray ar = sup();
+ return ar;
+}
+QBitArray OTodoAccessXML::sup() {
+ QBitArray ar( OTodo::CompletedDate +1 );
+ ar.fill( true );
+ ar[OTodo::CrossReference] = false;
+ ar[OTodo::State ] = false;
+ ar[OTodo::Reminders] = false;
+ ar[OTodo::Notifiers] = false;
+ ar[OTodo::Maintainer] = false;
+
+ return ar;
+}
diff --git a/libopie/pim/otodoaccessxml.h b/libopie/pim/otodoaccessxml.h
index 1032c92..cc4a16f 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/libopie/pim/otodoaccessxml.h
@@ -18,40 +18,42 @@ public:
OTodoAccessXML( const QString& appName,
const QString& fileName = QString::null );
~OTodoAccessXML();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
OTodo find( int uid )const;
void clear();
bool add( const OTodo& );
bool remove( int uid );
void removeAllCompleted();
bool replace( const OTodo& );
/* our functions */
QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
bool includeNoDates );
QArray<int> overDue();
QArray<int> sorted( bool asc, int sortOrder,
int sortFilter, int cat );
+ QBitArray supports()const;
private:
+ static QBitArray sup();
void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& );
QString toString( const OTodo& )const;
QString toString( const QArray<int>& ints ) const;
QMap<int, OTodo> m_events;
QString m_file;
QString m_app;
bool m_opened : 1;
bool m_changed : 1;
class OTodoAccessXMLPrivate;
OTodoAccessXMLPrivate* d;
int m_year, m_month, m_day;
};
#endif