summaryrefslogtreecommitdiffabout
path: root/kabc
authorzautrix <zautrix>2005-10-29 16:39:40 (UTC)
committer zautrix <zautrix>2005-10-29 16:39:40 (UTC)
commit898dbabef6d747447999add46201315d04f85f63 (patch) (unidiff)
treefb247cbbd99ca6918400547e16484a58a8ba1523 /kabc
parent1360f8e3b5da58b561f868643d2d5f04b874cee7 (diff)
downloadkdepimpi-898dbabef6d747447999add46201315d04f85f63.zip
kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.gz
kdepimpi-898dbabef6d747447999add46201315d04f85f63.tar.bz2
commit
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index aae923c..5c24acf 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -47,207 +47,209 @@
47#include "externalapphandler.h" 47#include "externalapphandler.h"
48#include <kabc/addresseeview.h> 48#include <kabc/addresseeview.h>
49 49
50 50
51//US #ifndef DESKTOP_VERSION 51//US #ifndef DESKTOP_VERSION
52//US #include <qtopia/qcopenvelope_qws.h> 52//US #include <qtopia/qcopenvelope_qws.h>
53//US #include <qpe/qpeapplication.h> 53//US #include <qpe/qpeapplication.h>
54//US #endif 54//US #endif
55 55
56//US static int kphoneInstalled = 0; 56//US static int kphoneInstalled = 0;
57 57
58using namespace KABC; 58using namespace KABC;
59bool AddresseeView::sFullDetailsMode = false; 59bool AddresseeView::sFullDetailsMode = false;
60 60
61AddresseeView::AddresseeView( QWidget *parent, const char *name ) 61AddresseeView::AddresseeView( QWidget *parent, const char *name )
62 : QTextBrowser( parent, name ) 62 : QTextBrowser( parent, name )
63 63
64 64
65{ 65{
66//US setWrapPolicy( QTextEdit::AtWordBoundary ); 66//US setWrapPolicy( QTextEdit::AtWordBoundary );
67 setLinkUnderline( false ); 67 setLinkUnderline( false );
68 // setVScrollBarMode( QScrollView::AlwaysOff ); 68 // setVScrollBarMode( QScrollView::AlwaysOff );
69 //setHScrollBarMode( QScrollView::AlwaysOff ); 69 //setHScrollBarMode( QScrollView::AlwaysOff );
70 70
71//US QStyleSheet *sheet = styleSheet(); 71//US QStyleSheet *sheet = styleSheet();
72//US QStyleSheetItem *link = sheet->item( "a" ); 72//US QStyleSheetItem *link = sheet->item( "a" );
73//US link->setColor( KGlobalSettings::linkColor() ); 73//US link->setColor( KGlobalSettings::linkColor() );
74 74
75 75
76} 76}
77void AddresseeView::printMe() 77void AddresseeView::printMe()
78{ 78{
79#ifdef DESKTOP_VERSION 79#ifdef DESKTOP_VERSION
80 QPrinter printer; 80 QPrinter printer;
81 if (!printer.setup() ) 81 if (!printer.setup() )
82 return; 82 return;
83 QPainter p; 83 QPainter p;
84 p.begin ( &printer ); 84 p.begin ( &printer );
85 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 85 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
86 float dx, dy; 86 float dx, dy;
87 int wid = (m.width() * 9)/10; 87 int wid = (m.width() * 9)/10;
88 dx = (float) wid/(float)contentsWidth (); 88 dx = (float) wid/(float)contentsWidth ();
89 dy = (float)(m.height()) / (float)contentsHeight (); 89 dy = (float)(m.height()) / (float)contentsHeight ();
90 float scale; 90 float scale;
91 // scale to fit the width or height of the paper 91 // scale to fit the width or height of the paper
92 if ( dx < dy ) 92 if ( dx < dy )
93 scale = dx; 93 scale = dx;
94 else 94 else
95 scale = dy; 95 scale = dy;
96 p.translate( m.width()/10,0 ); 96 p.translate( m.width()/10,0 );
97 p.scale( scale, scale ); 97 p.scale( scale, scale );
98 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 98 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
99 p.end(); 99 p.end();
100#endif 100#endif
101} 101}
102void AddresseeView::setSource(const QString& n) 102void AddresseeView::setSource(const QString& n)
103{ 103{
104 //qDebug("********AddresseeView::setSource %s", n.latin1()); 104 //qDebug("********AddresseeView::setSource %s", n.latin1());
105 105
106 if ( n == "allDetails" ) { 106 if ( n == "allDetails" ) {
107 sFullDetailsMode = true; 107 sFullDetailsMode = true;
108 setAddressee( mCurrentContact ); 108 setAddressee( mCurrentContact );
109 } else if ( n == "notAllDetails" ) { 109 } else if ( n == "notAllDetails" ) {
110 sFullDetailsMode = false; 110 sFullDetailsMode = false;
111 setAddressee( mCurrentContact ); 111 setAddressee( mCurrentContact );
112 } else if ( n.left( 6 ) == "mailto" ) 112 } else if ( n.left( 6 ) == "mailto" )
113 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); 113 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
114 else if ( n.left( 7 ) == "phoneto" ) 114 else if ( n.left( 7 ) == "phoneto" )
115 ExternalAppHandler::instance()->callByPhone( n.mid(8) ); 115 ExternalAppHandler::instance()->callByPhone( n.mid(8) );
116 else if ( n.left( 5 ) == "faxto" ) 116 else if ( n.left( 5 ) == "faxto" )
117 ExternalAppHandler::instance()->callByFax( n.mid(6) ); 117 ExternalAppHandler::instance()->callByFax( n.mid(6) );
118 else if ( n.left( 5 ) == "smsto" ) 118 else if ( n.left( 5 ) == "smsto" )
119 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 119 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
120 else if ( n.left( 7 ) == "pagerto" ) 120 else if ( n.left( 7 ) == "pagerto" )
121 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 121 ExternalAppHandler::instance()->callByPager( n.mid(8) );
122 else if ( n.left( 5 ) == "sipto" ) 122 else if ( n.left( 5 ) == "sipto" )
123 ExternalAppHandler::instance()->callBySIP( n.mid(6) ); 123 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
124 124
125} 125}
126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) 126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
127{ 127{
128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); 128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable();
129 // mAddressee = addr; 129 // mAddressee = addr;
130 // clear view 130 // clear view
131 //setText( QString::null ); 131 //setText( QString::null );
132 mCurrentContact = mAddressee; 132 mCurrentContact = mAddressee;
133 if ( mAddressee.isEmpty() ) { 133 if ( mAddressee.isEmpty() ) {
134 setText( QString::null); 134 setText( QString::null);
135 return; 135 return;
136 } 136 }
137#if 0 137#if 0
138 QString name = ( mAddressee.assembledName().isEmpty() ? 138 QString name = ( mAddressee.assembledName().isEmpty() ?
139 mAddressee.formattedName() : mAddressee.assembledName() ); 139 mAddressee.formattedName() : mAddressee.assembledName() );
140#endif 140#endif
141 141
142 QString name = mAddressee.realName(); 142 QString name = mAddressee.realName();
143 143 QString assName = mAddressee.assembledName();
144 if ( assName.isEmpty() )
145 assName = name;
144 QString dynamicPart; 146 QString dynamicPart;
145 147
146 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); 148 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true );
147 QStringList emails = mAddressee.emails(); 149 QStringList emails = mAddressee.emails();
148 QStringList::ConstIterator emailIt; 150 QStringList::ConstIterator emailIt;
149 QString type = i18n( "Email" ); 151 QString type = i18n( "Email" );
150 emailIt = emails.begin(); 152 emailIt = emails.begin();
151 if ( emailIt != emails.end() ) { 153 if ( emailIt != emails.end() ) {
152 if ( kemailAvail ) { 154 if ( kemailAvail ) {
153 dynamicPart += QString( 155 dynamicPart += QString(
154 "<tr><td align=\"right\"><b>%1</b></td>" 156 "<tr><td align=\"right\"><b>%1</b></td>"
155 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 157 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
156 .arg( type ) 158 .arg( type )
157 .arg( name ) 159 .arg( assName )
158 .arg( *emailIt ) 160 .arg( *emailIt )
159 .arg( *emailIt ); 161 .arg( *emailIt );
160 ++emailIt; 162 ++emailIt;
161 } else { 163 } else {
162 dynamicPart += QString( 164 dynamicPart += QString(
163 "<tr><td align=\"right\"><b>%1</b></td>" 165 "<tr><td align=\"right\"><b>%1</b></td>"
164 "<td align=\"left\">%2</td></tr>" ) 166 "<td align=\"left\">%2</td></tr>" )
165 .arg( type ) 167 .arg( type )
166 .arg( *emailIt ); 168 .arg( *emailIt );
167 ++emailIt; 169 ++emailIt;
168 } 170 }
169 } 171 }
170 if ( mAddressee.birthday().date().isValid() ) { 172 if ( mAddressee.birthday().date().isValid() ) {
171 dynamicPart += QString( 173 dynamicPart += QString(
172 "<tr><td align=\"right\"><b>%1</b></td>" 174 "<tr><td align=\"right\"><b>%1</b></td>"
173 "<td align=\"left\">%2</td></tr>" ) 175 "<td align=\"left\">%2</td></tr>" )
174 .arg( i18n ("Birthday") ) 176 .arg( i18n ("Birthday") )
175 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 177 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
176 } 178 }
177 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); 179 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false );
178 180
179 for ( ; emailIt != emails.end(); ++emailIt ) { 181 for ( ; emailIt != emails.end(); ++emailIt ) {
180 if ( kemailAvail ) { 182 if ( kemailAvail ) {
181 dynamicPart += QString( 183 dynamicPart += QString(
182 "<tr><td align=\"right\"><b>%1</b></td>" 184 "<tr><td align=\"right\"><b>%1</b></td>"
183 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 185 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
184 .arg( type ) 186 .arg( type )
185 .arg( name ) 187 .arg( name )
186 .arg( *emailIt ) 188 .arg( *emailIt )
187 .arg( *emailIt ); 189 .arg( *emailIt );
188 } else { 190 } else {
189 dynamicPart += QString( 191 dynamicPart += QString(
190 "<tr><td align=\"right\"><b>%1</b></td>" 192 "<tr><td align=\"right\"><b>%1</b></td>"
191 "<td align=\"left\">%2</td></tr>" ) 193 "<td align=\"left\">%2</td></tr>" )
192 .arg( type ) 194 .arg( type )
193 .arg( *emailIt ); 195 .arg( *emailIt );
194 } 196 }
195 } 197 }
196 198
197 199
198 200
199 KABC::Address::List addresses = mAddressee.addresses(); 201 KABC::Address::List addresses = mAddressee.addresses();
200 KABC::Address::List::ConstIterator addrIt; 202 KABC::Address::List::ConstIterator addrIt;
201 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 203 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
202 if ( true /*(*addrIt).label().isEmpty()*/ ) { 204 if ( true /*(*addrIt).label().isEmpty()*/ ) {
203 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 205 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
204//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 206//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
205 //qDebug("adresss %s ",formattedAddress.latin1() ); 207 //qDebug("adresss %s ",formattedAddress.latin1() );
206 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 208 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
207 //qDebug("AddresseeView::setAddressee has to be verified."); 209 //qDebug("AddresseeView::setAddressee has to be verified.");
208 210
209 dynamicPart += QString( 211 dynamicPart += QString(
210 "<tr><td align=\"right\"><b>%1</b></td>" 212 "<tr><td align=\"right\"><b>%1</b></td>"
211 "<td align=\"left\">%2</td></tr>" ) 213 "<td align=\"left\">%2</td></tr>" )
212 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 214 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
213 .arg( formattedAddress ); 215 .arg( formattedAddress );
214 } else { 216 } else {
215 217
216 dynamicPart += QString( 218 dynamicPart += QString(
217 "<tr><td align=\"right\"><b>%1</b></td>" 219 "<tr><td align=\"right\"><b>%1</b></td>"
218 "<td align=\"left\">%2</td></tr>" ) 220 "<td align=\"left\">%2</td></tr>" )
219 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 221 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
220//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 222//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
221 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 223 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
222 224
223 } 225 }
224 } 226 }
225 227
226 228
227 QString notes; 229 QString notes;
228 if ( sFullDetailsMode ) { 230 if ( sFullDetailsMode ) {
229 notes = QString( 231 notes = QString(
230 "<tr><td align=\"right\"><b>%1</b></td>" 232 "<tr><td align=\"right\"><b>%1</b></td>"
231 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" ) 233 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" )
232 .arg( i18n("Details") ) 234 .arg( i18n("Details") )
233 .arg( i18n("Hide!") ); 235 .arg( i18n("Hide!") );
234 236
235 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 237 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
236 if ( !tempX.isEmpty() ) { 238 if ( !tempX.isEmpty() ) {
237 if ( tempX == "male" || tempX == "female" ) { 239 if ( tempX == "male" || tempX == "female" ) {
238 notes += QString( 240 notes += QString(
239 "<tr><td align=\"right\"><b>%1</b></td>" 241 "<tr><td align=\"right\"><b>%1</b></td>"
240 "<td align=\"left\">%2</td></tr>" ) 242 "<td align=\"left\">%2</td></tr>" )
241 .arg( i18n( "" ) ) 243 .arg( i18n( "" ) )
242 .arg( i18n(tempX) ); 244 .arg( i18n(tempX) );
243 } 245 }
244 } 246 }
245 247
246 248
247 tempX = mAddressee.secrecy().asString(); 249 tempX = mAddressee.secrecy().asString();
248 250
249 notes += QString( 251 notes += QString(
250 "<tr><td align=\"right\"><b>%1</b></td>" 252 "<tr><td align=\"right\"><b>%1</b></td>"
251 "<td align=\"left\">%2</td></tr>" ) 253 "<td align=\"left\">%2</td></tr>" )
252 .arg( "" ) 254 .arg( "" )
253 .arg( tempX ); 255 .arg( tempX );