author | ar <ar> | 2004-06-01 21:38:07 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-01 21:38:07 (UTC) |
commit | baed1d5ab8589aef14440009bc4e7380bcc5a741 (patch) (unidiff) | |
tree | c636e892c5eec0df2b36d16cb601a7da41a2ef0f /libopie2/opiepim/core/opimcontact.cpp | |
parent | 4438393d8eef624565e840b798429071829adea8 (diff) | |
download | opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.zip opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.gz opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.bz2 |
- convert to odebug framework
Diffstat (limited to 'libopie2/opiepim/core/opimcontact.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimcontact.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp index c1e06c8..48a74d0 100644 --- a/libopie2/opiepim/core/opimcontact.cpp +++ b/libopie2/opiepim/core/opimcontact.cpp | |||
@@ -25,24 +25,26 @@ | |||
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #define QTOPIA_INTERNAL_CONTACT_MRE | 30 | #define QTOPIA_INTERNAL_CONTACT_MRE |
31 | 31 | ||
32 | #include "opimcontact.h" | 32 | #include "opimcontact.h" |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | #include <opie2/opimresolver.h> | 35 | #include <opie2/opimresolver.h> |
36 | #include <opie2/opimdateconversion.h> | 36 | #include <opie2/opimdateconversion.h> |
37 | #include <opie2/odebug.h> | ||
38 | |||
37 | #include <qpe/stringutil.h> | 39 | #include <qpe/stringutil.h> |
38 | #include <qpe/timestring.h> | 40 | #include <qpe/timestring.h> |
39 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
40 | 42 | ||
41 | /* QT */ | 43 | /* QT */ |
42 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
43 | 45 | ||
44 | /* STD */ | 46 | /* STD */ |
45 | #include <stdio.h> | 47 | #include <stdio.h> |
46 | 48 | ||
47 | /*! | 49 | /*! |
48 | \class Contact contact.h | 50 | \class Contact contact.h |
@@ -70,32 +72,32 @@ OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) | |||
70 | set from \a fromMap. | 72 | set from \a fromMap. |
71 | */ | 73 | */ |
72 | OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) | 74 | OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) |
73 | { | 75 | { |
74 | QString cats = mMap[ Qtopia::AddressCategory ]; | 76 | QString cats = mMap[ Qtopia::AddressCategory ]; |
75 | if ( !cats.isEmpty() ) | 77 | if ( !cats.isEmpty() ) |
76 | setCategories( idsFromString( cats ) ); | 78 | setCategories( idsFromString( cats ) ); |
77 | 79 | ||
78 | QString uidStr = find( Qtopia::AddressUid ); | 80 | QString uidStr = find( Qtopia::AddressUid ); |
79 | 81 | ||
80 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) | 82 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) |
81 | { | 83 | { |
82 | qWarning( "Invalid UID found. Generate new one.." ); | 84 | owarn << "Invalid UID found. Generate new one.." << oendl; |
83 | setUid( uidGen().generate() ); | 85 | setUid( uidGen().generate() ); |
84 | } | 86 | } |
85 | else | 87 | else |
86 | setUid( uidStr.toInt() ); | 88 | setUid( uidStr.toInt() ); |
87 | 89 | ||
88 | // if ( !uidStr.isEmpty() ) | 90 | // if ( !uidStr.isEmpty() ) |
89 | // setUid( uidStr.toInt() ); | 91 | // setUid( uidStr.toInt() ); |
90 | } | 92 | } |
91 | 93 | ||
92 | /*! | 94 | /*! |
93 | Destroys a contact. | 95 | Destroys a contact. |
94 | */ | 96 | */ |
95 | OPimContact::~OPimContact() | 97 | OPimContact::~OPimContact() |
96 | {} | 98 | {} |
97 | 99 | ||
98 | /*! \fn void OPimContact::setTitle( const QString &str ) | 100 | /*! \fn void OPimContact::setTitle( const QString &str ) |
99 | Sets the title of the contact to \a str. | 101 | Sets the title of the contact to \a str. |
100 | */ | 102 | */ |
101 | 103 | ||
@@ -922,25 +924,25 @@ QStringList OPimContact::childrenList() const | |||
922 | 924 | ||
923 | /*! | 925 | /*! |
924 | Returns a list of email addresses belonging to the contact, including | 926 | Returns a list of email addresses belonging to the contact, including |
925 | the default email address. | 927 | the default email address. |
926 | */ | 928 | */ |
927 | QStringList OPimContact::emailList() const | 929 | QStringList OPimContact::emailList() const |
928 | { | 930 | { |
929 | QString emailStr = emails(); | 931 | QString emailStr = emails(); |
930 | 932 | ||
931 | QStringList r; | 933 | QStringList r; |
932 | if ( !emailStr.isEmpty() ) | 934 | if ( !emailStr.isEmpty() ) |
933 | { | 935 | { |
934 | qDebug( " emailstr " ); | 936 | odebug << " emailstr " << oendl; |
935 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | 937 | QStringList l = QStringList::split( emailSeparator(), emailStr ); |
936 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | 938 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) |
937 | r += ( *it ).simplifyWhiteSpace(); | 939 | r += ( *it ).simplifyWhiteSpace(); |
938 | } | 940 | } |
939 | 941 | ||
940 | return r; | 942 | return r; |
941 | } | 943 | } |
942 | 944 | ||
943 | /*! | 945 | /*! |
944 | \overload | 946 | \overload |
945 | 947 | ||
946 | Generates the string for the contact to be filed as from the first, | 948 | Generates the string for the contact to be filed as from the first, |
@@ -1127,44 +1129,44 @@ class QString OPimContact::recordField( int pos ) const | |||
1127 | // In future releases, we should store birthday and anniversary | 1129 | // In future releases, we should store birthday and anniversary |
1128 | // internally as QDate instead of QString ! | 1130 | // internally as QDate instead of QString ! |
1129 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1131 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1130 | 1132 | ||
1131 | /*! \fn void OPimContact::setBirthday( const QDate& date ) | 1133 | /*! \fn void OPimContact::setBirthday( const QDate& date ) |
1132 | Sets the birthday for the contact to \a date. If date is null | 1134 | Sets the birthday for the contact to \a date. If date is null |
1133 | the current stored date will be removed. | 1135 | the current stored date will be removed. |
1134 | */ | 1136 | */ |
1135 | void OPimContact::setBirthday( const QDate &v ) | 1137 | void OPimContact::setBirthday( const QDate &v ) |
1136 | { | 1138 | { |
1137 | if ( v.isNull() ) | 1139 | if ( v.isNull() ) |
1138 | { | 1140 | { |
1139 | qWarning( "Remove Birthday" ); | 1141 | owarn << "Remove Birthday" << oendl; |
1140 | replace( Qtopia::Birthday, QString::null ); | 1142 | replace( Qtopia::Birthday, QString::null ); |
1141 | return ; | 1143 | return ; |
1142 | } | 1144 | } |
1143 | 1145 | ||
1144 | if ( v.isValid() ) | 1146 | if ( v.isValid() ) |
1145 | replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); | 1147 | replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); |
1146 | 1148 | ||
1147 | } | 1149 | } |
1148 | 1150 | ||
1149 | 1151 | ||
1150 | /*! \fn void OPimContact::setAnniversary( const QDate &date ) | 1152 | /*! \fn void OPimContact::setAnniversary( const QDate &date ) |
1151 | Sets the anniversary of the contact to \a date. If date is | 1153 | Sets the anniversary of the contact to \a date. If date is |
1152 | null, the current stored date will be removed. | 1154 | null, the current stored date will be removed. |
1153 | */ | 1155 | */ |
1154 | void OPimContact::setAnniversary( const QDate &v ) | 1156 | void OPimContact::setAnniversary( const QDate &v ) |
1155 | { | 1157 | { |
1156 | if ( v.isNull() ) | 1158 | if ( v.isNull() ) |
1157 | { | 1159 | { |
1158 | qWarning( "Remove Anniversary" ); | 1160 | owarn << "Remove Anniversary" << oendl; |
1159 | replace( Qtopia::Anniversary, QString::null ); | 1161 | replace( Qtopia::Anniversary, QString::null ); |
1160 | return ; | 1162 | return ; |
1161 | } | 1163 | } |
1162 | 1164 | ||
1163 | if ( v.isValid() ) | 1165 | if ( v.isValid() ) |
1164 | replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); | 1166 | replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); |
1165 | } | 1167 | } |
1166 | 1168 | ||
1167 | 1169 | ||
1168 | /*! \fn QDate OPimContact::birthday() const | 1170 | /*! \fn QDate OPimContact::birthday() const |
1169 | Returns the birthday of the contact. | 1171 | Returns the birthday of the contact. |
1170 | */ | 1172 | */ |
@@ -1187,25 +1189,25 @@ QDate OPimContact::anniversary() const | |||
1187 | QDate empty; | 1189 | QDate empty; |
1188 | QString str = find( Qtopia::Anniversary ); | 1190 | QString str = find( Qtopia::Anniversary ); |
1189 | // qWarning ("Anniversary %s", str.latin1() ); | 1191 | // qWarning ("Anniversary %s", str.latin1() ); |
1190 | if ( !str.isEmpty() ) | 1192 | if ( !str.isEmpty() ) |
1191 | return OPimDateConversion::dateFromString ( str ); | 1193 | return OPimDateConversion::dateFromString ( str ); |
1192 | else | 1194 | else |
1193 | return empty; | 1195 | return empty; |
1194 | } | 1196 | } |
1195 | 1197 | ||
1196 | 1198 | ||
1197 | void OPimContact::insertEmail( const QString &v ) | 1199 | void OPimContact::insertEmail( const QString &v ) |
1198 | { | 1200 | { |
1199 | //qDebug("insertEmail %s", v.latin1()); | 1201 | //odebug << "insertEmail " << v << "" << oendl; |
1200 | QString e = v.simplifyWhiteSpace(); | 1202 | QString e = v.simplifyWhiteSpace(); |
1201 | QString def = defaultEmail(); | 1203 | QString def = defaultEmail(); |
1202 | 1204 | ||
1203 | // if no default, set it as the default email and don't insert | 1205 | // if no default, set it as the default email and don't insert |
1204 | if ( def.isEmpty() ) | 1206 | if ( def.isEmpty() ) |
1205 | { | 1207 | { |
1206 | setDefaultEmail( e ); // will insert into the list for us | 1208 | setDefaultEmail( e ); // will insert into the list for us |
1207 | return ; | 1209 | return ; |
1208 | } | 1210 | } |
1209 | 1211 | ||
1210 | // otherwise, insert assuming doesn't already exist | 1212 | // otherwise, insert assuming doesn't already exist |
1211 | QString emailsStr = find( Qtopia::Emails ); | 1213 | QString emailsStr = find( Qtopia::Emails ); |
@@ -1221,54 +1223,54 @@ void OPimContact::insertEmail( const QString &v ) | |||
1221 | void OPimContact::removeEmail( const QString &v ) | 1223 | void OPimContact::removeEmail( const QString &v ) |
1222 | { | 1224 | { |
1223 | QString e = v.simplifyWhiteSpace(); | 1225 | QString e = v.simplifyWhiteSpace(); |
1224 | QString def = defaultEmail(); | 1226 | QString def = defaultEmail(); |
1225 | QString emailsStr = find( Qtopia::Emails ); | 1227 | QString emailsStr = find( Qtopia::Emails ); |
1226 | QStringList emails = emailList(); | 1228 | QStringList emails = emailList(); |
1227 | 1229 | ||
1228 | // otherwise, must first contain it | 1230 | // otherwise, must first contain it |
1229 | if ( !emailsStr.contains( e ) ) | 1231 | if ( !emailsStr.contains( e ) ) |
1230 | return ; | 1232 | return ; |
1231 | 1233 | ||
1232 | // remove it | 1234 | // remove it |
1233 | //qDebug(" removing email from list %s", e.latin1()); | 1235 | //odebug << " removing email from list " << e << "" << oendl; |
1234 | emails.remove( e ); | 1236 | emails.remove( e ); |
1235 | // reset the string | 1237 | // reset the string |
1236 | emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator | 1238 | emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator |
1237 | replace( Qtopia::Emails, emailsStr ); | 1239 | replace( Qtopia::Emails, emailsStr ); |
1238 | 1240 | ||
1239 | // if default, then replace the default email with the first one | 1241 | // if default, then replace the default email with the first one |
1240 | if ( def == e ) | 1242 | if ( def == e ) |
1241 | { | 1243 | { |
1242 | //qDebug("removeEmail is default; setting new default"); | 1244 | //odebug << "removeEmail is default; setting new default" << oendl; |
1243 | if ( !emails.count() ) | 1245 | if ( !emails.count() ) |
1244 | clearEmails(); | 1246 | clearEmails(); |
1245 | else // setDefaultEmail will remove e from the list | 1247 | else // setDefaultEmail will remove e from the list |
1246 | setDefaultEmail( emails.first() ); | 1248 | setDefaultEmail( emails.first() ); |
1247 | } | 1249 | } |
1248 | } | 1250 | } |
1249 | 1251 | ||
1250 | 1252 | ||
1251 | void OPimContact::clearEmails() | 1253 | void OPimContact::clearEmails() |
1252 | { | 1254 | { |
1253 | mMap.remove( Qtopia::DefaultEmail ); | 1255 | mMap.remove( Qtopia::DefaultEmail ); |
1254 | mMap.remove( Qtopia::Emails ); | 1256 | mMap.remove( Qtopia::Emails ); |
1255 | } | 1257 | } |
1256 | 1258 | ||
1257 | 1259 | ||
1258 | void OPimContact::setDefaultEmail( const QString &v ) | 1260 | void OPimContact::setDefaultEmail( const QString &v ) |
1259 | { | 1261 | { |
1260 | QString e = v.simplifyWhiteSpace(); | 1262 | QString e = v.simplifyWhiteSpace(); |
1261 | 1263 | ||
1262 | //qDebug("OPimContact::setDefaultEmail %s", e.latin1()); | 1264 | //odebug << "OPimContact::setDefaultEmail " << e << "" << oendl; |
1263 | replace( Qtopia::DefaultEmail, e ); | 1265 | replace( Qtopia::DefaultEmail, e ); |
1264 | 1266 | ||
1265 | if ( !e.isEmpty() ) | 1267 | if ( !e.isEmpty() ) |
1266 | insertEmail( e ); | 1268 | insertEmail( e ); |
1267 | 1269 | ||
1268 | } | 1270 | } |
1269 | 1271 | ||
1270 | 1272 | ||
1271 | void OPimContact::insertEmails( const QStringList &v ) | 1273 | void OPimContact::insertEmails( const QStringList &v ) |
1272 | { | 1274 | { |
1273 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1275 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1274 | insertEmail( *it ); | 1276 | insertEmail( *it ); |