summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp28
-rw-r--r--kabc/addresseeview.h10
-rw-r--r--kabc/vcard/VCardEntity.cpp45
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
@@ -73,83 +73,80 @@ void AddresseeView::setSource(const QString& n)
73 //qDebug("********AddresseeView::setSource %s", n.latin1()); 73 //qDebug("********AddresseeView::setSource %s", n.latin1());
74 74
75 if ( n.left( 6 ) == "mailto" ) 75 if ( n.left( 6 ) == "mailto" )
76 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 76 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
77 else if ( n.left( 7 ) == "phoneto" ) 77 else if ( n.left( 7 ) == "phoneto" )
78 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 78 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
79 else if ( n.left( 5 ) == "faxto" ) 79 else if ( n.left( 5 ) == "faxto" )
80 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 80 ExternalAppHandler::instance()->callByFax( n.mid(6) );
81 else if ( n.left( 5 ) == "smsto" ) 81 else if ( n.left( 5 ) == "smsto" )
82 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 82 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
83 else if ( n.left( 7 ) == "pagerto" ) 83 else if ( n.left( 7 ) == "pagerto" )
84 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 84 ExternalAppHandler::instance()->callByPager( n.mid(8) );
85 else if ( n.left( 5 ) == "sipto" ) 85 else if ( n.left( 5 ) == "sipto" )
86 ExternalAppHandler::instance()->callBySIP( n.mid(6) ); 86 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
87 87
88} 88}
89void AddresseeView::setAddressee( const KABC::Addressee& addr ) 89void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
90{ 90{
91 ExternalAppHandler* eah = ExternalAppHandler::instance(); 91 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable();
92 bool kemailAvail = eah->isEmailAppAvailable(); 92 // mAddressee = addr;
93
94
95
96 mAddressee = addr;
97 // clear view 93 // clear view
98 setText( QString::null ); 94 //setText( QString::null );
99
100 if ( mAddressee.isEmpty() )
101 return;
102 95
96 if ( mAddressee.isEmpty() ) {
97 setText( QString::null);
98 return;
99 }
103 QString name = ( mAddressee.assembledName().isEmpty() ? 100 QString name = ( mAddressee.assembledName().isEmpty() ?
104 mAddressee.formattedName() : mAddressee.assembledName() ); 101 mAddressee.formattedName() : mAddressee.assembledName() );
105 102
106 QString dynamicPart; 103 QString dynamicPart;
107 104
108 dynamicPart += getPhoneNumbers( true ); 105 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true );
109 QStringList emails = mAddressee.emails(); 106 QStringList emails = mAddressee.emails();
110 QStringList::ConstIterator emailIt; 107 QStringList::ConstIterator emailIt;
111 QString type = i18n( "Email" ); 108 QString type = i18n( "Email" );
112 emailIt = emails.begin(); 109 emailIt = emails.begin();
113 if ( emailIt != emails.end() ) { 110 if ( emailIt != emails.end() ) {
114 if ( kemailAvail ) { 111 if ( kemailAvail ) {
115 dynamicPart += QString( 112 dynamicPart += QString(
116 "<tr><td align=\"right\"><b>%1</b></td>" 113 "<tr><td align=\"right\"><b>%1</b></td>"
117 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 114 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
118 .arg( type ) 115 .arg( type )
119 .arg( name ) 116 .arg( name )
120 .arg( *emailIt ) 117 .arg( *emailIt )
121 .arg( *emailIt ); 118 .arg( *emailIt );
122 ++emailIt; 119 ++emailIt;
123 } else { 120 } else {
124 dynamicPart += QString( 121 dynamicPart += QString(
125 "<tr><td align=\"right\"><b>%1</b></td>" 122 "<tr><td align=\"right\"><b>%1</b></td>"
126 "<td align=\"left\">%2</td></tr>" ) 123 "<td align=\"left\">%2</td></tr>" )
127 .arg( type ) 124 .arg( type )
128 .arg( *emailIt ); 125 .arg( *emailIt );
129 ++emailIt; 126 ++emailIt;
130 } 127 }
131 } 128 }
132 if ( mAddressee.birthday().date().isValid() ) { 129 if ( mAddressee.birthday().date().isValid() ) {
133 dynamicPart += QString( 130 dynamicPart += QString(
134 "<tr><td align=\"right\"><b>%1</b></td>" 131 "<tr><td align=\"right\"><b>%1</b></td>"
135 "<td align=\"left\">%2</td></tr>" ) 132 "<td align=\"left\">%2</td></tr>" )
136 .arg( i18n ("Birthday") ) 133 .arg( i18n ("Birthday") )
137 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 134 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
138 } 135 }
139 dynamicPart += getPhoneNumbers( false ); 136 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false );
140 137
141 for ( ; emailIt != emails.end(); ++emailIt ) { 138 for ( ; emailIt != emails.end(); ++emailIt ) {
142 if ( kemailAvail ) { 139 if ( kemailAvail ) {
143 dynamicPart += QString( 140 dynamicPart += QString(
144 "<tr><td align=\"right\"><b>%1</b></td>" 141 "<tr><td align=\"right\"><b>%1</b></td>"
145 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 142 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
146 .arg( type ) 143 .arg( type )
147 .arg( name ) 144 .arg( name )
148 .arg( *emailIt ) 145 .arg( *emailIt )
149 .arg( *emailIt ); 146 .arg( *emailIt );
150 } else { 147 } else {
151 dynamicPart += QString( 148 dynamicPart += QString(
152 "<tr><td align=\"right\"><b>%1</b></td>" 149 "<tr><td align=\"right\"><b>%1</b></td>"
153 "<td align=\"left\">%2</td></tr>" ) 150 "<td align=\"left\">%2</td></tr>" )
154 .arg( type ) 151 .arg( type )
155 .arg( *emailIt ); 152 .arg( *emailIt );
@@ -295,42 +292,41 @@ mText = "<table width=\"100%\">\n";
295 if ( ! mAddressee.organization().isEmpty() ) 292 if ( ! mAddressee.organization().isEmpty() )
296 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 293 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
297 "<td align=\"left\">%2</td></tr>" ) 294 "<td align=\"left\">%2</td></tr>" )
298 .arg( i18n(" ") ) 295 .arg( i18n(" ") )
299 .arg( mAddressee.organization()); 296 .arg( mAddressee.organization());
300 mText += dynamicPart; 297 mText += dynamicPart;
301 mText += notes; 298 mText += notes;
302 mText += "</table>"; 299 mText += "</table>";
303 300
304 } 301 }
305 302
306 // at last display it... 303 // at last display it...
307 setText( mText ); 304 setText( mText );
308 305
309} 306}
310 307
311QString AddresseeView::getPhoneNumbers( bool preferred ) 308QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred )
312{ 309{
313 ExternalAppHandler* eah = ExternalAppHandler::instance(); 310 ExternalAppHandler* eah = ExternalAppHandler::instance();
314 bool kphoneAvail = eah->isPhoneAppAvailable(); 311 bool kphoneAvail = eah->isPhoneAppAvailable();
315 bool kfaxAvail = eah->isFaxAppAvailable(); 312 bool kfaxAvail = eah->isFaxAppAvailable();
316 bool ksmsAvail = eah->isSMSAppAvailable(); 313 bool ksmsAvail = eah->isSMSAppAvailable();
317 bool kpagerAvail = eah->isPagerAppAvailable(); 314 bool kpagerAvail = eah->isPagerAppAvailable();
318 bool ksipAvail = eah->isSIPAppAvailable(); 315 bool ksipAvail = eah->isSIPAppAvailable();
319 QString dynamicPart; 316 QString dynamicPart;
320 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
321 KABC::PhoneNumber::List::ConstIterator phoneIt; 317 KABC::PhoneNumber::List::ConstIterator phoneIt;
322 QString extension; 318 QString extension;
323 int phonetype; 319 int phonetype;
324 QString sms; 320 QString sms;
325 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 321 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
326 phonetype = (*phoneIt).type(); 322 phonetype = (*phoneIt).type();
327 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) 323 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred )
328 continue; 324 continue;
329 if (ksmsAvail && 325 if (ksmsAvail &&
330 ( 326 (
331 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 327 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
332 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 328 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
333 ) 329 )
334 ) 330 )
335 { 331 {
336 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 332 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
@@ -364,36 +360,38 @@ QString AddresseeView::getPhoneNumbers( bool preferred )
364 .arg( extension ) 360 .arg( extension )
365 .arg( (*phoneIt).number() ) 361 .arg( (*phoneIt).number() )
366 .arg( (*phoneIt).number() ) 362 .arg( (*phoneIt).number() )
367 .arg( sms ); 363 .arg( sms );
368 364
369 } else { 365 } else {
370 dynamicPart += QString( 366 dynamicPart += QString(
371 "<tr><td align=\"right\"><b>%1</b></td>" 367 "<tr><td align=\"right\"><b>%1</b></td>"
372 "<td align=\"left\">%2 %3</td></tr>" ) 368 "<td align=\"left\">%2 %3</td></tr>" )
373 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 369 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
374 .arg( (*phoneIt).number() ) 370 .arg( (*phoneIt).number() )
375 .arg( sms ); 371 .arg( sms );
376 } 372 }
377 } 373 }
378 return dynamicPart; 374 return dynamicPart;
379} 375}
376/*
380KABC::Addressee AddresseeView::addressee() const 377KABC::Addressee AddresseeView::addressee() const
381{ 378{
382 return mAddressee; 379 return mAddressee;
383} 380}
381*/
384void AddresseeView::addTag(const QString & tag,const QString & text) 382void AddresseeView::addTag(const QString & tag,const QString & text)
385{ 383{
386 if ( text.isEmpty() ) 384 if ( text.isEmpty() )
387 return; 385 return;
388 int number=text.contains("\n"); 386 int number=text.contains("\n");
389 QString str = "<" + tag + ">"; 387 QString str = "<" + tag + ">";
390 QString tmpText=text; 388 QString tmpText=text;
391 QString tmpStr=str; 389 QString tmpStr=str;
392 if(number !=-1) 390 if(number !=-1)
393 { 391 {
394 if (number > 0) { 392 if (number > 0) {
395 int pos=0; 393 int pos=0;
396 QString tmp; 394 QString tmp;
397 for(int i=0;i<=number;i++) { 395 for(int i=0;i<=number;i++) {
398 pos=tmpText.find("\n"); 396 pos=tmpText.find("\n");
399 tmp=tmpText.left(pos); 397 tmp=tmpText.left(pos);
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h
index d8a13ee..3800512 100644
--- a/kabc/addresseeview.h
+++ b/kabc/addresseeview.h
@@ -33,41 +33,41 @@ namespace KPIM {
33//US class AddresseeView : public KTextBrowser 33//US class AddresseeView : public KTextBrowser
34class AddresseeView : public QTextBrowser 34class AddresseeView : public QTextBrowser
35{ 35{
36 public: 36 public:
37 AddresseeView( QWidget *parent = 0, const char *name = 0 ); 37 AddresseeView( QWidget *parent = 0, const char *name = 0 );
38 38
39 /** 39 /**
40 Sets the addressee object. The addressee is displayed immediately. 40 Sets the addressee object. The addressee is displayed immediately.
41 41
42 @param addr The addressee object. 42 @param addr The addressee object.
43 */ 43 */
44 void setAddressee( const KABC::Addressee& addr ); 44 void setAddressee( const KABC::Addressee& addr );
45 void setSource(const QString& n); 45 void setSource(const QString& n);
46 /** 46 /**
47 Returns the current addressee object. 47 Returns the current addressee object.
48 */ 48 */
49 KABC::Addressee addressee() const; 49 //KABC::Addressee addressee() const;
50 50
51 private: 51 private:
52 KABC::Addressee mAddressee; 52 //KABC::Addressee mAddressee;
53 QString mText; 53 QString mText;
54 QString getPhoneNumbers( bool preferred ); 54 QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred );
55 void addTag(const QString & tag,const QString & text); 55 void addTag(const QString & tag,const QString & text);
56 class AddresseeViewPrivate; 56 //class AddresseeViewPrivate;
57 AddresseeViewPrivate *d; 57 //AddresseeViewPrivate *d;
58}; 58};
59class AddresseeChooser : public KDialogBase 59class AddresseeChooser : public KDialogBase
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62 62
63 public: 63 public:
64 AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); 64 AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 );
65 65
66 int executeD( bool local ); 66 int executeD( bool local );
67 67
68 private: 68 private:
69 int mSyncResult; 69 int mSyncResult;
70 70
71 private slots: 71 private slots:
72 void slot_remote(); 72 void slot_remote();
73 void slot_local(); 73 void slot_local();
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
@@ -60,54 +60,99 @@ VCardEntity::operator = (const QCString & s)
60{ 60{
61 Entity::operator = (s); 61 Entity::operator = (s);
62 return *this; 62 return *this;
63} 63}
64 64
65 bool 65 bool
66VCardEntity::operator == (VCardEntity & x) 66VCardEntity::operator == (VCardEntity & x)
67{ 67{
68 x.parse(); 68 x.parse();
69 return false; 69 return false;
70} 70}
71 71
72VCardEntity::~VCardEntity() 72VCardEntity::~VCardEntity()
73{ 73{
74} 74}
75 75
76#include <qdatetime.h>;
76 void 77 void
77VCardEntity::_parse() 78VCardEntity::_parse()
78{ 79{
80#if 0
81 QTime tim;
82 tim.start();
83 int num = 0;
84 // old code
79 vDebug("parse"); 85 vDebug("parse");
80 QCString s(strRep_); 86 QCString s(strRep_);
81 87
82 int i = s.find(QRegExp("BEGIN:VCARD", false)); 88 int i = s.find(QRegExp("BEGIN:VCARD", false));
83 89
84 while (i != -1) { 90 while (i != -1) {
85 91
86 i = s.find(QRegExp("BEGIN:VCARD", false), 11); 92 i = s.find(QRegExp("BEGIN:VCARD", false), 11);
87 93
88 QCString cardStr(s.left(i)); 94 QCString cardStr(s.left(i));
89 95
90 VCard * v = new VCard(cardStr); 96 VCard * v = new VCard(cardStr);
91 97
92 cardList_.append(v); 98 cardList_.append(v);
93 99
94 v->parse(); 100 v->parse();
95 101
96 s.remove(0, i); 102 s.remove(0, i);
97 } 103 }
104
105#else
106 // this code is up to 17 (!) times faster
107 int start = 0;
108 QTime tim;
109 tim.start();
110 int i = 11;
111 int len = strRep_.length();
112 int num = 0;
113 while (i < len ) {
114 while( i < len ) {
115 int add = 1;
116 if ( strRep_.at(i) == 'B' ) {
117 if ( i+add < len && strRep_.at(i+add++) == 'E')
118 if ( i+add < len && strRep_.at(i+add++) == 'G')
119 if ( i+add < len && strRep_.at(i+add++) == 'I')
120 if ( i+add < len && strRep_.at(i+add++) == 'N')
121 if ( i+add < len && strRep_.at(i+add++) == ':')
122 if ( i+add < len && strRep_.at(i+add++) == 'V')
123 if ( i+add < len && strRep_.at(i+add++) == 'C')
124 if ( i+add < len && strRep_.at(i+add++) == 'A')
125 if ( i+add < len && strRep_.at(i+add++) == 'R')
126 if ( i+add < len && strRep_.at(i+add++) == 'D')
127 break;
128 }
129 ++i;
130 }
131 if ( i <= len ) {
132 ++num;
133 char* dat = strRep_.data()+start;
134 VCard * v = new VCard( QCString ( dat,i-start ) );
135 start = i;
136 cardList_.append(v);
137 v->parse();
138 }
139 i+= 11;
140 }
141#endif
142 //qDebug("***time %d found %d", tim.elapsed(), num);
98} 143}
99 144
100 void 145 void
101VCardEntity::_assemble() 146VCardEntity::_assemble()
102{ 147{
103 VCardListIterator it(cardList_); 148 VCardListIterator it(cardList_);
104 149
105 for (; it.current(); ++it) 150 for (; it.current(); ++it)
106 strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. 151 strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck.
107} 152}
108 153
109 VCardList & 154 VCardList &
110VCardEntity::cardList() 155VCardEntity::cardList()
111{ 156{
112 parse(); 157 parse();
113 return cardList_; 158 return cardList_;