summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
authorzecke <zecke>2002-09-20 17:28:20 (UTC)
committer zecke <zecke>2002-09-20 17:28:20 (UTC)
commit55dd11ddae09bfc4907399c473f0387c135fdae6 (patch) (side-by-side diff)
tree69d52e2f0e1030bbdcbf518f0a334ff4861500fa /libopie2/opiepim
parent40df2487c53a5ab484d33d619f5b6ed449c0b485 (diff)
downloadopie-55dd11ddae09bfc4907399c473f0387c135fdae6.zip
opie-55dd11ddae09bfc4907399c473f0387c135fdae6.tar.gz
opie-55dd11ddae09bfc4907399c473f0387c135fdae6.tar.bz2
OTodo know is the first implementation of OPimRecord
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp26
-rw-r--r--libopie2/opiepim/core/opimrecord.h4
-rw-r--r--libopie2/opiepim/otodo.cpp265
-rw-r--r--libopie2/opiepim/otodo.h26
4 files changed, 95 insertions, 226 deletions
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index 95de1df..d8f73c7 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -4,3 +4,5 @@ OPimRecord::OPimRecord( int uid )
: Qtopia::Record() {
+
setUid( uid );
+ /* assign a new UID */
if ( uid == 1 )
@@ -10,3 +12,3 @@ OPimRecord::~OPimRecord() {
}
-OPimRecord::OPimRecord( OPimRecord& rec )
+OPimRecord::OPimRecord( const OPimRecord& rec )
: Qtopia::Record( rec )
@@ -17,5 +19,5 @@ OPimRecord::OPimRecord( OPimRecord& rec )
OPimRecord &OPimRecord::operator=( const OPimRecord& rec) {
- /* how do I call the parent copy operator ? */
- setUid( rec.uid() );
- setCategories( rec.categories() );
+ Qtopia::Record::operator=( rec );
+ m_relations = rec.m_relations;
+
return *this;
@@ -27,3 +29,3 @@ QStringList OPimRecord::categoryNames()const {
}
-void OPimRecord::setCategoryName( const QStringList& ) {
+void OPimRecord::setCategoryNames( const QStringList& ) {
@@ -90 +92,15 @@ void OPimRecord::setRelations( const QString& app, QArray<int> ids ) {
}
+QString OPimRecord::crossToString()const {
+ QString str;
+ QMap<QString, QArray<int> >::ConstIterator it;
+ for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
+ QArray<int> id = it.data();
+ for ( uint i = 0; i < id.size(); ++i ) {
+ str += it.key() + "," + QString::number( i ) + ";";
+ }
+ }
+ str = str.remove( str.length()-1, 1); // strip the ;
+ //qWarning("IDS " + str );
+
+ return str;
+}
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h
index a0e0413..18112d4 100644
--- a/libopie2/opiepim/core/opimrecord.h
+++ b/libopie2/opiepim/core/opimrecord.h
@@ -21,3 +21,3 @@ public:
*/
- OPimRecord( OPimRecord& rec );
+ OPimRecord( const OPimRecord& rec );
@@ -36,3 +36,3 @@ public:
*/
- void setCategoryName( const QStringList& );
+ void setCategoryNames( const QStringList& );
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp
index d8e0447..3c93838 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/otodo.cpp
@@ -13,10 +13,9 @@
-#include "todoevent.h"
-using namespace Opie;
-Qtopia::UidGen ToDoEvent::m_gen;
+#include "otodo.h"
-struct ToDoEvent::ToDoEventData : public QShared {
- ToDoEventData() : QShared() {
+
+struct OTodo::OTodoData : public QShared {
+ OTodoData() : QShared() {
};
@@ -31,4 +30,2 @@ struct ToDoEvent::ToDoEventData : public QShared {
QMap<QString, QString> extra;
- QMap<QString, QArray<int> > relations;
- int uid;
ushort prog;
@@ -38,4 +35,4 @@ struct ToDoEvent::ToDoEventData : public QShared {
-ToDoEvent::ToDoEvent(const ToDoEvent &event )
- : data( event.data )
+OTodo::OTodo(const OTodo &event )
+ : OPimRecord( event ), data( event.data )
{
@@ -44,5 +41,5 @@ ToDoEvent::ToDoEvent(const ToDoEvent &event )
}
-ToDoEvent::~ToDoEvent() {
+OTodo::~OTodo() {
if ( data->deref() ) {
- //qWarning("ToDoEvent::dereffing");
+ //qWarning("OTodo::dereffing");
delete data;
@@ -52,3 +49,3 @@ ToDoEvent::~ToDoEvent() {
-ToDoEvent::ToDoEvent(bool completed, int priority,
+OTodo::OTodo(bool completed, int priority,
const QStringList &category,
@@ -58,5 +55,7 @@ ToDoEvent::ToDoEvent(bool completed, int priority,
bool hasDate, QDate date, int uid )
+ : OPimRecord( uid )
{
- //qWarning("ToDoEventData");
- data = new ToDoEventData;
+ //qWarning("OTodoData");
+ setCategories( idsFromString( category.join(";") ) );
+ data = new OTodoData;
data->date = date;
@@ -65,3 +64,2 @@ ToDoEvent::ToDoEvent(bool completed, int priority,
data->priority = priority;
- data->category = category;
data->sum = summary;
@@ -69,9 +67,2 @@ ToDoEvent::ToDoEvent(bool completed, int priority,
data->desc = Qtopia::simplifyMultiLineSpace(description );
- if (uid == -1 ) {
- uid = m_gen.generate();
-
- }// generated the ids
- m_gen.store( uid );
-
- data->uid = uid;
data->hasAlarmDateTime = false;
@@ -79,10 +70,3 @@ ToDoEvent::ToDoEvent(bool completed, int priority,
}
-QArray<int> ToDoEvent::categories()const
-{
- qWarning( "ToDoEvent:cats" + data->category.join(";") );
- QArray<int> array(data->category.count() ); // currently the datebook can be only in one category
- array = Qtopia::Record::idsFromString( data->category.join(";") );
- return array;
-}
-bool ToDoEvent::match( const QRegExp &regExp )const
+bool OTodo::match( const QRegExp &regExp )const
{
@@ -94,2 +78,4 @@ bool ToDoEvent::match( const QRegExp &regExp )const
return true;
+ }else if(data->sum.find( regExp ) != -1 ) {
+ return true;
}
@@ -97,3 +83,3 @@ bool ToDoEvent::match( const QRegExp &regExp )const
}
-bool ToDoEvent::isCompleted() const
+bool OTodo::isCompleted() const
{
@@ -101,3 +87,3 @@ bool ToDoEvent::isCompleted() const
}
-bool ToDoEvent::hasDueDate() const
+bool OTodo::hasDueDate() const
{
@@ -105,3 +91,3 @@ bool ToDoEvent::hasDueDate() const
}
-bool ToDoEvent::hasAlarmDateTime() const
+bool OTodo::hasAlarmDateTime() const
{
@@ -109,3 +95,3 @@ bool ToDoEvent::hasAlarmDateTime() const
}
-int ToDoEvent::priority()const
+int OTodo::priority()const
{
@@ -113,11 +99,3 @@ int ToDoEvent::priority()const
}
-QStringList ToDoEvent::allCategories()const
-{
- return data->category;
-}
-QString ToDoEvent::extra(const QString& )const
-{
- return QString::null;
-}
-QString ToDoEvent::summary() const
+QString OTodo::summary() const
{
@@ -125,3 +103,3 @@ QString ToDoEvent::summary() const
}
-ushort ToDoEvent::progress() const
+ushort OTodo::progress() const
{
@@ -129,38 +107,3 @@ ushort ToDoEvent::progress() const
}
-QStringList ToDoEvent::relatedApps() const
-{
- QStringList list;
- QMap<QString, QArray<int> >::ConstIterator it;
- for ( it = data->relations.begin(); it != data->relations.end(); ++it ) {
- list << it.key();
- }
- return list;
-}
-QArray<int> ToDoEvent::relations( const QString& app)const
-{
- QArray<int> tmp;
- QMap<QString, QArray<int> >::ConstIterator it;
- it = data->relations.find( app);
- if ( it != data->relations.end() )
- tmp = it.data();
- return tmp;
-}
-void ToDoEvent::insertCategory(const QString &str )
-{
- changeOrModify();
- qWarning("insert category;" + str );
- data->category.append( str );
-}
-void ToDoEvent::clearCategories()
-{
- changeOrModify();
- data->category.clear();
-}
-void ToDoEvent::setCategories(const QStringList &list )
-{
- changeOrModify();
- qWarning("set categories" + list.join(";") );
- data->category = list;
-}
-QDate ToDoEvent::dueDate()const
+QDate OTodo::dueDate()const
{
@@ -169,3 +112,3 @@ QDate ToDoEvent::dueDate()const
-QDateTime ToDoEvent::alarmDateTime() const
+QDateTime OTodo::alarmDateTime() const
{
@@ -174,3 +117,3 @@ QDateTime ToDoEvent::alarmDateTime() const
-QString ToDoEvent::description()const
+QString OTodo::description()const
{
@@ -178,3 +121,3 @@ QString ToDoEvent::description()const
}
-void ToDoEvent::setCompleted( bool completed )
+void OTodo::setCompleted( bool completed )
{
@@ -183,3 +126,3 @@ void ToDoEvent::setCompleted( bool completed )
}
-void ToDoEvent::setHasDueDate( bool hasDate )
+void OTodo::setHasDueDate( bool hasDate )
{
@@ -188,3 +131,3 @@ void ToDoEvent::setHasDueDate( bool hasDate )
}
-void ToDoEvent::setHasAlarmDateTime( bool hasAlarmDateTime )
+void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime )
{
@@ -193,3 +136,3 @@ void ToDoEvent::setHasAlarmDateTime( bool hasAlarmDateTime )
}
-void ToDoEvent::setDescription(const QString &desc )
+void OTodo::setDescription(const QString &desc )
{
@@ -198,7 +141,3 @@ void ToDoEvent::setDescription(const QString &desc )
}
-void ToDoEvent::setExtra( const QString&, const QString& )
-{
-
-}
-void ToDoEvent::setSummary( const QString& sum )
+void OTodo::setSummary( const QString& sum )
{
@@ -207,10 +146,3 @@ void ToDoEvent::setSummary( const QString& sum )
}
-void ToDoEvent::setCategory( const QString &cat )
-{
- changeOrModify();
- //qWarning("setCategory %s", cat.latin1() );
- data->category.clear();
- data->category << cat;
-}
-void ToDoEvent::setPriority(int prio )
+void OTodo::setPriority(int prio )
{
@@ -219,3 +151,3 @@ void ToDoEvent::setPriority(int prio )
}
-void ToDoEvent::setDueDate( QDate date )
+void OTodo::setDueDate( QDate date )
{
@@ -224,3 +156,3 @@ void ToDoEvent::setDueDate( QDate date )
}
-void ToDoEvent::setAlarmDateTime( const QDateTime& alarm )
+void OTodo::setAlarmDateTime( const QDateTime& alarm )
{
@@ -229,47 +161,3 @@ void ToDoEvent::setAlarmDateTime( const QDateTime& alarm )
}
-void ToDoEvent::addRelated( const QString &app, int id )
-{
- changeOrModify();
-
- QMap<QString, QArray<int> >::Iterator it;
- QArray<int> tmp;
- it = data->relations.find( app );
- if ( it == data->relations.end() ) {
- tmp.resize(1 );
- tmp[0] = id;
- }else{
- tmp = it.data();
- tmp.resize( tmp.size() + 1 );
- tmp[tmp.size() - 1] = id;
- }
- data->relations.replace( app, tmp );
-}
-void ToDoEvent::addRelated(const QString& app, QArray<int> ids )
-{
- changeOrModify();
-
- QMap<QString, QArray<int> >::Iterator it;
- QArray<int> tmp;
- it = data->relations.find( app);
- if ( it == data->relations.end() ) { // not there
- /** tmp.resize( ids.size() ); stupid??
- */
- tmp = ids;
- }else{
- tmp = it.data();
- int offset = tmp.size()-1;
- tmp.resize( tmp.size() + ids.size() );
- for (uint i = 0; i < ids.size(); i++ ) {
- tmp[offset+i] = ids[i];
- }
-
- }
- data->relations.replace( app, tmp );
-}
-void ToDoEvent::clearRelated( const QString& app )
-{
- changeOrModify();
- data->relations.remove( app );
-}
-bool ToDoEvent::isOverdue( )
+bool OTodo::isOverdue( )
{
@@ -279,3 +167,3 @@ bool ToDoEvent::isOverdue( )
}
-void ToDoEvent::setProgress(ushort progress )
+void OTodo::setProgress(ushort progress )
{
@@ -284,2 +172,5 @@ void ToDoEvent::setProgress(ushort progress )
}
+QString OTodo::toShortText() const {
+ return summary();
+}
/*!
@@ -287,3 +178,3 @@ void ToDoEvent::setProgress(ushort progress )
*/
-QString ToDoEvent::richText() const
+QString OTodo::toRichText() const
{
@@ -318,20 +209,6 @@ QString ToDoEvent::richText() const
- // Open database of all categories and get the list of
- // the categories this todoevent belongs to.
- // Then print them...
- // I am not sure whether there is no better way doing this !?
- Categories catdb;
- bool firstloop = true;
- catdb.load( categoryFileName() );
- catlist = allCategories();
-
text += "<b>" + QObject::tr( "Category:") + "</b> ";
- for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) {
- if (!firstloop){
- text += ", ";
- }
- firstloop = false;
- text += catdb.label ("todo", (*it).toInt());
- }
+ text += categoryNames().join(", ");
text += "<br>";
+
return text;
@@ -339,3 +216,3 @@ QString ToDoEvent::richText() const
-bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
+bool OTodo::operator<( const OTodo &toDoEvent )const{
if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
@@ -351,3 +228,3 @@ bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
}
-bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
+bool OTodo::operator<=(const OTodo &toDoEvent )const
{
@@ -364,3 +241,3 @@ bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
}
-bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
+bool OTodo::operator>(const OTodo &toDoEvent )const
{
@@ -377,3 +254,3 @@ bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
}
-bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
+bool OTodo::operator>=(const OTodo &toDoEvent )const
{
@@ -390,3 +267,3 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
}
-bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
+bool OTodo::operator==(const OTodo &toDoEvent )const
{
@@ -406,3 +283,3 @@ bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
}
-void ToDoEvent::deref() {
+void OTodo::deref() {
@@ -415,4 +292,5 @@ void ToDoEvent::deref() {
}
-ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
+OTodo &OTodo::operator=(const OTodo &item )
{
+ OPimRecord::operator=( item );
//qWarning("operator= ref ");
@@ -421,5 +299,2 @@ ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
- data = item.data;
-
-
return *this;
@@ -427,7 +302,7 @@ ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
-QMap<int, QString> ToDoEvent::toMap() const {
+QMap<int, QString> OTodo::toMap() const {
QMap<int, QString> map;
- map.insert( Uid, QString::number( data->uid ) );
- map.insert( Category, data->category.join(";") );
+ map.insert( Uid, QString::number( uid() ) );
+ map.insert( Category, idsToString( categories() ) );
map.insert( HasDate, QString::number( data->hasDate ) );
@@ -448,28 +323,3 @@ QMap<int, QString> ToDoEvent::toMap() const {
-
-QString ToDoEvent::crossToString()const {
- QString str;
- QMap<QString, QArray<int> >::ConstIterator it;
- for (it = data->relations.begin(); it != data->relations.end(); ++it ) {
- QArray<int> id = it.data();
- for ( uint i = 0; i < id.size(); ++i ) {
- str += it.key() + "," + QString::number( i ) + ";";
- }
- }
- str = str.remove( str.length()-1, 1); // strip the ;
- //qWarning("IDS " + str );
-
- return str;
-}
-int ToDoEvent::uid()const {
- return data->uid;
-}
-void ToDoEvent::setUid( int id ) {
- if ( id == -1 )
- id = m_gen.generate();
- m_gen.store(id );
- changeOrModify();
- data->uid = id;
-}
-QMap<QString, QString> ToDoEvent::extras()const {
+QMap<QString, QString> OTodo::toExtraMap()const {
return data->extra;
@@ -481,3 +331,3 @@ QMap<QString, QString> ToDoEvent::extras()const {
*/
-void ToDoEvent::changeOrModify() {
+void OTodo::changeOrModify() {
if ( data->count != 1 ) {
@@ -485,3 +335,3 @@ void ToDoEvent::changeOrModify() {
data->deref();
- ToDoEventData* d2 = new ToDoEventData();
+ OTodoData* d2 = new OTodoData();
copy(data, d2 );
@@ -490,3 +340,3 @@ void ToDoEvent::changeOrModify() {
}
-void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) {
+void OTodo::copy( OTodoData* src, OTodoData* dest ) {
dest->date = src->date;
@@ -495,3 +345,2 @@ void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) {
dest->priority = src->priority;
- dest->category = src->category;
dest->desc = src->desc;
@@ -499,4 +348,2 @@ void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) {
dest->extra = src->extra;
- dest->relations = src->relations;
- dest->uid = src->uid;
dest->prog = src->prog;
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h
index 429108a..e1729db 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/otodo.h
@@ -20,3 +20,3 @@ class OTodo : public OPimRecord {
public:
- typedef QValueList<ToDoEvent> ValueList;
+ typedef QValueList<OTodo> ValueList;
enum RecordFields {
@@ -120,2 +120,9 @@ public:
+ /**
+ * reimplementation
+ */
+ QString type()const;
+ QString toShortText()const;
+ QMap<QString, QString> toExtraMap()const;
+ QString recordField(int id )const;
@@ -185,3 +192,3 @@ public:
bool operator==(const OTodo &toDoEvent )const;
- ToDoEvent &operator=(const OTodo &toDoEvent );
+ OTodo &operator=(const OTodo &toDoEvent );
@@ -189,3 +196,3 @@ public:
class OTodoPrivate;
- struct OTodoEventData;
+ struct OTodoData;
@@ -194,11 +201,10 @@ public:
void copy( OTodoData* src, OTodoData* dest );
- ToDoEventPrivate *d;
- ToDoEventData *data;
+ OTodoPrivate *d;
+ OTodoData *data;
- static Qtopia::UidGen m_gen;
-};
- inline bool ToDoEvent::operator!=(const ToDoEvent &toDoEvent )const {
- return !(*this == toDoEvent);
- }
};
+inline bool OTodo::operator!=(const OTodo &toDoEvent )const {
+ return !(*this == toDoEvent);
+}
+