28 Ticket::Ticket( Resource *resource )
29 : mResource( resource )
41 Resource *Ticket::resource()
46 struct Resource::Iterator::IteratorData
48 Addressee::Map::Iterator mIt;
51 struct Resource::ConstIterator::ConstIteratorData
53 Addressee::Map::ConstIterator mIt;
56 Resource::Iterator::Iterator()
78 Resource::Iterator::~Iterator()
83 const Addressee &Resource::Iterator::operator*()
const
88 Addressee &Resource::Iterator::operator*()
117 bool Resource::Iterator::operator==(
const Iterator &it )
119 return ( d->mIt == it.d->mIt );
122 bool Resource::Iterator::operator!=(
const Iterator &it )
124 return ( d->mIt != it.d->mIt );
127 Resource::ConstIterator::ConstIterator()
129 d =
new ConstIteratorData;
134 d =
new ConstIteratorData;
140 d =
new ConstIteratorData;
150 d =
new ConstIteratorData;
155 Resource::ConstIterator::~ConstIterator()
160 const Addressee &Resource::ConstIterator::operator*()
const
189 bool Resource::ConstIterator::operator==(
const ConstIterator &it )
191 return ( d->mIt == it.d->mIt );
194 bool Resource::ConstIterator::operator!=(
const ConstIterator &it )
196 return ( d->mIt != it.d->mIt );
200 Resource::Resource(
const TDEConfig *config )
201 : KRES::Resource( config ), mAddressBook( 0 )
205 Resource::~Resource()
212 it.d->mIt = mAddrMap.begin();
220 it.d->mIt = mAddrMap.constBegin();
227 it.d->mIt = mAddrMap.end();
235 it.d->mIt = mAddrMap.constEnd();
239 void Resource::writeConfig(
TDEConfig *config )
241 KRES::Resource::writeConfig( config );
254 Ticket *Resource::createTicket( Resource *resource )
256 return new Ticket( resource );
259 void Resource::insertAddressee(
const Addressee &addr )
261 mAddrMap.insert( addr.
uid(), addr );
264 void Resource::removeAddressee(
const Addressee &addr )
266 mAddrMap.erase( addr.
uid() );
269 Addressee Resource::findByUid(
const TQString &uid )
271 Addressee::Map::ConstIterator it = mAddrMap.find( uid );
273 if ( it != mAddrMap.end() )
279 Addressee::List Resource::findByName(
const TQString &name )
281 Addressee::List results;
284 for ( it = begin(); it !=
end(); ++it ) {
285 if ( name == (*it).name() )
286 results.append( *it );
292 Addressee::List Resource::findByEmail(
const TQString &email )
294 Addressee::List results;
295 const TQString lowerEmail = email.lower();
298 for ( it = begin(); it !=
end(); ++it ) {
299 const TQStringList mailList = (*it).emails();
300 for ( TQStringList::ConstIterator ite = mailList.begin(); ite != mailList.end(); ++ite ) {
301 if ( lowerEmail == (*ite).lower() )
302 results.append( *it );
309 Addressee::List Resource::findByCategory(
const TQString &category )
311 Addressee::List results;
314 for ( it = begin(); it !=
end(); ++it ) {
315 if ( (*it).hasCategory( category) ) {
316 results.append( *it );
323 void Resource::clear()
328 bool Resource::asyncLoad()
332 emit loadingError(
this, i18n(
"Loading resource '%1' failed!" )
333 .arg( resourceName() ) );
335 emit loadingFinished(
this );
340 bool Resource::asyncSave(
Ticket *ticket ) {
341 bool ok =
save( ticket );
343 emit savingError(
this, i18n(
"Saving resource '%1' failed!" )
344 .arg( resourceName() ) );
346 emit savingFinished(
this );
351 #include "resource.moc"
TQString uid() const
Return unique identifier.
Helper class for handling coordinated save of address books.
static data, shared by ALL addressee objects
const TDEShortcut & end()
const TDEShortcut & save()