summaryrefslogtreecommitdiff
path: root/libopie/pim
Side-by-side diff
Diffstat (limited to 'libopie/pim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/libopie.pro6
-rw-r--r--libopie/pim/orecordlist.h2
-rw-r--r--libopie/pim/orecur.cpp127
-rw-r--r--libopie/pim/orecur.h54
-rw-r--r--libopie/pim/otodoaccesssql.cpp2
5 files changed, 188 insertions, 3 deletions
diff --git a/libopie/pim/libopie.pro b/libopie/pim/libopie.pro
index 1dacbe7..b871374 100644
--- a/libopie/pim/libopie.pro
+++ b/libopie/pim/libopie.pro
@@ -22,17 +22,18 @@ HEADERS = ofontmenu.h \
pim/orecordlist.h \
pim/opimaccesstemplate.h \
pim/opimaccessbackend.h \
pim/otodoaccess.h \
pim/otodacessbackend.h \
pim/ocontact.h \
pim/ocontactaccess.h \
pim/ocontactaccessbackend.h \
- pim/ocontactaccessbackend_xml.h
+ pim/ocontactaccessbackend_xml.h \
+ pim/orecord.h
SOURCES = ofontmenu.cc \
xmltree.cc \
tododb.cpp todoevent.cpp \
todovcalresource.cpp colordialog.cpp \
colorpopupmenu.cpp oclickablelabel.cpp \
oprocctrl.cpp oprocess.cpp \
odevice.cpp otimepicker.cpp \
@@ -45,17 +46,18 @@ SOURCES = ofontmenu.cc \
ofileselector/olister.cpp \
ofileselector/olocallister.cpp \
ofileselector/ofileselectormain.cpp \
pim/otodo.cpp \
pim/opimrecord.cpp \
pim/otodoaccess.cpp \
pim/otodoaccessbackend.cpp \
pim/ocontact.cpp \
- pim/ocontactaccess.cpp
+ pim/ocontactaccess.cpp \
+ pim/orecord.cpp
TARGET = opie
INCLUDEPATH += $(OPIEDIR)/include
DESTDIR = $(QTDIR)/lib$(PROJMAK)
#VERSION = 1.0.0
INTERFACES = otimepickerbase.ui
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 5404910..e377447 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -255,16 +255,18 @@ ORecordList<T>::Iterator ORecordList<T>::end() {
return it;
}
template <class T>
uint ORecordList<T>::count()const {
return m_ids.count();
}
template <class T>
T ORecordList<T>::operator[]( uint i ) {
+ if ( i < 0 || (i+1) > m_ids.count() )
+ return T();
/* forward */
return m_acc->find( m_ids[i], m_ids, i );
}
template <class T>
int ORecordList<T>::uidAt( uint i ) {
return m_ids[i];
}
#endif
diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp
new file mode 100644
index 0000000..6c81f8f
--- a/dev/null
+++ b/libopie/pim/orecur.cpp
@@ -0,0 +1,127 @@
+#include <qshared.h>
+
+#include <qtopia/timeconversion.h>
+
+#include "orecur.h"
+
+struct ORecur::Data : public QShared {
+ Data() : QShared() {
+ type = ORecur::NoRepeat;
+ freq = -1;
+ days = 0;
+ pos = 0;
+ create = -1;
+ hasEnd = FALSE;
+ end = 0;
+ }
+ char days; // Q_UINT8 for 8 seven days;)
+ ORecur::RepeatType type;
+ int freq;
+ int pos;
+ bool hasEnd : 1;
+ time_t end;
+ time_t create;
+};
+
+
+ORecur::ORecur() {
+ data = new Data;
+}
+ORecur::ORecur( const ORecur& rec)
+ : data( rec.data )
+{
+ data->ref();
+}
+ORecur::~ORecur() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+void ORecur::deref() {
+ if ( data->deref() ) {
+ delete data;
+ data = 0l;
+ }
+}
+bool ORecur::operator==( const ORecur& )const {
+ return false;
+}
+ORecur &ORecur::operator=( const ORecur& re) {
+ re.data->ref();
+ deref();
+ data = re.data;
+
+ return *this;
+}
+ORecur::RepeatType ORecur::type()const{
+ return data->type;
+}
+int ORecur::frequency()const {
+ return data->freq;
+}
+int ORecur::position()const {
+ return data->pos;
+}
+char ORecur::days() const{
+ return data->days;
+}
+bool ORecur::hasEndDate()const {
+ return data->hasEnd;
+}
+QDate ORecur::endDate()const {
+ return TimeConversion::fromUTC( data->end ).date();
+}
+time_t ORecur::endDateUTC()const {
+ return data->end;
+}
+time_t ORecur::createTime()const {
+ return data->create;
+}
+void ORecur::setType( const RepeatType& z) {
+ checkOrModify();
+ data->type = z;
+}
+void ORecur::setFrequency( int freq ) {
+ checkOrModify();
+ data->freq = freq;
+}
+void ORecur::setPosition( int pos ) {
+ checkOrModify();
+ data->pos = pos;
+}
+void ORecur::setDays( char c ) {
+ checkOrModify();
+ data->days = c;
+}
+void ORecur::setEndDate( const QDate& dt) {
+ checkOrModify();
+ data->end = TimeConversion::toUTC( dt );
+}
+void ORecur::setEndDateUTC( time_t t) {
+ checkOrModify();
+ data->end = t;
+}
+void ORecur::setCreateTime( time_t t) {
+ checkOrModify();
+ data->create = t;
+}
+void ORecur::setHasEndDate( bool b) {
+ checkOrModify();
+ data->hasEnd = b;
+}
+void ORecur::checkOrModify() {
+ if ( data->count != 1 ) {
+ data->deref();
+ Data* d2 = new Data;
+ d2->days = data->days;
+ d2->type = data->type;
+ d2->freq = data->freq;
+ d2->pos = data->pos;
+ d2->hasEnd = data->hasEnd;
+ d2->end = data->end;
+ d2->create = data->create;
+ data = d2;
+ }
+}
+
diff --git a/libopie/pim/orecur.h b/libopie/pim/orecur.h
new file mode 100644
index 0000000..89258f8
--- a/dev/null
+++ b/libopie/pim/orecur.h
@@ -0,0 +1,54 @@
+/*
+ * GPL from TT
+ */
+
+#ifndef OPIE_RECUR_H
+#define OPIE_RECUR_H
+
+#include <sys/types.h>
+
+#include <qdatetime.h>
+
+
+
+class ORecur {
+public:
+ enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
+ MonthlyDate, Yearly };
+ enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
+ FRI = 0x10, SAT = 0x20, SUN = 0x40 };
+ ORecur();
+ ORecur( const ORecur& );
+ ~ORecur();
+
+ ORecur &operator=( const ORecur& );
+ bool operator==(const ORecur& )const;
+ RepeatType type()const;
+ int frequency()const;
+ int position()const;
+ char days()const;
+ bool hasEndDate()const;
+ QDate endDate()const;
+ time_t endDateUTC()const;
+ time_t createTime()const;
+
+ void setType( const RepeatType& );
+ void setFrequency( int freq );
+ void setPosition( int pos );
+ void setDays( char c);
+ void setEndDate( const QDate& dt );
+ void setEndDateUTC( time_t );
+ void setCreateTime( time_t );
+ void setHasEndDate( bool b );
+private:
+ void deref();
+ inline void checkOrModify();
+
+
+ class Data;
+ Data* data;
+ class ORecurPrivate;
+ ORecurPrivate *d;
+};
+
+#endif
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp
index 8c2ea3a..761d7d8 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/libopie/pim/otodoaccesssql.cpp
@@ -416,17 +416,17 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
/* completed */
case 0:
query += "completed";
break;
case 1:
query += "priority";
break;
case 2:
- query += "description";
+ query += "summary";
break;
case 3:
query += "DueDate";
break;
}
if ( !asc ) {
qWarning("not ascending!");