summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
index e9dc1e9..aa9b7f3 100644
--- a/libkdepim/addresseeview.cpp
+++ b/libkdepim/addresseeview.cpp
@@ -1,190 +1,194 @@
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 38
39#ifndef DESKTOP_VERSION 39#ifndef DESKTOP_VERSION
40#include <qtopia/qcopenvelope_qws.h> 40#include <qtopia/qcopenvelope_qws.h>
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42#endif 42#endif
43 43
44int kphoneInstalled = 0; 44static int kphoneInstalled = 0;
45 45
46using namespace KPIM; 46using namespace KPIM;
47 47
48AddresseeView::AddresseeView( QWidget *parent, const char *name ) 48AddresseeView::AddresseeView( QWidget *parent, const char *name )
49//US : KTextBrowser( parent, name ) 49//US : KTextBrowser( parent, name )
50 : QTextBrowser( parent, name ) 50 : QTextBrowser( parent, name )
51 51
52 52
53{ 53{
54//US setWrapPolicy( QTextEdit::AtWordBoundary ); 54//US setWrapPolicy( QTextEdit::AtWordBoundary );
55 setLinkUnderline( false ); 55 setLinkUnderline( false );
56 // setVScrollBarMode( QScrollView::AlwaysOff ); 56 // setVScrollBarMode( QScrollView::AlwaysOff );
57 //setHScrollBarMode( QScrollView::AlwaysOff ); 57 //setHScrollBarMode( QScrollView::AlwaysOff );
58 58
59//US QStyleSheet *sheet = styleSheet(); 59//US QStyleSheet *sheet = styleSheet();
60//US QStyleSheetItem *link = sheet->item( "a" ); 60//US QStyleSheetItem *link = sheet->item( "a" );
61//US link->setColor( KGlobalSettings::linkColor() ); 61//US link->setColor( KGlobalSettings::linkColor() );
62 62
63} 63}
64void AddresseeView::setSource(const QString& n) 64void AddresseeView::setSource(const QString& n)
65{ 65{
66 qDebug("********AddresseeView::setSource %s", n.latin1()); 66 qDebug("********AddresseeView::setSource %s", n.latin1());
67#ifndef DESKTOP_VERSION 67#ifndef DESKTOP_VERSION
68 if ( n.left( 6 ) == "mailto" ) { 68 if ( n.left( 6 ) == "mailto" ) {
69 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)"); 69 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)");
70 e << n.mid(7); 70 e << n.mid(7);
71 } 71 }
72 if ( n.left( 7 ) == "phoneto" ) { 72 if ( n.left( 7 ) == "phoneto" ) {
73 QString mess = "-ring:" + n.mid(8); 73 QString mess = "-ring:" + n.mid(8);
74 QCopEnvelope e("QPE/Application/kppi", mess.latin1()); 74 QCopEnvelope e("QPE/Application/kppi", mess.latin1());
75 } 75 }
76#endif 76#endif
77 77
78} 78}
79void AddresseeView::setAddressee( const KABC::Addressee& addr ) 79void AddresseeView::setAddressee( const KABC::Addressee& addr )
80{ 80{
81 bool kphoneAvail = false; 81 bool kphoneAvail = false;
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84 if ( ! kphoneInstalled ) { 84 if ( ! kphoneInstalled ) {
85 if ( QFile::exists( QPEApplication::qpeDir() + "/bin/kppi" ) ) 85 if ( QFile::exists( QPEApplication::qpeDir() + "/bin/kppi" ) )
86 kphoneInstalled = 1; 86 kphoneInstalled = 1;
87 else 87 else
88 kphoneInstalled = -1; 88 kphoneInstalled = -1;
89 } else { 89 }
90 if ( kphoneInstalled > 0 ) 90 if ( kphoneInstalled > 0 )
91 kphoneAvail = true; 91 kphoneAvail = true;
92 } 92#if 0
93 //if ( kphoneAvail ) 93 if ( kphoneAvail )
94 // qDebug("KPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPone avail "); 94 qDebug("KPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPone avail ");
95 else
96 qDebug("NOOOOOOOOOOOo KPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPone avail ");
97#endif
98
95#endif 99#endif
96 mAddressee = addr; 100 mAddressee = addr;
97 // clear view 101 // clear view
98 setText( QString::null ); 102 setText( QString::null );
99 103
100 if ( mAddressee.isEmpty() ) 104 if ( mAddressee.isEmpty() )
101 return; 105 return;
102 106
103 QString name = ( mAddressee.formattedName().isEmpty() ? 107 QString name = ( mAddressee.formattedName().isEmpty() ?
104 mAddressee.assembledName() : mAddressee.formattedName() ); 108 mAddressee.assembledName() : mAddressee.formattedName() );
105 109
106 QString dynamicPart; 110 QString dynamicPart;
107 111
108 QStringList emails = mAddressee.emails(); 112 QStringList emails = mAddressee.emails();
109 QStringList::ConstIterator emailIt; 113 QStringList::ConstIterator emailIt;
110 QString type = i18n( "Email" ); 114 QString type = i18n( "Email" );
111 emailIt = emails.begin(); 115 emailIt = emails.begin();
112 if ( emailIt != emails.end() ) { 116 if ( emailIt != emails.end() ) {
113 dynamicPart += QString( 117 dynamicPart += QString(
114 "<tr><td align=\"right\"><b>%1</b></td>" 118 "<tr><td align=\"right\"><b>%1</b></td>"
115 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 119 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
116 .arg( type ) 120 .arg( type )
117 .arg( name ) 121 .arg( name )
118 .arg( *emailIt ) 122 .arg( *emailIt )
119 .arg( *emailIt ); 123 .arg( *emailIt );
120 ++emailIt; 124 ++emailIt;
121 } 125 }
122 126
123 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); 127 KABC::PhoneNumber::List phones = mAddressee.phoneNumbers();
124 KABC::PhoneNumber::List::ConstIterator phoneIt; 128 KABC::PhoneNumber::List::ConstIterator phoneIt;
125 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 129 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
126 if ( kphoneAvail ) { 130 if ( kphoneAvail ) {
127 dynamicPart += QString( 131 dynamicPart += QString(
128 "<tr><td align=\"right\"><b>%1</b></td>" 132 "<tr><td align=\"right\"><b>%1</b></td>"
129 "<td align=\"left\"><a href=\"phoneto:%2 \">%3</a></td></tr>" ) 133 "<td align=\"left\"><a href=\"phoneto:%2 \">%3</a></td></tr>" )
130 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) 134 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) )
131 .arg( (*phoneIt).number() ) 135 .arg( (*phoneIt).number() )
132 .arg( (*phoneIt).number() ); 136 .arg( (*phoneIt).number() );
133 137
134 } else { 138 } else {
135 dynamicPart += QString( 139 dynamicPart += QString(
136 "<tr><td align=\"right\"><b>%1</b></td>" 140 "<tr><td align=\"right\"><b>%1</b></td>"
137 "<td align=\"left\">%2</td></tr>" ) 141 "<td align=\"left\">%2</td></tr>" )
138 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) ) 142 .arg( KABC::PhoneNumber::typeLabel( (*phoneIt).type() ) )
139 .arg( (*phoneIt).number() ); 143 .arg( (*phoneIt).number() );
140 } 144 }
141 } 145 }
142 146
143 147
144 for ( ; emailIt != emails.end(); ++emailIt ) { 148 for ( ; emailIt != emails.end(); ++emailIt ) {
145 dynamicPart += QString( 149 dynamicPart += QString(
146 "<tr><td align=\"right\"><b>%1</b></td>" 150 "<tr><td align=\"right\"><b>%1</b></td>"
147 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 151 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
148 .arg( type ) 152 .arg( type )
149 .arg( name ) 153 .arg( name )
150 .arg( *emailIt ) 154 .arg( *emailIt )
151 .arg( *emailIt ); 155 .arg( *emailIt );
152 } 156 }
153 157
154 if ( !mAddressee.url().url().isEmpty() ) { 158 if ( !mAddressee.url().url().isEmpty() ) {
155 dynamicPart += QString( 159 dynamicPart += QString(
156 "<tr><td align=\"right\"><b>%1</b></td>" 160 "<tr><td align=\"right\"><b>%1</b></td>"
157 "<td align=\"left\">%2</td></tr>" ) 161 "<td align=\"left\">%2</td></tr>" )
158 .arg( i18n( "Homepage" ) ) 162 .arg( i18n( "Homepage" ) )
159//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); 163//US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) );
160 .arg( mAddressee.url().url() ); 164 .arg( mAddressee.url().url() );
161 //qDebug("AddresseeView::setAddressee has to be verified."); 165 //qDebug("AddresseeView::setAddressee has to be verified.");
162 } 166 }
163 167
164 KABC::Address::List addresses = mAddressee.addresses(); 168 KABC::Address::List addresses = mAddressee.addresses();
165 KABC::Address::List::ConstIterator addrIt; 169 KABC::Address::List::ConstIterator addrIt;
166 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 170 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
167 if ( true /*(*addrIt).label().isEmpty()*/ ) { 171 if ( true /*(*addrIt).label().isEmpty()*/ ) {
168 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 172 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
169//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 173//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
170 //qDebug("adresss %s ",formattedAddress.latin1() ); 174 //qDebug("adresss %s ",formattedAddress.latin1() );
171 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 175 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
172 //qDebug("AddresseeView::setAddressee has to be verified."); 176 //qDebug("AddresseeView::setAddressee has to be verified.");
173 177
174 dynamicPart += QString( 178 dynamicPart += QString(
175 "<tr><td align=\"right\"><b>%1</b></td>" 179 "<tr><td align=\"right\"><b>%1</b></td>"
176 "<td align=\"left\">%2</td></tr>" ) 180 "<td align=\"left\">%2</td></tr>" )
177 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 181 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
178 .arg( formattedAddress ); 182 .arg( formattedAddress );
179 } else { 183 } else {
180 184
181 dynamicPart += QString( 185 dynamicPart += QString(
182 "<tr><td align=\"right\"><b>%1</b></td>" 186 "<tr><td align=\"right\"><b>%1</b></td>"
183 "<td align=\"left\">%2</td></tr>" ) 187 "<td align=\"left\">%2</td></tr>" )
184 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 188 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
185//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 189//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
186 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 190 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
187 191
188 } 192 }
189 } 193 }
190 194