-rw-r--r-- | kabc/addresseeview.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index af149a0..0564e85 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -13,193 +13,192 @@ | |||
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 <qvbox.h> | 33 | #include <qvbox.h> |
34 | #include <qlabel.h> | 34 | #include <qlabel.h> |
35 | #include <qwidget.h> | 35 | #include <qwidget.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qpushbutton.h> | 38 | #include <qpushbutton.h> |
39 | 39 | ||
40 | 40 | ||
41 | #include "externalapphandler.h" | 41 | #include "externalapphandler.h" |
42 | #include "addresseeview.h" | 42 | #include "addresseeview.h" |
43 | 43 | ||
44 | 44 | ||
45 | //US #ifndef DESKTOP_VERSION | 45 | //US #ifndef DESKTOP_VERSION |
46 | //US #include <qtopia/qcopenvelope_qws.h> | 46 | //US #include <qtopia/qcopenvelope_qws.h> |
47 | //US #include <qpe/qpeapplication.h> | 47 | //US #include <qpe/qpeapplication.h> |
48 | //US #endif | 48 | //US #endif |
49 | 49 | ||
50 | //US static int kphoneInstalled = 0; | 50 | //US static int kphoneInstalled = 0; |
51 | 51 | ||
52 | using namespace KPIM; | 52 | using namespace KPIM; |
53 | 53 | ||
54 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 54 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
55 | //US : KTextBrowser( parent, name ) | 55 | //US : KTextBrowser( parent, name ) |
56 | : QTextBrowser( parent, name ) | 56 | : QTextBrowser( parent, name ) |
57 | 57 | ||
58 | 58 | ||
59 | { | 59 | { |
60 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 60 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
61 | setLinkUnderline( false ); | 61 | setLinkUnderline( false ); |
62 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 62 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
63 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 63 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
64 | 64 | ||
65 | //US QStyleSheet *sheet = styleSheet(); | 65 | //US QStyleSheet *sheet = styleSheet(); |
66 | //US QStyleSheetItem *link = sheet->item( "a" ); | 66 | //US QStyleSheetItem *link = sheet->item( "a" ); |
67 | //US link->setColor( KGlobalSettings::linkColor() ); | 67 | //US link->setColor( KGlobalSettings::linkColor() ); |
68 | 68 | ||
69 | } | 69 | } |
70 | 70 | ||
71 | void AddresseeView::setSource(const QString& n) | 71 | void AddresseeView::setSource(const QString& n) |
72 | { | 72 | { |
73 | //qDebug("********AddresseeView::setSource %s", n.latin1()); | 73 | //qDebug("********AddresseeView::setSource %s", n.latin1()); |
74 | 74 | ||
75 | if ( n.left( 6 ) == "mailto" ) | 75 | if ( n.left( 6 ) == "mailto" ) |
76 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 76 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
77 | else if ( n.left( 7 ) == "phoneto" ) | 77 | else if ( n.left( 7 ) == "phoneto" ) |
78 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 78 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
79 | else if ( n.left( 5 ) == "faxto" ) | 79 | else if ( n.left( 5 ) == "faxto" ) |
80 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 80 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
81 | else if ( n.left( 5 ) == "smsto" ) | 81 | else if ( n.left( 5 ) == "smsto" ) |
82 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 82 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); |
83 | else if ( n.left( 7 ) == "pagerto" ) | 83 | else if ( n.left( 7 ) == "pagerto" ) |
84 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 84 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); |
85 | else if ( n.left( 5 ) == "sipto" ) | 85 | else if ( n.left( 5 ) == "sipto" ) |
86 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | 86 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); |
87 | 87 | ||
88 | } | 88 | } |
89 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) | 89 | void AddresseeView::setAddressee( const KABC::Addressee& addr ) |
90 | { | 90 | { |
91 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 91 | ExternalAppHandler* eah = ExternalAppHandler::instance(); |
92 | bool kemailAvail = eah->isEmailAppAvailable(); | 92 | bool kemailAvail = eah->isEmailAppAvailable(); |
93 | 93 | ||
94 | 94 | ||
95 | 95 | ||
96 | mAddressee = addr; | 96 | mAddressee = addr; |
97 | // clear view | 97 | // clear view |
98 | setText( QString::null ); | 98 | setText( QString::null ); |
99 | 99 | ||
100 | if ( mAddressee.isEmpty() ) | 100 | if ( mAddressee.isEmpty() ) |
101 | return; | 101 | return; |
102 | 102 | ||
103 | QString name = ( mAddressee.assembledName().isEmpty() ? | 103 | QString name = ( mAddressee.assembledName().isEmpty() ? |
104 | mAddressee.formattedName() : mAddressee.assembledName() ); | 104 | mAddressee.formattedName() : mAddressee.assembledName() ); |
105 | 105 | ||
106 | QString dynamicPart; | 106 | QString dynamicPart; |
107 | 107 | ||
108 | dynamicPart += getPhoneNumbers( true ); | 108 | dynamicPart += getPhoneNumbers( true ); |
109 | qDebug("dynamic preferred %s ",dynamicPart.latin1() ); | ||
110 | QStringList emails = mAddressee.emails(); | 109 | QStringList emails = mAddressee.emails(); |
111 | QStringList::ConstIterator emailIt; | 110 | QStringList::ConstIterator emailIt; |
112 | QString type = i18n( "Email" ); | 111 | QString type = i18n( "Email" ); |
113 | emailIt = emails.begin(); | 112 | emailIt = emails.begin(); |
114 | if ( emailIt != emails.end() ) { | 113 | if ( emailIt != emails.end() ) { |
115 | if ( kemailAvail ) { | 114 | if ( kemailAvail ) { |
116 | dynamicPart += QString( | 115 | dynamicPart += QString( |
117 | "<tr><td align=\"right\"><b>%1</b></td>" | 116 | "<tr><td align=\"right\"><b>%1</b></td>" |
118 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 117 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
119 | .arg( type ) | 118 | .arg( type ) |
120 | .arg( name ) | 119 | .arg( name ) |
121 | .arg( *emailIt ) | 120 | .arg( *emailIt ) |
122 | .arg( *emailIt ); | 121 | .arg( *emailIt ); |
123 | ++emailIt; | 122 | ++emailIt; |
124 | } else { | 123 | } else { |
125 | dynamicPart += QString( | 124 | dynamicPart += QString( |
126 | "<tr><td align=\"right\"><b>%1</b></td>" | 125 | "<tr><td align=\"right\"><b>%1</b></td>" |
127 | "<td align=\"left\">%2</td></tr>" ) | 126 | "<td align=\"left\">%2</td></tr>" ) |
128 | .arg( type ) | 127 | .arg( type ) |
129 | .arg( *emailIt ); | 128 | .arg( *emailIt ); |
130 | ++emailIt; | 129 | ++emailIt; |
131 | } | 130 | } |
132 | } | 131 | } |
133 | if ( mAddressee.birthday().date().isValid() ) { | 132 | if ( mAddressee.birthday().date().isValid() ) { |
134 | dynamicPart += QString( | 133 | dynamicPart += QString( |
135 | "<tr><td align=\"right\"><b>%1</b></td>" | 134 | "<tr><td align=\"right\"><b>%1</b></td>" |
136 | "<td align=\"left\">%2</td></tr>" ) | 135 | "<td align=\"left\">%2</td></tr>" ) |
137 | .arg( i18n ("Birthday") ) | 136 | .arg( i18n ("Birthday") ) |
138 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); | 137 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); |
139 | } | 138 | } |
140 | dynamicPart += getPhoneNumbers( false ); | 139 | dynamicPart += getPhoneNumbers( false ); |
141 | 140 | ||
142 | for ( ; emailIt != emails.end(); ++emailIt ) { | 141 | for ( ; emailIt != emails.end(); ++emailIt ) { |
143 | if ( kemailAvail ) { | 142 | if ( kemailAvail ) { |
144 | dynamicPart += QString( | 143 | dynamicPart += QString( |
145 | "<tr><td align=\"right\"><b>%1</b></td>" | 144 | "<tr><td align=\"right\"><b>%1</b></td>" |
146 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 145 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
147 | .arg( type ) | 146 | .arg( type ) |
148 | .arg( name ) | 147 | .arg( name ) |
149 | .arg( *emailIt ) | 148 | .arg( *emailIt ) |
150 | .arg( *emailIt ); | 149 | .arg( *emailIt ); |
151 | } else { | 150 | } else { |
152 | dynamicPart += QString( | 151 | dynamicPart += QString( |
153 | "<tr><td align=\"right\"><b>%1</b></td>" | 152 | "<tr><td align=\"right\"><b>%1</b></td>" |
154 | "<td align=\"left\">%2</td></tr>" ) | 153 | "<td align=\"left\">%2</td></tr>" ) |
155 | .arg( type ) | 154 | .arg( type ) |
156 | .arg( *emailIt ); | 155 | .arg( *emailIt ); |
157 | } | 156 | } |
158 | } | 157 | } |
159 | 158 | ||
160 | if ( !mAddressee.url().url().isEmpty() ) { | 159 | if ( !mAddressee.url().url().isEmpty() ) { |
161 | dynamicPart += QString( | 160 | dynamicPart += QString( |
162 | "<tr><td align=\"right\"><b>%1</b></td>" | 161 | "<tr><td align=\"right\"><b>%1</b></td>" |
163 | "<td align=\"left\">%2</td></tr>" ) | 162 | "<td align=\"left\">%2</td></tr>" ) |
164 | .arg( i18n( "Homepage" ) ) | 163 | .arg( i18n( "Homepage" ) ) |
165 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); | 164 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); |
166 | .arg( mAddressee.url().url() ); | 165 | .arg( mAddressee.url().url() ); |
167 | //qDebug("AddresseeView::setAddressee has to be verified."); | 166 | //qDebug("AddresseeView::setAddressee has to be verified."); |
168 | } | 167 | } |
169 | 168 | ||
170 | KABC::Address::List addresses = mAddressee.addresses(); | 169 | KABC::Address::List addresses = mAddressee.addresses(); |
171 | KABC::Address::List::ConstIterator addrIt; | 170 | KABC::Address::List::ConstIterator addrIt; |
172 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 171 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
173 | if ( true /*(*addrIt).label().isEmpty()*/ ) { | 172 | if ( true /*(*addrIt).label().isEmpty()*/ ) { |
174 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); | 173 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); |
175 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); | 174 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); |
176 | //qDebug("adresss %s ",formattedAddress.latin1() ); | 175 | //qDebug("adresss %s ",formattedAddress.latin1() ); |
177 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); | 176 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); |
178 | //qDebug("AddresseeView::setAddressee has to be verified."); | 177 | //qDebug("AddresseeView::setAddressee has to be verified."); |
179 | 178 | ||
180 | dynamicPart += QString( | 179 | dynamicPart += QString( |
181 | "<tr><td align=\"right\"><b>%1</b></td>" | 180 | "<tr><td align=\"right\"><b>%1</b></td>" |
182 | "<td align=\"left\">%2</td></tr>" ) | 181 | "<td align=\"left\">%2</td></tr>" ) |
183 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 182 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
184 | .arg( formattedAddress ); | 183 | .arg( formattedAddress ); |
185 | } else { | 184 | } else { |
186 | 185 | ||
187 | dynamicPart += QString( | 186 | dynamicPart += QString( |
188 | "<tr><td align=\"right\"><b>%1</b></td>" | 187 | "<tr><td align=\"right\"><b>%1</b></td>" |
189 | "<td align=\"left\">%2</td></tr>" ) | 188 | "<td align=\"left\">%2</td></tr>" ) |
190 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 189 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
191 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); | 190 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); |
192 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); | 191 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); |
193 | 192 | ||
194 | } | 193 | } |
195 | } | 194 | } |
196 | 195 | ||
197 | QString notes; | 196 | QString notes; |
198 | if ( !mAddressee.note().isEmpty() ) { | 197 | if ( !mAddressee.note().isEmpty() ) { |
199 | notes = QString( | 198 | notes = QString( |
200 | "<tr>" | 199 | "<tr>" |
201 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | 200 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label |
202 | "<td align=\"left\">%2</td>" // note | 201 | "<td align=\"left\">%2</td>" // note |
203 | "</tr>" ).arg( i18n( "Notes" ) ) | 202 | "</tr>" ).arg( i18n( "Notes" ) ) |
204 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | 203 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); |
205 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | 204 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); |