summaryrefslogtreecommitdiffabout
path: root/kabc
Side-by-side diff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp38
-rw-r--r--kabc/addresseeview.h4
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 @@
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <kabc/address.h>
#include <kabc/addressee.h>
#include <kabc/phonenumber.h>
#include <kglobal.h>
//US#include <kglobalsettings.h>
#include <kiconloader.h>
#include <klocale.h>
//US #include <kstringhandler.h>
#include <qscrollview.h>
#include <qregexp.h>
#include <qfile.h>
#include <qvbox.h>
#include <qlabel.h>
#include <qwidget.h>
#include <qlayout.h>
#include <qapplication.h>
#include <qpushbutton.h>
+#ifdef DESKTOP_VERSION
+#include <qpaintdevicemetrics.h>
+#include <qprinter.h>
+#include <qpainter.h>
+#endif
#include "externalapphandler.h"
-#include "addresseeview.h"
+#include <kabc/addresseeview.h>
//US #ifndef DESKTOP_VERSION
//US #include <qtopia/qcopenvelope_qws.h>
//US #include <qpe/qpeapplication.h>
//US #endif
//US static int kphoneInstalled = 0;
-using namespace KPIM;
+using namespace KABC;
AddresseeView::AddresseeView( QWidget *parent, const char *name )
-//US : KTextBrowser( parent, name )
: QTextBrowser( parent, name )
{
//US setWrapPolicy( QTextEdit::AtWordBoundary );
setLinkUnderline( false );
// setVScrollBarMode( QScrollView::AlwaysOff );
//setHScrollBarMode( QScrollView::AlwaysOff );
//US QStyleSheet *sheet = styleSheet();
//US QStyleSheetItem *link = sheet->item( "a" );
//US link->setColor( KGlobalSettings::linkColor() );
}
-
+void AddresseeView::printMe()
+{
+#ifdef DESKTOP_VERSION
+ QPrinter printer;
+ if (!printer.setup() )
+ return;
+ QPainter p;
+ p.begin ( &printer );
+ QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
+ float dx, dy;
+ int wid = (m.width() * 9)/10;
+ dx = (float) wid/(float)contentsWidth ();
+ dy = (float)(m.height()) / (float)contentsHeight ();
+ float scale;
+ // scale to fit the width or height of the paper
+ if ( dx < dy )
+ scale = dx;
+ else
+ scale = dy;
+ p.translate( m.width()/10,0 );
+ p.scale( scale, scale );
+ drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
+ p.end();
+#endif
+}
void AddresseeView::setSource(const QString& n)
{
//qDebug("********AddresseeView::setSource %s", n.latin1());
if ( n.left( 6 ) == "mailto" )
ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
else if ( n.left( 7 ) == "phoneto" )
ExternalAppHandler::instance()->callByPhone( n.mid(8) );
else if ( n.left( 5 ) == "faxto" )
ExternalAppHandler::instance()->callByFax( n.mid(6) );
else if ( n.left( 5 ) == "smsto" )
ExternalAppHandler::instance()->callBySMS( n.mid(6) );
else if ( n.left( 7 ) == "pagerto" )
ExternalAppHandler::instance()->callByPager( n.mid(8) );
else if ( n.left( 5 ) == "sipto" )
ExternalAppHandler::instance()->callBySIP( n.mid(6) );
}
void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
{
bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable();
// mAddressee = addr;
// clear view
//setText( QString::null );
@@ -190,49 +218,49 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
}
}
QString notes;
if ( !mAddressee.note().isEmpty() ) {
notes = QString(
"<tr>"
"<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
"<td align=\"left\">%2</td>" // note
"</tr>" ).arg( i18n( "Notes" ) )
//US .arg( mAddressee.note().replace( '\n', "<br>" ) );
.arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
//qDebug("AddresseeView::setAddressee has to be verified.");
}
QString aRole = "";
QString aOrga = "";
if ( true /*!mAddressee.role().isEmpty()*/ ) {
aRole = "<tr>"
"<td align=\"left\">" + mAddressee.role() + "</td>"
"</tr>";
}
if ( true /*!mAddressee.organization().isEmpty()*/ ) {
aOrga = "<tr>"
- "<td align=\"left\">" + mAddressee.organization() + "</td>" ;
+ "<td align=\"left\">" + mAddressee.organization() + "</td>"
"</tr>";
}
mText = "";
QString picString = "";
KABC::Picture picture = mAddressee.photo();
bool picAvailintern = false;
bool picAvailUrl = false;
if (! picture.undefined() ) {
picAvailintern = (picture.isIntern() && !picture.data().isNull());
picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
}
if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
if ( picAvailintern ) {
QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
} else {
if ( picAvailUrl ) {
QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
} else {
QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) );
}
}
picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
mText = QString::fromLatin1(
"<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 @@
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef KPIM_ADDRESSEEVIEW_H
#define KPIM_ADDRESSEEVIEW_H
#include <kabc/addressee.h>
#include <kdialogbase.h>
//US #include <ktextbrowser.h>
#include <qtextbrowser.h>
-namespace KPIM {
+namespace KABC {
//US class AddresseeView : public KTextBrowser
class AddresseeView : public QTextBrowser
{
+
public:
AddresseeView( QWidget *parent = 0, const char *name = 0 );
/**
Sets the addressee object. The addressee is displayed immediately.
@param addr The addressee object.
*/
void setAddressee( const KABC::Addressee& addr );
void setSource(const QString& n);
/**
Returns the current addressee object.
*/
//KABC::Addressee addressee() const;
+ void printMe();
private:
//KABC::Addressee mAddressee;
QString mText;
QString getPhoneNumbers( KABC::PhoneNumber::List phones, bool preferred );
void addTag(const QString & tag,const QString & text);
//class AddresseeViewPrivate;
//AddresseeViewPrivate *d;
};
class AddresseeChooser : public KDialogBase
{
Q_OBJECT
public:
AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent = 0, const char *name = 0 );
int executeD( bool local );
private:
int mSyncResult;
private slots:
void slot_remote();
void slot_local();