| # kabc Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# addressee.cpp

    00001 /*** Warning! This file has been generated by the script makeaddressee ***/
    00002 /*
    00003     This file is part of libkabc.
    00004     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
    00005
    00006     This library is free software; you can redistribute it and/or
    00007     modify it under the terms of the GNU Library General Public
    00008     License as published by the Free Software Foundation; either
    00009     version 2 of the License, or (at your option) any later version.
    00010
    00011     This library is distributed in the hope that it will be useful,
    00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014     Library General Public License for more details.
    00015
    00016     You should have received a copy of the GNU Library General Public License
    00017     along with this library; see the file COPYING.LIB.  If not, write to
    00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019     Boston, MA 02111-1307, USA.
    00020 */
    00021 #include <ksharedptr.h>
    00022 #include <kdebug.h>
    00023 #include <kapplication.h>
    00024 #include <klocale.h>
    00025
    00026 #include "resource.h"
    00027 #include "addressee.h"
    00028
    00029 using namespace KABC;
    00030
    00031 bool matchBinaryPattern( int value, int pattern, int max );
    00032
    00033 struct Addressee::AddresseeData : public KShared
    00034 {
    00035   QString uid;
    00036   QString name;
    00037   QString formattedName;
    00038   QString familyName;
    00039   QString givenName;
    00040   QString additionalName;
    00041   QString prefix;
    00042   QString suffix;
    00043   QString nickName;
    00044   QDateTime birthday;
    00045   QString mailer;
    00046   TimeZone timeZone;
    00047   Geo geo;
    00048   QString title;
    00049   QString role;
    00050   QString organization;
    00051   QString note;
    00052   QString productId;
    00053   QDateTime revision;
    00054   QString sortString;
    00055   KURL url;
    00056   Secrecy secrecy;
    00057   Picture logo;
    00058   Picture photo;
    00059   Sound sound;
    00060   Agent agent;
    00061
    00062   PhoneNumber::List phoneNumbers;
    00063   Address::List addresses;
    00064   Key::List keys;
    00065   QStringList emails;
    00066   QStringList categories;
    00067   QStringList custom;
    00068
    00069   Resource *resource;
    00070
    00071   bool empty;
    00072   bool changed;
    00073 };
    00074
    00075 Addressee::Addressee()
    00076 {
    00077   mData = new AddresseeData;
    00078   mData->uid = KApplication::randomString( 10 );
    00079   mData->empty = true;
    00080   mData->changed = false;
    00081   mData->resource = 0;
    00082 }
    00083
    00084 Addressee::~Addressee()
    00085 {
    00086 }
    00087
    00088 Addressee::Addressee( const Addressee &a )
    00089 {
    00090   mData = a.mData;
    00091 }
    00092
    00093 Addressee &Addressee::operator=( const Addressee &a )
    00094 {
    00095   mData = a.mData;
    00096   return (*this);
    00097 }
    00098
    00099 Addressee Addressee::copy()
    00100 {
    00101   Addressee a;
    00102   *(a.mData) = *mData;
    00103   return a;
    00104 }
    00105
    00106 void Addressee::detach()
    00107 {
    00108   if ( mData.count() == 1 ) return;
    00109   *this = copy();
    00110 }
    00111
    00112 bool Addressee::operator==( const Addressee &a ) const
    00113 {
    00114   if ( mData->uid != a.mData->uid ) return false;
    00115   if ( mData->name != a.mData->name ) return false;
    00116   if ( mData->formattedName != a.mData->formattedName ) return false;
    00117   if ( mData->familyName != a.mData->familyName ) return false;
    00118   if ( mData->givenName != a.mData->givenName ) return false;
    00119   if ( mData->additionalName != a.mData->additionalName ) return false;
    00120   if ( mData->prefix != a.mData->prefix ) return false;
    00121   if ( mData->suffix != a.mData->suffix ) return false;
    00122   if ( mData->nickName != a.mData->nickName ) return false;
    00123   if ( mData->birthday != a.mData->birthday ) return false;
    00124   if ( mData->mailer != a.mData->mailer ) return false;
    00125   if ( mData->timeZone != a.mData->timeZone ) return false;
    00126   if ( mData->geo != a.mData->geo ) return false;
    00127   if ( mData->title != a.mData->title ) return false;
    00128   if ( mData->role != a.mData->role ) return false;
    00129   if ( mData->organization != a.mData->organization ) return false;
    00130   if ( mData->note != a.mData->note ) return false;
    00131   if ( mData->productId != a.mData->productId ) return false;
    00132   if ( mData->revision != a.mData->revision ) return false;
    00133   if ( mData->sortString != a.mData->sortString ) return false;
    00134   if ( mData->secrecy != a.mData->secrecy ) return false;
    00135   if ( mData->logo != a.mData->logo ) return false;
    00136   if ( mData->photo != a.mData->photo ) return false;
    00137   if ( mData->sound != a.mData->sound ) return false;
    00138   if ( mData->agent != a.mData->agent ) return false;
    00139   if ( ( mData->url.isValid() || a.mData->url.isValid() ) &&
    00140        ( mData->url != a.mData->url ) ) return false;
    00141   if ( mData->phoneNumbers != a.mData->phoneNumbers ) return false;
    00142   if ( mData->addresses != a.mData->addresses ) return false;
    00143   if ( mData->keys != a.mData->keys ) return false;
    00144   if ( mData->emails != a.mData->emails ) return false;
    00145   if ( mData->categories != a.mData->categories ) return false;
    00146   if ( mData->custom != a.mData->custom ) return false;
    00147
    00148   return true;
    00149 }
    00150
    00151 bool Addressee::operator!=( const Addressee &a ) const
    00152 {
    00153   return !( a == *this );
    00154 }
    00155
    00156 bool Addressee::isEmpty() const
    00157 {
    00158   return mData->empty;
    00159 }
    00160
    00161 void Addressee::setUid( const QString &uid )
    00162 {
    00163   if ( uid == mData->uid ) return;
    00164   detach();
    00165   mData->empty = false;
    00166   mData->uid = uid;
    00167 }
    00168
    00169 QString Addressee::uid() const
    00170 {
    00171   return mData->uid;
    00172 }
    00173
    00174 QString Addressee::uidLabel()
    00175 {
    00176   return i18n("Unique Identifier");
    00177 }
    00178
    00179
    00180 void Addressee::setName( const QString &name )
    00181 {
    00182   if ( name == mData->name ) return;
    00183   detach();
    00184   mData->empty = false;
    00185   mData->name = name;
    00186 }
    00187
    00188 QString Addressee::name() const
    00189 {
    00190   return mData->name;
    00191 }
    00192
    00193 QString Addressee::nameLabel()
    00194 {
    00195   return i18n("Name");
    00196 }
    00197
    00198
    00199 void Addressee::setFormattedName( const QString &formattedName )
    00200 {
    00201   if ( formattedName == mData->formattedName ) return;
    00202   detach();
    00203   mData->empty = false;
    00204   mData->formattedName = formattedName;
    00205 }
    00206
    00207 QString Addressee::formattedName() const
    00208 {
    00209   return mData->formattedName;
    00210 }
    00211
    00212 QString Addressee::formattedNameLabel()
    00213 {
    00214   return i18n("Formatted Name");
    00215 }
    00216
    00217
    00218 void Addressee::setFamilyName( const QString &familyName )
    00219 {
    00220   if ( familyName == mData->familyName ) return;
    00221   detach();
    00222   mData->empty = false;
    00223   mData->familyName = familyName;
    00224 }
    00225
    00226 QString Addressee::familyName() const
    00227 {
    00228   return mData->familyName;
    00229 }
    00230
    00231 QString Addressee::familyNameLabel()
    00232 {
    00233   return i18n("Family Name");
    00234 }
    00235
    00236
    00237 void Addressee::setGivenName( const QString &givenName )
    00238 {
    00239   if ( givenName == mData->givenName ) return;
    00240   detach();
    00241   mData->empty = false;
    00242   mData->givenName = givenName;
    00243 }
    00244
    00245 QString Addressee::givenName() const
    00246 {
    00247   return mData->givenName;
    00248 }
    00249
    00250 QString Addressee::givenNameLabel()
    00251 {
    00252   return i18n("Given Name");
    00253 }
    00254
    00255
    00256 void Addressee::setAdditionalName( const QString &additionalName )
    00257 {
    00258   if ( additionalName == mData->additionalName ) return;
    00259   detach();
    00260   mData->empty = false;
    00261   mData->additionalName = additionalName;
    00262 }
    00263
    00264 QString Addressee::additionalName() const
    00265 {
    00266   return mData->additionalName;
    00267 }
    00268
    00269 QString Addressee::additionalNameLabel()
    00270 {
    00271   return i18n("Additional Names");
    00272 }
    00273
    00274
    00275 void Addressee::setPrefix( const QString &prefix )
    00276 {
    00277   if ( prefix == mData->prefix ) return;
    00278   detach();
    00279   mData->empty = false;
    00280   mData->prefix = prefix;
    00281 }
    00282
    00283 QString Addressee::prefix() const
    00284 {
    00285   return mData->prefix;
    00286 }
    00287
    00288 QString Addressee::prefixLabel()
    00289 {
    00290   return i18n("Honorific Prefixes");
    00291 }
    00292
    00293
    00294 void Addressee::setSuffix( const QString &suffix )
    00295 {
    00296   if ( suffix == mData->suffix ) return;
    00297   detach();
    00298   mData->empty = false;
    00299   mData->suffix = suffix;
    00300 }
    00301
    00302 QString Addressee::suffix() const
    00303 {
    00304   return mData->suffix;
    00305 }
    00306
    00307 QString Addressee::suffixLabel()
    00308 {
    00309   return i18n("Honorific Suffixes");
    00310 }
    00311
    00312
    00313 void Addressee::setNickName( const QString &nickName )
    00314 {
    00315   if ( nickName == mData->nickName ) return;
    00316   detach();
    00317   mData->empty = false;
    00318   mData->nickName = nickName;
    00319 }
    00320
    00321 QString Addressee::nickName() const
    00322 {
    00323   return mData->nickName;
    00324 }
    00325
    00326 QString Addressee::nickNameLabel()
    00327 {
    00328   return i18n("Nick Name");
    00329 }
    00330
    00331
    00332 void Addressee::setBirthday( const QDateTime &birthday )
    00333 {
    00334   if ( birthday == mData->birthday ) return;
    00335   detach();
    00336   mData->empty = false;
    00337   mData->birthday = birthday;
    00338 }
    00339
    00340 QDateTime Addressee::birthday() const
    00341 {
    00342   return mData->birthday;
    00343 }
    00344
    00345 QString Addressee::birthdayLabel()
    00346 {
    00347   return i18n("Birthday");
    00348 }
    00349
    00350
    00351 QString Addressee::homeAddressStreetLabel()
    00352 {
    00353   return i18n("Home Address Street");
    00354 }
    00355
    00356
    00357 QString Addressee::homeAddressLocalityLabel()
    00358 {
    00359   return i18n("Home Address Locality");
    00360 }
    00361
    00362
    00363 QString Addressee::homeAddressRegionLabel()
    00364 {
    00365   return i18n("Home Address Region");
    00366 }
    00367
    00368
    00369 QString Addressee::homeAddressPostalCodeLabel()
    00370 {
    00371   return i18n("Home Address Postal Code");
    00372 }
    00373
    00374
    00375 QString Addressee::homeAddressCountryLabel()
    00376 {
    00377   return i18n("Home Address Country");
    00378 }
    00379
    00380
    00381 QString Addressee::homeAddressLabelLabel()
    00382 {
    00383   return i18n("Home Address Label");
    00384 }
    00385
    00386
    00387 QString Addressee::businessAddressStreetLabel()
    00388 {
    00389   return i18n("Business Address Street");
    00390 }
    00391
    00392
    00393 QString Addressee::businessAddressLocalityLabel()
    00394 {
    00395   return i18n("Business Address Locality");
    00396 }
    00397
    00398
    00399 QString Addressee::businessAddressRegionLabel()
    00400 {
    00401   return i18n("Business Address Region");
    00402 }
    00403
    00404
    00405 QString Addressee::businessAddressPostalCodeLabel()
    00406 {
    00407   return i18n("Business Address Postal Code");
    00408 }
    00409
    00410
    00411 QString Addressee::businessAddressCountryLabel()
    00412 {
    00413   return i18n("Business Address Country");
    00414 }
    00415
    00416
    00417 QString Addressee::businessAddressLabelLabel()
    00418 {
    00419   return i18n("Business Address Label");
    00420 }
    00421
    00422
    00423 QString Addressee::homePhoneLabel()
    00424 {
    00425   return i18n("Home Phone");
    00426 }
    00427
    00428
    00429 QString Addressee::businessPhoneLabel()
    00430 {
    00431   return i18n("Business Phone");
    00432 }
    00433
    00434
    00435 QString Addressee::mobilePhoneLabel()
    00436 {
    00437   return i18n("Mobile Phone");
    00438 }
    00439
    00440
    00441 QString Addressee::homeFaxLabel()
    00442 {
    00443   return i18n("Home Fax");
    00444 }
    00445
    00446
    00447 QString Addressee::businessFaxLabel()
    00448 {
    00449   return i18n("Business Fax");
    00450 }
    00451
    00452
    00453 QString Addressee::carPhoneLabel()
    00454 {
    00455   return i18n("Car Phone");
    00456 }
    00457
    00458
    00459 QString Addressee::isdnLabel()
    00460 {
    00461   return i18n("ISDN");
    00462 }
    00463
    00464
    00465 QString Addressee::pagerLabel()
    00466 {
    00467   return i18n("Pager");
    00468 }
    00469
    00470
    00471 QString Addressee::emailLabel()
    00472 {
    00473   return i18n("Email Address");
    00474 }
    00475
    00476
    00477 void Addressee::setMailer( const QString &mailer )
    00478 {
    00479   if ( mailer == mData->mailer ) return;
    00480   detach();
    00481   mData->empty = false;
    00482   mData->mailer = mailer;
    00483 }
    00484
    00485 QString Addressee::mailer() const
    00486 {
    00487   return mData->mailer;
    00488 }
    00489
    00490 QString Addressee::mailerLabel()
    00491 {
    00492   return i18n("Mail Client");
    00493 }
    00494
    00495
    00496 void Addressee::setTimeZone( const TimeZone &timeZone )
    00497 {
    00498   if ( timeZone == mData->timeZone ) return;
    00499   detach();
    00500   mData->empty = false;
    00501   mData->timeZone = timeZone;
    00502 }
    00503
    00504 TimeZone Addressee::timeZone() const
    00505 {
    00506   return mData->timeZone;
    00507 }
    00508
    00509 QString Addressee::timeZoneLabel()
    00510 {
    00511   return i18n("Time Zone");
    00512 }
    00513
    00514
    00515 void Addressee::setGeo( const Geo &geo )
    00516 {
    00517   if ( geo == mData->geo ) return;
    00518   detach();
    00519   mData->empty = false;
    00520   mData->geo = geo;
    00521 }
    00522
    00523 Geo Addressee::geo() const
    00524 {
    00525   return mData->geo;
    00526 }
    00527
    00528 QString Addressee::geoLabel()
    00529 {
    00530   return i18n("Geographic Position");
    00531 }
    00532
    00533
    00534 void Addressee::setTitle( const QString &title )
    00535 {
    00536   if ( title == mData->title ) return;
    00537   detach();
    00538   mData->empty = false;
    00539   mData->title = title;
    00540 }
    00541
    00542 QString Addressee::title() const
    00543 {
    00544   return mData->title;
    00545 }
    00546
    00547 QString Addressee::titleLabel()
    00548 {
    00549   return i18n("Title");
    00550 }
    00551
    00552
    00553 void Addressee::setRole( const QString &role )
    00554 {
    00555   if ( role == mData->role ) return;
    00556   detach();
    00557   mData->empty = false;
    00558   mData->role = role;
    00559 }
    00560
    00561 QString Addressee::role() const
    00562 {
    00563   return mData->role;
    00564 }
    00565
    00566 QString Addressee::roleLabel()
    00567 {
    00568   return i18n("Role");
    00569 }
    00570
    00571
    00572 void Addressee::setOrganization( const QString &organization )
    00573 {
    00574   if ( organization == mData->organization ) return;
    00575   detach();
    00576   mData->empty = false;
    00577   mData->organization = organization;
    00578 }
    00579
    00580 QString Addressee::organization() const
    00581 {
    00582   return mData->organization;
    00583 }
    00584
    00585 QString Addressee::organizationLabel()
    00586 {
    00587   return i18n("Organization");
    00588 }
    00589
    00590
    00591 void Addressee::setNote( const QString &note )
    00592 {
    00593   if ( note == mData->note ) return;
    00594   detach();
    00595   mData->empty = false;
    00596   mData->note = note;
    00597 }
    00598
    00599 QString Addressee::note() const
    00600 {
    00601   return mData->note;
    00602 }
    00603
    00604 QString Addressee::noteLabel()
    00605 {
    00606   return i18n("Note");
    00607 }
    00608
    00609
    00610 void Addressee::setProductId( const QString &productId )
    00611 {
    00612   if ( productId == mData->productId ) return;
    00613   detach();
    00614   mData->empty = false;
    00615   mData->productId = productId;
    00616 }
    00617
    00618 QString Addressee::productId() const
    00619 {
    00620   return mData->productId;
    00621 }
    00622
    00623 QString Addressee::productIdLabel()
    00624 {
    00625   return i18n("Product Identifier");
    00626 }
    00627
    00628
    00629 void Addressee::setRevision( const QDateTime &revision )
    00630 {
    00631   if ( revision == mData->revision ) return;
    00632   detach();
    00633   mData->empty = false;
    00634   mData->revision = revision;
    00635 }
    00636
    00637 QDateTime Addressee::revision() const
    00638 {
    00639   return mData->revision;
    00640 }
    00641
    00642 QString Addressee::revisionLabel()
    00643 {
    00644   return i18n("Revision Date");
    00645 }
    00646
    00647
    00648 void Addressee::setSortString( const QString &sortString )
    00649 {
    00650   if ( sortString == mData->sortString ) return;
    00651   detach();
    00652   mData->empty = false;
    00653   mData->sortString = sortString;
    00654 }
    00655
    00656 QString Addressee::sortString() const
    00657 {
    00658   return mData->sortString;
    00659 }
    00660
    00661 QString Addressee::sortStringLabel()
    00662 {
    00663   return i18n("Sort String");
    00664 }
    00665
    00666
    00667 void Addressee::setUrl( const KURL &url )
    00668 {
    00669   if ( url == mData->url ) return;
    00670   detach();
    00671   mData->empty = false;
    00672   mData->url = url;
    00673 }
    00674
    00675 KURL Addressee::url() const
    00676 {
    00677   return mData->url;
    00678 }
    00679
    00680 QString Addressee::urlLabel()
    00681 {
    00682   return i18n("URL");
    00683 }
    00684
    00685
    00686 void Addressee::setSecrecy( const Secrecy &secrecy )
    00687 {
    00688   if ( secrecy == mData->secrecy ) return;
    00689   detach();
    00690   mData->empty = false;
    00691   mData->secrecy = secrecy;
    00692 }
    00693
    00694 Secrecy Addressee::secrecy() const
    00695 {
    00696   return mData->secrecy;
    00697 }
    00698
    00699 QString Addressee::secrecyLabel()
    00700 {
    00701   return i18n("Security Class");
    00702 }
    00703
    00704
    00705 void Addressee::setLogo( const Picture &logo )
    00706 {
    00707   if ( logo == mData->logo ) return;
    00708   detach();
    00709   mData->empty = false;
    00710   mData->logo = logo;
    00711 }
    00712
    00713 Picture Addressee::logo() const
    00714 {
    00715   return mData->logo;
    00716 }
    00717
    00718 QString Addressee::logoLabel()
    00719 {
    00720   return i18n("Logo");
    00721 }
    00722
    00723
    00724 void Addressee::setPhoto( const Picture &photo )
    00725 {
    00726   if ( photo == mData->photo ) return;
    00727   detach();
    00728   mData->empty = false;
    00729   mData->photo = photo;
    00730 }
    00731
    00732 Picture Addressee::photo() const
    00733 {
    00734   return mData->photo;
    00735 }
    00736
    00737 QString Addressee::photoLabel()
    00738 {
    00739   return i18n("Photo");
    00740 }
    00741
    00742
    00743 void Addressee::setSound( const Sound &sound )
    00744 {
    00745   if ( sound == mData->sound ) return;
    00746   detach();
    00747   mData->empty = false;
    00748   mData->sound = sound;
    00749 }
    00750
    00751 Sound Addressee::sound() const
    00752 {
    00753   return mData->sound;
    00754 }
    00755
    00756 QString Addressee::soundLabel()
    00757 {
    00758   return i18n("Sound");
    00759 }
    00760
    00761
    00762 void Addressee::setAgent( const Agent &agent )
    00763 {
    00764   if ( agent == mData->agent ) return;
    00765   detach();
    00766   mData->empty = false;
    00767   mData->agent = agent;
    00768 }
    00769
    00770 Agent Addressee::agent() const
    00771 {
    00772   return mData->agent;
    00773 }
    00774
    00775 QString Addressee::agentLabel()
    00776 {
    00777   return i18n("Agent");
    00778 }
    00779
    00780
    00781
    00782 void Addressee::setNameFromString( const QString &str )
    00783 {
    00784   setFormattedName( str );
    00785   setName( str );
    00786
    00787   QStringList titles;
    00788   titles += i18n( "Dr." );
    00789   titles += i18n( "Miss" );
    00790   titles += i18n( "Mr." );
    00791   titles += i18n( "Mrs." );
    00792   titles += i18n( "Ms." );
    00793   titles += i18n( "Prof." );
    00794
    00795   QStringList suffixes;
    00796   suffixes += i18n( "I" );
    00797   suffixes += i18n( "II" );
    00798   suffixes += i18n( "III" );
    00799   suffixes += i18n( "Jr." );
    00800   suffixes += i18n( "Sr." );
    00801
    00802   QStringList prefixes;
    00803   prefixes += "van";
    00804   prefixes += "von";
    00805   prefixes += "de";
    00806
    00807   // clear all name parts
    00808   setPrefix( "" );
    00809   setGivenName( "" );
    00810   setAdditionalName( "" );
    00811   setFamilyName( "" );
    00812   setSuffix( "" );
    00813
    00814   if ( str.isEmpty() )
    00815     return;
    00816
    00817   int i = str.find(',');
    00818   if( i < 0 ) {
    00819     QStringList parts = QStringList::split( " ", str );
    00820     int leftOffset = 0;
    00821     int rightOffset = parts.count() - 1;
    00822
    00823     QString suffix;
    00824     while ( rightOffset >= 0 ) {
    00825       if ( suffixes.contains( parts[ rightOffset ] ) ) {
    00826         suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
    00827         rightOffset--;
    00828       } else
    00829         break;
    00830     }
    00831     setSuffix( suffix );
    00832
    00833     if ( rightOffset < 0 )
    00834       return;
    00835
    00836     if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
    00837       setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
    00838       rightOffset--;
    00839     } else
    00840       setFamilyName( parts[ rightOffset ] );
    00841
    00842     QString prefix;
    00843     while ( leftOffset < rightOffset ) {
    00844       if ( titles.contains( parts[ leftOffset ] ) ) {
    00845         prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
    00846         leftOffset++;
    00847       } else
    00848         break;
    00849     }
    00850     setPrefix( prefix );
    00851
    00852     if ( leftOffset < rightOffset ) {
    00853       setGivenName( parts[ leftOffset ] );
    00854       leftOffset++;
    00855     }
    00856
    00857     QString additionalName;
    00858     while ( leftOffset < rightOffset ) {
    00859       additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
    00860       leftOffset++;
    00861     }
    00862     setAdditionalName( additionalName );
    00863   } else {
    00864     QString part1 = str.left( i );
    00865     QString part2 = str.mid( i + 1 );
    00866
    00867     QStringList parts = QStringList::split( " ", part1 );
    00868     int leftOffset = 0;
    00869     int rightOffset = parts.count() - 1;
    00870
    00871     QString suffix;
    00872     while ( rightOffset >= 0 ) {
    00873       if ( suffixes.contains( parts[ rightOffset ] ) ) {
    00874         suffix.prepend(parts[ rightOffset ] + (suffix.isEmpty() ? "" : " "));
    00875         rightOffset--;
    00876       } else
    00877         break;
    00878     }
    00879     setSuffix( suffix );
    00880
    00881     if ( rightOffset - 1 >= 0 && prefixes.contains( parts[ rightOffset - 1 ].lower() ) ) {
    00882       setFamilyName( parts[ rightOffset - 1 ] + " " + parts[ rightOffset ] );
    00883       rightOffset--;
    00884     } else
    00885       setFamilyName( parts[ rightOffset ] );
    00886
    00887     QString prefix;
    00888     while ( leftOffset < rightOffset ) {
    00889       if ( titles.contains( parts[ leftOffset ] ) ) {
    00890         prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
    00891         leftOffset++;
    00892       } else
    00893         break;
    00894     }
    00895
    00896     parts = QStringList::split( " ", part2 );
    00897
    00898     leftOffset = 0;
    00899     rightOffset = parts.count();
    00900
    00901     while ( leftOffset < rightOffset ) {
    00902       if ( titles.contains( parts[ leftOffset ] ) ) {
    00903         prefix.append( ( prefix.isEmpty() ? "" : " ") + parts[ leftOffset ] );
    00904         leftOffset++;
    00905       } else
    00906         break;
    00907     }
    00908     setPrefix( prefix );
    00909
    00910     if ( leftOffset < rightOffset ) {
    00911       setGivenName( parts[ leftOffset ] );
    00912       leftOffset++;
    00913     }
    00914
    00915     QString additionalName;
    00916     while ( leftOffset < rightOffset ) {
    00917       additionalName.append( ( additionalName.isEmpty() ? "" : " ") + parts[ leftOffset ] );
    00918       leftOffset++;
    00919     }
    00920     setAdditionalName( additionalName );
    00921   }
    00922 }
    00923
    00924 QString Addressee::realName() const
    00925 {
    00926   if ( !formattedName().isEmpty() )
    00927     return formattedName();
    00928
    00929   QString n = assembledName();
    00930
    00931   if ( n.isEmpty() )
    00932     n = name();
    00933
    00934   return n;
    00935 }
    00936
    00937 QString Addressee::assembledName() const
    00938 {
    00939   QString name = prefix() + " " + givenName() + " " + additionalName() + " " +
    00940               familyName() + " " + suffix();
    00941
    00942   return name.simplifyWhiteSpace();
    00943 }
    00944
    00945 QString Addressee::fullEmail( const QString &email ) const
    00946 {
    00947   QString e;
    00948   if ( email.isNull() ) {
    00949     e = preferredEmail();
    00950   } else {
    00951     e = email;
    00952   }
    00953   if ( e.isEmpty() ) return QString::null;
    00954
    00955   QString text;
    00956   if ( realName().isEmpty() )
    00957     text = e;
    00958   else
    00959     text = assembledName() + " <" + e + ">";
    00960
    00961   return text;
    00962 }
    00963
    00964 void Addressee::insertEmail( const QString &email, bool preferred )
    00965 {
    00966   detach();
    00967
    00968   QStringList::Iterator it = mData->emails.find( email );
    00969
    00970   if ( it != mData->emails.end() ) {
    00971     if ( !preferred || it == mData->emails.begin() ) return;
    00972     mData->emails.remove( it );
    00973     mData->emails.prepend( email );
    00974   } else {
    00975     if ( preferred ) {
    00976       mData->emails.prepend( email );
    00977     } else {
    00978       mData->emails.append( email );
    00979     }
    00980   }
    00981 }
    00982
    00983 void Addressee::removeEmail( const QString &email )
    00984 {
    00985   detach();
    00986
    00987   QStringList::Iterator it = mData->emails.find( email );
    00988   if ( it == mData->emails.end() ) return;
    00989
    00990   mData->emails.remove( it );
    00991 }
    00992
    00993 QString Addressee::preferredEmail() const
    00994 {
    00995   if ( mData->emails.count() == 0 ) return QString::null;
    00996   else return mData->emails.first();
    00997 }
    00998
    00999 QStringList Addressee::emails() const
    01000 {
    01001   return mData->emails;
    01002 }
    01003
    01004 void Addressee::insertPhoneNumber( const PhoneNumber &phoneNumber )
    01005 {
    01006   detach();
    01007   mData->empty = false;
    01008
    01009   PhoneNumber::List::Iterator it;
    01010   for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
    01011     if ( (*it).id() == phoneNumber.id() ) {
    01012       *it = phoneNumber;
    01013       return;
    01014     }
    01015   }
    01016   mData->phoneNumbers.append( phoneNumber );
    01017 }
    01018
    01019 void Addressee::removePhoneNumber( const PhoneNumber &phoneNumber )
    01020 {
    01021   detach();
    01022
    01023   PhoneNumber::List::Iterator it;
    01024   for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
    01025     if ( (*it).id() == phoneNumber.id() ) {
    01026       mData->phoneNumbers.remove( it );
    01027       return;
    01028     }
    01029   }
    01030 }
    01031
    01032 PhoneNumber Addressee::phoneNumber( int type ) const
    01033 {
    01034   PhoneNumber phoneNumber( "", type );
    01035   PhoneNumber::List::ConstIterator it;
    01036   for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
    01037     if ( matchBinaryPattern( (*it).type(), type, PhoneNumber::Pager ) ) {
    01038       if ( (*it).type() & PhoneNumber::Pref )
    01039         return (*it);
    01040       else if ( phoneNumber.number().isEmpty() )
    01041         phoneNumber = (*it);
    01042     }
    01043   }
    01044
    01045   return phoneNumber;
    01046 }
    01047
    01048 PhoneNumber::List Addressee::phoneNumbers() const
    01049 {
    01050   return mData->phoneNumbers;
    01051 }
    01052
    01053 PhoneNumber::List Addressee::phoneNumbers( int type ) const
    01054 {
    01055   PhoneNumber::List list;
    01056
    01057   PhoneNumber::List::ConstIterator it;
    01058   for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
    01059     if ( matchBinaryPattern( (*it).type(), type, PhoneNumber::Pager ) ) {
    01060       list.append( *it );
    01061     }
    01062   }
    01063   return list;
    01064 }
    01065
    01066 PhoneNumber Addressee::findPhoneNumber( const QString &id ) const
    01067 {
    01068   PhoneNumber::List::ConstIterator it;
    01069   for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) {
    01070     if ( (*it).id() == id ) {
    01071       return *it;
    01072     }
    01073   }
    01074   return PhoneNumber();
    01075 }
    01076
    01077 void Addressee::insertKey( const Key &key )
    01078 {
    01079   detach();
    01080   mData->empty = false;
    01081
    01082   Key::List::Iterator it;
    01083   for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
    01084     if ( (*it).id() == key.id() ) {
    01085       *it = key;
    01086       return;
    01087     }
    01088   }
    01089   mData->keys.append( key );
    01090 }
    01091
    01092 void Addressee::removeKey( const Key &key )
    01093 {
    01094   detach();
    01095
    01096   Key::List::Iterator it;
    01097   for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
    01098     if ( (*it).id() == key.id() ) {
    01099       mData->keys.remove( key );
    01100       return;
    01101     }
    01102   }
    01103 }
    01104
    01105 Key Addressee::key( int type, QString customTypeString ) const
    01106 {
    01107   Key::List::ConstIterator it;
    01108   for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
    01109     if ( (*it).type() == type ) {
    01110       if ( type == Key::Custom ) {
    01111         if ( customTypeString.isEmpty() ) {
    01112           return *it;
    01113         } else {
    01114           if ( (*it).customTypeString() == customTypeString )
    01115             return (*it);
    01116         }
    01117       } else {
    01118         return *it;
    01119       }
    01120     }
    01121   }
    01122   return Key( QString(), type );
    01123 }
    01124
    01125 Key::List Addressee::keys() const
    01126 {
    01127   return mData->keys;
    01128 }
    01129
    01130 Key::List Addressee::keys( int type, QString customTypeString ) const
    01131 {
    01132   Key::List list;
    01133
    01134   Key::List::ConstIterator it;
    01135   for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
    01136     if ( (*it).type() == type ) {
    01137       if ( type == Key::Custom ) {
    01138         if ( customTypeString.isEmpty() ) {
    01139           list.append(*it);
    01140         } else {
    01141           if ( (*it).customTypeString() == customTypeString )
    01142             list.append(*it);
    01143         }
    01144       } else {
    01145         list.append(*it);
    01146       }
    01147     }
    01148   }
    01149   return list;
    01150 }
    01151
    01152 Key Addressee::findKey( const QString &id ) const
    01153 {
    01154   Key::List::ConstIterator it;
    01155   for( it = mData->keys.begin(); it != mData->keys.end(); ++it ) {
    01156     if ( (*it).id() == id ) {
    01157       return *it;
    01158     }
    01159   }
    01160   return Key();
    01161 }
    01162
    01163 QString Addressee::asString() const
    01164 {
    01165   return "Smith, special agent Smith...";
    01166 }
    01167
    01168 void Addressee::dump() const
    01169 {
    01170   kdDebug(5700) << "Addressee {" << endl;
    01171
    01172   kdDebug(5700) << "  Uid: '" << uid() << "'" << endl;
    01173   kdDebug(5700) << "  Name: '" << name() << "'" << endl;
    01174   kdDebug(5700) << "  FormattedName: '" << formattedName() << "'" << endl;
    01175   kdDebug(5700) << "  FamilyName: '" << familyName() << "'" << endl;
    01176   kdDebug(5700) << "  GivenName: '" << givenName() << "'" << endl;
    01177   kdDebug(5700) << "  AdditionalName: '" << additionalName() << "'" << endl;
    01178   kdDebug(5700) << "  Prefix: '" << prefix() << "'" << endl;
    01179   kdDebug(5700) << "  Suffix: '" << suffix() << "'" << endl;
    01180   kdDebug(5700) << "  NickName: '" << nickName() << "'" << endl;
    01181   kdDebug(5700) << "  Birthday: '" << birthday().toString() << "'" << endl;
    01182   kdDebug(5700) << "  Mailer: '" << mailer() << "'" << endl;
    01183   kdDebug(5700) << "  TimeZone: '" << timeZone().asString() << "'" << endl;
    01184   kdDebug(5700) << "  Geo: '" << geo().asString() << "'" << endl;
    01185   kdDebug(5700) << "  Title: '" << title() << "'" << endl;
    01186   kdDebug(5700) << "  Role: '" << role() << "'" << endl;
    01187   kdDebug(5700) << "  Organization: '" << organization() << "'" << endl;
    01188   kdDebug(5700) << "  Note: '" << note() << "'" << endl;
    01189   kdDebug(5700) << "  ProductId: '" << productId() << "'" << endl;
    01190   kdDebug(5700) << "  Revision: '" << revision().toString() << "'" << endl;
    01191   kdDebug(5700) << "  SortString: '" << sortString() << "'" << endl;
    01192   kdDebug(5700) << "  Url: '" << url().url() << "'" << endl;
    01193   kdDebug(5700) << "  Secrecy: '" << secrecy().asString() << "'" << endl;
    01194   kdDebug(5700) << "  Logo: '" << logo().asString() << "'" << endl;
    01195   kdDebug(5700) << "  Photo: '" << photo().asString() << "'" << endl;
    01196   kdDebug(5700) << "  Sound: '" << sound().asString() << "'" << endl;
    01197   kdDebug(5700) << "  Agent: '" << agent().asString() << "'" << endl;
    01198
    01199   kdDebug(5700) << "  Emails {" << endl;
    01200   QStringList e = emails();
    01201   QStringList::ConstIterator it;
    01202   for( it = e.begin(); it != e.end(); ++it ) {
    01203     kdDebug(5700) << "    " << (*it) << endl;
    01204   }
    01205   kdDebug(5700) << "  }" << endl;
    01206
    01207   kdDebug(5700) << "  PhoneNumbers {" << endl;
    01208   PhoneNumber::List p = phoneNumbers();
    01209   PhoneNumber::List::ConstIterator it2;
    01210   for( it2 = p.begin(); it2 != p.end(); ++it2 ) {
    01211     kdDebug(5700) << "    Type: " << int((*it2).type()) << " Number: " << (*it2).number() << endl;
    01212   }
    01213   kdDebug(5700) << "  }" << endl;
    01214
    01215   Address::List a = addresses();
    01216   Address::List::ConstIterator it3;
    01217   for( it3 = a.begin(); it3 != a.end(); ++it3 ) {
    01218     (*it3).dump();
    01219   }
    01220
    01221   kdDebug(5700) << "  Keys {" << endl;
    01222   Key::List k = keys();
    01223   Key::List::ConstIterator it4;
    01224   for( it4 = k.begin(); it4 != k.end(); ++it4 ) {
    01225     kdDebug(5700) << "    Type: " << int((*it4).type()) <<
    01226                      " Key: " << (*it4).textData() <<
    01227                      " CustomString: " << (*it4).customTypeString() << endl;
    01228   }
    01229   kdDebug(5700) << "  }" << endl;
    01230
    01231   kdDebug(5700) << "}" << endl;
    01232 }
    01233
    01234
    01235 void Addressee::insertAddress( const Address &address )
    01236 {
    01237   detach();
    01238   mData->empty = false;
    01239
    01240   Address::List::Iterator it;
    01241   for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
    01242     if ( (*it).id() == address.id() ) {
    01243       *it = address;
    01244       return;
    01245     }
    01246   }
    01247   mData->addresses.append( address );
    01248 }
    01249
    01250 void Addressee::removeAddress( const Address &address )
    01251 {
    01252   detach();
    01253
    01254   Address::List::Iterator it;
    01255   for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
    01256     if ( (*it).id() == address.id() ) {
    01257       mData->addresses.remove( it );
    01258       return;
    01259     }
    01260   }
    01261 }
    01262
    01263 Address Addressee::address( int type ) const
    01264 {
    01265   Address address( type );
    01266   Address::List::ConstIterator it;
    01267   for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
    01268     if ( matchBinaryPattern( (*it).type(), type, Address::Pref ) ) {
    01269       if ( (*it).type() & Address::Pref )
    01270         return (*it);
    01271       else if ( address.isEmpty() )
    01272         address = (*it);
    01273     }
    01274   }
    01275
    01276   return address;
    01277 }
    01278
    01279 Address::List Addressee::addresses() const
    01280 {
    01281   return mData->addresses;
    01282 }
    01283
    01284 Address::List Addressee::addresses( int type ) const
    01285 {
    01286   Address::List list;
    01287
    01288   Address::List::ConstIterator it;
    01289   for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
    01290     if ( matchBinaryPattern( (*it).type(), type , Address::Pref ) ) {
    01291       list.append( *it );
    01292     }
    01293   }
    01294
    01295   return list;
    01296 }
    01297
    01298 Address Addressee::findAddress( const QString &id ) const
    01299 {
    01300   Address::List::ConstIterator it;
    01301   for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) {
    01302     if ( (*it).id() == id ) {
    01303       return *it;
    01304     }
    01305   }
    01306   return Address();
    01307 }
    01308
    01309 void Addressee::insertCategory( const QString &c )
    01310 {
    01311   detach();
    01312   mData->empty = false;
    01313
    01314   if ( mData->categories.contains( c ) ) return;
    01315
    01316   mData->categories.append( c );
    01317 }
    01318
    01319 void Addressee::removeCategory( const QString &c )
    01320 {
    01321   detach();
    01322
    01323   QStringList::Iterator it = mData->categories.find( c );
    01324   if ( it == mData->categories.end() ) return;
    01325
    01326   mData->categories.remove( it );
    01327 }
    01328
    01329 bool Addressee::hasCategory( const QString &c ) const
    01330 {
    01331   return ( mData->categories.contains( c ) );
    01332 }
    01333
    01334 void Addressee::setCategories( const QStringList &c )
    01335 {
    01336   detach();
    01337   mData->empty = false;
    01338
    01339   mData->categories = c;
    01340 }
    01341
    01342 QStringList Addressee::categories() const
    01343 {
    01344   return mData->categories;
    01345 }
    01346
    01347 void Addressee::insertCustom( const QString &app, const QString &name,
    01348                               const QString &value )
    01349 {
    01350   if ( value.isNull() || name.isEmpty() || app.isEmpty() ) return;
    01351
    01352   detach();
    01353   mData->empty = false;
    01354
    01355   QString qualifiedName = app + "-" + name + ":";
    01356
    01357   QStringList::Iterator it;
    01358   for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
    01359     if ( (*it).startsWith( qualifiedName ) ) {
    01360       (*it) = qualifiedName + value;
    01361       return;
    01362     }
    01363   }
    01364
    01365   mData->custom.append( qualifiedName + value );
    01366 }
    01367
    01368 void Addressee::removeCustom( const QString &app, const QString &name)
    01369 {
    01370   detach();
    01371
    01372   QString qualifiedName = app + "-" + name + ":";
    01373
    01374   QStringList::Iterator it;
    01375   for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
    01376     if ( (*it).startsWith( qualifiedName ) ) {
    01377       mData->custom.remove( it );
    01378       return;
    01379     }
    01380   }
    01381 }
    01382
    01383 QString Addressee::custom( const QString &app, const QString &name ) const
    01384 {
    01385   QString qualifiedName = app + "-" + name + ":";
    01386   QString value;
    01387
    01388   QStringList::ConstIterator it;
    01389   for( it = mData->custom.begin(); it != mData->custom.end(); ++it ) {
    01390     if ( (*it).startsWith( qualifiedName ) ) {
    01391       value = (*it).mid( (*it).find( ":" ) + 1 );
    01392       break;
    01393     }
    01394   }
    01395
    01396   return value;
    01397 }
    01398
    01399 void Addressee::setCustoms( const QStringList &l )
    01400 {
    01401   detach();
    01402   mData->empty = false;
    01403
    01404   mData->custom = l;
    01405 }
    01406
    01407 QStringList Addressee::customs() const
    01408 {
    01409   return mData->custom;
    01410 }
    01411
    01412 void Addressee::parseEmailAddress( const QString &rawEmail, QString &fullName,
    01413                                    QString &email)
    01414 {
    01415   int startPos, endPos, len;
    01416   QString partA, partB, result;
    01417   char endCh = '>';
    01418
    01419   startPos = rawEmail.find('<');
    01420   if (startPos < 0)
    01421   {
    01422     startPos = rawEmail.find('(');
    01423     endCh = ')';
    01424   }
    01425   if (startPos < 0)
    01426   {
    01427     // We couldn't find any separators, so we assume the whole string
    01428     // is the email address
    01429     email = rawEmail;
    01430     fullName = "";
    01431   }
    01432   else
    01433   {
    01434     // We have a start position, try to find an end
    01435     endPos = rawEmail.find(endCh, startPos+1);
    01436
    01437     if (endPos < 0)
    01438     {
    01439       // We couldn't find the end of the email address. We can only
    01440       // assume the entire string is the email address.
    01441       email = rawEmail;
    01442       fullName = "";
    01443     }
    01444     else
    01445     {
    01446       // We have a start and end to the email address
    01447
    01448       // Grab the name part
    01449       fullName = rawEmail.left(startPos).stripWhiteSpace();
    01450
    01451       // grab the email part
    01452       email = rawEmail.mid(startPos+1, endPos-startPos-1).stripWhiteSpace();
    01453
    01454       // Check that we do not have any extra characters on the end of the
    01455       // strings
    01456       len = fullName.length();
    01457       if (fullName[0]=='"' && fullName[len-1]=='"')
    01458         fullName = fullName.mid(1, len-2);
    01459       else if (fullName[0]=='<' && fullName[len-1]=='>')
    01460         fullName = fullName.mid(1, len-2);
    01461       else if (fullName[0]=='(' && fullName[len-1]==')')
    01462         fullName = fullName.mid(1, len-2);
    01463     }
    01464   }
    01465 }
    01466
    01467 void Addressee::setResource( Resource *resource )
    01468 {
    01469     detach();
    01470     mData->resource = resource;
    01471 }
    01472
    01473 Resource *Addressee::resource() const
    01474 {
    01475     return mData->resource;
    01476 }
    01477
    01478 void Addressee::setChanged( bool value )
    01479 {
    01480     detach();
    01481     mData->changed = value;
    01482 }
    01483
    01484 bool Addressee::changed() const
    01485 {
    01486     return mData->changed;
    01487 }
    01488
    01489 QDataStream &KABC::operator<<( QDataStream &s, const Addressee &a )
    01490 {
    01491   if (!a.mData) return s;
    01492
    01493   s << a.mData->uid;
    01494   s << a.mData->name;
    01495   s << a.mData->formattedName;
    01496   s << a.mData->familyName;
    01497   s << a.mData->givenName;
    01498   s << a.mData->additionalName;
    01499   s << a.mData->prefix;
    01500   s << a.mData->suffix;
    01501   s << a.mData->nickName;
    01502   s << a.mData->birthday;
    01503   s << a.mData->mailer;
    01504   s << a.mData->timeZone;
    01505   s << a.mData->geo;
    01506   s << a.mData->title;
    01507   s << a.mData->role;
    01508   s << a.mData->organization;
    01509   s << a.mData->note;
    01510   s << a.mData->productId;
    01511   s << a.mData->revision;
    01512   s << a.mData->sortString;
    01513   s << a.mData->url;
    01514   s << a.mData->secrecy;
    01515   s << a.mData->logo;
    01516   s << a.mData->photo;
    01517   s << a.mData->sound;
    01518   s << a.mData->agent;
    01519   s << a.mData->phoneNumbers;
    01520   s << a.mData->addresses;
    01521   s << a.mData->emails;
    01522   s << a.mData->categories;
    01523   s << a.mData->custom;
    01524   s << a.mData->keys;
    01525   return s;
    01526 }
    01527
    01528 QDataStream &KABC::operator>>( QDataStream &s, Addressee &a )
    01529 {
    01530   if (!a.mData) return s;
    01531
    01532   s >> a.mData->uid;
    01533   s >> a.mData->name;
    01534   s >> a.mData->formattedName;
    01535   s >> a.mData->familyName;
    01536   s >> a.mData->givenName;
    01537   s >> a.mData->additionalName;
    01538   s >> a.mData->prefix;
    01539   s >> a.mData->suffix;
    01540   s >> a.mData->nickName;
    01541   s >> a.mData->birthday;
    01542   s >> a.mData->mailer;
    01543   s >> a.mData->timeZone;
    01544   s >> a.mData->geo;
    01545   s >> a.mData->title;
    01546   s >> a.mData->role;
    01547   s >> a.mData->organization;
    01548   s >> a.mData->note;
    01549   s >> a.mData->productId;
    01550   s >> a.mData->revision;
    01551   s >> a.mData->sortString;
    01552   s >> a.mData->url;
    01553   s >> a.mData->secrecy;
    01554   s >> a.mData->logo;
    01555   s >> a.mData->photo;
    01556   s >> a.mData->sound;
    01557   s >> a.mData->agent;
    01558   s >> a.mData->phoneNumbers;
    01559   s >> a.mData->addresses;
    01560   s >> a.mData->emails;
    01561   s >> a.mData->categories;
    01562   s >> a.mData->custom;
    01563   s >> a.mData->keys;
    01564
    01565   a.mData->empty = false;
    01566
    01567   return s;
    01568 }
    01569
    01570 bool matchBinaryPattern( int value, int pattern, int max )
    01571 {
    01572   if ( pattern == 0 ) {
    01573     if ( value != 0 )
    01574       return false;
    01575     else
    01576       return true;
    01577   }
    01578
    01579   int counter = 0;
    01580   while ( 1 ) {
    01581     if ( ( pattern & ( 1 << counter ) ) && !( value & ( 1 << counter ) ) )
    01582       return false;
    01583
    01584     if ( ( 1 << counter ) == max )
    01585       break;
    01586
    01587     counter++;
    01588   }
    01589
    01590   return true;
    01591 }

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:29:16 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001