-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 127 | ||||
-rw-r--r-- | libopie2/opiepim/core/orecur.h | 54 | ||||
-rw-r--r-- | libopie2/opiepim/orecordlist.h | 2 |
4 files changed, 184 insertions, 1 deletions
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index 8c2ea3a..761d7d8 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp | |||
@@ -421,7 +421,7 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder, | |||
421 | query += "priority"; | 421 | query += "priority"; |
422 | break; | 422 | break; |
423 | case 2: | 423 | case 2: |
424 | query += "description"; | 424 | query += "summary"; |
425 | break; | 425 | break; |
426 | case 3: | 426 | case 3: |
427 | query += "DueDate"; | 427 | query += "DueDate"; |
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp new file mode 100644 index 0000000..6c81f8f --- a/dev/null +++ b/libopie2/opiepim/core/orecur.cpp | |||
@@ -0,0 +1,127 @@ | |||
1 | #include <qshared.h> | ||
2 | |||
3 | #include <qtopia/timeconversion.h> | ||
4 | |||
5 | #include "orecur.h" | ||
6 | |||
7 | struct ORecur::Data : public QShared { | ||
8 | Data() : QShared() { | ||
9 | type = ORecur::NoRepeat; | ||
10 | freq = -1; | ||
11 | days = 0; | ||
12 | pos = 0; | ||
13 | create = -1; | ||
14 | hasEnd = FALSE; | ||
15 | end = 0; | ||
16 | } | ||
17 | char days; // Q_UINT8 for 8 seven days;) | ||
18 | ORecur::RepeatType type; | ||
19 | int freq; | ||
20 | int pos; | ||
21 | bool hasEnd : 1; | ||
22 | time_t end; | ||
23 | time_t create; | ||
24 | }; | ||
25 | |||
26 | |||
27 | ORecur::ORecur() { | ||
28 | data = new Data; | ||
29 | } | ||
30 | ORecur::ORecur( const ORecur& rec) | ||
31 | : data( rec.data ) | ||
32 | { | ||
33 | data->ref(); | ||
34 | } | ||
35 | ORecur::~ORecur() { | ||
36 | if ( data->deref() ) { | ||
37 | delete data; | ||
38 | data = 0l; | ||
39 | } | ||
40 | } | ||
41 | void ORecur::deref() { | ||
42 | if ( data->deref() ) { | ||
43 | delete data; | ||
44 | data = 0l; | ||
45 | } | ||
46 | } | ||
47 | bool ORecur::operator==( const ORecur& )const { | ||
48 | return false; | ||
49 | } | ||
50 | ORecur &ORecur::operator=( const ORecur& re) { | ||
51 | re.data->ref(); | ||
52 | deref(); | ||
53 | data = re.data; | ||
54 | |||
55 | return *this; | ||
56 | } | ||
57 | ORecur::RepeatType ORecur::type()const{ | ||
58 | return data->type; | ||
59 | } | ||
60 | int ORecur::frequency()const { | ||
61 | return data->freq; | ||
62 | } | ||
63 | int ORecur::position()const { | ||
64 | return data->pos; | ||
65 | } | ||
66 | char ORecur::days() const{ | ||
67 | return data->days; | ||
68 | } | ||
69 | bool ORecur::hasEndDate()const { | ||
70 | return data->hasEnd; | ||
71 | } | ||
72 | QDate ORecur::endDate()const { | ||
73 | return TimeConversion::fromUTC( data->end ).date(); | ||
74 | } | ||
75 | time_t ORecur::endDateUTC()const { | ||
76 | return data->end; | ||
77 | } | ||
78 | time_t ORecur::createTime()const { | ||
79 | return data->create; | ||
80 | } | ||
81 | void ORecur::setType( const RepeatType& z) { | ||
82 | checkOrModify(); | ||
83 | data->type = z; | ||
84 | } | ||
85 | void ORecur::setFrequency( int freq ) { | ||
86 | checkOrModify(); | ||
87 | data->freq = freq; | ||
88 | } | ||
89 | void ORecur::setPosition( int pos ) { | ||
90 | checkOrModify(); | ||
91 | data->pos = pos; | ||
92 | } | ||
93 | void ORecur::setDays( char c ) { | ||
94 | checkOrModify(); | ||
95 | data->days = c; | ||
96 | } | ||
97 | void ORecur::setEndDate( const QDate& dt) { | ||
98 | checkOrModify(); | ||
99 | data->end = TimeConversion::toUTC( dt ); | ||
100 | } | ||
101 | void ORecur::setEndDateUTC( time_t t) { | ||
102 | checkOrModify(); | ||
103 | data->end = t; | ||
104 | } | ||
105 | void ORecur::setCreateTime( time_t t) { | ||
106 | checkOrModify(); | ||
107 | data->create = t; | ||
108 | } | ||
109 | void ORecur::setHasEndDate( bool b) { | ||
110 | checkOrModify(); | ||
111 | data->hasEnd = b; | ||
112 | } | ||
113 | void ORecur::checkOrModify() { | ||
114 | if ( data->count != 1 ) { | ||
115 | data->deref(); | ||
116 | Data* d2 = new Data; | ||
117 | d2->days = data->days; | ||
118 | d2->type = data->type; | ||
119 | d2->freq = data->freq; | ||
120 | d2->pos = data->pos; | ||
121 | d2->hasEnd = data->hasEnd; | ||
122 | d2->end = data->end; | ||
123 | d2->create = data->create; | ||
124 | data = d2; | ||
125 | } | ||
126 | } | ||
127 | |||
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h new file mode 100644 index 0000000..89258f8 --- a/dev/null +++ b/libopie2/opiepim/core/orecur.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * GPL from TT | ||
3 | */ | ||
4 | |||
5 | #ifndef OPIE_RECUR_H | ||
6 | #define OPIE_RECUR_H | ||
7 | |||
8 | #include <sys/types.h> | ||
9 | |||
10 | #include <qdatetime.h> | ||
11 | |||
12 | |||
13 | |||
14 | class ORecur { | ||
15 | public: | ||
16 | enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, | ||
17 | MonthlyDate, Yearly }; | ||
18 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, | ||
19 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; | ||
20 | ORecur(); | ||
21 | ORecur( const ORecur& ); | ||
22 | ~ORecur(); | ||
23 | |||
24 | ORecur &operator=( const ORecur& ); | ||
25 | bool operator==(const ORecur& )const; | ||
26 | RepeatType type()const; | ||
27 | int frequency()const; | ||
28 | int position()const; | ||
29 | char days()const; | ||
30 | bool hasEndDate()const; | ||
31 | QDate endDate()const; | ||
32 | time_t endDateUTC()const; | ||
33 | time_t createTime()const; | ||
34 | |||
35 | void setType( const RepeatType& ); | ||
36 | void setFrequency( int freq ); | ||
37 | void setPosition( int pos ); | ||
38 | void setDays( char c); | ||
39 | void setEndDate( const QDate& dt ); | ||
40 | void setEndDateUTC( time_t ); | ||
41 | void setCreateTime( time_t ); | ||
42 | void setHasEndDate( bool b ); | ||
43 | private: | ||
44 | void deref(); | ||
45 | inline void checkOrModify(); | ||
46 | |||
47 | |||
48 | class Data; | ||
49 | Data* data; | ||
50 | class ORecurPrivate; | ||
51 | ORecurPrivate *d; | ||
52 | }; | ||
53 | |||
54 | #endif | ||
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index 5404910..e377447 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -260,6 +260,8 @@ return m_ids.count(); | |||
260 | } | 260 | } |
261 | template <class T> | 261 | template <class T> |
262 | T ORecordList<T>::operator[]( uint i ) { | 262 | T ORecordList<T>::operator[]( uint i ) { |
263 | if ( i < 0 || (i+1) > m_ids.count() ) | ||
264 | return T(); | ||
263 | /* forward */ | 265 | /* forward */ |
264 | return m_acc->find( m_ids[i], m_ids, i ); | 266 | return m_acc->find( m_ids[i], m_ids, i ); |
265 | } | 267 | } |