-rw-r--r-- | kaddressbook/details/detailsviewcontainer.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/details/detailsviewcontainer.h | 1 | ||||
-rw-r--r-- | kaddressbook/details/look_basic.h | 2 | ||||
-rw-r--r-- | kaddressbook/details/look_html.cpp | 10 | ||||
-rw-r--r-- | kaddressbook/details/look_html.h | 6 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 19 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 1 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 9 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 3 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 27 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 29 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/xxportmanager.cpp | 2 |
17 files changed, 105 insertions, 16 deletions
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp index 229cce0..cee5886 100644 --- a/kaddressbook/details/detailsviewcontainer.cpp +++ b/kaddressbook/details/detailsviewcontainer.cpp @@ -75,12 +75,16 @@ ViewContainer::ViewContainer( QWidget *parent, const char* name ) label->hide(); mStyleCombo->hide(); frameRuler->hide(); #endif } +void ViewContainer::printView() +{ + mCurrentLook->printView(); +} KABBasicLook *ViewContainer::currentLook() { return mCurrentLook; } void ViewContainer::registerLooks() diff --git a/kaddressbook/details/detailsviewcontainer.h b/kaddressbook/details/detailsviewcontainer.h index 667f0cb..9684736 100644 --- a/kaddressbook/details/detailsviewcontainer.h +++ b/kaddressbook/details/detailsviewcontainer.h @@ -48,12 +48,13 @@ class ViewContainer : public QWidget /** Return the contact currently displayed. */ KABC::Addressee addressee(); public slots: + void printView(); /** Set the contact currently displayed. */ void setAddressee( const KABC::Addressee& addressee ); /** diff --git a/kaddressbook/details/look_basic.h b/kaddressbook/details/look_basic.h index 7e8baff..a65c99c 100644 --- a/kaddressbook/details/look_basic.h +++ b/kaddressbook/details/look_basic.h @@ -72,14 +72,16 @@ class KABBasicLook : public QVBox virtual void saveSettings( KConfig* ); /** Retrieve read-write state. */ bool isReadOnly() const; + void printView(){ emit printMyView();} signals: + void printMyView(); /** This signal is emitted when the user changed the entry. */ void entryChanged(); /** diff --git a/kaddressbook/details/look_html.cpp b/kaddressbook/details/look_html.cpp index 64987b8..bb30650 100644 --- a/kaddressbook/details/look_html.cpp +++ b/kaddressbook/details/look_html.cpp @@ -23,22 +23,30 @@ #include <addresseeview.h> #include "look_html.h" #include <qscrollview.h> #include "kabprefs.h" +#include <kabc/addresseeview.h> KABHtmlView::KABHtmlView( QWidget *parent, const char *name ) : KABBasicLook( parent, name ) { - mView = new KPIM::AddresseeView( this ); + mView = new KABC::AddresseeView( this ); mView->setFont( KABPrefs::instance()->mDetailsFont ); + connect(this, SIGNAL(printMyView()), + this , SLOT(printMe())); } KABHtmlView::~KABHtmlView() { } +void KABHtmlView::printMe() +{ + mView->printMe(); + +} void KABHtmlView::setAddressee( const KABC::Addressee &addr ) { mView->setFont( KABPrefs::instance()->mDetailsFont ); mView->setAddressee( addr ); } diff --git a/kaddressbook/details/look_html.h b/kaddressbook/details/look_html.h index 68a02d9..57eb56f 100644 --- a/kaddressbook/details/look_html.h +++ b/kaddressbook/details/look_html.h @@ -26,13 +26,13 @@ #include <klocale.h> #include "look_basic.h" namespace KABC { class Addressee; } -namespace KPIM { class AddresseeView; } +namespace KABC { class AddresseeView; } class KABHtmlView : public KABBasicLook { Q_OBJECT public: @@ -47,15 +47,17 @@ class KABHtmlView : public KABBasicLook virtual ~KABHtmlView(); /** Set the addressee. */ void setAddressee( const KABC::Addressee& ); + public slots: + void printMe(); private: - KPIM::AddresseeView *mView; + KABC::AddresseeView *mView; }; class KABHtmlViewFactory : public KABLookFactory { public: KABHtmlViewFactory( QWidget *parent = 0, const char *name = 0 ) diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 4098dda..e61f65f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1874,25 +1874,22 @@ void KABCore::initActions() #ifndef KAB_EMBEDDED connect( QApplication::clipboard(), SIGNAL( dataChanged() ), SLOT( clipboardDataChanged() ) ); #endif //KAB_EMBEDDED // file menu - if ( mIsPart ) { - mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, - SLOT( sendMail() ), actionCollection(), - "kaddressbook_mail" ); - mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, - SLOT( print() ), actionCollection(), "kaddressbook_print" ); - } else { mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); - mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); - } + //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); + mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, + SLOT( printView() ), actionCollection(), "kaddressbook_print" ); + mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, + SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); + mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, SLOT( save() ), actionCollection(), "file_sync" ); mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, SLOT( newContact() ), actionCollection(), "file_new_contact" ); @@ -2136,12 +2133,14 @@ void KABCore::addActionsManually() //US Now connect the actions with the menue entries. #ifdef DESKTOP_VERSION mActionPrint->plug( fileMenu ); + mActionPrintDetails->plug( fileMenu ); + fileMenu->insertSeparator(); #endif mActionMail->plug( fileMenu ); fileMenu->insertSeparator(); mActionNewContact->plug( fileMenu ); mActionNewContact->plug( tb ); @@ -2765,13 +2764,13 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i return 1; if ( lastSync > localMod ) return 2; localIsNew = localMod >= remoteMod; //qDebug("conflict! ************************************** "); { - KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); + KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); result = acd.executeD(localIsNew); return result; } break; case SYNC_PREF_FORCE_LOCAL: return 1; diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 0d5891e..ecfe6e9 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -427,12 +427,13 @@ class KABCore : public QWidget, public KSyncInterface //US file menu KAction *mActionMail; KAction *mActionBeam; KToggleAction *mActionBR; KAction *mActionExport2phone; KAction* mActionPrint; + KAction* mActionPrintDetails; KAction* mActionNewContact; KAction *mActionSave; KAction *mActionEditAddressee; KAction *mActionMailVCard; KAction *mActionBeamVCard; diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 8646136..8f31910 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h @@ -35,12 +35,18 @@ class QDropEvent; #include <kabc/field.h> #include <qwidget.h> #include "viewconfigurewidget.h" #include "filter.h" +#ifdef DESKTOP_VERSION +#include <qpaintdevicemetrics.h> +#include <qprinter.h> +#include <qpainter.h> +#endif + namespace KABC { class AddressBook; } /** Base class for all views in kaddressbook. This class implements all the common methods needed to provide a view to the user. @@ -147,12 +153,13 @@ class KAddressBookView : public QWidget const QString &defaultFilterName() const; /** @return The address book. */ KABC::AddressBook *addressBook() const; + void printMyView() { emit printView() ;} public slots: /** Must be overloaded in subclasses to refresh the view. Refreshing includes updating the view to ensure that only items in the document are visible. If <i>uid</i> is valid, only the @@ -173,12 +180,14 @@ class KAddressBookView : public QWidget #else //KAB_EMBEDDED //US my moc can not handle the default parameters. Is this a problem ??? virtual void setSelected( QString uid, bool selected) = 0; #endif //KAB_EMBEDDED signals: + + void printView(); /** This signal should be emitted by a subclass whenever an addressee is modified. */ void modified(); diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index 8bf9bb0..3ad2f74 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp @@ -154,13 +154,13 @@ KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char * groupBox->layout()->setMargin(1) ; groupBox->layout()->setSpacing(0); mExtensionView = new KListView( groupBox ); mExtensionView->setAllColumnsShowFocus( true ); mExtensionView->addColumn( i18n( "Name" ) ); mExtensionView->addColumn( i18n( "Description" ) ); - mExtensionView->setMaximumHeight(80); + //mExtensionView->setMaximumHeight(80); boxLayout->addWidget( mExtensionView ); mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); mConfigureButton->setEnabled( false ); boxLayout->addWidget( mConfigureButton ); diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 771bec9..1e03dba 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -73,14 +73,15 @@ int main( int argc, char **argv ) #endif KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook"))); // init language KPimGlobalPrefs::instance()->setGlobalConfig(); KAddressBookMain m ; //US MainWindow m; +#ifndef DESKTOP_VERSION QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); - +#endif #ifndef DESKTOP_VERSION a.showMainWidget( &m ); #else diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 272e1b0..dff9998 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h @@ -66,12 +66,13 @@ class ViewManager : public QWidget QStringList selectedEmails() const; KABC::Addressee::List selectedAddressees() const; void setListSelected(QStringList); void setFocusAV(); public slots: + void printView() { if (mActiveView) mActiveView->printMyView() ;} void scrollUP(); void scrollDOWN(); //US void setSelected( const QString &uid = QString::null, bool selected = true ); void setSelected( const QString &uid, bool); //US added another method with no parameter, since my moc compiler does not support default parameters. diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp index 23b091c..e75810e 100644 --- a/kaddressbook/views/contactlistview.cpp +++ b/kaddressbook/views/contactlistview.cpp @@ -274,12 +274,39 @@ ContactListView::ContactListView(KAddressBookTableView *view, this, SLOT(itemDropped(QDropEvent*))); #endif //KAB_EMBEDDED new DynamicTip( this ); } +void ContactListView::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 ); + qDebug("scale %f ", scale); + drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); + p.end(); + qDebug("Why does it not print??? "); +#endif +} void ContactListView::setAlternateColor(const QColor &m_AlternateColor) { mAlternateColor = m_AlternateColor; } diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h index fad7f38..9d1a672 100644 --- a/kaddressbook/views/contactlistview.h +++ b/kaddressbook/views/contactlistview.h @@ -102,12 +102,13 @@ protected: virtual bool acceptDrag(QDropEvent *e) const; protected slots: void itemDropped(QDropEvent *e); public slots: + void printMe(); signals: void startAddresseeDrag(); void addresseeDropped(QDropEvent *); private: diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 2d7ed08..107be59 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -35,12 +35,13 @@ #include <kdebug.h> #include <klocale.h> #include "kabprefs.h" #include "viewmanager.h" + #include "kaddressbookcardview.h" #ifndef KAB_EMBEDDED extern "C" { void *init_libkaddrbk_cardview() { @@ -113,12 +114,38 @@ AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) setAcceptDrops(true); } AddresseeCardView::~AddresseeCardView() { } +void AddresseeCardView::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(); + repaint(); +#endif +} void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) { #ifndef KAB_EMBEDDED if (QTextDrag::canDecode(e)) @@ -161,12 +188,14 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, connect(mCardView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); connect(mCardView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); + connect(this, SIGNAL(printView()), + mCardView , SLOT(printMe())); } KAddressBookCardView::~KAddressBookCardView() { } void KAddressBookCardView::setFocusAV() diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index 8f22d54..2a71f7e 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h @@ -82,12 +82,14 @@ class KAddressBookCardView : public KAddressBookView class AddresseeCardView : public CardView { Q_OBJECT public: AddresseeCardView(QWidget *parent, const char *name = 0); ~AddresseeCardView(); +public slots: + void printMe(); signals: void startAddresseeDrag(); void addresseeDropped(QDropEvent *); protected: diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 61703ee..ecd6f05 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -86,12 +86,14 @@ void KAddressBookTableView::reconstructListView() SIGNAL(dropped(QDropEvent*))); delete mListView; } mListView = new ContactListView( this, addressBook(), viewWidget() ); + connect(this, SIGNAL(printView()), + mListView , SLOT(printMe())); //US set singleClick manually, because it is no global configparameter in embedded space mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick); // Add the columns KABC::Field::List fieldList = fields(); KABC::Field::List::ConstIterator it; diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 8d40ffe..89a2626 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp @@ -225,13 +225,13 @@ PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, : KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent, name, true, true ) { QWidget *page = plainPage(); QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() ); - KPIM::AddresseeView *view = new KPIM::AddresseeView( page ); + KABC::AddresseeView *view = new KABC::AddresseeView( page ); view->setAddressee( addr ); layout->addWidget( view ); resize( 400, 300 ); } |