summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-10-29 22:45:39 (UTC)
committer zautrix <zautrix>2005-10-29 22:45:39 (UTC)
commitb06fa1090f3fa7a71ab2710be444815df8bd6c17 (patch) (unidiff)
tree16f5aed10d0c78c255ae732959e3dd184ae5e218 /kabc
parenta4f17bd35c56280c45bda847b42b7d3a003b0a42 (diff)
downloadkdepimpi-b06fa1090f3fa7a71ab2710be444815df8bd6c17.zip
kdepimpi-b06fa1090f3fa7a71ab2710be444815df8bd6c17.tar.gz
kdepimpi-b06fa1090f3fa7a71ab2710be444815df8bd6c17.tar.bz2
commit
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressee.cpp2
-rw-r--r--kabc/addresseeview.cpp29
-rw-r--r--kabc/phonenumber.cpp15
3 files changed, 38 insertions, 8 deletions
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp
index 2f4a9af..6cfac80 100644
--- a/kabc/addressee.cpp
+++ b/kabc/addressee.cpp
@@ -903,385 +903,385 @@ void Addressee::setPrefix( const QString &prefix )
903 903
904QString Addressee::prefix() const 904QString Addressee::prefix() const
905{ 905{
906 return mData->prefix; 906 return mData->prefix;
907} 907}
908 908
909QString Addressee::prefixLabel() 909QString Addressee::prefixLabel()
910{ 910{
911 return i18n("Honorific Prefixes"); 911 return i18n("Honorific Prefixes");
912} 912}
913 913
914 914
915void Addressee::setSuffix( const QString &suffix ) 915void Addressee::setSuffix( const QString &suffix )
916{ 916{
917 if ( suffix == mData->suffix ) return; 917 if ( suffix == mData->suffix ) return;
918 detach(); 918 detach();
919 mData->empty = false; 919 mData->empty = false;
920 mData->suffix = suffix; 920 mData->suffix = suffix;
921} 921}
922 922
923QString Addressee::suffix() const 923QString Addressee::suffix() const
924{ 924{
925 return mData->suffix; 925 return mData->suffix;
926} 926}
927 927
928QString Addressee::suffixLabel() 928QString Addressee::suffixLabel()
929{ 929{
930 return i18n("Honorific Suffixes"); 930 return i18n("Honorific Suffixes");
931} 931}
932 932
933 933
934void Addressee::setNickName( const QString &nickName ) 934void Addressee::setNickName( const QString &nickName )
935{ 935{
936 if ( nickName == mData->nickName ) return; 936 if ( nickName == mData->nickName ) return;
937 detach(); 937 detach();
938 mData->empty = false; 938 mData->empty = false;
939 mData->nickName = nickName; 939 mData->nickName = nickName;
940} 940}
941 941
942QString Addressee::nickName() const 942QString Addressee::nickName() const
943{ 943{
944 return mData->nickName; 944 return mData->nickName;
945} 945}
946 946
947QString Addressee::nickNameLabel() 947QString Addressee::nickNameLabel()
948{ 948{
949 return i18n("Nick Name"); 949 return i18n("Nick Name");
950} 950}
951 951
952 952
953void Addressee::setBirthday( const QDateTime &birthday ) 953void Addressee::setBirthday( const QDateTime &birthday )
954{ 954{
955 if ( birthday == mData->birthday ) return; 955 if ( birthday == mData->birthday ) return;
956 detach(); 956 detach();
957 mData->empty = false; 957 mData->empty = false;
958 mData->birthday = birthday; 958 mData->birthday = birthday;
959} 959}
960 960
961QDateTime Addressee::birthday() const 961QDateTime Addressee::birthday() const
962{ 962{
963 return mData->birthday; 963 return mData->birthday;
964} 964}
965 965
966QString Addressee::birthdayLabel() 966QString Addressee::birthdayLabel()
967{ 967{
968 return i18n("Birthday"); 968 return i18n("Birthday");
969} 969}
970 970
971 971
972QString Addressee::homeAddressStreetLabel() 972QString Addressee::homeAddressStreetLabel()
973{ 973{
974 return i18n("Home Address Street"); 974 return i18n("Home Address Street");
975} 975}
976 976
977 977
978QString Addressee::homeAddressLocalityLabel() 978QString Addressee::homeAddressLocalityLabel()
979{ 979{
980 return i18n("Home Address Locality"); 980 return i18n("Home Address Locality");
981} 981}
982 982
983 983
984QString Addressee::homeAddressRegionLabel() 984QString Addressee::homeAddressRegionLabel()
985{ 985{
986 return i18n("Home Address Region"); 986 return i18n("Home Address Region");
987} 987}
988 988
989 989
990QString Addressee::homeAddressPostalCodeLabel() 990QString Addressee::homeAddressPostalCodeLabel()
991{ 991{
992 return i18n("Home Address Postal Code"); 992 return i18n("Home Address Postal Code");
993} 993}
994 994
995 995
996QString Addressee::homeAddressCountryLabel() 996QString Addressee::homeAddressCountryLabel()
997{ 997{
998 return i18n("Home Address Country"); 998 return i18n("Home Address Country");
999} 999}
1000 1000
1001 1001
1002QString Addressee::homeAddressLabelLabel() 1002QString Addressee::homeAddressLabelLabel()
1003{ 1003{
1004 return i18n("Home Address Label"); 1004 return i18n("Home Address Label");
1005} 1005}
1006 1006
1007 1007
1008QString Addressee::businessAddressStreetLabel() 1008QString Addressee::businessAddressStreetLabel()
1009{ 1009{
1010 return i18n("Business Address Street"); 1010 return i18n("Business Address Street");
1011} 1011}
1012 1012
1013 1013
1014QString Addressee::businessAddressLocalityLabel() 1014QString Addressee::businessAddressLocalityLabel()
1015{ 1015{
1016 return i18n("Business Address Locality"); 1016 return i18n("Business Address Locality");
1017} 1017}
1018 1018
1019 1019
1020QString Addressee::businessAddressRegionLabel() 1020QString Addressee::businessAddressRegionLabel()
1021{ 1021{
1022 return i18n("Business Address Region"); 1022 return i18n("Business Address Region");
1023} 1023}
1024 1024
1025 1025
1026QString Addressee::businessAddressPostalCodeLabel() 1026QString Addressee::businessAddressPostalCodeLabel()
1027{ 1027{
1028 return i18n("Business Address Postal Code"); 1028 return i18n("Business Address Postal Code");
1029} 1029}
1030 1030
1031 1031
1032QString Addressee::businessAddressCountryLabel() 1032QString Addressee::businessAddressCountryLabel()
1033{ 1033{
1034 return i18n("Business Address Country"); 1034 return i18n("Business Address Country");
1035} 1035}
1036 1036
1037 1037
1038QString Addressee::businessAddressLabelLabel() 1038QString Addressee::businessAddressLabelLabel()
1039{ 1039{
1040 return i18n("Business Address Label"); 1040 return i18n("Business Address Label");
1041} 1041}
1042 1042
1043 1043
1044QString Addressee::homePhoneLabel() 1044QString Addressee::homePhoneLabel()
1045{ 1045{
1046 return i18n("Home Phone"); 1046 return i18n("Home Phone");
1047} 1047}
1048 1048
1049 1049
1050QString Addressee::businessPhoneLabel() 1050QString Addressee::businessPhoneLabel()
1051{ 1051{
1052 return i18n("Work Phone"); 1052 return i18n("Work Phone");
1053} 1053}
1054 1054
1055 1055
1056QString Addressee::mobilePhoneLabel() 1056QString Addressee::mobilePhoneLabel()
1057{ 1057{
1058 return i18n("Mobile"); 1058 return i18n("Mobile");
1059} 1059}
1060QString Addressee::mobileWorkPhoneLabel() 1060QString Addressee::mobileWorkPhoneLabel()
1061{ 1061{
1062 return i18n("Mobile2"); 1062 return i18n("Mobile2");
1063} 1063}
1064 1064
1065 1065
1066QString Addressee::homeFaxLabel() 1066QString Addressee::homeFaxLabel()
1067{ 1067{
1068 return i18n("Fax (Home)"); 1068 return i18n("Fax (Home)");
1069} 1069}
1070 1070
1071 1071
1072QString Addressee::businessFaxLabel() 1072QString Addressee::businessFaxLabel()
1073{ 1073{
1074 return i18n("Fax (Work)"); 1074 return i18n("Fax (Work)");
1075} 1075}
1076 1076
1077 1077
1078QString Addressee::isdnLabel() 1078QString Addressee::isdnLabel()
1079{ 1079{
1080 return i18n("ISDN"); 1080 return i18n("ISDN");
1081} 1081}
1082 1082
1083 1083
1084QString Addressee::pagerLabel() 1084QString Addressee::pagerLabel()
1085{ 1085{
1086 return i18n("Pager"); 1086 return i18n("Pager");
1087} 1087}
1088QString Addressee::otherPhoneLabel() 1088QString Addressee::otherPhoneLabel()
1089{ 1089{
1090 return i18n("Other Phone"); 1090 return i18n("Other Phone");
1091} 1091}
1092 1092
1093QString Addressee::sipLabel() 1093QString Addressee::sipLabel()
1094{ 1094{
1095 return i18n("SIP"); 1095 return i18n("SiP");
1096} 1096}
1097 1097
1098QString Addressee::emailLabel() 1098QString Addressee::emailLabel()
1099{ 1099{
1100 return i18n("Email Address"); 1100 return i18n("Email Address");
1101} 1101}
1102 1102
1103 1103
1104void Addressee::setMailer( const QString &mailer ) 1104void Addressee::setMailer( const QString &mailer )
1105{ 1105{
1106 if ( mailer == mData->mailer ) return; 1106 if ( mailer == mData->mailer ) return;
1107 detach(); 1107 detach();
1108 mData->empty = false; 1108 mData->empty = false;
1109 mData->mailer = mailer; 1109 mData->mailer = mailer;
1110} 1110}
1111 1111
1112QString Addressee::mailer() const 1112QString Addressee::mailer() const
1113{ 1113{
1114 return mData->mailer; 1114 return mData->mailer;
1115} 1115}
1116 1116
1117QString Addressee::mailerLabel() 1117QString Addressee::mailerLabel()
1118{ 1118{
1119 return i18n("Mail Client"); 1119 return i18n("Mail Client");
1120} 1120}
1121 1121
1122 1122
1123void Addressee::setTimeZone( const TimeZone &timeZone ) 1123void Addressee::setTimeZone( const TimeZone &timeZone )
1124{ 1124{
1125 if ( timeZone == mData->timeZone ) return; 1125 if ( timeZone == mData->timeZone ) return;
1126 detach(); 1126 detach();
1127 mData->empty = false; 1127 mData->empty = false;
1128 mData->timeZone = timeZone; 1128 mData->timeZone = timeZone;
1129} 1129}
1130 1130
1131TimeZone Addressee::timeZone() const 1131TimeZone Addressee::timeZone() const
1132{ 1132{
1133 return mData->timeZone; 1133 return mData->timeZone;
1134} 1134}
1135 1135
1136QString Addressee::timeZoneLabel() 1136QString Addressee::timeZoneLabel()
1137{ 1137{
1138 return i18n("Time Zone"); 1138 return i18n("Time Zone");
1139} 1139}
1140 1140
1141 1141
1142void Addressee::setGeo( const Geo &geo ) 1142void Addressee::setGeo( const Geo &geo )
1143{ 1143{
1144 if ( geo == mData->geo ) return; 1144 if ( geo == mData->geo ) return;
1145 detach(); 1145 detach();
1146 mData->empty = false; 1146 mData->empty = false;
1147 mData->geo = geo; 1147 mData->geo = geo;
1148} 1148}
1149 1149
1150Geo Addressee::geo() const 1150Geo Addressee::geo() const
1151{ 1151{
1152 return mData->geo; 1152 return mData->geo;
1153} 1153}
1154 1154
1155QString Addressee::geoLabel() 1155QString Addressee::geoLabel()
1156{ 1156{
1157 return i18n("Geographic Position"); 1157 return i18n("Geographic Position");
1158} 1158}
1159 1159
1160 1160
1161void Addressee::setTitle( const QString &title ) 1161void Addressee::setTitle( const QString &title )
1162{ 1162{
1163 if ( title == mData->title ) return; 1163 if ( title == mData->title ) return;
1164 detach(); 1164 detach();
1165 mData->empty = false; 1165 mData->empty = false;
1166 mData->title = title; 1166 mData->title = title;
1167} 1167}
1168 1168
1169QString Addressee::title() const 1169QString Addressee::title() const
1170{ 1170{
1171 return mData->title; 1171 return mData->title;
1172} 1172}
1173 1173
1174QString Addressee::titleLabel() 1174QString Addressee::titleLabel()
1175{ 1175{
1176 return i18n("Title"); 1176 return i18n("Title");
1177} 1177}
1178 1178
1179 1179
1180void Addressee::setRole( const QString &role ) 1180void Addressee::setRole( const QString &role )
1181{ 1181{
1182 if ( role == mData->role ) return; 1182 if ( role == mData->role ) return;
1183 detach(); 1183 detach();
1184 mData->empty = false; 1184 mData->empty = false;
1185 mData->role = role; 1185 mData->role = role;
1186} 1186}
1187 1187
1188QString Addressee::role() const 1188QString Addressee::role() const
1189{ 1189{
1190 return mData->role; 1190 return mData->role;
1191} 1191}
1192 1192
1193QString Addressee::roleLabel() 1193QString Addressee::roleLabel()
1194{ 1194{
1195 return i18n("Role"); 1195 return i18n("Role");
1196} 1196}
1197 1197
1198 1198
1199void Addressee::setOrganization( const QString &organization ) 1199void Addressee::setOrganization( const QString &organization )
1200{ 1200{
1201 if ( organization == mData->organization ) return; 1201 if ( organization == mData->organization ) return;
1202 detach(); 1202 detach();
1203 mData->empty = false; 1203 mData->empty = false;
1204 mData->organization = organization; 1204 mData->organization = organization;
1205} 1205}
1206 1206
1207QString Addressee::organization() const 1207QString Addressee::organization() const
1208{ 1208{
1209 return mData->organization; 1209 return mData->organization;
1210} 1210}
1211 1211
1212QString Addressee::organizationLabel() 1212QString Addressee::organizationLabel()
1213{ 1213{
1214 return i18n("Organization"); 1214 return i18n("Organization");
1215} 1215}
1216 1216
1217 1217
1218void Addressee::setNote( const QString &note ) 1218void Addressee::setNote( const QString &note )
1219{ 1219{
1220 if ( note == mData->note ) return; 1220 if ( note == mData->note ) return;
1221 detach(); 1221 detach();
1222 mData->empty = false; 1222 mData->empty = false;
1223 mData->note = note; 1223 mData->note = note;
1224} 1224}
1225 1225
1226QString Addressee::note() const 1226QString Addressee::note() const
1227{ 1227{
1228 return mData->note; 1228 return mData->note;
1229} 1229}
1230 1230
1231QString Addressee::noteLabel() 1231QString Addressee::noteLabel()
1232{ 1232{
1233 return i18n("Note"); 1233 return i18n("Note");
1234} 1234}
1235 1235
1236 1236
1237void Addressee::setProductId( const QString &productId ) 1237void Addressee::setProductId( const QString &productId )
1238{ 1238{
1239 if ( productId == mData->productId ) return; 1239 if ( productId == mData->productId ) return;
1240 detach(); 1240 detach();
1241 mData->empty = false; 1241 mData->empty = false;
1242 mData->productId = productId; 1242 mData->productId = productId;
1243} 1243}
1244 1244
1245QString Addressee::productId() const 1245QString Addressee::productId() const
1246{ 1246{
1247 return mData->productId; 1247 return mData->productId;
1248} 1248}
1249 1249
1250QString Addressee::productIdLabel() 1250QString Addressee::productIdLabel()
1251{ 1251{
1252 return i18n("Product Identifier"); 1252 return i18n("Product Identifier");
1253} 1253}
1254 1254
1255 1255
1256void Addressee::setRevision( const QDateTime &revision ) 1256void Addressee::setRevision( const QDateTime &revision )
1257{ 1257{
1258 if ( revision == mData->revision ) return; 1258 if ( revision == mData->revision ) return;
1259 detach(); 1259 detach();
1260 mData->empty = false; 1260 mData->empty = false;
1261 mData->revision = QDateTime( revision.date(), 1261 mData->revision = QDateTime( revision.date(),
1262 QTime (revision.time().hour(), 1262 QTime (revision.time().hour(),
1263 revision.time().minute(), 1263 revision.time().minute(),
1264 revision.time().second())); 1264 revision.time().second()));
1265} 1265}
1266 1266
1267QDateTime Addressee::revision() const 1267QDateTime Addressee::revision() const
1268{ 1268{
1269 return mData->revision; 1269 return mData->revision;
1270} 1270}
1271 1271
1272QString Addressee::revisionLabel() 1272QString Addressee::revisionLabel()
1273{ 1273{
1274 return i18n("Revision Date"); 1274 return i18n("Revision Date");
1275} 1275}
1276 1276
1277 1277
1278void Addressee::setSortString( const QString &sortString ) 1278void Addressee::setSortString( const QString &sortString )
1279{ 1279{
1280 if ( sortString == mData->sortString ) return; 1280 if ( sortString == mData->sortString ) return;
1281 detach(); 1281 detach();
1282 mData->empty = false; 1282 mData->empty = false;
1283 mData->sortString = sortString; 1283 mData->sortString = sortString;
1284} 1284}
1285 1285
1286QString Addressee::sortString() const 1286QString Addressee::sortString() const
1287{ 1287{
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 5c24acf..cde19a1 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -359,356 +359,381 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
359 359
360 if ( !mAddressee.note().isEmpty() ) { 360 if ( !mAddressee.note().isEmpty() ) {
361 notes += QString( 361 notes += QString(
362 "<tr>" 362 "<tr>"
363 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label 363 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
364 "<td align=\"left\">%2</td>" // note 364 "<td align=\"left\">%2</td>" // note
365 "</tr>" ).arg( i18n( "Notes" ) ) 365 "</tr>" ).arg( i18n( "Notes" ) )
366 //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 366 //US .arg( mAddressee.note().replace( '\n', "<br>" ) );
367 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 367 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
368 //qDebug("AddresseeView::setAddressee has to be verified."); 368 //qDebug("AddresseeView::setAddressee has to be verified.");
369 } 369 }
370 } else { 370 } else {
371 notes = QString( 371 notes = QString(
372 "<tr><td align=\"right\"><b>%1</b></td>" 372 "<tr><td align=\"right\"><b>%1</b></td>"
373 "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) 373 "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" )
374 .arg( i18n("Details") ) 374 .arg( i18n("Details") )
375 .arg( i18n("Show!") ); 375 .arg( i18n("Show!") );
376 376
377 377
378 } 378 }
379 379
380 QString aRole = ""; 380 QString aRole = "";
381 QString aOrga = ""; 381 QString aOrga = "";
382 if ( true /*!mAddressee.role().isEmpty()*/ ) { 382 if ( true /*!mAddressee.role().isEmpty()*/ ) {
383 aRole = "<tr>" 383 aRole = "<tr>"
384 "<td align=\"left\">" + mAddressee.role() + "</td>" 384 "<td align=\"left\">" + mAddressee.role() + "</td>"
385 "</tr>"; 385 "</tr>";
386 } 386 }
387 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 387 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
388 aOrga = "<tr>" 388 aOrga = "<tr>"
389 "<td align=\"left\">" + mAddressee.organization() + "</td>" 389 "<td align=\"left\">" + mAddressee.organization() + "</td>"
390 "</tr>"; 390 "</tr>";
391 } 391 }
392 mText = ""; 392 mText = "";
393 QString picString = ""; 393 QString picString = "";
394 KABC::Picture picture = mAddressee.photo(); 394 KABC::Picture picture = mAddressee.photo();
395 if (picture.undefined() ) picture = mAddressee.logo(); 395 if (picture.undefined() ) picture = mAddressee.logo();
396 bool picAvailintern = false; 396 bool picAvailintern = false;
397 bool picAvailUrl = false; 397 bool picAvailUrl = false;
398 if (! picture.undefined() ) { 398 if (! picture.undefined() ) {
399 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 399 picAvailintern = (picture.isIntern() && !picture.data().isNull());
400 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 400 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
401 } 401 }
402 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 402 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
403 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 403 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
404 if ( picAvailintern ) { 404 if ( picAvailintern ) {
405 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 405 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
406 int wid = picture.data().width(); 406 int wid = picture.data().width();
407 int hei = picture.data().height(); 407 int hei = picture.data().height();
408 if ( wid > 128 || hei > 128 ) { 408 if ( wid > 128 || hei > 128 ) {
409 if ( wid > hei ) { 409 if ( wid > hei ) {
410 hei = (hei*128)/wid; 410 hei = (hei*128)/wid;
411 wid = 128; 411 wid = 128;
412 } else { 412 } else {
413 wid = (wid*128)/hei; 413 wid = (wid*128)/hei;
414 hei = 128; 414 hei = 128;
415 } 415 }
416 } 416 }
417 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); 417 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei);
418 } else { 418 } else {
419 if ( picAvailUrl ) { 419 if ( picAvailUrl ) {
420 QPixmap picPix( picture.url() ); 420 QPixmap picPix( picture.url() );
421 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); 421 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix );
422 int wid = picPix.width(); 422 int wid = picPix.width();
423 int hei = picPix.height(); 423 int hei = picPix.height();
424 if ( wid > 128 || hei > 128 ) { 424 if ( wid > 128 || hei > 128 ) {
425 if ( wid > hei ) { 425 if ( wid > hei ) {
426 hei = (hei*128)/wid; 426 hei = (hei*128)/wid;
427 wid = 128; 427 wid = 128;
428 } else { 428 } else {
429 wid = (wid*128)/hei; 429 wid = (wid*128)/hei;
430 hei = 128; 430 hei = 128;
431 } 431 }
432 } 432 }
433 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); 433 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei);
434 } else { 434 } else {
435 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { 435 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) {
436 static bool setDefaultImageChildren = false; 436 static bool setDefaultImageChildren = false;
437 if ( !setDefaultImageChildren ) { 437 if ( !setDefaultImageChildren ) {
438 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); 438 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) );
439 setDefaultImageChildren = true; 439 setDefaultImageChildren = true;
440 } 440 }
441 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; 441 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">";
442 442
443 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { 443 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) {
444 static bool setDefaultImagepouses = false; 444 static bool setDefaultImagepouses = false;
445 if ( !setDefaultImagepouses ) { 445 if ( !setDefaultImagepouses ) {
446 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); 446 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) );
447 setDefaultImagepouses = true; 447 setDefaultImagepouses = true;
448 } 448 }
449 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; 449 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">";
450 } else { 450 } else {
451 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 451 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
452 if ( gen == "male" ) { 452 if ( gen == "male" ) {
453 static bool setDefaultImageMale = false; 453 static bool setDefaultImageMale = false;
454 if ( !setDefaultImageMale ) { 454 if ( !setDefaultImageMale ) {
455 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); 455 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) );
456 setDefaultImageMale = true; 456 setDefaultImageMale = true;
457 } 457 }
458 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; 458 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">";
459 459
460 } else if ( gen == "female" ) { 460 } else if ( gen == "female" ) {
461 static bool setDefaultImageFemale = false; 461 static bool setDefaultImageFemale = false;
462 if ( !setDefaultImageFemale ) { 462 if ( !setDefaultImageFemale ) {
463 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); 463 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) );
464 setDefaultImageFemale = true; 464 setDefaultImageFemale = true;
465 } 465 }
466 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; 466 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">";
467 467
468 } else { 468 } else {
469 static bool setDefaultImage = false; 469 static bool setDefaultImage = false;
470 if ( !setDefaultImage ) { 470 if ( !setDefaultImage ) {
471 //qDebug("Setting default pixmap "); 471 //qDebug("Setting default pixmap ");
472 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); 472 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) );
473 setDefaultImage = true; 473 setDefaultImage = true;
474 } 474 }
475 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; 475 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">";
476 } 476 }
477 } 477 }
478 } 478 }
479 } 479 }
480 mText = QString::fromLatin1( 480 mText = QString::fromLatin1(
481 "<html>" 481 "<html>"
482 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 482 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
483 "<table>" 483 "<table>"
484 "<tr>" 484 "<tr>"
485 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 485 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
486 "%3" 486 "%3"
487 "</td>" 487 "</td>"
488 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 488 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
489 "</tr>" 489 "</tr>"
490 "%5" // role 490 "%5" // role
491 "%6" // organization 491 "%6" // organization
492 "<td colspan=\"2\">&nbsp;</td>" 492 "<td colspan=\"2\">&nbsp;</td>"
493 "%7" // dynamic part 493 "%7" // dynamic part
494 "%8" // notes 494 "%8" // notes
495 "</table>" 495 "</table>"
496 "</body>" 496 "</body>"
497 "</html>") 497 "</html>")
498//US 498//US
499 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 499 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
500//US 500//US
501 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 501 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
502 .arg( picString ) 502 .arg( picString )
503 .arg( name ) 503 .arg( name )
504 .arg( aRole ) 504 .arg( aRole )
505 .arg( aOrga ) 505 .arg( aOrga )
506 .arg( dynamicPart ) 506 .arg( dynamicPart )
507 .arg( notes ); 507 .arg( notes );
508 508
509 } else { // no picture! 509 } else { // no picture!
510 510
511mText = "<table width=\"100%\">\n"; 511mText = "<table width=\"100%\">\n";
512 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 512 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
513#ifdef DESKTOP_VERSION 513#ifdef DESKTOP_VERSION
514 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 514 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
515 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; 515 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>";
516#else 516#else
517 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; 517 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>";
518 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; 518 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>";
519#endif 519#endif
520 520
521 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 521 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
522 522
523 mText += "<table><td colspan=\"2\">&nbsp;</td>"; 523 mText += "<table><td colspan=\"2\">&nbsp;</td>";
524 /* 524 /*
525 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" 525 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
526 "<td align=\"left\"><b>%2</b></td></tr>" ) 526 "<td align=\"left\"><b>%2</b></td></tr>" )
527 .arg( i18n(" ") ) 527 .arg( i18n(" ") )
528 .arg( name ); 528 .arg( name );
529 */ 529 */
530 if ( ! mAddressee.role().isEmpty() ) 530 if ( ! mAddressee.role().isEmpty() )
531 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 531 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
532 "<td align=\"left\">%2</td></tr>" ) 532 "<td align=\"left\">%2</td></tr>" )
533 .arg( i18n(" ") ) 533 .arg( i18n(" ") )
534 .arg( mAddressee.role()); 534 .arg( mAddressee.role());
535 if ( ! mAddressee.organization().isEmpty() ) 535 if ( ! mAddressee.organization().isEmpty() )
536 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 536 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
537 "<td align=\"left\">%2</td></tr>" ) 537 "<td align=\"left\">%2</td></tr>" )
538 .arg( i18n(" ") ) 538 .arg( i18n(" ") )
539 .arg( mAddressee.organization()); 539 .arg( mAddressee.organization());
540 mText += dynamicPart; 540 mText += dynamicPart;
541 mText += notes; 541 mText += notes;
542 mText += "</table>"; 542 mText += "</table>";
543 543
544 } 544 }
545 545
546 // at last display it... 546 // at last display it...
547 setText( mText ); 547 setText( mText );
548 548
549} 549}
550 550
551QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) 551QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones_unsorted ,bool preferred )
552{ 552{
553 ExternalAppHandler* eah = ExternalAppHandler::instance(); 553 ExternalAppHandler* eah = ExternalAppHandler::instance();
554 bool kphoneAvail = eah->isPhoneAppAvailable(); 554 bool kphoneAvail = eah->isPhoneAppAvailable();
555 bool kfaxAvail = eah->isFaxAppAvailable(); 555 bool kfaxAvail = eah->isFaxAppAvailable();
556 bool ksmsAvail = eah->isSMSAppAvailable(); 556 bool ksmsAvail = eah->isSMSAppAvailable();
557 bool kpagerAvail = eah->isPagerAppAvailable(); 557 bool kpagerAvail = eah->isPagerAppAvailable();
558 bool ksipAvail = eah->isSIPAppAvailable(); 558 bool ksipAvail = eah->isSIPAppAvailable();
559 QString dynamicPart; 559 QString dynamicPart;
560 KABC::PhoneNumber::List::ConstIterator phoneIt; 560 KABC::PhoneNumber::List::ConstIterator phoneIt;
561 QString extension; 561 QString extension;
562 int phonetype; 562 int phonetype;
563 QString sms; 563 QString sms;
564
565 KABC::PhoneNumber::List::Iterator it;
566 KABC::PhoneNumber::List phones ;
567
568 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList();
569 int i = 0;
570 int max = tList.count();
571 while ( i < max-1 ) {
572 for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) {
573 if ( (*it).type() == tList[i] ) {
574 phones.append( (*it ) );
575 break;
576 }
577 }
578 ++i;
579 }
580 for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) {
581 if ( (*it).type() == tList[ max-1 ] )
582 phones.append( (*it ) );
583 }
584
564 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 585 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
565 phonetype = (*phoneIt).type(); 586 phonetype = (*phoneIt).type();
566 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) 587 bool con = false;
588 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) con = true;
589 if ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell ) con = !preferred;;
590 if ( con )
567 continue; 591 continue;
592
568 if (ksmsAvail && 593 if (ksmsAvail &&
569 ( 594 (
570 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 595 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
571 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 596 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
572 ) 597 )
573 ) 598 )
574 { 599 {
575 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 600 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
576 .arg( (*phoneIt).number() ); 601 .arg( (*phoneIt).number() );
577 602
578 } 603 }
579 else 604 else
580 sms = ""; 605 sms = "";
581 606
582 extension = QString::null; 607 extension = QString::null;
583 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 608 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
584 if (kfaxAvail) extension = "faxto:"; 609 if (kfaxAvail) extension = "faxto:";
585 } 610 }
586 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 611 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
587 if (kpagerAvail) extension = "pagerto:"; 612 if (kpagerAvail) extension = "pagerto:";
588 } 613 }
589#if 0 614#if 0
590 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { 615 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
591 if (ksipAvail) extension = "sipto:"; 616 if (ksipAvail) extension = "sipto:";
592 } 617 }
593#endif 618#endif
594 else if (kphoneAvail) { 619 else if (kphoneAvail) {
595 extension = "phoneto:"; 620 extension = "phoneto:";
596 } 621 }
597 else 622 else
598 extension = QString::null; 623 extension = QString::null;
599 624
600 if ( !extension.isEmpty() ) { 625 if ( !extension.isEmpty() ) {
601 dynamicPart += QString( 626 dynamicPart += QString(
602 "<tr><td align=\"right\"><b>%1</b></td>" 627 "<tr><td align=\"right\"><b>%1</b></td>"
603 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 628 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
604 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 629 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
605 .arg( extension ) 630 .arg( extension )
606 .arg( (*phoneIt).number() ) 631 .arg( (*phoneIt).number() )
607 .arg( (*phoneIt).number() ) 632 .arg( (*phoneIt).number() )
608 .arg( sms ); 633 .arg( sms );
609 634
610 } else { 635 } else {
611 dynamicPart += QString( 636 dynamicPart += QString(
612 "<tr><td align=\"right\"><b>%1</b></td>" 637 "<tr><td align=\"right\"><b>%1</b></td>"
613 "<td align=\"left\">%2 %3</td></tr>" ) 638 "<td align=\"left\">%2 %3</td></tr>" )
614 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 639 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
615 .arg( (*phoneIt).number() ) 640 .arg( (*phoneIt).number() )
616 .arg( sms ); 641 .arg( sms );
617 } 642 }
618 } 643 }
619 return dynamicPart; 644 return dynamicPart;
620} 645}
621/* 646/*
622KABC::Addressee AddresseeView::addressee() const 647KABC::Addressee AddresseeView::addressee() const
623{ 648{
624 return mAddressee; 649 return mAddressee;
625} 650}
626*/ 651*/
627void AddresseeView::addTag(const QString & tag,const QString & text) 652void AddresseeView::addTag(const QString & tag,const QString & text)
628{ 653{
629 if ( text.isEmpty() ) 654 if ( text.isEmpty() )
630 return; 655 return;
631 int number=text.contains("\n"); 656 int number=text.contains("\n");
632 QString str = "<" + tag + ">"; 657 QString str = "<" + tag + ">";
633 QString tmpText=text; 658 QString tmpText=text;
634 QString tmpStr=str; 659 QString tmpStr=str;
635 if(number !=-1) 660 if(number !=-1)
636 { 661 {
637 if (number > 0) { 662 if (number > 0) {
638 int pos=0; 663 int pos=0;
639 QString tmp; 664 QString tmp;
640 for(int i=0;i<=number;i++) { 665 for(int i=0;i<=number;i++) {
641 pos=tmpText.find("\n"); 666 pos=tmpText.find("\n");
642 tmp=tmpText.left(pos); 667 tmp=tmpText.left(pos);
643 tmpText=tmpText.right(tmpText.length()-pos-1); 668 tmpText=tmpText.right(tmpText.length()-pos-1);
644 tmpStr+=tmp+"<br>"; 669 tmpStr+=tmp+"<br>";
645 } 670 }
646 } 671 }
647 else tmpStr += tmpText; 672 else tmpStr += tmpText;
648 tmpStr+="</" + tag + ">"; 673 tmpStr+="</" + tag + ">";
649 mText.append(tmpStr); 674 mText.append(tmpStr);
650 } 675 }
651 else 676 else
652 { 677 {
653 str += text + "</" + tag + ">"; 678 str += text + "</" + tag + ">";
654 mText.append(str); 679 mText.append(str);
655 } 680 }
656} 681}
657 682
658AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 683AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
659 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) 684 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
660{ 685{
661 findButton( Close )->setText( i18n("Cancel Sync")); 686 findButton( Close )->setText( i18n("Cancel Sync"));
662 findButton( Ok )->setText( i18n("Remote")); 687 findButton( Ok )->setText( i18n("Remote"));
663 findButton( User1 )->setText( i18n("Local")); 688 findButton( User1 )->setText( i18n("Local"));
664 QWidget* topframe = new QWidget( this ); 689 QWidget* topframe = new QWidget( this );
665 setMainWidget( topframe ); 690 setMainWidget( topframe );
666 QBoxLayout* bl; 691 QBoxLayout* bl;
667 if ( QApplication::desktop()->width() < 640 ) { 692 if ( QApplication::desktop()->width() < 640 ) {
668 bl = new QVBoxLayout( topframe ); 693 bl = new QVBoxLayout( topframe );
669 } else { 694 } else {
670 bl = new QHBoxLayout( topframe ); 695 bl = new QHBoxLayout( topframe );
671 } 696 }
672 QVBox* subframe = new QVBox( topframe ); 697 QVBox* subframe = new QVBox( topframe );
673 bl->addWidget(subframe ); 698 bl->addWidget(subframe );
674 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 699 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
675 if ( takeloc ) 700 if ( takeloc )
676 lab->setBackgroundColor(Qt::green.light() ); 701 lab->setBackgroundColor(Qt::green.light() );
677 AddresseeView * av = new AddresseeView( subframe ); 702 AddresseeView * av = new AddresseeView( subframe );
678 av->setAddressee( loc ); 703 av->setAddressee( loc );
679 subframe = new QVBox( topframe ); 704 subframe = new QVBox( topframe );
680 bl->addWidget(subframe ); 705 bl->addWidget(subframe );
681 lab = new QLabel( i18n("Remote Addressee"), subframe ); 706 lab = new QLabel( i18n("Remote Addressee"), subframe );
682 if ( !takeloc ) 707 if ( !takeloc )
683 lab->setBackgroundColor(Qt::green.light() ); 708 lab->setBackgroundColor(Qt::green.light() );
684 av = new AddresseeView( subframe ); 709 av = new AddresseeView( subframe );
685 av->setAddressee( rem ); 710 av->setAddressee( rem );
686 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 711 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
687 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 712 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
688#ifndef DESKTOP_VERSION 713#ifndef DESKTOP_VERSION
689 showMaximized(); 714 showMaximized();
690#else 715#else
691 resize ( 640, 400 ); 716 resize ( 640, 400 );
692#endif 717#endif
693} 718}
694 719
695int AddresseeChooser::executeD( bool local ) 720int AddresseeChooser::executeD( bool local )
696{ 721{
697 mSyncResult = 3; 722 mSyncResult = 3;
698 if ( local ) 723 if ( local )
699 findButton( User1 )->setFocus(); 724 findButton( User1 )->setFocus();
700 else 725 else
701 findButton( Ok )->setFocus(); 726 findButton( Ok )->setFocus();
702 exec(); 727 exec();
703 return mSyncResult; 728 return mSyncResult;
704} 729}
705void AddresseeChooser::slot_remote() 730void AddresseeChooser::slot_remote()
706{ 731{
707 mSyncResult = 2; 732 mSyncResult = 2;
708 accept(); 733 accept();
709} 734}
710void AddresseeChooser::slot_local() 735void AddresseeChooser::slot_local()
711{ 736{
712 mSyncResult = 1; 737 mSyncResult = 1;
713 accept(); 738 accept();
714} 739}
diff --git a/kabc/phonenumber.cpp b/kabc/phonenumber.cpp
index 6db1bcf..897c56d 100644
--- a/kabc/phonenumber.cpp
+++ b/kabc/phonenumber.cpp
@@ -1,369 +1,374 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kapplication.h> 28#include <kapplication.h>
29#include <klocale.h> 29#include <klocale.h>
30 30
31#include "phonenumber.h" 31#include "phonenumber.h"
32 32
33using namespace KABC; 33using namespace KABC;
34 34
35PhoneNumber::PhoneNumber() : 35PhoneNumber::PhoneNumber() :
36 mType( Home ) 36 mType( Home )
37{ 37{
38 init(); 38 init();
39} 39}
40 40
41PhoneNumber::PhoneNumber( const QString &number, int type ) : 41PhoneNumber::PhoneNumber( const QString &number, int type ) :
42 mType( type ), mNumber( number ) 42 mType( type ), mNumber( number )
43{ 43{
44 init(); 44 init();
45} 45}
46 46
47PhoneNumber::~PhoneNumber() 47PhoneNumber::~PhoneNumber()
48{ 48{
49} 49}
50 50
51void PhoneNumber::init() 51void PhoneNumber::init()
52{ 52{
53 mId = KApplication::randomString( 8 ); 53 mId = KApplication::randomString( 8 );
54} 54}
55 55
56bool PhoneNumber::operator==( const PhoneNumber &p ) const 56bool PhoneNumber::operator==( const PhoneNumber &p ) const
57{ 57{
58 if ( mNumber != p.mNumber ) return false; 58 if ( mNumber != p.mNumber ) return false;
59 if ( mType != p.mType ) return false; 59 if ( mType != p.mType ) return false;
60 60
61 return true; 61 return true;
62} 62}
63 63
64bool PhoneNumber::operator!=( const PhoneNumber &p ) const 64bool PhoneNumber::operator!=( const PhoneNumber &p ) const
65{ 65{
66 return !( p == *this ); 66 return !( p == *this );
67} 67}
68void PhoneNumber::makeCompat() 68void PhoneNumber::makeCompat()
69{ 69{
70 mType = getCompatType( mType ); 70 mType = getCompatType( mType );
71} 71}
72int PhoneNumber::getCompatType( int type ) 72int PhoneNumber::getCompatType( int type )
73{ 73{
74 74
75 if ((type & Cell) == Cell) { 75 if ((type & Cell) == Cell) {
76 if ((type & Work) == Work) 76 if ((type & Work) == Work)
77 return Car; 77 return Car;
78 return Cell; 78 return Cell;
79 } 79 }
80 if ((type & Home) == Home) { 80 if ((type & Home) == Home) {
81 if ((type & Pref) == Pref) 81 if ((type & Pref) == Pref)
82 return (Home | Pref); 82 return (Home | Pref);
83 if ((type & Fax) == Fax) 83 if ((type & Fax) == Fax)
84 return (Home | Fax); 84 return (Home | Fax);
85 return (Home); 85 return (Home);
86 } 86 }
87 if ((type & Work) == Work) { 87 if ((type & Work) == Work) {
88 if ((type & Pref) == Pref) 88 if ((type & Pref) == Pref)
89 return (Work| Pref); 89 return (Work| Pref);
90 if ((type & Fax) == Fax) 90 if ((type & Fax) == Fax)
91 return (Fax |Work); 91 return (Fax |Work);
92 if ((type & Msg) == Msg) { 92 if ((type & Msg) == Msg) {
93 if ((type & Voice) == Voice) 93 if ((type & Voice) == Voice)
94 return ( Msg | Voice |Work); 94 return ( Msg | Voice |Work);
95 return ( Msg | Work); 95 return ( Msg | Work);
96 } 96 }
97 return Work; 97 return Work;
98 } 98 }
99 if ((type & Pcs) == Pcs) { 99 if ((type & Pcs) == Pcs) {
100 if ((type & Pref) == Pref) 100 if ((type & Pref) == Pref)
101 return Pcs | Pref; 101 return Pcs | Pref;
102 if ((type & Voice) == Voice)
103 return Pcs | Voice;
102 return Pcs; 104 return Pcs;
103 } 105 }
104 if ((type & Car) == Car) 106 if ((type & Car) == Car)
105 return Car; 107 return Car;
106 if ((type & Pager) == Pager) 108 if ((type & Pager) == Pager)
107 return Pager; 109 return Pager;
108 if ((type & Isdn) == Isdn) 110 if ((type & Isdn) == Isdn)
109 return Isdn; 111 return Isdn;
112#if 0
110 if ((type & Video) == Video) 113 if ((type & Video) == Video)
111 return Video; 114 return Video;
112 115#endif
113 if ((type & Msg) == Msg) 116 if ((type & Msg) == Msg)
114 return Msg; 117 return Msg;
115 if ((type & Fax) == Fax) 118 if ((type & Fax) == Fax)
116 return Fax; 119 return Fax;
117 120
118 if ((type & Pref) == Pref) 121 if ((type & Pref) == Pref)
119 return Pref; 122 return Pref;
120 123
121 return Voice; 124 return Voice;
122 125
123} 126}
124bool PhoneNumber::simplifyNumber() 127bool PhoneNumber::simplifyNumber()
125{ 128{
126 QString Number; 129 QString Number;
127 int i; 130 int i;
128 Number = mNumber.stripWhiteSpace (); 131 Number = mNumber.stripWhiteSpace ();
129 mNumber = ""; 132 mNumber = "";
130 for ( i = 0; i < Number.length(); ++i) { 133 for ( i = 0; i < Number.length(); ++i) {
131 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' ) 134 if ( Number.at(i).isDigit() || Number.at(i) == '+'|| Number.at(i) == '*'|| Number.at(i) == '#' )
132 mNumber += Number.at(i); 135 mNumber += Number.at(i);
133 } 136 }
134 return ( mNumber.length() > 0 ); 137 return ( mNumber.length() > 0 );
135} 138}
136// make cellphone compatible 139// make cellphone compatible
137void PhoneNumber::simplifyType() 140void PhoneNumber::simplifyType()
138{ 141{
139 if ( mType & Fax ) mType = Fax; 142 if ( mType & Fax ) mType = Fax;
140 else if ( mType & Cell ) mType = Cell; 143 else if ( mType & Cell ) mType = Cell;
141 else if ( mType & Work ) mType = Work ; 144 else if ( mType & Work ) mType = Work ;
142 else if ( mType & Home ) mType = Home; 145 else if ( mType & Home ) mType = Home;
143 else mType = Pref; 146 else mType = Pref;
144} 147}
145bool PhoneNumber::contains( const PhoneNumber &p ) 148bool PhoneNumber::contains( const PhoneNumber &p )
146{ 149{
147 PhoneNumber myself; 150 PhoneNumber myself;
148 PhoneNumber other; 151 PhoneNumber other;
149 myself = *this; 152 myself = *this;
150 other = p; 153 other = p;
151 myself.simplifyNumber(); 154 myself.simplifyNumber();
152 other.simplifyNumber(); 155 other.simplifyNumber();
153 if ( myself.number() != other.number ()) 156 if ( myself.number() != other.number ())
154 return false; 157 return false;
155 myself.simplifyType(); 158 myself.simplifyType();
156 other.simplifyType(); 159 other.simplifyType();
157 if ( myself.type() == other.type()) 160 if ( myself.type() == other.type())
158 return true; 161 return true;
159 return false; 162 return false;
160} 163}
161 164
162void PhoneNumber::setId( const QString &id ) 165void PhoneNumber::setId( const QString &id )
163{ 166{
164 mId = id; 167 mId = id;
165} 168}
166 169
167QString PhoneNumber::id() const 170QString PhoneNumber::id() const
168{ 171{
169 return mId; 172 return mId;
170} 173}
171 174
172void PhoneNumber::setNumber( const QString &number ) 175void PhoneNumber::setNumber( const QString &number )
173{ 176{
174 mNumber = number; 177 mNumber = number;
175} 178}
176 179
177QString PhoneNumber::number() const 180QString PhoneNumber::number() const
178{ 181{
179 return mNumber; 182 return mNumber;
180} 183}
181 184
182void PhoneNumber::setType( int type ) 185void PhoneNumber::setType( int type )
183{ 186{
184 mType = type; 187 mType = type;
185} 188}
186 189
187int PhoneNumber::type() const 190int PhoneNumber::type() const
188{ 191{
189 return mType; 192 return mType;
190} 193}
191 194
192QString PhoneNumber::typeLabel() const 195QString PhoneNumber::typeLabel() const
193{ 196{
194 QString label; 197 QString label;
195 bool first = true; 198 bool first = true;
196 199
197 TypeList list = typeList(); 200 TypeList list = typeList();
198 201
199 TypeList::Iterator it; 202 TypeList::Iterator it;
200 for ( it = list.begin(); it != list.end(); ++it ) { 203 for ( it = list.begin(); it != list.end(); ++it ) {
201 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) { 204 if ( ( type() & (*it) ) && ( (*it) != Pref ) ) {
202 label.append( ( first ? "" : "/" ) + typeLabel( *it ) ); 205 label.append( ( first ? "" : "/" ) + typeLabel( *it ) );
203 if ( first ) 206 if ( first )
204 first = false; 207 first = false;
205 } 208 }
206 } 209 }
207 210
208 return label; 211 return label;
209} 212}
210 213
211QString PhoneNumber::label() const 214QString PhoneNumber::label() const
212{ 215{
213 return typeLabel( type() ); 216 return typeLabel( type() );
214} 217}
215 218
216PhoneNumber::TypeList PhoneNumber::typeList() 219PhoneNumber::TypeList PhoneNumber::typeList()
217{ 220{
218 TypeList list; 221 TypeList list;
219 222
220 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video 223 list << Home << Work << Msg << Pref << Voice << Fax << Cell << Video
221 << Bbs << Modem << Car << Isdn << Pcs << Pager; 224 << Bbs << Modem << Car << Isdn << Pcs << Pager;
222 225
223 return list; 226 return list;
224} 227}
225PhoneNumber::TypeList PhoneNumber::supportedTypeList() 228PhoneNumber::TypeList PhoneNumber::supportedTypeList()
226{ 229{
227 static TypeList list; 230 static TypeList list;
228 if ( list.count() == 0 ) 231 if ( list.count() == 0 )
229 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< Pcs<< Home << Work << Car << (Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Video << Msg << Pref << Voice; 232 list << (Home| Pref) << (Work| Pref) << Cell <<(Pcs|Pref)<< (Pcs|Voice)<< Home << Work << Car << Pcs <<(Work| Msg | Voice) << (Work| Msg) << (Home | Fax) << (Work| Fax) << Fax<< Pager << Isdn << Msg << Pref << Voice;
230 return list; 233 return list;
231} 234}
232QStringList PhoneNumber::supportedTypeListNames() 235QStringList PhoneNumber::supportedTypeListNames()
233{ 236{
234 static QStringList list; 237 static QStringList list;
235 if ( list.count() == 0 ) 238 if ( list.count() == 0 )
236 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SIP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Video") << i18n("Callback") << i18n("Primary")<< i18n("Other"); 239 list << i18n("Home") << i18n("Work") << i18n("Mobile") << i18n("SIP") << i18n("VoIP") <<i18n("Home2")<< i18n("Work2") << i18n("Mobile2") << i18n("SIP2") << i18n("Assistent") << i18n("Company") << i18n("Fax (Home)") << i18n("Fax (Work)") << i18n("Fax (Other)") << i18n("Pager") << i18n("ISDN") << i18n("Callback") << i18n("Primary")<< i18n("Other");
237 return list; 240 return list;
238} 241}
239 242
240int PhoneNumber::typeListIndex4Type(int type ) 243int PhoneNumber::typeListIndex4Type(int type )
241{ 244{
242 TypeList list = supportedTypeList(); 245 TypeList list = supportedTypeList();
243 int i = 0; 246 int i = 0;
244 while ( i < list.count() ) { 247 while ( i < list.count() ) {
245 if ( list [i] == type ) 248 if ( list [i] == type )
246 return i; 249 return i;
247 ++i; 250 ++i;
248 } 251 }
249 return list.count()-1; 252 return list.count()-1;
250} 253}
251 254
252QString PhoneNumber::label( int type ) 255QString PhoneNumber::label( int type )
253{ 256{
254 return typeLabel( type ); 257 return typeLabel( type );
255} 258}
256 259
257QString PhoneNumber::typeLabel( int type ) 260QString PhoneNumber::typeLabel( int type )
258{ 261{
259 if ((type & Cell) == Cell) 262 if ((type & Cell) == Cell)
260 return i18n("Mobile"); 263 return i18n("Mobile");
261 if ((type & Home) == Home) { 264 if ((type & Home) == Home) {
262 if ((type & Pref) == Pref) 265 if ((type & Pref) == Pref)
263 return i18n("Home"); 266 return i18n("Home");
264 if ((type & Fax) == Fax) 267 if ((type & Fax) == Fax)
265 return i18n("Fax (Home)"); 268 return i18n("Fax (Home)");
266 return i18n("Home2"); 269 return i18n("Home2");
267 } 270 }
268 271
269 if ((type & Work) == Work) { 272 if ((type & Work) == Work) {
270 if ((type & Pref) == Pref) 273 if ((type & Pref) == Pref)
271 return i18n("Work"); 274 return i18n("Work");
272 if ((type & Fax) == Fax) 275 if ((type & Fax) == Fax)
273 return i18n("Fax (Work)"); 276 return i18n("Fax (Work)");
274 if ((type & Msg) == Msg) { 277 if ((type & Msg) == Msg) {
275 if ((type & Voice) == Voice) 278 if ((type & Voice) == Voice)
276 return i18n("Assistent"); 279 return i18n("Assistent");
277 return i18n("Company"); 280 return i18n("Company");
278 } 281 }
279 return i18n("Work2"); 282 return i18n("Work2");
280 } 283 }
281 if ((type & Pcs) == Pcs) { 284 if ((type & Pcs) == Pcs) {
282 if ((type & Pref) == Pref) 285 if ((type & Pref) == Pref)
283 return i18n("SIP"); 286 return i18n("SiP");
284 return i18n("VoIP"); 287 if ((type & Voice) == Voice)
288 return i18n("VoIP");
289 return i18n("SiP2");
285 } 290 }
286 if ((type & Car) == Car) 291 if ((type & Car) == Car)
287 return i18n("Mobile2"); 292 return i18n("Mobile2");
288 if ((type & Pager) == Pager) 293 if ((type & Pager) == Pager)
289 return i18n("Pager"); 294 return i18n("Pager");
290 if ((type & Isdn) == Isdn) 295 if ((type & Isdn) == Isdn)
291 return i18n("ISDN"); 296 return i18n("ISDN");
292 if ((type & Video) == Video) 297 if ((type & Video) == Video)
293 return i18n("Video"); 298 return i18n("Video");
294 299
295 if ((type & Msg) == Msg) 300 if ((type & Msg) == Msg)
296 return i18n("Callback"); 301 return i18n("Callback");
297 if ((type & Fax) == Fax) 302 if ((type & Fax) == Fax)
298 return i18n("Fax (Other)"); 303 return i18n("Fax (Other)");
299 304
300 if ((type & Pref) == Pref) 305 if ((type & Pref) == Pref)
301 return i18n("Primary"); 306 return i18n("Primary");
302 307
303 308
304 return i18n("Other"); 309 return i18n("Other");
305 310
306 311
307#if 0 312#if 0
308 313
309 314
310 315
311 QString typeString; 316 QString typeString;
312 317
313 318
314 if ((type & Cell) == Cell) 319 if ((type & Cell) == Cell)
315 typeString += i18n("Mobile") +" "; 320 typeString += i18n("Mobile") +" ";
316 if ((type & Home) == Home) 321 if ((type & Home) == Home)
317 typeString += i18n("Home")+" "; 322 typeString += i18n("Home")+" ";
318 else if ((type & Work) == Work) 323 else if ((type & Work) == Work)
319 typeString += i18n("Work")+" "; 324 typeString += i18n("Work")+" ";
320 325
321 if ((type & Sip) == Sip) 326 if ((type & Sip) == Sip)
322 typeString += i18n("SIP")+" "; 327 typeString += i18n("SIP")+" ";
323 if ((type & Car) == Car) 328 if ((type & Car) == Car)
324 typeString += i18n("Car")+" "; 329 typeString += i18n("Car")+" ";
325 330
326 if ((type & Fax) == Fax) 331 if ((type & Fax) == Fax)
327 typeString += i18n("Fax"); 332 typeString += i18n("Fax");
328 else if ((type & Msg) == Msg) 333 else if ((type & Msg) == Msg)
329 typeString += i18n("Messenger"); 334 typeString += i18n("Messenger");
330 else if ((type & Video) == Video) 335 else if ((type & Video) == Video)
331 typeString += i18n("Video"); 336 typeString += i18n("Video");
332 else if ((type & Bbs) == Bbs) 337 else if ((type & Bbs) == Bbs)
333 typeString += i18n("Mailbox"); 338 typeString += i18n("Mailbox");
334 else if ((type & Modem) == Modem) 339 else if ((type & Modem) == Modem)
335 typeString += i18n("Modem"); 340 typeString += i18n("Modem");
336 else if ((type & Isdn) == Isdn) 341 else if ((type & Isdn) == Isdn)
337 typeString += i18n("ISDN"); 342 typeString += i18n("ISDN");
338 else if ((type & Pcs) == Pcs) 343 else if ((type & Pcs) == Pcs)
339 typeString += i18n("PCS"); 344 typeString += i18n("PCS");
340 else if ((type & Pager) == Pager) 345 else if ((type & Pager) == Pager)
341 typeString += i18n("Pager"); 346 typeString += i18n("Pager");
342 // add the prefered flag 347 // add the prefered flag
343 /* 348 /*
344 if ((type & Pref) == Pref) 349 if ((type & Pref) == Pref)
345 typeString += i18n("(p)"); 350 typeString += i18n("(p)");
346 */ 351 */
347 //if we still have no match, return "other" 352 //if we still have no match, return "other"
348 if (typeString.isEmpty()) { 353 if (typeString.isEmpty()) {
349 if ((type & Voice) == Voice) 354 if ((type & Voice) == Voice)
350 return i18n("Voice"); 355 return i18n("Voice");
351 else 356 else
352 return i18n("Other"); 357 return i18n("Other");
353 } 358 }
354 359
355 return typeString.stripWhiteSpace(); 360 return typeString.stripWhiteSpace();
356#endif 361#endif
357} 362}
358 363
359QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone ) 364QDataStream &KABC::operator<<( QDataStream &s, const PhoneNumber &phone )
360{ 365{
361 return s << phone.mId << phone.mType << phone.mNumber; 366 return s << phone.mId << phone.mType << phone.mNumber;
362} 367}
363 368
364QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone ) 369QDataStream &KABC::operator>>( QDataStream &s, PhoneNumber &phone )
365{ 370{
366 s >> phone.mId >> phone.mType >> phone.mNumber; 371 s >> phone.mId >> phone.mType >> phone.mNumber;
367 372
368 return s; 373 return s;
369} 374}