summaryrefslogtreecommitdiffabout
path: root/libkdepim/addresseeview.cpp
Unidiff
Diffstat (limited to 'libkdepim/addresseeview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
index deafd34..70fc57c 100644
--- a/libkdepim/addresseeview.cpp
+++ b/libkdepim/addresseeview.cpp
@@ -1,137 +1,153 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <kabc/address.h> 22#include <kabc/address.h>
23#include <kabc/addressee.h> 23#include <kabc/addressee.h>
24#include <kabc/phonenumber.h> 24#include <kabc/phonenumber.h>
25#include <kglobal.h> 25#include <kglobal.h>
26//US#include <kglobalsettings.h> 26//US#include <kglobalsettings.h>
27#include <kiconloader.h> 27#include <kiconloader.h>
28#include <klocale.h> 28#include <klocale.h>
29//US #include <kstringhandler.h> 29//US #include <kstringhandler.h>
30#include <qscrollview.h> 30#include <qscrollview.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qapplication.h> 33#include <qapplication.h>
34 34
35 35
36#include "addresseeview.h" 36#include "addresseeview.h"
37 37
38
39#ifndef DESKTOP_VERSION
40#include <qtopia/qcopenvelope_qws.h>
41#endif
42
43
44
38using namespace KPIM; 45using namespace KPIM;
39 46
40AddresseeView::AddresseeView( QWidget *parent, const char *name ) 47AddresseeView::AddresseeView( QWidget *parent, const char *name )
41//US : KTextBrowser( parent, name ) 48//US : KTextBrowser( parent, name )
42 : QTextBrowser( parent, name ) 49 : QTextBrowser( parent, name )
43 50
44 51
45{ 52{
46//US setWrapPolicy( QTextEdit::AtWordBoundary ); 53//US setWrapPolicy( QTextEdit::AtWordBoundary );
47 setLinkUnderline( false ); 54 setLinkUnderline( false );
48 // setVScrollBarMode( QScrollView::AlwaysOff ); 55 // setVScrollBarMode( QScrollView::AlwaysOff );
49 //setHScrollBarMode( QScrollView::AlwaysOff ); 56 //setHScrollBarMode( QScrollView::AlwaysOff );
50 57
51//US QStyleSheet *sheet = styleSheet(); 58//US QStyleSheet *sheet = styleSheet();
52//US QStyleSheetItem *link = sheet->item( "a" ); 59//US QStyleSheetItem *link = sheet->item( "a" );
53//US link->setColor( KGlobalSettings::linkColor() ); 60//US link->setColor( KGlobalSettings::linkColor() );
54 61
55} 62}
63void AddresseeView::setSource(const QString& n)
64{
65 //qDebug("********AddresseeView::setSource %s", n.mid(7).latin1());
66#ifndef DESKTOP_VERSION
67 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)");
68 e << n.mid(7);
69#endif
56 70
71}
57void AddresseeView::setAddressee( const KABC::Addressee& addr ) 72void AddresseeView::setAddressee( const KABC::Addressee& addr )
58{ 73{
59 mAddressee = addr; 74 mAddressee = addr;
60 75
61 // clear view 76 // clear view
62 setText( QString::null ); 77 setText( QString::null );
63 78
64 if ( mAddressee.isEmpty() ) 79 if ( mAddressee.isEmpty() )
65 return; 80 return;
66 81
67 QString name = ( mAddressee.formattedName().isEmpty() ? 82 QString name = ( mAddressee.formattedName().isEmpty() ?
68 mAddressee.assembledName() : mAddressee.formattedName() ); 83 mAddressee.assembledName() : mAddressee.formattedName() );
69 84
70 QString dynamicPart; 85 QString dynamicPart;
71 86
72 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 87 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
73 KABC::PhoneNumber::List::ConstIterator phoneIt; 88 KABC::PhoneNumber::List::ConstIterator phoneIt;
74 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 89 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
75 dynamicPart += QString( 90 dynamicPart += QString(
76 "<tr><td align=\"right\"><b>%1</b></td>" 91 "<tr><td align=\"right\"><b>%1</b></td>"
77 "<td align=\"left\">%2</td></tr>" ) 92 "<td align=\"left\">%2</td></tr>" )
78 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) 93 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) )
79 .arg( (*phoneIt).number() ); 94 .arg( (*phoneIt).number() );
80 } 95 }
81 96
82 QStringList emails = mAddressee.emails(); 97 QStringList emails = mAddressee.emails();
83 QStringList::ConstIterator emailIt; 98 QStringList::ConstIterator emailIt;
84 QString type = i18n( "Email" ); 99 QString type = i18n( "Email" );
85 for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) { 100 for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) {
86 dynamicPart += QString( 101 dynamicPart += QString(
87 "<tr><td align=\"right\"><b>%1</b></td>" 102 "<tr><td align=\"right\"><b>%1</b></td>"
88 "<td align=\"left\"><a href=\"mailto:%2\">%3</a></td></tr>" ) 103 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
89 .arg( type ) 104 .arg( type )
105 .arg( name )
90 .arg( *emailIt ) 106 .arg( *emailIt )
91 .arg( *emailIt ); 107 .arg( *emailIt );
92 type = i18n( "Other" ); 108 type = i18n( "Other" );
93 } 109 }
94 110
95 if ( !mAddressee.url().url().isEmpty() ) { 111 if ( !mAddressee.url().url().isEmpty() ) {
96 dynamicPart += QString( 112 dynamicPart += QString(
97 "<tr><td align=\"right\"><b>%1</b></td>" 113 "<tr><td align=\"right\"><b>%1</b></td>"
98 "<td align=\"left\">%2</td></tr>" ) 114 "<td align=\"left\">%2</td></tr>" )
99 .arg( i18n( "Homepage" ) ) 115 .arg( i18n( "Homepage" ) )
100//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 116//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
101 .arg( mAddressee.url().url() ); 117 .arg( mAddressee.url().url() );
102 //qDebug("AddresseeView::setAddressee has to be verified."); 118 //qDebug("AddresseeView::setAddressee has to be verified.");
103 } 119 }
104 120
105 KABC::Address::List addresses = mAddressee.addresses(); 121 KABC::Address::List addresses = mAddressee.addresses();
106 KABC::Address::List::ConstIterator addrIt; 122 KABC::Address::List::ConstIterator addrIt;
107 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 123 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
108 if ( true /*(*addrIt).label().isEmpty()*/ ) { 124 if ( true /*(*addrIt).label().isEmpty()*/ ) {
109 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 125 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
110//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 126//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
111 //qDebug("adresss %s ",formattedAddress.latin1() ); 127 //qDebug("adresss %s ",formattedAddress.latin1() );
112 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 128 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
113 //qDebug("AddresseeView::setAddressee has to be verified."); 129 //qDebug("AddresseeView::setAddressee has to be verified.");
114 130
115 dynamicPart += QString( 131 dynamicPart += QString(
116 "<tr><td align=\"right\"><b>%1</b></td>" 132 "<tr><td align=\"right\"><b>%1</b></td>"
117 "<td align=\"left\">%2</td></tr>" ) 133 "<td align=\"left\">%2</td></tr>" )
118 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 134 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
119 .arg( formattedAddress ); 135 .arg( formattedAddress );
120 } else { 136 } else {
121 137
122 dynamicPart += QString( 138 dynamicPart += QString(
123 "<tr><td align=\"right\"><b>%1</b></td>" 139 "<tr><td align=\"right\"><b>%1</b></td>"
124 "<td align=\"left\">%2</td></tr>" ) 140 "<td align=\"left\">%2</td></tr>" )
125 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 141 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
126//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 142//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
127 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 143 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
128 144
129 } 145 }
130 } 146 }
131 147
132 QString notes; 148 QString notes;
133 if ( !mAddressee.note().isEmpty() ) { 149 if ( !mAddressee.note().isEmpty() ) {
134 notes = QString( 150 notes = QString(
135 "<tr>" 151 "<tr>"
136 "<td align=\"right\" valign=\"top\"><b>%1:</b></td>" // note label 152 "<td align=\"right\" valign=\"top\"><b>%1:</b></td>" // note label
137 "<td align=\"left\">%2</td>" // note 153 "<td align=\"left\">%2</td>" // note