-rw-r--r-- | kabc/addresseeview.cpp | 28 | ||||
-rw-r--r-- | kabc/addresseeview.h | 10 | ||||
-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 45 |
3 files changed, 63 insertions, 20 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 90be928..7a4336b 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -81,36 +81,33 @@ void AddresseeView::setSource(const QString& n) else if ( n.left( 5 ) == "smsto" ) ExternalAppHandler::instance()->callBySMS( n.mid(6) ); else if ( n.left( 7 ) == "pagerto" ) ExternalAppHandler::instance()->callByPager( n.mid(8) ); else if ( n.left( 5 ) == "sipto" ) ExternalAppHandler::instance()->callBySIP( n.mid(6) ); } -void AddresseeView::setAddressee( const KABC::Addressee& addr ) +void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) { - ExternalAppHandler* eah = ExternalAppHandler::instance(); - bool kemailAvail = eah->isEmailAppAvailable(); - - - - mAddressee = addr; + bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); + // mAddressee = addr; // clear view - setText( QString::null ); - - if ( mAddressee.isEmpty() ) - return; + //setText( QString::null ); + if ( mAddressee.isEmpty() ) { + setText( QString::null); + return; + } QString name = ( mAddressee.assembledName().isEmpty() ? mAddressee.formattedName() : mAddressee.assembledName() ); QString dynamicPart; - dynamicPart += getPhoneNumbers( true ); + dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); QStringList emails = mAddressee.emails(); QStringList::ConstIterator emailIt; QString type = i18n( "Email" ); emailIt = emails.begin(); if ( emailIt != emails.end() ) { if ( kemailAvail ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" @@ -131,17 +128,17 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) } if ( mAddressee.birthday().date().isValid() ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n ("Birthday") ) .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); } - dynamicPart += getPhoneNumbers( false ); + dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); for ( ; emailIt != emails.end(); ++emailIt ) { if ( kemailAvail ) { dynamicPart += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) .arg( type ) .arg( name ) @@ -303,26 +300,25 @@ mText = "<table width=\"100%\">\n"; } // at last display it... setText( mText ); } -QString AddresseeView::getPhoneNumbers( bool preferred ) +QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) { ExternalAppHandler* eah = ExternalAppHandler::instance(); bool kphoneAvail = eah->isPhoneAppAvailable(); bool kfaxAvail = eah->isFaxAppAvailable(); bool ksmsAvail = eah->isSMSAppAvailable(); bool kpagerAvail = eah->isPagerAppAvailable(); bool ksipAvail = eah->isSIPAppAvailable(); QString dynamicPart; - KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); KABC::PhoneNumber::List::ConstIterator phoneIt; QString extension; int phonetype; QString sms; for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { phonetype = (*phoneIt).type(); if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) continue; @@ -372,20 +368,22 @@ QString AddresseeView::getPhoneNumbers( bool preferred ) "<td align=\"left\">%2 %3</td></tr>" ) .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) .arg( (*phoneIt).number() ) .arg( sms ); } } return dynamicPart; } +/* KABC::Addressee AddresseeView::addressee() const { return mAddressee; } +*/ void AddresseeView::addTag(const QString & tag,const QString & text) { if ( text.isEmpty() ) return; int number=text.contains("\n"); QString str = "<" + tag + ">"; QString tmpText=text; QString tmpStr=str; diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index d8a13ee..3800512 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h @@ -41,25 +41,25 @@ class AddresseeView : public QTextBrowser @param addr The addressee object. */ void setAddressee( const KABC::Addressee& addr ); void setSource(const QString& n); /** Returns the current addressee object. */ - KABC::Addressee addressee() const; + //KABC::Addressee addressee() const; private: - KABC::Addressee mAddressee; + //KABC::Addressee mAddressee; QString mText; - QString getPhoneNumbers( bool preferred ); + QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); void addTag(const QString & tag,const QString & text); - class AddresseeViewPrivate; - AddresseeViewPrivate *d; + //class AddresseeViewPrivate; + //AddresseeViewPrivate *d; }; class AddresseeChooser : public KDialogBase { Q_OBJECT public: AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp index 5fca3bc..b676cc7 100644 --- a/kabc/vcard/VCardEntity.cpp +++ b/kabc/vcard/VCardEntity.cpp @@ -68,19 +68,25 @@ VCardEntity::operator == (VCardEntity & x) x.parse(); return false; } VCardEntity::~VCardEntity() { } +#include <qdatetime.h>; void VCardEntity::_parse() { +#if 0 + QTime tim; + tim.start(); + int num = 0; + // old code vDebug("parse"); QCString s(strRep_); int i = s.find(QRegExp("BEGIN:VCARD", false)); while (i != -1) { i = s.find(QRegExp("BEGIN:VCARD", false), 11); @@ -90,16 +96,55 @@ VCardEntity::_parse() VCard * v = new VCard(cardStr); cardList_.append(v); v->parse(); s.remove(0, i); } + +#else + // this code is up to 17 (!) times faster + int start = 0; + QTime tim; + tim.start(); + int i = 11; + int len = strRep_.length(); + int num = 0; + while (i < len ) { + while( i < len ) { + int add = 1; + if ( strRep_.at(i) == 'B' ) { + if ( i+add < len && strRep_.at(i+add++) == 'E') + if ( i+add < len && strRep_.at(i+add++) == 'G') + if ( i+add < len && strRep_.at(i+add++) == 'I') + if ( i+add < len && strRep_.at(i+add++) == 'N') + if ( i+add < len && strRep_.at(i+add++) == ':') + if ( i+add < len && strRep_.at(i+add++) == 'V') + if ( i+add < len && strRep_.at(i+add++) == 'C') + if ( i+add < len && strRep_.at(i+add++) == 'A') + if ( i+add < len && strRep_.at(i+add++) == 'R') + if ( i+add < len && strRep_.at(i+add++) == 'D') + break; + } + ++i; + } + if ( i <= len ) { + ++num; + char* dat = strRep_.data()+start; + VCard * v = new VCard( QCString ( dat,i-start ) ); + start = i; + cardList_.append(v); + v->parse(); + } + i+= 11; + } +#endif + //qDebug("***time %d found %d", tim.elapsed(), num); } void VCardEntity::_assemble() { VCardListIterator it(cardList_); for (; it.current(); ++it) |