summaryrefslogtreecommitdiffabout
path: root/kabc/addresseeview.cpp
authorzautrix <zautrix>2004-10-22 02:21:29 (UTC)
committer zautrix <zautrix>2004-10-22 02:21:29 (UTC)
commitc17118a0b2da49ec633e21cdcd51798c0c38644a (patch) (side-by-side diff)
tree581fbcaa64a5566991ffe0bd3b1b2d428589d87f /kabc/addresseeview.cpp
parentd6f9bd535e8cabe653bdff329500f9153e5e11fb (diff)
downloadkdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.zip
kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.gz
kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.bz2
made addressbook much faster
Diffstat (limited to 'kabc/addresseeview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 90be928..7a4336b 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -77,44 +77,41 @@ void AddresseeView::setSource(const QString& n)
else if ( n.left( 7 ) == "phoneto" )
ExternalAppHandler::instance()->callByPhone( n.mid(8) );
else if ( n.left( 5 ) == "faxto" )
ExternalAppHandler::instance()->callByFax( n.mid(6) );
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>"
"<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
.arg( type )
.arg( name )
.arg( *emailIt )
@@ -127,25 +124,25 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr )
.arg( type )
.arg( *emailIt );
++emailIt;
}
}
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 )
.arg( *emailIt )
.arg( *emailIt );
} else {
dynamicPart += QString(
@@ -299,34 +296,33 @@ mText = "<table width=\"100%\">\n";
.arg( mAddressee.organization());
mText += dynamicPart;
mText += notes;
mText += "</table>";
}
// 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;
if (ksmsAvail &&
(
((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
@@ -368,28 +364,30 @@ QString AddresseeView::getPhoneNumbers( bool preferred )
} else {
dynamicPart += QString(
"<tr><td align=\"right\"><b>%1</b></td>"
"<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;
if(number !=-1)
{
if (number > 0) {
int pos=0;