author | zecke <zecke> | 2004-11-18 21:45:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-18 21:45:49 (UTC) |
commit | 7484344ff5be1f7c54e51715776d0e3cadeb1ed0 (patch) (unidiff) | |
tree | 96f427f7a1fb1c8ca0a6efbd72b51e916cb1651d /libopie2/opiepim/core/opimcontact.cpp | |
parent | 3302eb30390e6053637929316670da3e8fbe279e (diff) | |
download | opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.zip opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.gz opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.bz2 |
Big PIM API Update Core Part (1/2 of what should be implemented):
OPimRecords:
-Add a so called safeCast using the rtti value
OPimTodo:
-Fix memleak with OPimState
OPimOccurrence:
-New class. Every 'Access' can give occurrences
for a period of time
Move Documentation
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 | |||
@@ -78,13 +78,12 @@ OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap | |||
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() ) |
@@ -1135,13 +1134,12 @@ class QString OPimContact::recordField( int pos ) const | |||
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 ) ); |
@@ -1154,13 +1152,12 @@ void OPimContact::setBirthday( const QDate &v ) | |||
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 ) ); |
@@ -1170,13 +1167,12 @@ void OPimContact::setAnniversary( const QDate &v ) | |||
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 | ||
@@ -1185,13 +1181,12 @@ QDate OPimContact::birthday() 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 | ||
@@ -1279,12 +1274,31 @@ void OPimContact::insertEmails( const QStringList &v ) | |||
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 | } |