author | zautrix <zautrix> | 2005-06-26 12:08:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-26 12:08:10 (UTC) |
commit | d45f07d85ab62205e07089f6e2f41b0d112ca757 (patch) (unidiff) | |
tree | 7497c33233867bcd9d461da44deedca839f61298 | |
parent | 9dc21277b3e6080e8bec244ad4e9ec5a0bf90af2 (diff) | |
download | kdepimpi-d45f07d85ab62205e07089f6e2f41b0d112ca757.zip kdepimpi-d45f07d85ab62205e07089f6e2f41b0d112ca757.tar.gz kdepimpi-d45f07d85ab62205e07089f6e2f41b0d112ca757.tar.bz2 |
dr
-rw-r--r-- | kabc/addresseeview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 7c70ab1..2691d9a 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -8,193 +8,193 @@ | |||
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 | #ifdef DESKTOP_VERSION | 39 | #ifdef DESKTOP_VERSION |
40 | #include <qpaintdevicemetrics.h> | 40 | #include <qpaintdevicemetrics.h> |
41 | #include <qprinter.h> | 41 | #include <qprinter.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | 45 | ||
46 | #include <qstylesheet.h> | 46 | #include <qstylesheet.h> |
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 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | bool AddresseeView::sFullDetailsMode = false; | 59 | bool AddresseeView::sFullDetailsMode = false; |
60 | 60 | ||
61 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 61 | AddresseeView::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 | } |
77 | void AddresseeView::printMe() | 77 | void 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 | } |
102 | void AddresseeView::setSource(const QString& n) | 102 | void 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 | } |
126 | void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | 126 | void 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 | ||
144 | QString dynamicPart; | 144 | QString dynamicPart; |
145 | 145 | ||
146 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); | 146 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); |
147 | QStringList emails = mAddressee.emails(); | 147 | QStringList emails = mAddressee.emails(); |
148 | QStringList::ConstIterator emailIt; | 148 | QStringList::ConstIterator emailIt; |
149 | QString type = i18n( "Email" ); | 149 | QString type = i18n( "Email" ); |
150 | emailIt = emails.begin(); | 150 | emailIt = emails.begin(); |
151 | if ( emailIt != emails.end() ) { | 151 | if ( emailIt != emails.end() ) { |
152 | if ( kemailAvail ) { | 152 | if ( kemailAvail ) { |
153 | dynamicPart += QString( | 153 | dynamicPart += QString( |
154 | "<tr><td align=\"right\"><b>%1</b></td>" | 154 | "<tr><td align=\"right\"><b>%1</b></td>" |
155 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 155 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
156 | .arg( type ) | 156 | .arg( type ) |
157 | .arg( name ) | 157 | .arg( name ) |
158 | .arg( *emailIt ) | 158 | .arg( *emailIt ) |
159 | .arg( *emailIt ); | 159 | .arg( *emailIt ); |
160 | ++emailIt; | 160 | ++emailIt; |
161 | } else { | 161 | } else { |
162 | dynamicPart += QString( | 162 | dynamicPart += QString( |
163 | "<tr><td align=\"right\"><b>%1</b></td>" | 163 | "<tr><td align=\"right\"><b>%1</b></td>" |
164 | "<td align=\"left\">%2</td></tr>" ) | 164 | "<td align=\"left\">%2</td></tr>" ) |
165 | .arg( type ) | 165 | .arg( type ) |
166 | .arg( *emailIt ); | 166 | .arg( *emailIt ); |
167 | ++emailIt; | 167 | ++emailIt; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | if ( mAddressee.birthday().date().isValid() ) { | 170 | if ( mAddressee.birthday().date().isValid() ) { |
171 | dynamicPart += QString( | 171 | dynamicPart += QString( |
172 | "<tr><td align=\"right\"><b>%1</b></td>" | 172 | "<tr><td align=\"right\"><b>%1</b></td>" |
173 | "<td align=\"left\">%2</td></tr>" ) | 173 | "<td align=\"left\">%2</td></tr>" ) |
174 | .arg( i18n ("Birthday") ) | 174 | .arg( i18n ("Birthday") ) |
175 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); | 175 | .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); |
176 | } | 176 | } |
177 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); | 177 | dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); |
178 | 178 | ||
179 | for ( ; emailIt != emails.end(); ++emailIt ) { | 179 | for ( ; emailIt != emails.end(); ++emailIt ) { |
180 | if ( kemailAvail ) { | 180 | if ( kemailAvail ) { |
181 | dynamicPart += QString( | 181 | dynamicPart += QString( |
182 | "<tr><td align=\"right\"><b>%1</b></td>" | 182 | "<tr><td align=\"right\"><b>%1</b></td>" |
183 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) | 183 | "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) |
184 | .arg( type ) | 184 | .arg( type ) |
185 | .arg( name ) | 185 | .arg( name ) |
186 | .arg( *emailIt ) | 186 | .arg( *emailIt ) |
187 | .arg( *emailIt ); | 187 | .arg( *emailIt ); |
188 | } else { | 188 | } else { |
189 | dynamicPart += QString( | 189 | dynamicPart += QString( |
190 | "<tr><td align=\"right\"><b>%1</b></td>" | 190 | "<tr><td align=\"right\"><b>%1</b></td>" |
191 | "<td align=\"left\">%2</td></tr>" ) | 191 | "<td align=\"left\">%2</td></tr>" ) |
192 | .arg( type ) | 192 | .arg( type ) |
193 | .arg( *emailIt ); | 193 | .arg( *emailIt ); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | 198 | ||
199 | KABC::Address::List addresses = mAddressee.addresses(); | 199 | KABC::Address::List addresses = mAddressee.addresses(); |
200 | KABC::Address::List::ConstIterator addrIt; | 200 | KABC::Address::List::ConstIterator addrIt; |