author | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
commit | 507b362d42d5eed6277ad17422b6ba61acca636e (patch) (unidiff) | |
tree | d3d29451d37649b102c3e171e2927437925f8ce8 /kabc | |
parent | a704468d5fd02d30cf962c8b2d6815c7e9208e5d (diff) | |
download | kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.zip kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.gz kdepimpi-507b362d42d5eed6277ad17422b6ba61acca636e.tar.bz2 |
print AB
-rw-r--r-- | kabc/addresseeview.cpp | 38 | ||||
-rw-r--r-- | kabc/addresseeview.h | 4 |
2 files changed, 36 insertions, 6 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 7a4336b..e85991e 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -15,80 +15,108 @@ | |||
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 | ||
40 | #include <qpaintdevicemetrics.h> | ||
41 | #include <qprinter.h> | ||
42 | #include <qpainter.h> | ||
43 | #endif | ||
39 | 44 | ||
40 | 45 | ||
41 | #include "externalapphandler.h" | 46 | #include "externalapphandler.h" |
42 | #include "addresseeview.h" | 47 | #include <kabc/addresseeview.h> |
43 | 48 | ||
44 | 49 | ||
45 | //US #ifndef DESKTOP_VERSION | 50 | //US #ifndef DESKTOP_VERSION |
46 | //US #include <qtopia/qcopenvelope_qws.h> | 51 | //US #include <qtopia/qcopenvelope_qws.h> |
47 | //US #include <qpe/qpeapplication.h> | 52 | //US #include <qpe/qpeapplication.h> |
48 | //US #endif | 53 | //US #endif |
49 | 54 | ||
50 | //US static int kphoneInstalled = 0; | 55 | //US static int kphoneInstalled = 0; |
51 | 56 | ||
52 | using namespace KPIM; | 57 | using namespace KABC; |
53 | 58 | ||
54 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) | 59 | AddresseeView::AddresseeView( QWidget *parent, const char *name ) |
55 | //US : KTextBrowser( parent, name ) | ||
56 | : QTextBrowser( parent, name ) | 60 | : QTextBrowser( parent, name ) |
57 | 61 | ||
58 | 62 | ||
59 | { | 63 | { |
60 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); | 64 | //US setWrapPolicy( QTextEdit::AtWordBoundary ); |
61 | setLinkUnderline( false ); | 65 | setLinkUnderline( false ); |
62 | // setVScrollBarMode( QScrollView::AlwaysOff ); | 66 | // setVScrollBarMode( QScrollView::AlwaysOff ); |
63 | //setHScrollBarMode( QScrollView::AlwaysOff ); | 67 | //setHScrollBarMode( QScrollView::AlwaysOff ); |
64 | 68 | ||
65 | //US QStyleSheet *sheet = styleSheet(); | 69 | //US QStyleSheet *sheet = styleSheet(); |
66 | //US QStyleSheetItem *link = sheet->item( "a" ); | 70 | //US QStyleSheetItem *link = sheet->item( "a" ); |
67 | //US link->setColor( KGlobalSettings::linkColor() ); | 71 | //US link->setColor( KGlobalSettings::linkColor() ); |
68 | 72 | ||
69 | } | 73 | } |
70 | 74 | void AddresseeView::printMe() | |
75 | { | ||
76 | #ifdef DESKTOP_VERSION | ||
77 | QPrinter printer; | ||
78 | if (!printer.setup() ) | ||
79 | return; | ||
80 | QPainter p; | ||
81 | p.begin ( &printer ); | ||
82 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | ||
83 | float dx, dy; | ||
84 | int wid = (m.width() * 9)/10; | ||
85 | dx = (float) wid/(float)contentsWidth (); | ||
86 | dy = (float)(m.height()) / (float)contentsHeight (); | ||
87 | float scale; | ||
88 | // scale to fit the width or height of the paper | ||
89 | if ( dx < dy ) | ||
90 | scale = dx; | ||
91 | else | ||
92 | scale = dy; | ||
93 | p.translate( m.width()/10,0 ); | ||
94 | p.scale( scale, scale ); | ||
95 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | ||
96 | p.end(); | ||
97 | #endif | ||
98 | } | ||
71 | void AddresseeView::setSource(const QString& n) | 99 | void AddresseeView::setSource(const QString& n) |
72 | { | 100 | { |
73 | //qDebug("********AddresseeView::setSource %s", n.latin1()); | 101 | //qDebug("********AddresseeView::setSource %s", n.latin1()); |
74 | 102 | ||
75 | if ( n.left( 6 ) == "mailto" ) | 103 | if ( n.left( 6 ) == "mailto" ) |
76 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 104 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
77 | else if ( n.left( 7 ) == "phoneto" ) | 105 | else if ( n.left( 7 ) == "phoneto" ) |
78 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); | 106 | ExternalAppHandler::instance()->callByPhone( n.mid(8) ); |
79 | else if ( n.left( 5 ) == "faxto" ) | 107 | else if ( n.left( 5 ) == "faxto" ) |
80 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); | 108 | ExternalAppHandler::instance()->callByFax( n.mid(6) ); |
81 | else if ( n.left( 5 ) == "smsto" ) | 109 | else if ( n.left( 5 ) == "smsto" ) |
82 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); | 110 | ExternalAppHandler::instance()->callBySMS( n.mid(6) ); |
83 | else if ( n.left( 7 ) == "pagerto" ) | 111 | else if ( n.left( 7 ) == "pagerto" ) |
84 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); | 112 | ExternalAppHandler::instance()->callByPager( n.mid(8) ); |
85 | else if ( n.left( 5 ) == "sipto" ) | 113 | else if ( n.left( 5 ) == "sipto" ) |
86 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); | 114 | ExternalAppHandler::instance()->callBySIP( n.mid(6) ); |
87 | 115 | ||
88 | } | 116 | } |
89 | void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | 117 | void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) |
90 | { | 118 | { |
91 | bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); | 119 | bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); |
92 | // mAddressee = addr; | 120 | // mAddressee = addr; |
93 | // clear view | 121 | // clear view |
94 | //setText( QString::null ); | 122 | //setText( QString::null ); |
@@ -190,49 +218,49 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | |||
190 | } | 218 | } |
191 | } | 219 | } |
192 | 220 | ||
193 | QString notes; | 221 | QString notes; |
194 | if ( !mAddressee.note().isEmpty() ) { | 222 | if ( !mAddressee.note().isEmpty() ) { |
195 | notes = QString( | 223 | notes = QString( |
196 | "<tr>" | 224 | "<tr>" |
197 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | 225 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label |
198 | "<td align=\"left\">%2</td>" // note | 226 | "<td align=\"left\">%2</td>" // note |
199 | "</tr>" ).arg( i18n( "Notes" ) ) | 227 | "</tr>" ).arg( i18n( "Notes" ) ) |
200 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | 228 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); |
201 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | 229 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); |
202 | //qDebug("AddresseeView::setAddressee has to be verified."); | 230 | //qDebug("AddresseeView::setAddressee has to be verified."); |
203 | } | 231 | } |
204 | 232 | ||
205 | QString aRole = ""; | 233 | QString aRole = ""; |
206 | QString aOrga = ""; | 234 | QString aOrga = ""; |
207 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 235 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
208 | aRole = "<tr>" | 236 | aRole = "<tr>" |
209 | "<td align=\"left\">" + mAddressee.role() + "</td>" | 237 | "<td align=\"left\">" + mAddressee.role() + "</td>" |
210 | "</tr>"; | 238 | "</tr>"; |
211 | } | 239 | } |
212 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { | 240 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { |
213 | aOrga = "<tr>" | 241 | aOrga = "<tr>" |
214 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; | 242 | "<td align=\"left\">" + mAddressee.organization() + "</td>" |
215 | "</tr>"; | 243 | "</tr>"; |
216 | } | 244 | } |
217 | mText = ""; | 245 | mText = ""; |
218 | QString picString = ""; | 246 | QString picString = ""; |
219 | KABC::Picture picture = mAddressee.photo(); | 247 | KABC::Picture picture = mAddressee.photo(); |
220 | bool picAvailintern = false; | 248 | bool picAvailintern = false; |
221 | bool picAvailUrl = false; | 249 | bool picAvailUrl = false; |
222 | if (! picture.undefined() ) { | 250 | if (! picture.undefined() ) { |
223 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); | 251 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); |
224 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); | 252 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); |
225 | } | 253 | } |
226 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 254 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
227 | if ( picAvailintern ) { | 255 | if ( picAvailintern ) { |
228 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 256 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
229 | } else { | 257 | } else { |
230 | if ( picAvailUrl ) { | 258 | if ( picAvailUrl ) { |
231 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); | 259 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); |
232 | } else { | 260 | } else { |
233 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); | 261 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); |
234 | } | 262 | } |
235 | } | 263 | } |
236 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 264 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
237 | mText = QString::fromLatin1( | 265 | mText = QString::fromLatin1( |
238 | "<html>" | 266 | "<html>" |
diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index 3800512..e977d8f 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h | |||
@@ -7,67 +7,69 @@ | |||
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 KABC { |
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 | |||
36 | public: | 37 | public: |
37 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); | 38 | AddresseeView( QWidget *parent = 0, const char *name = 0 ); |
38 | 39 | ||
39 | /** | 40 | /** |
40 | Sets the addressee object. The addressee is displayed immediately. | 41 | Sets the addressee object. The addressee is displayed immediately. |
41 | 42 | ||
42 | @param addr The addressee object. | 43 | @param addr The addressee object. |
43 | */ | 44 | */ |
44 | void setAddressee( const KABC::Addressee& addr ); | 45 | void setAddressee( const KABC::Addressee& addr ); |
45 | void setSource(const QString& n); | 46 | void setSource(const QString& n); |
46 | /** | 47 | /** |
47 | Returns the current addressee object. | 48 | Returns the current addressee object. |
48 | */ | 49 | */ |
49 | //KABC::Addressee addressee() const; | 50 | //KABC::Addressee addressee() const; |
51 | void printMe(); | ||
50 | 52 | ||
51 | private: | 53 | private: |
52 | //KABC::Addressee mAddressee; | 54 | //KABC::Addressee mAddressee; |
53 | QString mText; | 55 | QString mText; |
54 | QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); | 56 | QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred ); |
55 | void addTag(const QString & tag,const QString & text); | 57 | void addTag(const QString & tag,const QString & text); |
56 | //class AddresseeViewPrivate; | 58 | //class AddresseeViewPrivate; |
57 | //AddresseeViewPrivate *d; | 59 | //AddresseeViewPrivate *d; |
58 | }; | 60 | }; |
59 | class AddresseeChooser : public KDialogBase | 61 | class AddresseeChooser : public KDialogBase |
60 | { | 62 | { |
61 | Q_OBJECT | 63 | Q_OBJECT |
62 | 64 | ||
63 | public: | 65 | public: |
64 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); | 66 | AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 ); |
65 | 67 | ||
66 | int executeD( bool local ); | 68 | int executeD( bool local ); |
67 | 69 | ||
68 | private: | 70 | private: |
69 | int mSyncResult; | 71 | int mSyncResult; |
70 | 72 | ||
71 | private slots: | 73 | private slots: |
72 | void slot_remote(); | 74 | void slot_remote(); |
73 | void slot_local(); | 75 | void slot_local(); |