summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
index 70fc57c..71c7817 100644
--- a/libkdepim/addresseeview.cpp
+++ b/libkdepim/addresseeview.cpp
@@ -39,162 +39,174 @@
39#ifndef DESKTOP_VERSION 39#ifndef DESKTOP_VERSION
40#include <qtopia/qcopenvelope_qws.h> 40#include <qtopia/qcopenvelope_qws.h>
41#endif 41#endif
42 42
43 43
44 44
45using namespace KPIM; 45using namespace KPIM;
46 46
47AddresseeView::AddresseeView( QWidget *parent, const char *name ) 47AddresseeView::AddresseeView( QWidget *parent, const char *name )
48//US : KTextBrowser( parent, name ) 48//US : KTextBrowser( parent, name )
49 : QTextBrowser( parent, name ) 49 : QTextBrowser( parent, name )
50 50
51 51
52{ 52{
53//US setWrapPolicy( QTextEdit::AtWordBoundary ); 53//US setWrapPolicy( QTextEdit::AtWordBoundary );
54 setLinkUnderline( false ); 54 setLinkUnderline( false );
55 // setVScrollBarMode( QScrollView::AlwaysOff ); 55 // setVScrollBarMode( QScrollView::AlwaysOff );
56 //setHScrollBarMode( QScrollView::AlwaysOff ); 56 //setHScrollBarMode( QScrollView::AlwaysOff );
57 57
58//US QStyleSheet *sheet = styleSheet(); 58//US QStyleSheet *sheet = styleSheet();
59//US QStyleSheetItem *link = sheet->item( "a" ); 59//US QStyleSheetItem *link = sheet->item( "a" );
60//US link->setColor( KGlobalSettings::linkColor() ); 60//US link->setColor( KGlobalSettings::linkColor() );
61 61
62} 62}
63void AddresseeView::setSource(const QString& n) 63void AddresseeView::setSource(const QString& n)
64{ 64{
65 //qDebug("********AddresseeView::setSource %s", n.mid(7).latin1()); 65 //qDebug("********AddresseeView::setSource %s", n.mid(7).latin1());
66#ifndef DESKTOP_VERSION 66#ifndef DESKTOP_VERSION
67 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)"); 67 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)");
68 e << n.mid(7); 68 e << n.mid(7);
69#endif 69#endif
70 70
71} 71}
72void AddresseeView::setAddressee( const KABC::Addressee& addr ) 72void AddresseeView::setAddressee( const KABC::Addressee& addr )
73{ 73{
74 mAddressee = addr; 74 mAddressee = addr;
75 75
76 // clear view 76 // clear view
77 setText( QString::null ); 77 setText( QString::null );
78 78
79 if ( mAddressee.isEmpty() ) 79 if ( mAddressee.isEmpty() )
80 return; 80 return;
81 81
82 QString name = ( mAddressee.formattedName().isEmpty() ? 82 QString name = ( mAddressee.formattedName().isEmpty() ?
83 mAddressee.assembledName() : mAddressee.formattedName() ); 83 mAddressee.assembledName() : mAddressee.formattedName() );
84 84
85 QString dynamicPart; 85 QString dynamicPart;
86 86
87 QStringList emails = mAddressee.emails();
88 QStringList::ConstIterator emailIt;
89 QString type = i18n( "Email" );
90 emailIt = emails.begin();
91 if ( emailIt != emails.end() ) {
92 dynamicPart += QString(
93 "<tr><td align=\"right\"><b>%1</b></td>"
94 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
95 .arg( type )
96 .arg( name )
97 .arg( *emailIt )
98 .arg( *emailIt );
99 ++emailIt;
100 }
101
87 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 102 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
88 KABC::PhoneNumber::List::ConstIterator phoneIt; 103 KABC::PhoneNumber::List::ConstIterator phoneIt;
89 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 104 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
90 dynamicPart += QString( 105 dynamicPart += QString(
91 "<tr><td align=\"right\"><b>%1</b></td>" 106 "<tr><td align=\"right\"><b>%1</b></td>"
92 "<td align=\"left\">%2</td></tr>" ) 107 "<td align=\"left\">%2</td></tr>" )
93 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) 108 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) )
94 .arg( (*phoneIt).number() ); 109 .arg( (*phoneIt).number() );
95 } 110 }
96 111
97 QStringList emails = mAddressee.emails(); 112
98 QStringList::ConstIterator emailIt; 113 for ( ; emailIt != emails.end(); ++emailIt ) {
99 QString type = i18n( "Email" );
100 for ( emailIt = emails.begin(); emailIt != emails.end(); ++emailIt ) {
101 dynamicPart += QString( 114 dynamicPart += QString(
102 "<tr><td align=\"right\"><b>%1</b></td>" 115 "<tr><td align=\"right\"><b>%1</b></td>"
103 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 116 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
104 .arg( type ) 117 .arg( type )
105 .arg( name ) 118 .arg( name )
106 .arg( *emailIt ) 119 .arg( *emailIt )
107 .arg( *emailIt ); 120 .arg( *emailIt );
108 type = i18n( "Other" );
109 } 121 }
110 122
111 if ( !mAddressee.url().url().isEmpty() ) { 123 if ( !mAddressee.url().url().isEmpty() ) {
112 dynamicPart += QString( 124 dynamicPart += QString(
113 "<tr><td align=\"right\"><b>%1</b></td>" 125 "<tr><td align=\"right\"><b>%1</b></td>"
114 "<td align=\"left\">%2</td></tr>" ) 126 "<td align=\"left\">%2</td></tr>" )
115 .arg( i18n( "Homepage" ) ) 127 .arg( i18n( "Homepage" ) )
116//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 128//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
117 .arg( mAddressee.url().url() ); 129 .arg( mAddressee.url().url() );
118 //qDebug("AddresseeView::setAddressee has to be verified."); 130 //qDebug("AddresseeView::setAddressee has to be verified.");
119 } 131 }
120 132
121 KABC::Address::List addresses = mAddressee.addresses(); 133 KABC::Address::List addresses = mAddressee.addresses();
122 KABC::Address::List::ConstIterator addrIt; 134 KABC::Address::List::ConstIterator addrIt;
123 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 135 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
124 if ( true /*(*addrIt).label().isEmpty()*/ ) { 136 if ( true /*(*addrIt).label().isEmpty()*/ ) {
125 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 137 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
126//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 138//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
127 //qDebug("adresss %s ",formattedAddress.latin1() ); 139 //qDebug("adresss %s ",formattedAddress.latin1() );
128 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 140 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
129 //qDebug("AddresseeView::setAddressee has to be verified."); 141 //qDebug("AddresseeView::setAddressee has to be verified.");
130 142
131 dynamicPart += QString( 143 dynamicPart += QString(
132 "<tr><td align=\"right\"><b>%1</b></td>" 144 "<tr><td align=\"right\"><b>%1</b></td>"
133 "<td align=\"left\">%2</td></tr>" ) 145 "<td align=\"left\">%2</td></tr>" )
134 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 146 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
135 .arg( formattedAddress ); 147 .arg( formattedAddress );
136 } else { 148 } else {
137 149
138 dynamicPart += QString( 150 dynamicPart += QString(
139 "<tr><td align=\"right\"><b>%1</b></td>" 151 "<tr><td align=\"right\"><b>%1</b></td>"
140 "<td align=\"left\">%2</td></tr>" ) 152 "<td align=\"left\">%2</td></tr>" )
141 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 153 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
142//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 154//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
143 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 155 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
144 156
145 } 157 }
146 } 158 }
147 159
148 QString notes; 160 QString notes;
149 if ( !mAddressee.note().isEmpty() ) { 161 if ( !mAddressee.note().isEmpty() ) {
150 notes = QString( 162 notes = QString(
151 "<tr>" 163 "<tr>"
152 "<td align=\"right\" valign=\"top\"><b>%1:</b></td>" // note label 164 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
153 "<td align=\"left\">%2</td>" // note 165 "<td align=\"left\">%2</td>" // note
154 "</tr>" ).arg( i18n( "Notes" ) ) 166 "</tr>" ).arg( i18n( "Notes" ) )
155//US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 167//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
156 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 168 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
157 //qDebug("AddresseeView::setAddressee has to be verified."); 169 //qDebug("AddresseeView::setAddressee has to be verified.");
158 } 170 }
159 171
160 QString aRole = ""; 172 QString aRole = "";
161 QString aOrga = ""; 173 QString aOrga = "";
162 if ( true /*!mAddressee.role().isEmpty()*/ ) { 174 if ( true /*!mAddressee.role().isEmpty()*/ ) {
163 aRole = "<tr>" 175 aRole = "<tr>"
164 "<td align=\"left\">" + mAddressee.role() + "</td>" 176 "<td align=\"left\">" + mAddressee.role() + "</td>"
165 "</tr>"; 177 "</tr>";
166 } 178 }
167 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 179 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
168 aOrga = "<tr>" 180 aOrga = "<tr>"
169 "<td align=\"left\">" + mAddressee.organization() + "</td>" ; 181 "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
170 "</tr>"; 182 "</tr>";
171 } 183 }
172 mText = ""; 184 mText = "";
173 QString picString = ""; 185 QString picString = "";
174 KABC::Picture picture = mAddressee.photo(); 186 KABC::Picture picture = mAddressee.photo();
175 bool picAvailintern = false; 187 bool picAvailintern = false;
176 bool picAvailUrl = false; 188 bool picAvailUrl = false;
177 if (! picture.undefined() ) { 189 if (! picture.undefined() ) {
178 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 190 picAvailintern = (picture.isIntern() && !picture.data().isNull());
179 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 191 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
180 } 192 }
181 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 193 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
182 if ( picAvailintern ) { 194 if ( picAvailintern ) {
183 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 195 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
184 } else { 196 } else {
185 if ( picAvailUrl ) { 197 if ( picAvailUrl ) {
186 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); 198 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
187 } else { 199 } else {
188 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); 200 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
189 } 201 }
190 } 202 }
191 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 203 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
192 mText = QString::fromLatin1( 204 mText = QString::fromLatin1(
193 "<html>" 205 "<html>"
194 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 206 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
195 "<table>" 207 "<table>"
196 "<tr>" 208 "<tr>"
197 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 209 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
198 "%3" 210 "%3"
199 "</td>" 211 "</td>"
200 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 212 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name