author | zautrix <zautrix> | 2004-10-22 02:21:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-22 02:21:29 (UTC) |
commit | c17118a0b2da49ec633e21cdcd51798c0c38644a (patch) (unidiff) | |
tree | 581fbcaa64a5566991ffe0bd3b1b2d428589d87f /kabc | |
parent | d6f9bd535e8cabe653bdff329500f9153e5e11fb (diff) | |
download | kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.zip kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.gz kdepimpi-c17118a0b2da49ec633e21cdcd51798c0c38644a.tar.bz2 |
made addressbook much faster
-rw-r--r-- | kabc/addresseeview.cpp | 28 | ||||
-rw-r--r-- | kabc/addresseeview.h | 10 | ||||
-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 45 |
3 files changed, 63 insertions, 20 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 90be928..7a4336b 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -1,471 +1,469 @@ | |||
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 <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& mAddressee ) |
90 | { | 90 | { |
91 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 91 | bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); |
92 | bool kemailAvail = eah->isEmailAppAvailable(); | 92 | // mAddressee = addr; |
93 | |||
94 | |||
95 | |||
96 | mAddressee = addr; | ||
97 | // clear view | 93 | // clear view |
98 | setText( QString::null ); | 94 | //setText( QString::null ); |
99 | |||
100 | if ( mAddressee.isEmpty() ) | ||
101 | return; | ||
102 | 95 | ||
96 | if ( mAddressee.isEmpty() ) { | ||
97 | setText( QString::null); | ||
98 | return; | ||
99 | } | ||
103 | QString name = ( mAddressee.assembledName().isEmpty() ? | 100 | QString name = ( mAddressee.assembledName().isEmpty() ? |
104 | mAddressee.formattedName() : mAddressee.assembledName() ); | 101 | mAddressee.formattedName() : mAddressee.assembledName() ); |
105 | 102 | ||
106 | QString dynamicPart; | 103 | QString dynamicPart; |
107 | 104 | ||
108 | dynamicPart += getPhoneNumbers( true ); | 105 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); |
109 | QStringList emails = mAddressee.emails(); | 106 | QStringList emails = mAddressee.emails(); |
110 | QStringList::ConstIterator emailIt; | 107 | QStringList::ConstIterator emailIt; |
111 | QString type = i18n( "Email" ); | 108 | QString type = i18n( "Email" ); |
112 | emailIt = emails.begin(); | 109 | emailIt = emails.begin(); |
113 | if ( emailIt != emails.end() ) { | 110 | if ( emailIt != emails.end() ) { |
114 | if ( kemailAvail ) { | 111 | if ( kemailAvail ) { |
115 | dynamicPart += QString( | 112 | dynamicPart += QString( |
116 | "<tr><td align=\"right\"><b>%1</b></td>" | 113 | "<tr><td align=\"right\"><b>%1</b></td>" |
117 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 114 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
118 | .arg( type ) | 115 | .arg( type ) |
119 | .arg( name ) | 116 | .arg( name ) |
120 | .arg( *emailIt ) | 117 | .arg( *emailIt ) |
121 | .arg( *emailIt ); | 118 | .arg( *emailIt ); |
122 | ++emailIt; | 119 | ++emailIt; |
123 | } else { | 120 | } else { |
124 | dynamicPart += QString( | 121 | dynamicPart += QString( |
125 | "<tr><td align=\"right\"><b>%1</b></td>" | 122 | "<tr><td align=\"right\"><b>%1</b></td>" |
126 | "<td align=\"left\">%2</td></tr>" ) | 123 | "<td align=\"left\">%2</td></tr>" ) |
127 | .arg( type ) | 124 | .arg( type ) |
128 | .arg( *emailIt ); | 125 | .arg( *emailIt ); |
129 | ++emailIt; | 126 | ++emailIt; |
130 | } | 127 | } |
131 | } | 128 | } |
132 | if ( mAddressee.birthday().date().isValid() ) { | 129 | if ( mAddressee.birthday().date().isValid() ) { |
133 | dynamicPart += QString( | 130 | dynamicPart += QString( |
134 | "<tr><td align=\"right\"><b>%1</b></td>" | 131 | "<tr><td align=\"right\"><b>%1</b></td>" |
135 | "<td align=\"left\">%2</td></tr>" ) | 132 | "<td align=\"left\">%2</td></tr>" ) |
136 | .arg( i18n ("Birthday") ) | 133 | .arg( i18n ("Birthday") ) |
137 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); | 134 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); |
138 | } | 135 | } |
139 | dynamicPart += getPhoneNumbers( false ); | 136 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); |
140 | 137 | ||
141 | for ( ; emailIt != emails.end(); ++emailIt ) { | 138 | for ( ; emailIt != emails.end(); ++emailIt ) { |
142 | if ( kemailAvail ) { | 139 | if ( kemailAvail ) { |
143 | dynamicPart += QString( | 140 | dynamicPart += QString( |
144 | "<tr><td align=\"right\"><b>%1</b></td>" | 141 | "<tr><td align=\"right\"><b>%1</b></td>" |
145 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 142 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
146 | .arg( type ) | 143 | .arg( type ) |
147 | .arg( name ) | 144 | .arg( name ) |
148 | .arg( *emailIt ) | 145 | .arg( *emailIt ) |
149 | .arg( *emailIt ); | 146 | .arg( *emailIt ); |
150 | } else { | 147 | } else { |
151 | dynamicPart += QString( | 148 | dynamicPart += QString( |
152 | "<tr><td align=\"right\"><b>%1</b></td>" | 149 | "<tr><td align=\"right\"><b>%1</b></td>" |
153 | "<td align=\"left\">%2</td></tr>" ) | 150 | "<td align=\"left\">%2</td></tr>" ) |
154 | .arg( type ) | 151 | .arg( type ) |
155 | .arg( *emailIt ); | 152 | .arg( *emailIt ); |
156 | } | 153 | } |
157 | } | 154 | } |
158 | 155 | ||
159 | if ( !mAddressee.url().url().isEmpty() ) { | 156 | if ( !mAddressee.url().url().isEmpty() ) { |
160 | dynamicPart += QString( | 157 | dynamicPart += QString( |
161 | "<tr><td align=\"right\"><b>%1</b></td>" | 158 | "<tr><td align=\"right\"><b>%1</b></td>" |
162 | "<td align=\"left\">%2</td></tr>" ) | 159 | "<td align=\"left\">%2</td></tr>" ) |
163 | .arg( i18n( "Homepage" ) ) | 160 | .arg( i18n( "Homepage" ) ) |
164 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); | 161 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); |
165 | .arg( mAddressee.url().url() ); | 162 | .arg( mAddressee.url().url() ); |
166 | //qDebug("AddresseeView::setAddressee has to be verified."); | 163 | //qDebug("AddresseeView::setAddressee has to be verified."); |
167 | } | 164 | } |
168 | 165 | ||
169 | KABC::Address::List addresses = mAddressee.addresses(); | 166 | KABC::Address::List addresses = mAddressee.addresses(); |
170 | KABC::Address::List::ConstIterator addrIt; | 167 | KABC::Address::List::ConstIterator addrIt; |
171 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 168 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
172 | if ( true /*(*addrIt).label().isEmpty()*/ ) { | 169 | if ( true /*(*addrIt).label().isEmpty()*/ ) { |
173 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); | 170 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); |
174 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); | 171 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); |
175 | //qDebug("adresss %s ",formattedAddress.latin1() ); | 172 | //qDebug("adresss %s ",formattedAddress.latin1() ); |
176 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); | 173 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); |
177 | //qDebug("AddresseeView::setAddressee has to be verified."); | 174 | //qDebug("AddresseeView::setAddressee has to be verified."); |
178 | 175 | ||
179 | dynamicPart += QString( | 176 | dynamicPart += QString( |
180 | "<tr><td align=\"right\"><b>%1</b></td>" | 177 | "<tr><td align=\"right\"><b>%1</b></td>" |
181 | "<td align=\"left\">%2</td></tr>" ) | 178 | "<td align=\"left\">%2</td></tr>" ) |
182 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 179 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
183 | .arg( formattedAddress ); | 180 | .arg( formattedAddress ); |
184 | } else { | 181 | } else { |
185 | 182 | ||
186 | dynamicPart += QString( | 183 | dynamicPart += QString( |
187 | "<tr><td align=\"right\"><b>%1</b></td>" | 184 | "<tr><td align=\"right\"><b>%1</b></td>" |
188 | "<td align=\"left\">%2</td></tr>" ) | 185 | "<td align=\"left\">%2</td></tr>" ) |
189 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 186 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
190 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); | 187 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); |
191 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); | 188 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); |
192 | 189 | ||
193 | } | 190 | } |
194 | } | 191 | } |
195 | 192 | ||
196 | QString notes; | 193 | QString notes; |
197 | if ( !mAddressee.note().isEmpty() ) { | 194 | if ( !mAddressee.note().isEmpty() ) { |
198 | notes = QString( | 195 | notes = QString( |
199 | "<tr>" | 196 | "<tr>" |
200 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | 197 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label |
201 | "<td align=\"left\">%2</td>" // note | 198 | "<td align=\"left\">%2</td>" // note |
202 | "</tr>" ).arg( i18n( "Notes" ) ) | 199 | "</tr>" ).arg( i18n( "Notes" ) ) |
203 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | 200 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); |
204 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | 201 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); |
205 | //qDebug("AddresseeView::setAddressee has to be verified."); | 202 | //qDebug("AddresseeView::setAddressee has to be verified."); |
206 | } | 203 | } |
207 | 204 | ||
208 | QString aRole = ""; | 205 | QString aRole = ""; |
209 | QString aOrga = ""; | 206 | QString aOrga = ""; |
210 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 207 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
211 | aRole = "<tr>" | 208 | aRole = "<tr>" |
212 | "<td align=\"left\">" + mAddressee.role() + "</td>" | 209 | "<td align=\"left\">" + mAddressee.role() + "</td>" |
213 | "</tr>"; | 210 | "</tr>"; |
214 | } | 211 | } |
215 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { | 212 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { |
216 | aOrga = "<tr>" | 213 | aOrga = "<tr>" |
217 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; | 214 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; |
218 | "</tr>"; | 215 | "</tr>"; |
219 | } | 216 | } |
220 | mText = ""; | 217 | mText = ""; |
221 | QString picString = ""; | 218 | QString picString = ""; |
222 | KABC::Picture picture = mAddressee.photo(); | 219 | KABC::Picture picture = mAddressee.photo(); |
223 | bool picAvailintern = false; | 220 | bool picAvailintern = false; |
224 | bool picAvailUrl = false; | 221 | bool picAvailUrl = false; |
225 | if (! picture.undefined() ) { | 222 | if (! picture.undefined() ) { |
226 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); | 223 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); |
227 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); | 224 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); |
228 | } | 225 | } |
229 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 226 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
230 | if ( picAvailintern ) { | 227 | if ( picAvailintern ) { |
231 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 228 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
232 | } else { | 229 | } else { |
233 | if ( picAvailUrl ) { | 230 | if ( picAvailUrl ) { |
234 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); | 231 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); |
235 | } else { | 232 | } else { |
236 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); | 233 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); |
237 | } | 234 | } |
238 | } | 235 | } |
239 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 236 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
240 | mText = QString::fromLatin1( | 237 | mText = QString::fromLatin1( |
241 | "<html>" | 238 | "<html>" |
242 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color | 239 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color |
243 | "<table>" | 240 | "<table>" |
244 | "<tr>" | 241 | "<tr>" |
245 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" | 242 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" |
246 | "%3" | 243 | "%3" |
247 | "</td>" | 244 | "</td>" |
248 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name | 245 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name |
249 | "</tr>" | 246 | "</tr>" |
250 | "%5" // role | 247 | "%5" // role |
251 | "%6" // organization | 248 | "%6" // organization |
252 | "<td colspan=\"2\"> </td>" | 249 | "<td colspan=\"2\"> </td>" |
253 | "%7" // dynamic part | 250 | "%7" // dynamic part |
254 | "%8" // notes | 251 | "%8" // notes |
255 | "</table>" | 252 | "</table>" |
256 | "</body>" | 253 | "</body>" |
257 | "</html>") | 254 | "</html>") |
258 | //US | 255 | //US |
259 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) | 256 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) |
260 | //US | 257 | //US |
261 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) | 258 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) |
262 | .arg( picString ) | 259 | .arg( picString ) |
263 | .arg( name ) | 260 | .arg( name ) |
264 | .arg( aRole ) | 261 | .arg( aRole ) |
265 | .arg( aOrga ) | 262 | .arg( aOrga ) |
266 | .arg( dynamicPart ) | 263 | .arg( dynamicPart ) |
267 | .arg( notes ); | 264 | .arg( notes ); |
268 | 265 | ||
269 | } else { // no picture! | 266 | } else { // no picture! |
270 | 267 | ||
271 | mText = "<table width=\"100%\">\n"; | 268 | mText = "<table width=\"100%\">\n"; |
272 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 269 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
273 | #ifdef DESKTOP_VERSION | 270 | #ifdef DESKTOP_VERSION |
274 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; | 271 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; |
275 | mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; | 272 | mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; |
276 | #else | 273 | #else |
277 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; | 274 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; |
278 | mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; | 275 | mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; |
279 | #endif | 276 | #endif |
280 | 277 | ||
281 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 278 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
282 | 279 | ||
283 | mText += "<table><td colspan=\"2\"> </td>"; | 280 | mText += "<table><td colspan=\"2\"> </td>"; |
284 | /* | 281 | /* |
285 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 282 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
286 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 283 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
287 | .arg( i18n(" ") ) | 284 | .arg( i18n(" ") ) |
288 | .arg( name ); | 285 | .arg( name ); |
289 | */ | 286 | */ |
290 | if ( ! mAddressee.role().isEmpty() ) | 287 | if ( ! mAddressee.role().isEmpty() ) |
291 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 288 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
292 | "<td align=\"left\">%2</td></tr>" ) | 289 | "<td align=\"left\">%2</td></tr>" ) |
293 | .arg( i18n(" ") ) | 290 | .arg( i18n(" ") ) |
294 | .arg( mAddressee.role()); | 291 | .arg( mAddressee.role()); |
295 | if ( ! mAddressee.organization().isEmpty() ) | 292 | if ( ! mAddressee.organization().isEmpty() ) |
296 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 293 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
297 | "<td align=\"left\">%2</td></tr>" ) | 294 | "<td align=\"left\">%2</td></tr>" ) |
298 | .arg( i18n(" ") ) | 295 | .arg( i18n(" ") ) |
299 | .arg( mAddressee.organization()); | 296 | .arg( mAddressee.organization()); |
300 | mText += dynamicPart; | 297 | mText += dynamicPart; |
301 | mText += notes; | 298 | mText += notes; |
302 | mText += "</table>"; | 299 | mText += "</table>"; |
303 | 300 | ||
304 | } | 301 | } |
305 | 302 | ||
306 | // at last display it... | 303 | // at last display it... |
307 | setText( mText ); | 304 | setText( mText ); |
308 | 305 | ||
309 | } | 306 | } |
310 | 307 | ||
311 | QString AddresseeView::getPhoneNumbers( bool preferred ) | 308 | QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) |
312 | { | 309 | { |
313 | ExternalAppHandler* eah = ExternalAppHandler::instance(); | 310 | ExternalAppHandler* eah = ExternalAppHandler::instance(); |
314 | bool kphoneAvail = eah->isPhoneAppAvailable(); | 311 | bool kphoneAvail = eah->isPhoneAppAvailable(); |
315 | bool kfaxAvail = eah->isFaxAppAvailable(); | 312 | bool kfaxAvail = eah->isFaxAppAvailable(); |
316 | bool ksmsAvail = eah->isSMSAppAvailable(); | 313 | bool ksmsAvail = eah->isSMSAppAvailable(); |
317 | bool kpagerAvail = eah->isPagerAppAvailable(); | 314 | bool kpagerAvail = eah->isPagerAppAvailable(); |
318 | bool ksipAvail = eah->isSIPAppAvailable(); | 315 | bool ksipAvail = eah->isSIPAppAvailable(); |
319 | QString dynamicPart; | 316 | QString dynamicPart; |
320 | KABC::PhoneNumber::List phones = mAddressee.phoneNumbers(); | ||
321 | KABC::PhoneNumber::List::ConstIterator phoneIt; | 317 | KABC::PhoneNumber::List::ConstIterator phoneIt; |
322 | QString extension; | 318 | QString extension; |
323 | int phonetype; | 319 | int phonetype; |
324 | QString sms; | 320 | QString sms; |
325 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { | 321 | for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { |
326 | phonetype = (*phoneIt).type(); | 322 | phonetype = (*phoneIt).type(); |
327 | if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) | 323 | if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) |
328 | continue; | 324 | continue; |
329 | if (ksmsAvail && | 325 | if (ksmsAvail && |
330 | ( | 326 | ( |
331 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || | 327 | ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || |
332 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) | 328 | ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) |
333 | ) | 329 | ) |
334 | ) | 330 | ) |
335 | { | 331 | { |
336 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) | 332 | sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) |
337 | .arg( (*phoneIt).number() ); | 333 | .arg( (*phoneIt).number() ); |
338 | 334 | ||
339 | } | 335 | } |
340 | else | 336 | else |
341 | sms = ""; | 337 | sms = ""; |
342 | 338 | ||
343 | extension = QString::null; | 339 | extension = QString::null; |
344 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { | 340 | if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { |
345 | if (kfaxAvail) extension = "faxto:"; | 341 | if (kfaxAvail) extension = "faxto:"; |
346 | } | 342 | } |
347 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { | 343 | else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { |
348 | if (kpagerAvail) extension = "pagerto:"; | 344 | if (kpagerAvail) extension = "pagerto:"; |
349 | } | 345 | } |
350 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { | 346 | else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { |
351 | if (ksipAvail) extension = "sipto:"; | 347 | if (ksipAvail) extension = "sipto:"; |
352 | } | 348 | } |
353 | else if (kphoneAvail) { | 349 | else if (kphoneAvail) { |
354 | extension = "phoneto:"; | 350 | extension = "phoneto:"; |
355 | } | 351 | } |
356 | else | 352 | else |
357 | extension = QString::null; | 353 | extension = QString::null; |
358 | 354 | ||
359 | if ( !extension.isEmpty() ) { | 355 | if ( !extension.isEmpty() ) { |
360 | dynamicPart += QString( | 356 | dynamicPart += QString( |
361 | "<tr><td align=\"right\"><b>%1</b></td>" | 357 | "<tr><td align=\"right\"><b>%1</b></td>" |
362 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) | 358 | "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) |
363 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 359 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
364 | .arg( extension ) | 360 | .arg( extension ) |
365 | .arg( (*phoneIt).number() ) | 361 | .arg( (*phoneIt).number() ) |
366 | .arg( (*phoneIt).number() ) | 362 | .arg( (*phoneIt).number() ) |
367 | .arg( sms ); | 363 | .arg( sms ); |
368 | 364 | ||
369 | } else { | 365 | } else { |
370 | dynamicPart += QString( | 366 | dynamicPart += QString( |
371 | "<tr><td align=\"right\"><b>%1</b></td>" | 367 | "<tr><td align=\"right\"><b>%1</b></td>" |
372 | "<td align=\"left\">%2 %3</td></tr>" ) | 368 | "<td align=\"left\">%2 %3</td></tr>" ) |
373 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) | 369 | .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) |
374 | .arg( (*phoneIt).number() ) | 370 | .arg( (*phoneIt).number() ) |
375 | .arg( sms ); | 371 | .arg( sms ); |
376 | } | 372 | } |
377 | } | 373 | } |
378 | return dynamicPart; | 374 | return dynamicPart; |
379 | } | 375 | } |
376 | /* | ||
380 | KABC::Addressee AddresseeView::addressee() const | 377 | KABC::Addressee AddresseeView::addressee() const |
381 | { | 378 | { |
382 | return mAddressee; | 379 | return mAddressee; |
383 | } | 380 | } |
381 | */ | ||
384 | void AddresseeView::addTag(const QString & tag,const QString & text) | 382 | void AddresseeView::addTag(const QString & tag,const QString & text) |
385 | { | 383 | { |
386 | if ( text.isEmpty() ) | 384 | if ( text.isEmpty() ) |
387 | return; | 385 | return; |
388 | int number=text.contains("\n"); | 386 | int number=text.contains("\n"); |
389 | QString str = "<" + tag + ">"; | 387 | QString str = "<" + tag + ">"; |
390 | QString tmpText=text; | 388 | QString tmpText=text; |
391 | QString tmpStr=str; | 389 | QString tmpStr=str; |
392 | if(number !=-1) | 390 | if(number !=-1) |
393 | { | 391 | { |
394 | if (number > 0) { | 392 | if (number > 0) { |
395 | int pos=0; | 393 | int pos=0; |
396 | QString tmp; | 394 | QString tmp; |
397 | for(int i=0;i<=number;i++) { | 395 | for(int i=0;i<=number;i++) { |
398 | pos=tmpText.find("\n"); | 396 | pos=tmpText.find("\n"); |
399 | tmp=tmpText.left(pos); | 397 | tmp=tmpText.left(pos); |
400 | tmpText=tmpText.right(tmpText.length()-pos-1); | 398 | tmpText=tmpText.right(tmpText.length()-pos-1); |
401 | tmpStr+=tmp+"<br>"; | 399 | tmpStr+=tmp+"<br>"; |
402 | } | 400 | } |
403 | } | 401 | } |
404 | else tmpStr += tmpText; | 402 | else tmpStr += tmpText; |
405 | tmpStr+="</" + tag + ">"; | 403 | tmpStr+="</" + tag + ">"; |
406 | mText.append(tmpStr); | 404 | mText.append(tmpStr); |
407 | } | 405 | } |
408 | else | 406 | else |
409 | { | 407 | { |
410 | str += text + "</" + tag + ">"; | 408 | str += text + "</" + tag + ">"; |
411 | mText.append(str); | 409 | mText.append(str); |
412 | } | 410 | } |
413 | } | 411 | } |
414 | 412 | ||
415 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, | 413 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, |
416 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) | 414 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) |
417 | { | 415 | { |
418 | findButton( Close )->setText( i18n("Cancel Sync")); | 416 | findButton( Close )->setText( i18n("Cancel Sync")); |
419 | findButton( Ok )->setText( i18n("Remote")); | 417 | findButton( Ok )->setText( i18n("Remote")); |
420 | findButton( User1 )->setText( i18n("Local")); | 418 | findButton( User1 )->setText( i18n("Local")); |
421 | QWidget* topframe = new QWidget( this ); | 419 | QWidget* topframe = new QWidget( this ); |
422 | setMainWidget( topframe ); | 420 | setMainWidget( topframe ); |
423 | QBoxLayout* bl; | 421 | QBoxLayout* bl; |
424 | if ( QApplication::desktop()->width() < 640 ) { | 422 | if ( QApplication::desktop()->width() < 640 ) { |
425 | bl = new QVBoxLayout( topframe ); | 423 | bl = new QVBoxLayout( topframe ); |
426 | } else { | 424 | } else { |
427 | bl = new QHBoxLayout( topframe ); | 425 | bl = new QHBoxLayout( topframe ); |
428 | } | 426 | } |
429 | QVBox* subframe = new QVBox( topframe ); | 427 | QVBox* subframe = new QVBox( topframe ); |
430 | bl->addWidget(subframe ); | 428 | bl->addWidget(subframe ); |
431 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); | 429 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); |
432 | if ( takeloc ) | 430 | if ( takeloc ) |
433 | lab->setBackgroundColor(Qt::green.light() ); | 431 | lab->setBackgroundColor(Qt::green.light() ); |
434 | AddresseeView * av = new AddresseeView( subframe ); | 432 | AddresseeView * av = new AddresseeView( subframe ); |
435 | av->setAddressee( loc ); | 433 | av->setAddressee( loc ); |
436 | subframe = new QVBox( topframe ); | 434 | subframe = new QVBox( topframe ); |
437 | bl->addWidget(subframe ); | 435 | bl->addWidget(subframe ); |
438 | lab = new QLabel( i18n("Remote Addressee"), subframe ); | 436 | lab = new QLabel( i18n("Remote Addressee"), subframe ); |
439 | if ( !takeloc ) | 437 | if ( !takeloc ) |
440 | lab->setBackgroundColor(Qt::green.light() ); | 438 | lab->setBackgroundColor(Qt::green.light() ); |
441 | av = new AddresseeView( subframe ); | 439 | av = new AddresseeView( subframe ); |
442 | av->setAddressee( rem ); | 440 | av->setAddressee( rem ); |
443 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); | 441 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); |
444 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); | 442 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); |
445 | #ifndef DESKTOP_VERSION | 443 | #ifndef DESKTOP_VERSION |
446 | showMaximized(); | 444 | showMaximized(); |
447 | #else | 445 | #else |
448 | resize ( 640, 400 ); | 446 | resize ( 640, 400 ); |
449 | #endif | 447 | #endif |
450 | } | 448 | } |
451 | 449 | ||
452 | int AddresseeChooser::executeD( bool local ) | 450 | int AddresseeChooser::executeD( bool local ) |
453 | { | 451 | { |
454 | mSyncResult = 3; | 452 | mSyncResult = 3; |
455 | if ( local ) | 453 | if ( local ) |
456 | findButton( User1 )->setFocus(); | 454 | findButton( User1 )->setFocus(); |
457 | else | 455 | else |
458 | findButton( Ok )->setFocus(); | 456 | findButton( Ok )->setFocus(); |
459 | exec(); | 457 | exec(); |
460 | return mSyncResult; | 458 | return mSyncResult; |
461 | } | 459 | } |
462 | void AddresseeChooser::slot_remote() | 460 | void AddresseeChooser::slot_remote() |
463 | { | 461 | { |
464 | mSyncResult = 2; | 462 | mSyncResult = 2; |
465 | accept(); | 463 | accept(); |
466 | } | 464 | } |
467 | void AddresseeChooser::slot_local() | 465 | void AddresseeChooser::slot_local() |
468 | { | 466 | { |
469 | mSyncResult = 1; | 467 | mSyncResult = 1; |
470 | accept(); | 468 | accept(); |
471 | } | 469 | } |
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index d8a13ee..3800512 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -1,79 +1,79 @@ | |||
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 | #ifndef KPIM_ADDRESSEEVIEW_H | 22 | #ifndef KPIM_ADDRESSEEVIEW_H |
23 | #define KPIM_ADDRESSEEVIEW_H | 23 | #define KPIM_ADDRESSEEVIEW_H |
24 | 24 | ||
25 | #include <kabc/addressee.h> | 25 | #include <kabc/addressee.h> |
26 | #include <kdialogbase.h> | 26 | #include <kdialogbase.h> |
27 | 27 | ||
28 | //US #include <ktextbrowser.h> | 28 | //US #include <ktextbrowser.h> |
29 | #include <qtextbrowser.h> | 29 | #include <qtextbrowser.h> |
30 | 30 | ||
31 | namespace KPIM { | 31 | namespace KPIM { |
32 | 32 | ||
33 | //US class AddresseeView : public KTextBrowser | 33 | //US class AddresseeView : public KTextBrowser |
34 | class AddresseeView : public QTextBrowser | 34 | class AddresseeView : public QTextBrowser |
35 | { | 35 | { |
36 | public: | 36 | public: |
37 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); | 37 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | Sets the addressee object. The addressee is displayed immediately. | 40 | Sets the addressee object. The addressee is displayed immediately. |
41 | 41 | ||
42 | @param addr The addressee object. | 42 | @param addr The addressee object. |
43 | */ | 43 | */ |
44 | void setAddressee( const KABC::Addressee& addr ); | 44 | void setAddressee( const KABC::Addressee& addr ); |
45 | void setSource(const QString& n); | 45 | void setSource(const QString& n); |
46 | /** | 46 | /** |
47 | Returns the current addressee object. | 47 | Returns the current addressee object. |
48 | */ | 48 | */ |
49 | KABC::Addressee addressee() const; | 49 | //KABC::Addressee addressee() const; |
50 | 50 | ||
51 | private: | 51 | private: |
52 | KABC::Addressee mAddressee; | 52 | //KABC::Addressee mAddressee; |
53 | QString mText; | 53 | QString mText; |
54 | QString getPhoneNumbers( bool preferred ); | 54 | QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); |
55 | void addTag(const QString & tag,const QString & text); | 55 | void addTag(const QString & tag,const QString & text); |
56 | class AddresseeViewPrivate; | 56 | //class AddresseeViewPrivate; |
57 | AddresseeViewPrivate *d; | 57 | //AddresseeViewPrivate *d; |
58 | }; | 58 | }; |
59 | class AddresseeChooser : public KDialogBase | 59 | class AddresseeChooser : public KDialogBase |
60 | { | 60 | { |
61 | Q_OBJECT | 61 | Q_OBJECT |
62 | 62 | ||
63 | public: | 63 | public: |
64 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); | 64 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); |
65 | 65 | ||
66 | int executeD( bool local ); | 66 | int executeD( bool local ); |
67 | 67 | ||
68 | private: | 68 | private: |
69 | int mSyncResult; | 69 | int mSyncResult; |
70 | 70 | ||
71 | private slots: | 71 | private slots: |
72 | void slot_remote(); | 72 | void slot_remote(); |
73 | void slot_local(); | 73 | void slot_local(); |
74 | 74 | ||
75 | }; | 75 | }; |
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | #endif | 79 | #endif |
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp index 5fca3bc..b676cc7 100644 --- a/kabc/vcard/VCardEntity.cpp +++ b/kabc/vcard/VCardEntity.cpp | |||
@@ -1,129 +1,174 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
12 | 12 | ||
13 | The above copyright notice and this permission notice shall be included in | 13 | The above copyright notice and this permission notice shall be included in |
14 | all copies or substantial portions of the Software. | 14 | all copies or substantial portions of the Software. |
15 | 15 | ||
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | 19 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qregexp.h> | 24 | #include <qregexp.h> |
25 | 25 | ||
26 | #include <VCardDefines.h> | 26 | #include <VCardDefines.h> |
27 | #include <VCardVCardEntity.h> | 27 | #include <VCardVCardEntity.h> |
28 | 28 | ||
29 | using namespace VCARD; | 29 | using namespace VCARD; |
30 | 30 | ||
31 | VCardEntity::VCardEntity() | 31 | VCardEntity::VCardEntity() |
32 | :Entity() | 32 | :Entity() |
33 | { | 33 | { |
34 | cardList_.setAutoDelete( TRUE ); | 34 | cardList_.setAutoDelete( TRUE ); |
35 | } | 35 | } |
36 | 36 | ||
37 | VCardEntity::VCardEntity(const VCardEntity & x) | 37 | VCardEntity::VCardEntity(const VCardEntity & x) |
38 | :Entity(x) | 38 | :Entity(x) |
39 | { | 39 | { |
40 | cardList_.setAutoDelete( TRUE ); | 40 | cardList_.setAutoDelete( TRUE ); |
41 | } | 41 | } |
42 | 42 | ||
43 | VCardEntity::VCardEntity(const QCString & s) | 43 | VCardEntity::VCardEntity(const QCString & s) |
44 | :Entity(s) | 44 | :Entity(s) |
45 | { | 45 | { |
46 | cardList_.setAutoDelete( TRUE ); | 46 | cardList_.setAutoDelete( TRUE ); |
47 | } | 47 | } |
48 | 48 | ||
49 | VCardEntity & | 49 | VCardEntity & |
50 | VCardEntity::operator = (VCardEntity & x) | 50 | VCardEntity::operator = (VCardEntity & x) |
51 | { | 51 | { |
52 | if (*this == x) return *this; | 52 | if (*this == x) return *this; |
53 | 53 | ||
54 | Entity::operator = (x); | 54 | Entity::operator = (x); |
55 | return *this; | 55 | return *this; |
56 | } | 56 | } |
57 | 57 | ||
58 | VCardEntity & | 58 | VCardEntity & |
59 | VCardEntity::operator = (const QCString & s) | 59 | VCardEntity::operator = (const QCString & s) |
60 | { | 60 | { |
61 | Entity::operator = (s); | 61 | Entity::operator = (s); |
62 | return *this; | 62 | return *this; |
63 | } | 63 | } |
64 | 64 | ||
65 | bool | 65 | bool |
66 | VCardEntity::operator == (VCardEntity & x) | 66 | VCardEntity::operator == (VCardEntity & x) |
67 | { | 67 | { |
68 | x.parse(); | 68 | x.parse(); |
69 | return false; | 69 | return false; |
70 | } | 70 | } |
71 | 71 | ||
72 | VCardEntity::~VCardEntity() | 72 | VCardEntity::~VCardEntity() |
73 | { | 73 | { |
74 | } | 74 | } |
75 | 75 | ||
76 | #include <qdatetime.h>; | ||
76 | void | 77 | void |
77 | VCardEntity::_parse() | 78 | VCardEntity::_parse() |
78 | { | 79 | { |
80 | #if 0 | ||
81 | QTime tim; | ||
82 | tim.start(); | ||
83 | int num = 0; | ||
84 | // old code | ||
79 | vDebug("parse"); | 85 | vDebug("parse"); |
80 | QCString s(strRep_); | 86 | QCString s(strRep_); |
81 | 87 | ||
82 | int i = s.find(QRegExp("BEGIN:VCARD", false)); | 88 | int i = s.find(QRegExp("BEGIN:VCARD", false)); |
83 | 89 | ||
84 | while (i != -1) { | 90 | while (i != -1) { |
85 | 91 | ||
86 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); | 92 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); |
87 | 93 | ||
88 | QCString cardStr(s.left(i)); | 94 | QCString cardStr(s.left(i)); |
89 | 95 | ||
90 | VCard * v = new VCard(cardStr); | 96 | VCard * v = new VCard(cardStr); |
91 | 97 | ||
92 | cardList_.append(v); | 98 | cardList_.append(v); |
93 | 99 | ||
94 | v->parse(); | 100 | v->parse(); |
95 | 101 | ||
96 | s.remove(0, i); | 102 | s.remove(0, i); |
97 | } | 103 | } |
104 | |||
105 | #else | ||
106 | // this code is up to 17 (!) times faster | ||
107 | int start = 0; | ||
108 | QTime tim; | ||
109 | tim.start(); | ||
110 | int i = 11; | ||
111 | int len = strRep_.length(); | ||
112 | int num = 0; | ||
113 | while (i < len ) { | ||
114 | while( i < len ) { | ||
115 | int add = 1; | ||
116 | if ( strRep_.at(i) == 'B' ) { | ||
117 | if ( i+add < len && strRep_.at(i+add++) == 'E') | ||
118 | if ( i+add < len && strRep_.at(i+add++) == 'G') | ||
119 | if ( i+add < len && strRep_.at(i+add++) == 'I') | ||
120 | if ( i+add < len && strRep_.at(i+add++) == 'N') | ||
121 | if ( i+add < len && strRep_.at(i+add++) == ':') | ||
122 | if ( i+add < len && strRep_.at(i+add++) == 'V') | ||
123 | if ( i+add < len && strRep_.at(i+add++) == 'C') | ||
124 | if ( i+add < len && strRep_.at(i+add++) == 'A') | ||
125 | if ( i+add < len && strRep_.at(i+add++) == 'R') | ||
126 | if ( i+add < len && strRep_.at(i+add++) == 'D') | ||
127 | break; | ||
128 | } | ||
129 | ++i; | ||
130 | } | ||
131 | if ( i <= len ) { | ||
132 | ++num; | ||
133 | char* dat = strRep_.data()+start; | ||
134 | VCard * v = new VCard( QCString ( dat,i-start ) ); | ||
135 | start = i; | ||
136 | cardList_.append(v); | ||
137 | v->parse(); | ||
138 | } | ||
139 | i+= 11; | ||
140 | } | ||
141 | #endif | ||
142 | //qDebug("***time %d found %d", tim.elapsed(), num); | ||
98 | } | 143 | } |
99 | 144 | ||
100 | void | 145 | void |
101 | VCardEntity::_assemble() | 146 | VCardEntity::_assemble() |
102 | { | 147 | { |
103 | VCardListIterator it(cardList_); | 148 | VCardListIterator it(cardList_); |
104 | 149 | ||
105 | for (; it.current(); ++it) | 150 | for (; it.current(); ++it) |
106 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. | 151 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. |
107 | } | 152 | } |
108 | 153 | ||
109 | VCardList & | 154 | VCardList & |
110 | VCardEntity::cardList() | 155 | VCardEntity::cardList() |
111 | { | 156 | { |
112 | parse(); | 157 | parse(); |
113 | return cardList_; | 158 | return cardList_; |
114 | } | 159 | } |
115 | 160 | ||
116 | void | 161 | void |
117 | VCardEntity::setCardList(const VCardList & l) | 162 | VCardEntity::setCardList(const VCardList & l) |
118 | { | 163 | { |
119 | parse(); | 164 | parse(); |
120 | //UScardList_ = l; | 165 | //UScardList_ = l; |
121 | VCardListIterator it(l); | 166 | VCardListIterator it(l); |
122 | 167 | ||
123 | for (; it.current(); ++it) { | 168 | for (; it.current(); ++it) { |
124 | VCard* v = new VCard(*it.current()); | 169 | VCard* v = new VCard(*it.current()); |
125 | cardList_.append(v); | 170 | cardList_.append(v); |
126 | } | 171 | } |
127 | 172 | ||
128 | } | 173 | } |
129 | 174 | ||