-rw-r--r-- | libopie/pim/ocontactfields.cpp | 209 | ||||
-rw-r--r-- | libopie/pim/ocontactfields.h | 7 | ||||
-rw-r--r-- | libopie/pim/opimnotifymanager.cpp | 72 | ||||
-rw-r--r-- | libopie/pim/opimnotifymanager.h | 24 | ||||
-rw-r--r-- | libopie/pim/otodoaccesssql.cpp | 48 | ||||
-rw-r--r-- | libopie/pim/otodoaccesssql.h | 2 | ||||
-rw-r--r-- | libopie/pim/otodoaccessxml.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.cpp | 48 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccesssql.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 72 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.h | 24 | ||||
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 209 | ||||
-rw-r--r-- | libopie2/opiepim/ocontactfields.h | 7 |
14 files changed, 492 insertions, 236 deletions
diff --git a/libopie/pim/ocontactfields.cpp b/libopie/pim/ocontactfields.cpp index 7206f0d..0f08a5a 100644 --- a/libopie/pim/ocontactfields.cpp +++ b/libopie/pim/ocontactfields.cpp | |||
@@ -11,24 +11,33 @@ | |||
11 | 11 | ||
12 | /*! | 12 | /*! |
13 | \internal | 13 | \internal |
14 | Returns a list of details field names for a contact. | 14 | Returns a list of personal field names for a contact. |
15 | */ | 15 | */ |
16 | QStringList OContactFields::untrdetailsfields( bool sorted ) | 16 | QStringList OContactFields::personalfields( bool sorted, bool translated ) |
17 | { | 17 | { |
18 | QStringList list; | 18 | QStringList list; |
19 | QMap<int, QString> mapIdToStr = idToUntrFields(); | 19 | QMap<int, QString> mapIdToStr; |
20 | if ( translated ) | ||
21 | mapIdToStr = idToTrFields(); | ||
22 | else | ||
23 | mapIdToStr = idToUntrFields(); | ||
20 | 24 | ||
21 | list.append( mapIdToStr[ Qtopia::Office ] ); | 25 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); |
22 | list.append( mapIdToStr[ Qtopia::Profession ] ); | 26 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); |
23 | list.append( mapIdToStr[ Qtopia::Assistant ] ); | ||
24 | list.append( mapIdToStr[ Qtopia::Manager ] ); | ||
25 | 27 | ||
26 | list.append( mapIdToStr[ Qtopia::Spouse ] ); | 28 | list.append( mapIdToStr[ Qtopia::Title ] ); |
27 | list.append( mapIdToStr[ Qtopia::Gender ] ); | 29 | list.append( mapIdToStr[ Qtopia::FirstName ] ); |
28 | list.append( mapIdToStr[ Qtopia::Birthday ] ); | 30 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); |
29 | list.append( mapIdToStr[ Qtopia::Anniversary ] ); | 31 | list.append( mapIdToStr[ Qtopia::LastName ] ); |
30 | list.append( mapIdToStr[ Qtopia::Nickname ] ); | 32 | list.append( mapIdToStr[ Qtopia::Suffix ] ); |
31 | list.append( mapIdToStr[ Qtopia::Children ] ); | 33 | list.append( mapIdToStr[ Qtopia::FileAs ] ); |
34 | |||
35 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | ||
36 | list.append( mapIdToStr[ Qtopia::Department ] ); | ||
37 | list.append( mapIdToStr[ Qtopia::Company ] ); | ||
38 | |||
39 | list.append( mapIdToStr[ Qtopia::Notes ] ); | ||
40 | list.append( mapIdToStr[ Qtopia::Groups ] ); | ||
32 | 41 | ||
33 | if (sorted) list.sort(); | 42 | if (sorted) list.sort(); |
34 | return list; | 43 | return list; |
@@ -36,12 +45,16 @@ QStringList OContactFields::untrdetailsfields( bool sorted ) | |||
36 | 45 | ||
37 | /*! | 46 | /*! |
38 | \internal | 47 | \internal |
39 | Returns a translated list of details field names for a contact. | 48 | Returns a list of details field names for a contact. |
40 | */ | 49 | */ |
41 | QStringList OContactFields::trdetailsfields( bool sorted ) | 50 | QStringList OContactFields::detailsfields( bool sorted, bool translated ) |
42 | { | 51 | { |
43 | QStringList list; | 52 | QStringList list; |
44 | QMap<int, QString> mapIdToStr = idToTrFields(); | 53 | QMap<int, QString> mapIdToStr; |
54 | if ( translated ) | ||
55 | mapIdToStr = idToTrFields(); | ||
56 | else | ||
57 | mapIdToStr = idToUntrFields(); | ||
45 | 58 | ||
46 | list.append( mapIdToStr[Qtopia::Office] ); | 59 | list.append( mapIdToStr[Qtopia::Office] ); |
47 | list.append( mapIdToStr[Qtopia::Profession] ); | 60 | list.append( mapIdToStr[Qtopia::Profession] ); |
@@ -59,45 +72,18 @@ QStringList OContactFields::trdetailsfields( bool sorted ) | |||
59 | return list; | 72 | return list; |
60 | } | 73 | } |
61 | 74 | ||
62 | |||
63 | /*! | ||
64 | \internal | ||
65 | Returns a translated list of phone field names for a contact. | ||
66 | */ | ||
67 | QStringList OContactFields::trphonefields( bool sorted ) | ||
68 | { | ||
69 | QStringList list; | ||
70 | QMap<int, QString> mapIdToStr = idToTrFields(); | ||
71 | |||
72 | list.append( mapIdToStr[Qtopia::BusinessPhone] ); | ||
73 | list.append( mapIdToStr[Qtopia::BusinessFax] ); | ||
74 | list.append( mapIdToStr[Qtopia::BusinessMobile] ); | ||
75 | list.append( mapIdToStr[Qtopia::BusinessPager] ); | ||
76 | list.append( mapIdToStr[Qtopia::BusinessWebPage] ); | ||
77 | |||
78 | list.append( mapIdToStr[Qtopia::DefaultEmail] ); | ||
79 | list.append( mapIdToStr[Qtopia::Emails] ); | ||
80 | |||
81 | list.append( mapIdToStr[Qtopia::HomePhone] ); | ||
82 | list.append( mapIdToStr[Qtopia::HomeFax] ); | ||
83 | list.append( mapIdToStr[Qtopia::HomeMobile] ); | ||
84 | // list.append( mapIdToStr[Qtopia::HomePager] ); | ||
85 | list.append( mapIdToStr[Qtopia::HomeWebPage] ); | ||
86 | |||
87 | if (sorted) list.sort(); | ||
88 | |||
89 | return list; | ||
90 | } | ||
91 | |||
92 | |||
93 | /*! | 75 | /*! |
94 | \internal | 76 | \internal |
95 | Returns a list of phone field names for a contact. | 77 | Returns a list of phone field names for a contact. |
96 | */ | 78 | */ |
97 | QStringList OContactFields::untrphonefields( bool sorted ) | 79 | QStringList OContactFields::phonefields( bool sorted, bool translated ) |
98 | { | 80 | { |
99 | QStringList list; | 81 | QStringList list; |
100 | QMap<int, QString> mapIdToStr = idToUntrFields(); | 82 | QMap<int, QString> mapIdToStr; |
83 | if ( translated ) | ||
84 | mapIdToStr = idToTrFields(); | ||
85 | else | ||
86 | mapIdToStr = idToUntrFields(); | ||
101 | 87 | ||
102 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); | 88 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); |
103 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); | 89 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); |
@@ -119,28 +105,22 @@ QStringList OContactFields::untrphonefields( bool sorted ) | |||
119 | return list; | 105 | return list; |
120 | } | 106 | } |
121 | 107 | ||
122 | |||
123 | /*! | 108 | /*! |
124 | \internal | 109 | \internal |
125 | Returns a translated list of field names for a contact. | 110 | Returns a list of field names for a contact. |
126 | */ | 111 | */ |
127 | QStringList OContactFields::trfields( bool sorted ) | 112 | QStringList OContactFields::fields( bool sorted, bool translated ) |
128 | { | 113 | { |
129 | QStringList list; | 114 | QStringList list; |
130 | QMap<int, QString> mapIdToStr = idToTrFields(); | 115 | QMap<int, QString> mapIdToStr; |
131 | 116 | if ( translated ) | |
132 | list.append( mapIdToStr[Qtopia::Title]); | 117 | mapIdToStr = idToTrFields(); |
133 | list.append( mapIdToStr[Qtopia::FirstName] ); | 118 | else |
134 | list.append( mapIdToStr[Qtopia::MiddleName] ); | 119 | mapIdToStr = idToUntrFields(); |
135 | list.append( mapIdToStr[Qtopia::LastName] ); | ||
136 | list.append( mapIdToStr[Qtopia::Suffix] ); | ||
137 | list.append( mapIdToStr[Qtopia::FileAs] ); | ||
138 | 120 | ||
139 | list.append( mapIdToStr[Qtopia::JobTitle] ); | 121 | list += personalfields( sorted, translated ); |
140 | list.append( mapIdToStr[Qtopia::Department] ); | ||
141 | list.append( mapIdToStr[Qtopia::Company] ); | ||
142 | 122 | ||
143 | list += trphonefields( sorted ); | 123 | list += phonefields( sorted, translated ); |
144 | 124 | ||
145 | list.append( mapIdToStr[Qtopia::BusinessStreet] ); | 125 | list.append( mapIdToStr[Qtopia::BusinessStreet] ); |
146 | list.append( mapIdToStr[Qtopia::BusinessCity] ); | 126 | list.append( mapIdToStr[Qtopia::BusinessCity] ); |
@@ -154,62 +134,91 @@ QStringList OContactFields::trfields( bool sorted ) | |||
154 | list.append( mapIdToStr[Qtopia::HomeZip] ); | 134 | list.append( mapIdToStr[Qtopia::HomeZip] ); |
155 | list.append( mapIdToStr[Qtopia::HomeCountry] ); | 135 | list.append( mapIdToStr[Qtopia::HomeCountry] ); |
156 | 136 | ||
157 | list += trdetailsfields( sorted ); | 137 | list += detailsfields( sorted, translated ); |
158 | |||
159 | list.append( mapIdToStr[Qtopia::Notes] ); | ||
160 | list.append( mapIdToStr[Qtopia::Groups] ); | ||
161 | 138 | ||
162 | if (sorted) list.sort(); | 139 | if (sorted) list.sort(); |
163 | 140 | ||
164 | return list; | 141 | return list; |
165 | } | 142 | } |
166 | 143 | ||
144 | |||
167 | /*! | 145 | /*! |
168 | \internal | 146 | \internal |
169 | Returns an untranslated list of field names for a contact. | 147 | Returns an untranslated list of personal field names for a contact. |
170 | */ | 148 | */ |
171 | QStringList OContactFields::untrfields( bool sorted ) | 149 | QStringList OContactFields::untrpersonalfields( bool sorted ) |
172 | { | 150 | { |
173 | QStringList list; | 151 | return personalfields( sorted, false ); |
174 | QMap<int, QString> mapIdToStr = idToUntrFields(); | 152 | } |
175 | 153 | ||
176 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); | ||
177 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); | ||
178 | 154 | ||
179 | list.append( mapIdToStr[ Qtopia::Title ] ); | 155 | /*! |
180 | list.append( mapIdToStr[ Qtopia::FirstName ] ); | 156 | \internal |
181 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); | 157 | Returns a translated list of personal field names for a contact. |
182 | list.append( mapIdToStr[ Qtopia::LastName ] ); | 158 | */ |
183 | list.append( mapIdToStr[ Qtopia::Suffix ] ); | 159 | QStringList OContactFields::trpersonalfields( bool sorted ) |
184 | list.append( mapIdToStr[ Qtopia::FileAs ] ); | 160 | { |
161 | return personalfields( sorted, true ); | ||
162 | } | ||
185 | 163 | ||
186 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | ||
187 | list.append( mapIdToStr[ Qtopia::Department ] ); | ||
188 | list.append( mapIdToStr[ Qtopia::Company ] ); | ||
189 | 164 | ||
190 | list += untrphonefields( sorted ); | 165 | /*! |
166 | \internal | ||
167 | Returns an untranslated list of details field names for a contact. | ||
168 | */ | ||
169 | QStringList OContactFields::untrdetailsfields( bool sorted ) | ||
170 | { | ||
171 | return detailsfields( sorted, false ); | ||
172 | } | ||
191 | 173 | ||
192 | list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); | ||
193 | list.append( mapIdToStr[ Qtopia::BusinessCity ] ); | ||
194 | list.append( mapIdToStr[ Qtopia::BusinessState ] ); | ||
195 | list.append( mapIdToStr[ Qtopia::BusinessZip ] ); | ||
196 | list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); | ||
197 | 174 | ||
198 | list.append( mapIdToStr[ Qtopia::HomeStreet ] ); | 175 | /*! |
199 | list.append( mapIdToStr[ Qtopia::HomeCity ] ); | 176 | \internal |
200 | list.append( mapIdToStr[ Qtopia::HomeState ] ); | 177 | Returns a translated list of details field names for a contact. |
201 | list.append( mapIdToStr[ Qtopia::HomeZip ] ); | 178 | */ |
202 | list.append( mapIdToStr[ Qtopia::HomeCountry ] ); | 179 | QStringList OContactFields::trdetailsfields( bool sorted ) |
180 | { | ||
181 | return detailsfields( sorted, true ); | ||
182 | } | ||
203 | 183 | ||
204 | list += untrdetailsfields( sorted ); | ||
205 | 184 | ||
206 | list.append( mapIdToStr[ Qtopia::Notes ] ); | 185 | /*! |
207 | list.append( mapIdToStr[ Qtopia::Groups ] ); | 186 | \internal |
187 | Returns a translated list of phone field names for a contact. | ||
188 | */ | ||
189 | QStringList OContactFields::trphonefields( bool sorted ) | ||
190 | { | ||
191 | return phonefields( sorted, true ); | ||
192 | } | ||
208 | 193 | ||
209 | if (sorted) list.sort(); | 194 | /*! |
195 | \internal | ||
196 | Returns an untranslated list of phone field names for a contact. | ||
197 | */ | ||
198 | QStringList OContactFields::untrphonefields( bool sorted ) | ||
199 | { | ||
200 | return phonefields( sorted, false ); | ||
201 | } | ||
210 | 202 | ||
211 | return list; | 203 | |
204 | /*! | ||
205 | \internal | ||
206 | Returns a translated list of field names for a contact. | ||
207 | */ | ||
208 | QStringList OContactFields::trfields( bool sorted ) | ||
209 | { | ||
210 | return fields( sorted, true ); | ||
212 | } | 211 | } |
212 | |||
213 | /*! | ||
214 | \internal | ||
215 | Returns an untranslated list of field names for a contact. | ||
216 | */ | ||
217 | QStringList OContactFields::untrfields( bool sorted ) | ||
218 | { | ||
219 | return fields( sorted, false ); | ||
220 | } | ||
221 | |||
213 | QMap<int, QString> OContactFields::idToTrFields() | 222 | QMap<int, QString> OContactFields::idToTrFields() |
214 | { | 223 | { |
215 | QMap<int, QString> ret_map; | 224 | QMap<int, QString> ret_map; |
@@ -357,6 +366,8 @@ QMap<QString, int> OContactFields::trFieldsToId() | |||
357 | return ret_map; | 366 | return ret_map; |
358 | } | 367 | } |
359 | 368 | ||
369 | /* ======================================================================= */ | ||
370 | |||
360 | QMap<QString, int> OContactFields::untrFieldsToId() | 371 | QMap<QString, int> OContactFields::untrFieldsToId() |
361 | { | 372 | { |
362 | QMap<int, QString> idtostr = idToUntrFields(); | 373 | QMap<int, QString> idtostr = idToUntrFields(); |
diff --git a/libopie/pim/ocontactfields.h b/libopie/pim/ocontactfields.h index 9f6171b..f105de7 100644 --- a/libopie/pim/ocontactfields.h +++ b/libopie/pim/ocontactfields.h | |||
@@ -43,6 +43,13 @@ class OContactFields{ | |||
43 | bool changedFieldOrder; | 43 | bool changedFieldOrder; |
44 | 44 | ||
45 | public: | 45 | public: |
46 | static QStringList personalfields( bool sorted = true, bool translated = false ); | ||
47 | static QStringList phonefields( bool sorted = true, bool translated = false ); | ||
48 | static QStringList detailsfields( bool sorted = true, bool translated = false ); | ||
49 | static QStringList fields( bool sorted = true, bool translated = false ); | ||
50 | |||
51 | static QStringList trpersonalfields( bool sorted = true ); | ||
52 | static QStringList untrpersonalfields( bool sorted = true ); | ||
46 | static QStringList trphonefields( bool sorted = true ); | 53 | static QStringList trphonefields( bool sorted = true ); |
47 | static QStringList untrphonefields( bool sorted = true ); | 54 | static QStringList untrphonefields( bool sorted = true ); |
48 | static QStringList trdetailsfields( bool sorted = true ); | 55 | static QStringList trdetailsfields( bool sorted = true ); |
diff --git a/libopie/pim/opimnotifymanager.cpp b/libopie/pim/opimnotifymanager.cpp index 06b5987..53ad4c3 100644 --- a/libopie/pim/opimnotifymanager.cpp +++ b/libopie/pim/opimnotifymanager.cpp | |||
@@ -1,5 +1,9 @@ | |||
1 | #include "opimnotifymanager.h" | 1 | #include "opimnotifymanager.h" |
2 | 2 | ||
3 | #include "oconversion.h" | ||
4 | |||
5 | #include <qstringlist.h> | ||
6 | |||
3 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | 7 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) |
4 | : m_rem( rem ), m_al( al ) | 8 | : m_rem( rem ), m_al( al ) |
5 | {} | 9 | {} |
@@ -67,8 +71,76 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) { | |||
67 | void OPimNotifyManager::deregister( const OPimNotify& ) { | 71 | void OPimNotifyManager::deregister( const OPimNotify& ) { |
68 | 72 | ||
69 | } | 73 | } |
74 | |||
70 | bool OPimNotifyManager::isEmpty()const { | 75 | bool OPimNotifyManager::isEmpty()const { |
71 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); | 76 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); |
72 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; | 77 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; |
73 | else return false; | 78 | else return false; |
74 | } | 79 | } |
80 | |||
81 | // Taken from otodoaccessxml.. | ||
82 | QString OPimNotifyManager::alarmsToString() const | ||
83 | { | ||
84 | QString str; | ||
85 | |||
86 | OPimNotifyManager::Alarms alarms = m_al; | ||
87 | if ( !alarms.isEmpty() ) { | ||
88 | QStringList als; | ||
89 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | ||
90 | for ( ; it != alarms.end(); ++it ) { | ||
91 | /* only if time is valid */ | ||
92 | if ( (*it).dateTime().isValid() ) { | ||
93 | als << OConversion::dateTimeToString( (*it).dateTime() ) | ||
94 | + ":" + QString::number( (*it).duration() ) | ||
95 | + ":" + QString::number( (*it).sound() ) | ||
96 | + ":"; | ||
97 | } | ||
98 | } | ||
99 | // now write the list | ||
100 | qWarning("als: %s", als.join("____________").latin1() ); | ||
101 | str = als.join(";"); | ||
102 | } | ||
103 | |||
104 | return str; | ||
105 | } | ||
106 | QString OPimNotifyManager::remindersToString() const | ||
107 | { | ||
108 | QString str; | ||
109 | |||
110 | OPimNotifyManager::Reminders reminders = m_rem; | ||
111 | if (!reminders.isEmpty() ) { | ||
112 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | ||
113 | QStringList records; | ||
114 | for ( ; it != reminders.end(); ++it ) { | ||
115 | records << QString::number( (*it).recordUid() ); | ||
116 | } | ||
117 | str = records.join(";"); | ||
118 | } | ||
119 | |||
120 | return str; | ||
121 | } | ||
122 | |||
123 | void OPimNotifyManager::alarmsFromString( const QString& str ) | ||
124 | { | ||
125 | QStringList als = QStringList::split(";", str ); | ||
126 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | ||
127 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | ||
128 | qWarning("alarm: %s", alarm.join("___").latin1() ); | ||
129 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), | ||
130 | OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | ||
131 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), | ||
132 | alarm[1].toInt() ); | ||
133 | add( al ); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | void OPimNotifyManager::remindersFromString( const QString& str ) | ||
138 | { | ||
139 | |||
140 | QStringList rems = QStringList::split(";", str ); | ||
141 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | ||
142 | OPimReminder rem( (*it).toInt() ); | ||
143 | add( rem ); | ||
144 | } | ||
145 | |||
146 | } | ||
diff --git a/libopie/pim/opimnotifymanager.h b/libopie/pim/opimnotifymanager.h index 0ac30a1..48410e7 100644 --- a/libopie/pim/opimnotifymanager.h +++ b/libopie/pim/opimnotifymanager.h | |||
@@ -39,9 +39,31 @@ public: | |||
39 | */ | 39 | */ |
40 | void deregister( const OPimNotify& ); | 40 | void deregister( const OPimNotify& ); |
41 | 41 | ||
42 | |||
43 | bool isEmpty()const; | 42 | bool isEmpty()const; |
44 | 43 | ||
44 | /** | ||
45 | * Return all alarms as string | ||
46 | */ | ||
47 | QString alarmsToString() const; | ||
48 | /** | ||
49 | * Return all notifiers as string | ||
50 | */ | ||
51 | QString remindersToString() const; | ||
52 | |||
53 | /** | ||
54 | * Convert string to alarms | ||
55 | * @param str String created by alarmsToString() | ||
56 | */ | ||
57 | void alarmsFromString( const QString& str ); | ||
58 | |||
59 | /** | ||
60 | * Convert string to reminders | ||
61 | * @param str String created by remindersToString() | ||
62 | */ | ||
63 | void remindersFromString( const QString& str ); | ||
64 | |||
65 | |||
66 | |||
45 | private: | 67 | private: |
46 | Reminders m_rem; | 68 | Reminders m_rem; |
47 | Alarms m_al; | 69 | Alarms m_al; |
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp index d255c66..ebd03bb 100644 --- a/libopie/pim/otodoaccesssql.cpp +++ b/libopie/pim/otodoaccesssql.cpp | |||
@@ -9,6 +9,9 @@ | |||
9 | #include <opie2/osqlquery.h> | 9 | #include <opie2/osqlquery.h> |
10 | 10 | ||
11 | #include "otodoaccesssql.h" | 11 | #include "otodoaccesssql.h" |
12 | #include "opimstate.h" | ||
13 | #include "opimnotifymanager.h" | ||
14 | #include "orecur.h" | ||
12 | 15 | ||
13 | /* | 16 | /* |
14 | * first some query | 17 | * first some query |
@@ -120,7 +123,8 @@ namespace { | |||
120 | QString qu; | 123 | QString qu; |
121 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; | 124 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; |
122 | qu += "description, summary, priority, DueDate, progress , state, "; | 125 | qu += "description, summary, priority, DueDate, progress , state, "; |
123 | qu += "Recurrence, notifiers, maintainer, startdate, completeddate)"; | 126 | qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);"; |
127 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; | ||
124 | return qu; | 128 | return qu; |
125 | } | 129 | } |
126 | 130 | ||
@@ -181,11 +185,20 @@ namespace { | |||
181 | + QString::number(month) | 185 | + QString::number(month) |
182 | + "-" + QString::number( day ) + "'" + "," | 186 | + "-" + QString::number( day ) + "'" + "," |
183 | + QString::number( m_todo.progress() ) + "," | 187 | + QString::number( m_todo.progress() ) + "," |
184 | + "''" + "," // state (conversion needed) | 188 | + QString::number( m_todo.state().state() ) + "," |
185 | // + QString::number( m_todo.state() ) + "," | 189 | + "'" + m_todo.recurrence().toString() + "'"+ ","; |
186 | + "''" + "," // Recurrence (conversion needed) | 190 | |
187 | + "''" + "," // Notifiers (conversion needed) | 191 | if ( m_todo.hasNotifiers() ) { |
188 | + "''" + "," // Maintainers (conversion needed) | 192 | OPimNotifyManager manager = m_todo.notifiers(); |
193 | qu += "'" + manager.remindersToString() + "'" + "," | ||
194 | + "'" + manager.alarmsToString() + "'" + ","; | ||
195 | } | ||
196 | else{ | ||
197 | qu += QString( "''" ) + "," | ||
198 | + "''" + ","; | ||
199 | } | ||
200 | |||
201 | qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) | ||
189 | + "'" + QString::number(sYear) + "-" | 202 | + "'" + QString::number(sYear) + "-" |
190 | + QString::number(sMonth) | 203 | + QString::number(sMonth) |
191 | + "-" + QString::number(sDay) + "'" + "," | 204 | + "-" + QString::number(sDay) + "'" + "," |
@@ -531,6 +544,17 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | |||
531 | if ( hasCompletedDate ) | 544 | if ( hasCompletedDate ) |
532 | to.setCompletedDate( completedDate ); | 545 | to.setCompletedDate( completedDate ); |
533 | 546 | ||
547 | OPimNotifyManager& manager = to.notifiers(); | ||
548 | manager.alarmsFromString( item.data("alarms") ); | ||
549 | manager.remindersFromString( item.data("reminders") ); | ||
550 | |||
551 | OPimState pimState; | ||
552 | pimState.setState( QString( item.data("state") ).toInt() ); | ||
553 | to.setState( pimState ); | ||
554 | |||
555 | // Recurrence not supported yet | ||
556 | // to.setRecurrence( | ||
557 | |||
534 | return to; | 558 | return to; |
535 | } | 559 | } |
536 | OTodo OTodoAccessBackendSQL::todo( int uid )const { | 560 | OTodo OTodoAccessBackendSQL::todo( int uid )const { |
@@ -621,18 +645,10 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const | |||
621 | } | 645 | } |
622 | QBitArray OTodoAccessBackendSQL::supports()const { | 646 | QBitArray OTodoAccessBackendSQL::supports()const { |
623 | 647 | ||
624 | QBitArray ar( OTodo::CompletedDate + 1 ); | 648 | return sup(); |
625 | ar.fill( true ); | ||
626 | ar[OTodo::CrossReference] = false; | ||
627 | ar[OTodo::State ] = false; | ||
628 | ar[OTodo::Reminders] = false; | ||
629 | ar[OTodo::Notifiers] = false; | ||
630 | ar[OTodo::Maintainer] = false; | ||
631 | |||
632 | return ar; | ||
633 | } | 649 | } |
634 | 650 | ||
635 | QBitArray OTodoAccessBackendSQL::sup() { | 651 | QBitArray OTodoAccessBackendSQL::sup() const{ |
636 | 652 | ||
637 | QBitArray ar( OTodo::CompletedDate + 1 ); | 653 | QBitArray ar( OTodo::CompletedDate + 1 ); |
638 | ar.fill( true ); | 654 | ar.fill( true ); |
diff --git a/libopie/pim/otodoaccesssql.h b/libopie/pim/otodoaccesssql.h index 77d8b77..1c55567 100644 --- a/libopie/pim/otodoaccesssql.h +++ b/libopie/pim/otodoaccesssql.h | |||
@@ -44,7 +44,7 @@ private: | |||
44 | inline OTodo todo( OSQLResultItem& )const; | 44 | inline OTodo todo( OSQLResultItem& )const; |
45 | inline QArray<int> uids( const OSQLResult& )const; | 45 | inline QArray<int> uids( const OSQLResult& )const; |
46 | OTodo todo( int uid )const; | 46 | OTodo todo( int uid )const; |
47 | QBitArray sup(); | 47 | QBitArray sup() const; |
48 | 48 | ||
49 | QAsciiDict<int> m_dict; | 49 | QAsciiDict<int> m_dict; |
50 | OSQLDriver* m_driver; | 50 | OSQLDriver* m_driver; |
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index f688735..4a5cb33 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp | |||
@@ -568,7 +568,7 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
568 | 568 | ||
569 | /* | 569 | /* |
570 | * save reminders and notifiers! | 570 | * save reminders and notifiers! |
571 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... | 571 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... |
572 | */ | 572 | */ |
573 | if ( ev.hasNotifiers() ) { | 573 | if ( ev.hasNotifiers() ) { |
574 | OPimNotifyManager manager = ev.notifiers(); | 574 | OPimNotifyManager manager = ev.notifiers(); |
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index d255c66..ebd03bb 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp | |||
@@ -9,6 +9,9 @@ | |||
9 | #include <opie2/osqlquery.h> | 9 | #include <opie2/osqlquery.h> |
10 | 10 | ||
11 | #include "otodoaccesssql.h" | 11 | #include "otodoaccesssql.h" |
12 | #include "opimstate.h" | ||
13 | #include "opimnotifymanager.h" | ||
14 | #include "orecur.h" | ||
12 | 15 | ||
13 | /* | 16 | /* |
14 | * first some query | 17 | * first some query |
@@ -120,7 +123,8 @@ namespace { | |||
120 | QString qu; | 123 | QString qu; |
121 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; | 124 | qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; |
122 | qu += "description, summary, priority, DueDate, progress , state, "; | 125 | qu += "description, summary, priority, DueDate, progress , state, "; |
123 | qu += "Recurrence, notifiers, maintainer, startdate, completeddate)"; | 126 | qu += "Recurrence, reminders, alarms, maintainer, startdate, completeddate);"; |
127 | qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; | ||
124 | return qu; | 128 | return qu; |
125 | } | 129 | } |
126 | 130 | ||
@@ -181,11 +185,20 @@ namespace { | |||
181 | + QString::number(month) | 185 | + QString::number(month) |
182 | + "-" + QString::number( day ) + "'" + "," | 186 | + "-" + QString::number( day ) + "'" + "," |
183 | + QString::number( m_todo.progress() ) + "," | 187 | + QString::number( m_todo.progress() ) + "," |
184 | + "''" + "," // state (conversion needed) | 188 | + QString::number( m_todo.state().state() ) + "," |
185 | // + QString::number( m_todo.state() ) + "," | 189 | + "'" + m_todo.recurrence().toString() + "'"+ ","; |
186 | + "''" + "," // Recurrence (conversion needed) | 190 | |
187 | + "''" + "," // Notifiers (conversion needed) | 191 | if ( m_todo.hasNotifiers() ) { |
188 | + "''" + "," // Maintainers (conversion needed) | 192 | OPimNotifyManager manager = m_todo.notifiers(); |
193 | qu += "'" + manager.remindersToString() + "'" + "," | ||
194 | + "'" + manager.alarmsToString() + "'" + ","; | ||
195 | } | ||
196 | else{ | ||
197 | qu += QString( "''" ) + "," | ||
198 | + "''" + ","; | ||
199 | } | ||
200 | |||
201 | qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) | ||
189 | + "'" + QString::number(sYear) + "-" | 202 | + "'" + QString::number(sYear) + "-" |
190 | + QString::number(sMonth) | 203 | + QString::number(sMonth) |
191 | + "-" + QString::number(sDay) + "'" + "," | 204 | + "-" + QString::number(sDay) + "'" + "," |
@@ -531,6 +544,17 @@ OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | |||
531 | if ( hasCompletedDate ) | 544 | if ( hasCompletedDate ) |
532 | to.setCompletedDate( completedDate ); | 545 | to.setCompletedDate( completedDate ); |
533 | 546 | ||
547 | OPimNotifyManager& manager = to.notifiers(); | ||
548 | manager.alarmsFromString( item.data("alarms") ); | ||
549 | manager.remindersFromString( item.data("reminders") ); | ||
550 | |||
551 | OPimState pimState; | ||
552 | pimState.setState( QString( item.data("state") ).toInt() ); | ||
553 | to.setState( pimState ); | ||
554 | |||
555 | // Recurrence not supported yet | ||
556 | // to.setRecurrence( | ||
557 | |||
534 | return to; | 558 | return to; |
535 | } | 559 | } |
536 | OTodo OTodoAccessBackendSQL::todo( int uid )const { | 560 | OTodo OTodoAccessBackendSQL::todo( int uid )const { |
@@ -621,18 +645,10 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const | |||
621 | } | 645 | } |
622 | QBitArray OTodoAccessBackendSQL::supports()const { | 646 | QBitArray OTodoAccessBackendSQL::supports()const { |
623 | 647 | ||
624 | QBitArray ar( OTodo::CompletedDate + 1 ); | 648 | return sup(); |
625 | ar.fill( true ); | ||
626 | ar[OTodo::CrossReference] = false; | ||
627 | ar[OTodo::State ] = false; | ||
628 | ar[OTodo::Reminders] = false; | ||
629 | ar[OTodo::Notifiers] = false; | ||
630 | ar[OTodo::Maintainer] = false; | ||
631 | |||
632 | return ar; | ||
633 | } | 649 | } |
634 | 650 | ||
635 | QBitArray OTodoAccessBackendSQL::sup() { | 651 | QBitArray OTodoAccessBackendSQL::sup() const{ |
636 | 652 | ||
637 | QBitArray ar( OTodo::CompletedDate + 1 ); | 653 | QBitArray ar( OTodo::CompletedDate + 1 ); |
638 | ar.fill( true ); | 654 | ar.fill( true ); |
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h index 77d8b77..1c55567 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.h +++ b/libopie2/opiepim/backend/otodoaccesssql.h | |||
@@ -44,7 +44,7 @@ private: | |||
44 | inline OTodo todo( OSQLResultItem& )const; | 44 | inline OTodo todo( OSQLResultItem& )const; |
45 | inline QArray<int> uids( const OSQLResult& )const; | 45 | inline QArray<int> uids( const OSQLResult& )const; |
46 | OTodo todo( int uid )const; | 46 | OTodo todo( int uid )const; |
47 | QBitArray sup(); | 47 | QBitArray sup() const; |
48 | 48 | ||
49 | QAsciiDict<int> m_dict; | 49 | QAsciiDict<int> m_dict; |
50 | OSQLDriver* m_driver; | 50 | OSQLDriver* m_driver; |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index f688735..4a5cb33 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -568,7 +568,7 @@ QString OTodoAccessXML::toString( const OTodo& ev )const { | |||
568 | 568 | ||
569 | /* | 569 | /* |
570 | * save reminders and notifiers! | 570 | * save reminders and notifiers! |
571 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER:DURATION:SOUND:.... | 571 | * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... |
572 | */ | 572 | */ |
573 | if ( ev.hasNotifiers() ) { | 573 | if ( ev.hasNotifiers() ) { |
574 | OPimNotifyManager manager = ev.notifiers(); | 574 | OPimNotifyManager manager = ev.notifiers(); |
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 06b5987..53ad4c3 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -1,5 +1,9 @@ | |||
1 | #include "opimnotifymanager.h" | 1 | #include "opimnotifymanager.h" |
2 | 2 | ||
3 | #include "oconversion.h" | ||
4 | |||
5 | #include <qstringlist.h> | ||
6 | |||
3 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | 7 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) |
4 | : m_rem( rem ), m_al( al ) | 8 | : m_rem( rem ), m_al( al ) |
5 | {} | 9 | {} |
@@ -67,8 +71,76 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) { | |||
67 | void OPimNotifyManager::deregister( const OPimNotify& ) { | 71 | void OPimNotifyManager::deregister( const OPimNotify& ) { |
68 | 72 | ||
69 | } | 73 | } |
74 | |||
70 | bool OPimNotifyManager::isEmpty()const { | 75 | bool OPimNotifyManager::isEmpty()const { |
71 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); | 76 | qWarning("is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); |
72 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; | 77 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; |
73 | else return false; | 78 | else return false; |
74 | } | 79 | } |
80 | |||
81 | // Taken from otodoaccessxml.. | ||
82 | QString OPimNotifyManager::alarmsToString() const | ||
83 | { | ||
84 | QString str; | ||
85 | |||
86 | OPimNotifyManager::Alarms alarms = m_al; | ||
87 | if ( !alarms.isEmpty() ) { | ||
88 | QStringList als; | ||
89 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | ||
90 | for ( ; it != alarms.end(); ++it ) { | ||
91 | /* only if time is valid */ | ||
92 | if ( (*it).dateTime().isValid() ) { | ||
93 | als << OConversion::dateTimeToString( (*it).dateTime() ) | ||
94 | + ":" + QString::number( (*it).duration() ) | ||
95 | + ":" + QString::number( (*it).sound() ) | ||
96 | + ":"; | ||
97 | } | ||
98 | } | ||
99 | // now write the list | ||
100 | qWarning("als: %s", als.join("____________").latin1() ); | ||
101 | str = als.join(";"); | ||
102 | } | ||
103 | |||
104 | return str; | ||
105 | } | ||
106 | QString OPimNotifyManager::remindersToString() const | ||
107 | { | ||
108 | QString str; | ||
109 | |||
110 | OPimNotifyManager::Reminders reminders = m_rem; | ||
111 | if (!reminders.isEmpty() ) { | ||
112 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | ||
113 | QStringList records; | ||
114 | for ( ; it != reminders.end(); ++it ) { | ||
115 | records << QString::number( (*it).recordUid() ); | ||
116 | } | ||
117 | str = records.join(";"); | ||
118 | } | ||
119 | |||
120 | return str; | ||
121 | } | ||
122 | |||
123 | void OPimNotifyManager::alarmsFromString( const QString& str ) | ||
124 | { | ||
125 | QStringList als = QStringList::split(";", str ); | ||
126 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | ||
127 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | ||
128 | qWarning("alarm: %s", alarm.join("___").latin1() ); | ||
129 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), | ||
130 | OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | ||
131 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), | ||
132 | alarm[1].toInt() ); | ||
133 | add( al ); | ||
134 | } | ||
135 | } | ||
136 | |||
137 | void OPimNotifyManager::remindersFromString( const QString& str ) | ||
138 | { | ||
139 | |||
140 | QStringList rems = QStringList::split(";", str ); | ||
141 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | ||
142 | OPimReminder rem( (*it).toInt() ); | ||
143 | add( rem ); | ||
144 | } | ||
145 | |||
146 | } | ||
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h index 0ac30a1..48410e7 100644 --- a/libopie2/opiepim/core/opimnotifymanager.h +++ b/libopie2/opiepim/core/opimnotifymanager.h | |||
@@ -39,9 +39,31 @@ public: | |||
39 | */ | 39 | */ |
40 | void deregister( const OPimNotify& ); | 40 | void deregister( const OPimNotify& ); |
41 | 41 | ||
42 | |||
43 | bool isEmpty()const; | 42 | bool isEmpty()const; |
44 | 43 | ||
44 | /** | ||
45 | * Return all alarms as string | ||
46 | */ | ||
47 | QString alarmsToString() const; | ||
48 | /** | ||
49 | * Return all notifiers as string | ||
50 | */ | ||
51 | QString remindersToString() const; | ||
52 | |||
53 | /** | ||
54 | * Convert string to alarms | ||
55 | * @param str String created by alarmsToString() | ||
56 | */ | ||
57 | void alarmsFromString( const QString& str ); | ||
58 | |||
59 | /** | ||
60 | * Convert string to reminders | ||
61 | * @param str String created by remindersToString() | ||
62 | */ | ||
63 | void remindersFromString( const QString& str ); | ||
64 | |||
65 | |||
66 | |||
45 | private: | 67 | private: |
46 | Reminders m_rem; | 68 | Reminders m_rem; |
47 | Alarms m_al; | 69 | Alarms m_al; |
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp index 7206f0d..0f08a5a 100644 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/libopie2/opiepim/ocontactfields.cpp | |||
@@ -11,24 +11,33 @@ | |||
11 | 11 | ||
12 | /*! | 12 | /*! |
13 | \internal | 13 | \internal |
14 | Returns a list of details field names for a contact. | 14 | Returns a list of personal field names for a contact. |
15 | */ | 15 | */ |
16 | QStringList OContactFields::untrdetailsfields( bool sorted ) | 16 | QStringList OContactFields::personalfields( bool sorted, bool translated ) |
17 | { | 17 | { |
18 | QStringList list; | 18 | QStringList list; |
19 | QMap<int, QString> mapIdToStr = idToUntrFields(); | 19 | QMap<int, QString> mapIdToStr; |
20 | if ( translated ) | ||
21 | mapIdToStr = idToTrFields(); | ||
22 | else | ||
23 | mapIdToStr = idToUntrFields(); | ||
20 | 24 | ||
21 | list.append( mapIdToStr[ Qtopia::Office ] ); | 25 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); |
22 | list.append( mapIdToStr[ Qtopia::Profession ] ); | 26 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); |
23 | list.append( mapIdToStr[ Qtopia::Assistant ] ); | ||
24 | list.append( mapIdToStr[ Qtopia::Manager ] ); | ||
25 | 27 | ||
26 | list.append( mapIdToStr[ Qtopia::Spouse ] ); | 28 | list.append( mapIdToStr[ Qtopia::Title ] ); |
27 | list.append( mapIdToStr[ Qtopia::Gender ] ); | 29 | list.append( mapIdToStr[ Qtopia::FirstName ] ); |
28 | list.append( mapIdToStr[ Qtopia::Birthday ] ); | 30 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); |
29 | list.append( mapIdToStr[ Qtopia::Anniversary ] ); | 31 | list.append( mapIdToStr[ Qtopia::LastName ] ); |
30 | list.append( mapIdToStr[ Qtopia::Nickname ] ); | 32 | list.append( mapIdToStr[ Qtopia::Suffix ] ); |
31 | list.append( mapIdToStr[ Qtopia::Children ] ); | 33 | list.append( mapIdToStr[ Qtopia::FileAs ] ); |
34 | |||
35 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | ||
36 | list.append( mapIdToStr[ Qtopia::Department ] ); | ||
37 | list.append( mapIdToStr[ Qtopia::Company ] ); | ||
38 | |||
39 | list.append( mapIdToStr[ Qtopia::Notes ] ); | ||
40 | list.append( mapIdToStr[ Qtopia::Groups ] ); | ||
32 | 41 | ||
33 | if (sorted) list.sort(); | 42 | if (sorted) list.sort(); |
34 | return list; | 43 | return list; |
@@ -36,12 +45,16 @@ QStringList OContactFields::untrdetailsfields( bool sorted ) | |||
36 | 45 | ||
37 | /*! | 46 | /*! |
38 | \internal | 47 | \internal |
39 | Returns a translated list of details field names for a contact. | 48 | Returns a list of details field names for a contact. |
40 | */ | 49 | */ |
41 | QStringList OContactFields::trdetailsfields( bool sorted ) | 50 | QStringList OContactFields::detailsfields( bool sorted, bool translated ) |
42 | { | 51 | { |
43 | QStringList list; | 52 | QStringList list; |
44 | QMap<int, QString> mapIdToStr = idToTrFields(); | 53 | QMap<int, QString> mapIdToStr; |
54 | if ( translated ) | ||
55 | mapIdToStr = idToTrFields(); | ||
56 | else | ||
57 | mapIdToStr = idToUntrFields(); | ||
45 | 58 | ||
46 | list.append( mapIdToStr[Qtopia::Office] ); | 59 | list.append( mapIdToStr[Qtopia::Office] ); |
47 | list.append( mapIdToStr[Qtopia::Profession] ); | 60 | list.append( mapIdToStr[Qtopia::Profession] ); |
@@ -59,45 +72,18 @@ QStringList OContactFields::trdetailsfields( bool sorted ) | |||
59 | return list; | 72 | return list; |
60 | } | 73 | } |
61 | 74 | ||
62 | |||
63 | /*! | ||
64 | \internal | ||
65 | Returns a translated list of phone field names for a contact. | ||
66 | */ | ||
67 | QStringList OContactFields::trphonefields( bool sorted ) | ||
68 | { | ||
69 | QStringList list; | ||
70 | QMap<int, QString> mapIdToStr = idToTrFields(); | ||
71 | |||
72 | list.append( mapIdToStr[Qtopia::BusinessPhone] ); | ||
73 | list.append( mapIdToStr[Qtopia::BusinessFax] ); | ||
74 | list.append( mapIdToStr[Qtopia::BusinessMobile] ); | ||
75 | list.append( mapIdToStr[Qtopia::BusinessPager] ); | ||
76 | list.append( mapIdToStr[Qtopia::BusinessWebPage] ); | ||
77 | |||
78 | list.append( mapIdToStr[Qtopia::DefaultEmail] ); | ||
79 | list.append( mapIdToStr[Qtopia::Emails] ); | ||
80 | |||
81 | list.append( mapIdToStr[Qtopia::HomePhone] ); | ||
82 | list.append( mapIdToStr[Qtopia::HomeFax] ); | ||
83 | list.append( mapIdToStr[Qtopia::HomeMobile] ); | ||
84 | // list.append( mapIdToStr[Qtopia::HomePager] ); | ||
85 | list.append( mapIdToStr[Qtopia::HomeWebPage] ); | ||
86 | |||
87 | if (sorted) list.sort(); | ||
88 | |||
89 | return list; | ||
90 | } | ||
91 | |||
92 | |||
93 | /*! | 75 | /*! |
94 | \internal | 76 | \internal |
95 | Returns a list of phone field names for a contact. | 77 | Returns a list of phone field names for a contact. |
96 | */ | 78 | */ |
97 | QStringList OContactFields::untrphonefields( bool sorted ) | 79 | QStringList OContactFields::phonefields( bool sorted, bool translated ) |
98 | { | 80 | { |
99 | QStringList list; | 81 | QStringList list; |
100 | QMap<int, QString> mapIdToStr = idToUntrFields(); | 82 | QMap<int, QString> mapIdToStr; |
83 | if ( translated ) | ||
84 | mapIdToStr = idToTrFields(); | ||
85 | else | ||
86 | mapIdToStr = idToUntrFields(); | ||
101 | 87 | ||
102 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); | 88 | list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); |
103 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); | 89 | list.append( mapIdToStr[ Qtopia::BusinessFax ] ); |
@@ -119,28 +105,22 @@ QStringList OContactFields::untrphonefields( bool sorted ) | |||
119 | return list; | 105 | return list; |
120 | } | 106 | } |
121 | 107 | ||
122 | |||
123 | /*! | 108 | /*! |
124 | \internal | 109 | \internal |
125 | Returns a translated list of field names for a contact. | 110 | Returns a list of field names for a contact. |
126 | */ | 111 | */ |
127 | QStringList OContactFields::trfields( bool sorted ) | 112 | QStringList OContactFields::fields( bool sorted, bool translated ) |
128 | { | 113 | { |
129 | QStringList list; | 114 | QStringList list; |
130 | QMap<int, QString> mapIdToStr = idToTrFields(); | 115 | QMap<int, QString> mapIdToStr; |
131 | 116 | if ( translated ) | |
132 | list.append( mapIdToStr[Qtopia::Title]); | 117 | mapIdToStr = idToTrFields(); |
133 | list.append( mapIdToStr[Qtopia::FirstName] ); | 118 | else |
134 | list.append( mapIdToStr[Qtopia::MiddleName] ); | 119 | mapIdToStr = idToUntrFields(); |
135 | list.append( mapIdToStr[Qtopia::LastName] ); | ||
136 | list.append( mapIdToStr[Qtopia::Suffix] ); | ||
137 | list.append( mapIdToStr[Qtopia::FileAs] ); | ||
138 | 120 | ||
139 | list.append( mapIdToStr[Qtopia::JobTitle] ); | 121 | list += personalfields( sorted, translated ); |
140 | list.append( mapIdToStr[Qtopia::Department] ); | ||
141 | list.append( mapIdToStr[Qtopia::Company] ); | ||
142 | 122 | ||
143 | list += trphonefields( sorted ); | 123 | list += phonefields( sorted, translated ); |
144 | 124 | ||
145 | list.append( mapIdToStr[Qtopia::BusinessStreet] ); | 125 | list.append( mapIdToStr[Qtopia::BusinessStreet] ); |
146 | list.append( mapIdToStr[Qtopia::BusinessCity] ); | 126 | list.append( mapIdToStr[Qtopia::BusinessCity] ); |
@@ -154,62 +134,91 @@ QStringList OContactFields::trfields( bool sorted ) | |||
154 | list.append( mapIdToStr[Qtopia::HomeZip] ); | 134 | list.append( mapIdToStr[Qtopia::HomeZip] ); |
155 | list.append( mapIdToStr[Qtopia::HomeCountry] ); | 135 | list.append( mapIdToStr[Qtopia::HomeCountry] ); |
156 | 136 | ||
157 | list += trdetailsfields( sorted ); | 137 | list += detailsfields( sorted, translated ); |
158 | |||
159 | list.append( mapIdToStr[Qtopia::Notes] ); | ||
160 | list.append( mapIdToStr[Qtopia::Groups] ); | ||
161 | 138 | ||
162 | if (sorted) list.sort(); | 139 | if (sorted) list.sort(); |
163 | 140 | ||
164 | return list; | 141 | return list; |
165 | } | 142 | } |
166 | 143 | ||
144 | |||
167 | /*! | 145 | /*! |
168 | \internal | 146 | \internal |
169 | Returns an untranslated list of field names for a contact. | 147 | Returns an untranslated list of personal field names for a contact. |
170 | */ | 148 | */ |
171 | QStringList OContactFields::untrfields( bool sorted ) | 149 | QStringList OContactFields::untrpersonalfields( bool sorted ) |
172 | { | 150 | { |
173 | QStringList list; | 151 | return personalfields( sorted, false ); |
174 | QMap<int, QString> mapIdToStr = idToUntrFields(); | 152 | } |
175 | 153 | ||
176 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); | ||
177 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); | ||
178 | 154 | ||
179 | list.append( mapIdToStr[ Qtopia::Title ] ); | 155 | /*! |
180 | list.append( mapIdToStr[ Qtopia::FirstName ] ); | 156 | \internal |
181 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); | 157 | Returns a translated list of personal field names for a contact. |
182 | list.append( mapIdToStr[ Qtopia::LastName ] ); | 158 | */ |
183 | list.append( mapIdToStr[ Qtopia::Suffix ] ); | 159 | QStringList OContactFields::trpersonalfields( bool sorted ) |
184 | list.append( mapIdToStr[ Qtopia::FileAs ] ); | 160 | { |
161 | return personalfields( sorted, true ); | ||
162 | } | ||
185 | 163 | ||
186 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | ||
187 | list.append( mapIdToStr[ Qtopia::Department ] ); | ||
188 | list.append( mapIdToStr[ Qtopia::Company ] ); | ||
189 | 164 | ||
190 | list += untrphonefields( sorted ); | 165 | /*! |
166 | \internal | ||
167 | Returns an untranslated list of details field names for a contact. | ||
168 | */ | ||
169 | QStringList OContactFields::untrdetailsfields( bool sorted ) | ||
170 | { | ||
171 | return detailsfields( sorted, false ); | ||
172 | } | ||
191 | 173 | ||
192 | list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); | ||
193 | list.append( mapIdToStr[ Qtopia::BusinessCity ] ); | ||
194 | list.append( mapIdToStr[ Qtopia::BusinessState ] ); | ||
195 | list.append( mapIdToStr[ Qtopia::BusinessZip ] ); | ||
196 | list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); | ||
197 | 174 | ||
198 | list.append( mapIdToStr[ Qtopia::HomeStreet ] ); | 175 | /*! |
199 | list.append( mapIdToStr[ Qtopia::HomeCity ] ); | 176 | \internal |
200 | list.append( mapIdToStr[ Qtopia::HomeState ] ); | 177 | Returns a translated list of details field names for a contact. |
201 | list.append( mapIdToStr[ Qtopia::HomeZip ] ); | 178 | */ |
202 | list.append( mapIdToStr[ Qtopia::HomeCountry ] ); | 179 | QStringList OContactFields::trdetailsfields( bool sorted ) |
180 | { | ||
181 | return detailsfields( sorted, true ); | ||
182 | } | ||
203 | 183 | ||
204 | list += untrdetailsfields( sorted ); | ||
205 | 184 | ||
206 | list.append( mapIdToStr[ Qtopia::Notes ] ); | 185 | /*! |
207 | list.append( mapIdToStr[ Qtopia::Groups ] ); | 186 | \internal |
187 | Returns a translated list of phone field names for a contact. | ||
188 | */ | ||
189 | QStringList OContactFields::trphonefields( bool sorted ) | ||
190 | { | ||
191 | return phonefields( sorted, true ); | ||
192 | } | ||
208 | 193 | ||
209 | if (sorted) list.sort(); | 194 | /*! |
195 | \internal | ||
196 | Returns an untranslated list of phone field names for a contact. | ||
197 | */ | ||
198 | QStringList OContactFields::untrphonefields( bool sorted ) | ||
199 | { | ||
200 | return phonefields( sorted, false ); | ||
201 | } | ||
210 | 202 | ||
211 | return list; | 203 | |
204 | /*! | ||
205 | \internal | ||
206 | Returns a translated list of field names for a contact. | ||
207 | */ | ||
208 | QStringList OContactFields::trfields( bool sorted ) | ||
209 | { | ||
210 | return fields( sorted, true ); | ||
212 | } | 211 | } |
212 | |||
213 | /*! | ||
214 | \internal | ||
215 | Returns an untranslated list of field names for a contact. | ||
216 | */ | ||
217 | QStringList OContactFields::untrfields( bool sorted ) | ||
218 | { | ||
219 | return fields( sorted, false ); | ||
220 | } | ||
221 | |||
213 | QMap<int, QString> OContactFields::idToTrFields() | 222 | QMap<int, QString> OContactFields::idToTrFields() |
214 | { | 223 | { |
215 | QMap<int, QString> ret_map; | 224 | QMap<int, QString> ret_map; |
@@ -357,6 +366,8 @@ QMap<QString, int> OContactFields::trFieldsToId() | |||
357 | return ret_map; | 366 | return ret_map; |
358 | } | 367 | } |
359 | 368 | ||
369 | /* ======================================================================= */ | ||
370 | |||
360 | QMap<QString, int> OContactFields::untrFieldsToId() | 371 | QMap<QString, int> OContactFields::untrFieldsToId() |
361 | { | 372 | { |
362 | QMap<int, QString> idtostr = idToUntrFields(); | 373 | QMap<int, QString> idtostr = idToUntrFields(); |
diff --git a/libopie2/opiepim/ocontactfields.h b/libopie2/opiepim/ocontactfields.h index 9f6171b..f105de7 100644 --- a/libopie2/opiepim/ocontactfields.h +++ b/libopie2/opiepim/ocontactfields.h | |||
@@ -43,6 +43,13 @@ class OContactFields{ | |||
43 | bool changedFieldOrder; | 43 | bool changedFieldOrder; |
44 | 44 | ||
45 | public: | 45 | public: |
46 | static QStringList personalfields( bool sorted = true, bool translated = false ); | ||
47 | static QStringList phonefields( bool sorted = true, bool translated = false ); | ||
48 | static QStringList detailsfields( bool sorted = true, bool translated = false ); | ||
49 | static QStringList fields( bool sorted = true, bool translated = false ); | ||
50 | |||
51 | static QStringList trpersonalfields( bool sorted = true ); | ||
52 | static QStringList untrpersonalfields( bool sorted = true ); | ||
46 | static QStringList trphonefields( bool sorted = true ); | 53 | static QStringList trphonefields( bool sorted = true ); |
47 | static QStringList untrphonefields( bool sorted = true ); | 54 | static QStringList untrphonefields( bool sorted = true ); |
48 | static QStringList trdetailsfields( bool sorted = true ); | 55 | static QStringList trdetailsfields( bool sorted = true ); |