Diffstat (limited to 'libopie2/opiepim/core/opimcontact.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimcontact.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp index 36e9a93..64f195b 100644 --- a/libopie2/opiepim/core/opimcontact.cpp +++ b/libopie2/opiepim/core/opimcontact.cpp | |||
@@ -72,25 +72,24 @@ OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) | |||
72 | set from \a fromMap. | 72 | set from \a fromMap. |
73 | */ | 73 | */ |
74 | 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 ) |
75 | { | 75 | { |
76 | QString cats = mMap[ Qtopia::AddressCategory ]; | 76 | QString cats = mMap[ Qtopia::AddressCategory ]; |
77 | if ( !cats.isEmpty() ) | 77 | if ( !cats.isEmpty() ) |
78 | setCategories( idsFromString( cats ) ); | 78 | setCategories( idsFromString( cats ) ); |
79 | 79 | ||
80 | QString uidStr = find( Qtopia::AddressUid ); | 80 | QString uidStr = find( Qtopia::AddressUid ); |
81 | 81 | ||
82 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) | 82 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) |
83 | { | 83 | { |
84 | owarn << "Invalid UID found. Generate new one.." << oendl; | ||
85 | setUid( uidGen().generate() ); | 84 | setUid( uidGen().generate() ); |
86 | } | 85 | } |
87 | else | 86 | else |
88 | setUid( uidStr.toInt() ); | 87 | setUid( uidStr.toInt() ); |
89 | 88 | ||
90 | // if ( !uidStr.isEmpty() ) | 89 | // if ( !uidStr.isEmpty() ) |
91 | // setUid( uidStr.toInt() ); | 90 | // setUid( uidStr.toInt() ); |
92 | } | 91 | } |
93 | 92 | ||
94 | /*! | 93 | /*! |
95 | Destroys a contact. | 94 | Destroys a contact. |
96 | */ | 95 | */ |
@@ -1129,75 +1128,71 @@ class QString OPimContact::recordField( int pos ) const | |||
1129 | // In future releases, we should store birthday and anniversary | 1128 | // In future releases, we should store birthday and anniversary |
1130 | // internally as QDate instead of QString ! | 1129 | // internally as QDate instead of QString ! |
1131 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1130 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1132 | 1131 | ||
1133 | /*! \fn void OPimContact::setBirthday( const QDate& date ) | 1132 | /*! \fn void OPimContact::setBirthday( const QDate& date ) |
1134 | Sets the birthday for the contact to \a date. If date is null | 1133 | Sets the birthday for the contact to \a date. If date is null |
1135 | the current stored date will be removed. | 1134 | the current stored date will be removed. |
1136 | */ | 1135 | */ |
1137 | void OPimContact::setBirthday( const QDate &v ) | 1136 | void OPimContact::setBirthday( const QDate &v ) |
1138 | { | 1137 | { |
1139 | if ( v.isNull() ) | 1138 | if ( v.isNull() ) |
1140 | { | 1139 | { |
1141 | owarn << "Remove Birthday" << oendl; | ||
1142 | replace( Qtopia::Birthday, QString::null ); | 1140 | replace( Qtopia::Birthday, QString::null ); |
1143 | return ; | 1141 | return ; |
1144 | } | 1142 | } |
1145 | 1143 | ||
1146 | if ( v.isValid() ) | 1144 | if ( v.isValid() ) |
1147 | replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); | 1145 | replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); |
1148 | 1146 | ||
1149 | } | 1147 | } |
1150 | 1148 | ||
1151 | 1149 | ||
1152 | /*! \fn void OPimContact::setAnniversary( const QDate &date ) | 1150 | /*! \fn void OPimContact::setAnniversary( const QDate &date ) |
1153 | Sets the anniversary of the contact to \a date. If date is | 1151 | Sets the anniversary of the contact to \a date. If date is |
1154 | null, the current stored date will be removed. | 1152 | null, the current stored date will be removed. |
1155 | */ | 1153 | */ |
1156 | void OPimContact::setAnniversary( const QDate &v ) | 1154 | void OPimContact::setAnniversary( const QDate &v ) |
1157 | { | 1155 | { |
1158 | if ( v.isNull() ) | 1156 | if ( v.isNull() ) |
1159 | { | 1157 | { |
1160 | owarn << "Remove Anniversary" << oendl; | ||
1161 | replace( Qtopia::Anniversary, QString::null ); | 1158 | replace( Qtopia::Anniversary, QString::null ); |
1162 | return ; | 1159 | return ; |
1163 | } | 1160 | } |
1164 | 1161 | ||
1165 | if ( v.isValid() ) | 1162 | if ( v.isValid() ) |
1166 | replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); | 1163 | replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); |
1167 | } | 1164 | } |
1168 | 1165 | ||
1169 | 1166 | ||
1170 | /*! \fn QDate OPimContact::birthday() const | 1167 | /*! \fn QDate OPimContact::birthday() const |
1171 | Returns the birthday of the contact. | 1168 | Returns the birthday of the contact. |
1172 | */ | 1169 | */ |
1173 | QDate OPimContact::birthday() const | 1170 | QDate OPimContact::birthday() const |
1174 | { | 1171 | { |
1175 | QString str = find( Qtopia::Birthday ); | 1172 | QString str = find( Qtopia::Birthday ); |
1176 | // owarn << "Birthday " << str << oendl; | ||
1177 | if ( !str.isEmpty() ) | 1173 | if ( !str.isEmpty() ) |
1178 | return OPimDateConversion::dateFromString ( str ); | 1174 | return OPimDateConversion::dateFromString ( str ); |
1179 | else | 1175 | else |
1180 | return QDate(); | 1176 | return QDate(); |
1181 | } | 1177 | } |
1182 | 1178 | ||
1183 | 1179 | ||
1184 | /*! \fn QDate OPimContact::anniversary() const | 1180 | /*! \fn QDate OPimContact::anniversary() const |
1185 | Returns the anniversary of the contact. | 1181 | Returns the anniversary of the contact. |
1186 | */ | 1182 | */ |
1187 | QDate OPimContact::anniversary() const | 1183 | QDate OPimContact::anniversary() const |
1188 | { | 1184 | { |
1189 | QDate empty; | 1185 | QDate empty; |
1190 | QString str = find( Qtopia::Anniversary ); | 1186 | QString str = find( Qtopia::Anniversary ); |
1191 | // owarn << "Anniversary " << str << oendl; | ||
1192 | if ( !str.isEmpty() ) | 1187 | if ( !str.isEmpty() ) |
1193 | return OPimDateConversion::dateFromString ( str ); | 1188 | return OPimDateConversion::dateFromString ( str ); |
1194 | else | 1189 | else |
1195 | return empty; | 1190 | return empty; |
1196 | } | 1191 | } |
1197 | 1192 | ||
1198 | 1193 | ||
1199 | void OPimContact::insertEmail( const QString &v ) | 1194 | void OPimContact::insertEmail( const QString &v ) |
1200 | { | 1195 | { |
1201 | //odebug << "insertEmail " << v << "" << oendl; | 1196 | //odebug << "insertEmail " << v << "" << oendl; |
1202 | QString e = v.simplifyWhiteSpace(); | 1197 | QString e = v.simplifyWhiteSpace(); |
1203 | QString def = defaultEmail(); | 1198 | QString def = defaultEmail(); |
@@ -1273,19 +1268,38 @@ void OPimContact::setDefaultEmail( const QString &v ) | |||
1273 | void OPimContact::insertEmails( const QStringList &v ) | 1268 | void OPimContact::insertEmails( const QStringList &v ) |
1274 | { | 1269 | { |
1275 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1270 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1276 | insertEmail( *it ); | 1271 | insertEmail( *it ); |
1277 | } | 1272 | } |
1278 | 1273 | ||
1279 | 1274 | ||
1280 | int OPimContact::rtti() const | 1275 | int OPimContact::rtti() const |
1281 | { | 1276 | { |
1282 | return OPimResolver::AddressBook; | 1277 | return OPimResolver::AddressBook; |
1283 | } | 1278 | } |
1284 | 1279 | ||
1280 | /** | ||
1281 | * \brief Cast to OPimContact or on failure return 0l | ||
1282 | * | ||
1283 | * This method tries to cast from a OPimRecord to a | ||
1284 | * OPimContact it uses. If the OPimRecord is from type | ||
1285 | * OPimContact the case will suceed and a pointer to | ||
1286 | * OPimContact is returned otherwise a Null Pointer is returned. | ||
1287 | * | ||
1288 | * | ||
1289 | * @see OPimTodo::safeCast() | ||
1290 | * @see OPimEvent::safeCast() | ||
1291 | * @return Return a OPimContact or a Null Pointer | ||
1292 | */ | ||
1293 | OPimContact* OPimContact::safeCast( const OPimRecord* rec ) { | ||
1294 | return( rec && rec->rtti() == OPimResolver::AddressBook ) ? | ||
1295 | static_cast<OPimContact*>( const_cast<OPimRecord*>(rec) ) : | ||
1296 | 0l; | ||
1297 | } | ||
1298 | |||
1285 | 1299 | ||
1286 | void OPimContact::setUid( int i ) | 1300 | void OPimContact::setUid( int i ) |
1287 | { | 1301 | { |
1288 | OPimRecord::setUid( i ); | 1302 | OPimRecord::setUid( i ); |
1289 | replace( Qtopia::AddressUid , QString::number( i ) ); | 1303 | replace( Qtopia::AddressUid , QString::number( i ) ); |
1290 | } | 1304 | } |
1291 | } | 1305 | } |