summaryrefslogtreecommitdiffabout
path: root/kabc/addressbook.cpp
authorzautrix <zautrix>2004-10-29 14:01:58 (UTC)
committer zautrix <zautrix>2004-10-29 14:01:58 (UTC)
commit102cc4a711e303372efea9797623ee2d9f27f63c (patch) (unidiff)
tree32e56b436e52b5b1bab701839a24fc175288d57c /kabc/addressbook.cpp
parent8c55eb6afe84ef69bb284d384a0c9f1ef1484ad8 (diff)
downloadkdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.zip
kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.gz
kdepimpi-102cc4a711e303372efea9797623ee2d9f27f63c.tar.bz2
removed debug output
Diffstat (limited to 'kabc/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addressbook.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp
index 4c4ae09..8487ff3 100644
--- a/kabc/addressbook.cpp
+++ b/kabc/addressbook.cpp
@@ -1035,214 +1035,225 @@ Addressee::List AddressBook::findByName( const QString &name )
1035 } 1035 }
1036 1036
1037 return results; 1037 return results;
1038} 1038}
1039 1039
1040Addressee::List AddressBook::findByEmail( const QString &email ) 1040Addressee::List AddressBook::findByEmail( const QString &email )
1041{ 1041{
1042 Addressee::List results; 1042 Addressee::List results;
1043 QStringList mailList; 1043 QStringList mailList;
1044 1044
1045 Iterator it; 1045 Iterator it;
1046 for ( it = begin(); it != end(); ++it ) { 1046 for ( it = begin(); it != end(); ++it ) {
1047 mailList = (*it).emails(); 1047 mailList = (*it).emails();
1048 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { 1048 for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
1049 if ( email == (*ite) ) { 1049 if ( email == (*ite) ) {
1050 results.append( *it ); 1050 results.append( *it );
1051 } 1051 }
1052 } 1052 }
1053 } 1053 }
1054 1054
1055 return results; 1055 return results;
1056} 1056}
1057 1057
1058Addressee::List AddressBook::findByCategory( const QString &category ) 1058Addressee::List AddressBook::findByCategory( const QString &category )
1059{ 1059{
1060 Addressee::List results; 1060 Addressee::List results;
1061 1061
1062 Iterator it; 1062 Iterator it;
1063 for ( it = begin(); it != end(); ++it ) { 1063 for ( it = begin(); it != end(); ++it ) {
1064 if ( (*it).hasCategory( category) ) { 1064 if ( (*it).hasCategory( category) ) {
1065 results.append( *it ); 1065 results.append( *it );
1066 } 1066 }
1067 } 1067 }
1068 1068
1069 return results; 1069 return results;
1070} 1070}
1071 1071
1072void AddressBook::dump() const 1072void AddressBook::dump() const
1073{ 1073{
1074 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; 1074 kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl;
1075 1075
1076 ConstIterator it; 1076 ConstIterator it;
1077 for( it = begin(); it != end(); ++it ) { 1077 for( it = begin(); it != end(); ++it ) {
1078 (*it).dump(); 1078 (*it).dump();
1079 } 1079 }
1080 1080
1081 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; 1081 kdDebug(5700) << "AddressBook::dump() --- end ---" << endl;
1082} 1082}
1083 1083
1084QString AddressBook::identifier() 1084QString AddressBook::identifier()
1085{ 1085{
1086 QStringList identifier; 1086 QStringList identifier;
1087 1087
1088 1088
1089 KRES::Manager<Resource>::ActiveIterator it; 1089 KRES::Manager<Resource>::ActiveIterator it;
1090 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1090 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1091 if ( !(*it)->identifier().isEmpty() ) 1091 if ( !(*it)->identifier().isEmpty() )
1092 identifier.append( (*it)->identifier() ); 1092 identifier.append( (*it)->identifier() );
1093 } 1093 }
1094 1094
1095 return identifier.join( ":" ); 1095 return identifier.join( ":" );
1096} 1096}
1097 1097
1098Field::List AddressBook::fields( int category ) 1098Field::List AddressBook::fields( int category )
1099{ 1099{
1100 if ( d->mAllFields.isEmpty() ) { 1100 if ( d->mAllFields.isEmpty() ) {
1101 d->mAllFields = Field::allFields(); 1101 d->mAllFields = Field::allFields();
1102 } 1102 }
1103 1103
1104 if ( category == Field::All ) return d->mAllFields; 1104 if ( category == Field::All ) return d->mAllFields;
1105 1105
1106 Field::List result; 1106 Field::List result;
1107 Field::List::ConstIterator it; 1107 Field::List::ConstIterator it;
1108 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { 1108 for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) {
1109 if ( (*it)->category() & category ) result.append( *it ); 1109 if ( (*it)->category() & category ) result.append( *it );
1110 } 1110 }
1111 1111
1112 return result; 1112 return result;
1113} 1113}
1114 1114
1115bool AddressBook::addCustomField( const QString &label, int category, 1115bool AddressBook::addCustomField( const QString &label, int category,
1116 const QString &key, const QString &app ) 1116 const QString &key, const QString &app )
1117{ 1117{
1118 if ( d->mAllFields.isEmpty() ) { 1118 if ( d->mAllFields.isEmpty() ) {
1119 d->mAllFields = Field::allFields(); 1119 d->mAllFields = Field::allFields();
1120 } 1120 }
1121//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; 1121//US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app;
1122 QString a = app.isNull() ? KGlobal::getAppName() : app; 1122 QString a = app.isNull() ? KGlobal::getAppName() : app;
1123 1123
1124 QString k = key.isNull() ? label : key; 1124 QString k = key.isNull() ? label : key;
1125 1125
1126 Field *field = Field::createCustomField( label, category, k, a ); 1126 Field *field = Field::createCustomField( label, category, k, a );
1127 1127
1128 if ( !field ) return false; 1128 if ( !field ) return false;
1129 1129
1130 d->mAllFields.append( field ); 1130 d->mAllFields.append( field );
1131 1131
1132 return true; 1132 return true;
1133} 1133}
1134 1134
1135QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) 1135QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab )
1136{ 1136{
1137 if (!ab.d) return s; 1137 if (!ab.d) return s;
1138 1138
1139 return s << ab.d->mAddressees; 1139 return s << ab.d->mAddressees;
1140} 1140}
1141 1141
1142QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) 1142QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab )
1143{ 1143{
1144 if (!ab.d) return s; 1144 if (!ab.d) return s;
1145 1145
1146 s >> ab.d->mAddressees; 1146 s >> ab.d->mAddressees;
1147 1147
1148 return s; 1148 return s;
1149} 1149}
1150 1150
1151bool AddressBook::addResource( Resource *resource ) 1151bool AddressBook::addResource( Resource *resource )
1152{ 1152{
1153 if ( !resource->open() ) { 1153 if ( !resource->open() ) {
1154 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; 1154 kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl;
1155 return false; 1155 return false;
1156 } 1156 }
1157 1157
1158 resource->setAddressBook( this ); 1158 resource->setAddressBook( this );
1159 1159
1160 d->mManager->add( resource ); 1160 d->mManager->add( resource );
1161 return true; 1161 return true;
1162} 1162}
1163void AddressBook::removeResources()
1164{
1165 //remove all possible resources. This should cleanup the configfile.
1166 QPtrList<KABC::Resource> mResources = resources();
1167
1168 QPtrListIterator<KABC::Resource> it(mResources);
1169 for ( ; it.current(); ++it ) {
1170 KABC::Resource *res = it.current();
1171 removeResource(res);
1172 }
1173}
1163 1174
1164bool AddressBook::removeResource( Resource *resource ) 1175bool AddressBook::removeResource( Resource *resource )
1165{ 1176{
1166 resource->close(); 1177 resource->close();
1167 1178
1168 if ( resource == standardResource() ) 1179 if ( resource == standardResource() )
1169 d->mManager->setStandardResource( 0 ); 1180 d->mManager->setStandardResource( 0 );
1170 1181
1171 resource->setAddressBook( 0 ); 1182 resource->setAddressBook( 0 );
1172 1183
1173 d->mManager->remove( resource ); 1184 d->mManager->remove( resource );
1174 return true; 1185 return true;
1175} 1186}
1176 1187
1177QPtrList<Resource> AddressBook::resources() 1188QPtrList<Resource> AddressBook::resources()
1178{ 1189{
1179 QPtrList<Resource> list; 1190 QPtrList<Resource> list;
1180 1191
1181// qDebug("AddressBook::resources() 1"); 1192// qDebug("AddressBook::resources() 1");
1182 1193
1183 KRES::Manager<Resource>::ActiveIterator it; 1194 KRES::Manager<Resource>::ActiveIterator it;
1184 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) 1195 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it )
1185 list.append( *it ); 1196 list.append( *it );
1186 1197
1187 return list; 1198 return list;
1188} 1199}
1189 1200
1190/*US 1201/*US
1191void AddressBook::setErrorHandler( ErrorHandler *handler ) 1202void AddressBook::setErrorHandler( ErrorHandler *handler )
1192{ 1203{
1193 delete d->mErrorHandler; 1204 delete d->mErrorHandler;
1194 d->mErrorHandler = handler; 1205 d->mErrorHandler = handler;
1195} 1206}
1196*/ 1207*/
1197 1208
1198void AddressBook::error( const QString& msg ) 1209void AddressBook::error( const QString& msg )
1199{ 1210{
1200/*US 1211/*US
1201 if ( !d->mErrorHandler ) // create default error handler 1212 if ( !d->mErrorHandler ) // create default error handler
1202 d->mErrorHandler = new ConsoleErrorHandler; 1213 d->mErrorHandler = new ConsoleErrorHandler;
1203 1214
1204 if ( d->mErrorHandler ) 1215 if ( d->mErrorHandler )
1205 d->mErrorHandler->error( msg ); 1216 d->mErrorHandler->error( msg );
1206 else 1217 else
1207 kdError(5700) << "no error handler defined" << endl; 1218 kdError(5700) << "no error handler defined" << endl;
1208*/ 1219*/
1209 kdDebug(5700) << "msg" << endl; 1220 kdDebug(5700) << "msg" << endl;
1210 qDebug(msg); 1221 qDebug(msg);
1211} 1222}
1212 1223
1213void AddressBook::deleteRemovedAddressees() 1224void AddressBook::deleteRemovedAddressees()
1214{ 1225{
1215 Addressee::List::Iterator it; 1226 Addressee::List::Iterator it;
1216 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { 1227 for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) {
1217 Resource *resource = (*it).resource(); 1228 Resource *resource = (*it).resource();
1218 if ( resource && !resource->readOnly() && resource->isOpen() ) 1229 if ( resource && !resource->readOnly() && resource->isOpen() )
1219 resource->removeAddressee( *it ); 1230 resource->removeAddressee( *it );
1220 } 1231 }
1221 1232
1222 d->mRemovedAddressees.clear(); 1233 d->mRemovedAddressees.clear();
1223} 1234}
1224 1235
1225void AddressBook::setStandardResource( Resource *resource ) 1236void AddressBook::setStandardResource( Resource *resource )
1226{ 1237{
1227// qDebug("AddressBook::setStandardResource 1"); 1238// qDebug("AddressBook::setStandardResource 1");
1228 d->mManager->setStandardResource( resource ); 1239 d->mManager->setStandardResource( resource );
1229} 1240}
1230 1241
1231Resource *AddressBook::standardResource() 1242Resource *AddressBook::standardResource()
1232{ 1243{
1233 return d->mManager->standardResource(); 1244 return d->mManager->standardResource();
1234} 1245}
1235 1246
1236KRES::Manager<Resource> *AddressBook::resourceManager() 1247KRES::Manager<Resource> *AddressBook::resourceManager()
1237{ 1248{
1238 return d->mManager; 1249 return d->mManager;
1239} 1250}
1240 1251
1241void AddressBook::cleanUp() 1252void AddressBook::cleanUp()
1242{ 1253{
1243 KRES::Manager<Resource>::ActiveIterator it; 1254 KRES::Manager<Resource>::ActiveIterator it;
1244 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { 1255 for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) {
1245 if ( !(*it)->readOnly() && (*it)->isOpen() ) 1256 if ( !(*it)->readOnly() && (*it)->isOpen() )
1246 (*it)->cleanUp(); 1257 (*it)->cleanUp();
1247 } 1258 }
1248} 1259}