author | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-16 22:19:12 (UTC) |
commit | 507b362d42d5eed6277ad17422b6ba61acca636e (patch) (side-by-side diff) | |
tree | d3d29451d37649b102c3e171e2927437925f8ce8 | |
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 | ||||
-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 | 8 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 21 | ||||
-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 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 2 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 42 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.h | 5 |
22 files changed, 176 insertions, 40 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 7a4336b..e85991e 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp @@ -27,56 +27,84 @@ #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) ); @@ -202,25 +230,25 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) //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 ) { diff --git a/kabc/addresseeview.h b/kabc/addresseeview.h index 3800512..e977d8f 100644 --- a/kabc/addresseeview.h +++ b/kabc/addresseeview.h @@ -19,43 +19,45 @@ 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 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 @@ -69,24 +69,28 @@ ViewContainer::ViewContainer( QWidget *parent, const char* name ) registerLooks(); #if 1 // Hide detailed view selection combo box, because we currently have // only one. Reenable it when there are more detailed views. label->hide(); mStyleCombo->hide(); frameRuler->hide(); #endif } +void ViewContainer::printView() +{ + mCurrentLook->printView(); +} KABBasicLook *ViewContainer::currentLook() { return mCurrentLook; } void ViewContainer::registerLooks() { mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); mStyleCombo->clear(); for ( uint i = 0; i < mLookFactories.count(); ++i ) 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 @@ -42,24 +42,25 @@ class ViewContainer : public QWidget Return the look currently selected. If there is none, it returns zero. Do not use this pointer to store a reference to a look, the user might select another one (e.g., create a new object) at any time. */ KABBasicLook *currentLook(); /** Return the contact currently displayed. */ KABC::Addressee addressee(); public slots: + void printView(); /** Set the contact currently displayed. */ void setAddressee( const KABC::Addressee& addressee ); /** Set read-write state. */ void setReadOnly( bool state ); signals: /** 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 @@ -66,26 +66,28 @@ class KABBasicLook : public QVBox */ virtual void restoreSettings( KConfig* ); /** Save the view settings to the configuration file. */ 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(); /** This signal indicates that the entry needs to be changed immidiately in the database. This might be due to changes in values that are available in menus. */ void saveMe(); 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 @@ -17,32 +17,40 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #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 ); } #ifndef KAB_EMBEDDED #include "look_html.moc" #endif //KAB_EMBEDDED 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 @@ -20,48 +20,50 @@ with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef LOOK_HTML_H #define LOOK_HTML_H #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: /** The constructor. */ KABHtmlView( QWidget *parent = 0, const char* name = 0 ); /** The virtual destructor. */ virtual ~KABHtmlView(); /** Set the addressee. */ - void setAddressee( const KABC::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 ) : KABLookFactory( parent, name ) {} KABBasicLook *create() { return new KABHtmlView( mParent, mName ); } diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 4098dda..e61f65f 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1868,36 +1868,33 @@ void KABCore::initGUI() } void KABCore::initActions() { //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); #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" ); mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, this, SLOT( mailVCard() ), actionCollection(), "file_mail_vcard"); mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, @@ -2130,24 +2127,26 @@ void KABCore::addActionsManually() if (QApplication::desktop()->width() > 320 ) { // mViewManager->getFilterAction()->plug ( tb); } } #endif // mActionQuit->plug ( mMainWindow->toolBar()); //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 ); mActionEditAddressee->plug( fileMenu ); // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || // (!KABPrefs::instance()->mMultipleViewsAtOnce )) mActionEditAddressee->plug( tb ); @@ -2759,25 +2758,25 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i else return 2; break; case SYNC_PREF_ASK: //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); if ( lastSync > remoteMod ) 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; break; case SYNC_PREF_FORCE_REMOTE: return 2; break; default: diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 0d5891e..ecfe6e9 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -421,24 +421,25 @@ class KABCore : public QWidget, public KSyncInterface bool mReadWrite; bool mModified; bool mIsPart; bool mMultipleViewsAtOnce; //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; KAction *mActionQuit; //US edit menu KAction *mActionCopy; KAction *mActionCut; KAction *mActionPaste; diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 8646136..8f31910 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h @@ -29,24 +29,30 @@ #endif //KAB_EMBEDDED class KConfig; class QDropEvent; #include <qstringlist.h> #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. To implement a specific view (table, card, etc), just inherit from this class and implement all the pure virtuals. @author Mike Pilone <mpilone@slac.com> */ class KAddressBookView : public QWidget @@ -141,24 +147,25 @@ class KAddressBookView : public QWidget DefaultFilterType defaultFilterType() const; /** @return The name of the default filter. This string is only valid if defaultFilterType() is returning SpecificFilter. */ 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 addressee with uid needs to be refreshed. This is an optimization only. */ virtual void refresh( QString uid = QString::null ) = 0; /** @@ -167,24 +174,26 @@ class KAddressBookView : public QWidget is equal to QString::null, then all addressees should be selected. */ #ifndef KAB_EMBEDDED //MOC_SKIP_BEGIN virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0; //MOC_SKIP_END #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(); /** This signal should be emitted by a subclass whenever an addressee is selected. Selected means that the addressee was given the focus. Some widgets may call this 'highlighted'. The view is responsible for emitting this signal multiple times if multiple items are selected, with the last item selected being the last emit. 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 @@ -148,25 +148,25 @@ KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char * QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); boxLayout = new QVBoxLayout( groupBox->layout() ); boxLayout->setAlignment( Qt::AlignTop ); boxLayout->setMargin(KDialog::marginHintSmall()); boxLayout->setSpacing(KDialog::spacingHintSmall()); 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 ); extensionLayout->addWidget( groupBox ); connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 771bec9..1e03dba 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -67,26 +67,27 @@ int main( int argc, char **argv ) #else QString fileName ; fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/"; KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); QApplication::addLibraryPath ( qApp->applicationDirPath () ); #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 a.setMainWidget( &m ); m.resize (640, 480 ); m.show(); #endif a.exec(); diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 272e1b0..dff9998 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h @@ -60,24 +60,25 @@ class ViewManager : public QWidget void unloadViews(); KSelectAction * getFilterAction() { return mActionSelectFilter; } Filter getFilterByName( const QString &name ) const; QStringList selectedUids() const; 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. void setSelected(); //US added another method with no parameter, since my moc compiler does not support default parameters. void refreshView(); 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 @@ -268,24 +268,51 @@ ContactListView::ContactListView(KAddressBookTableView *view, // setFrameStyle(QFrame::NoFrame); //setLineWidth ( 0 ); //setMidLineWidth ( 0 ); //setMargin ( 0 ); #ifndef KAB_EMBEDDED connect(this, SIGNAL(dropped(QDropEvent*)), 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; } void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) { QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); // Get the brush, which will have the background pixmap if there is one. if (b.pixmap()) 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 @@ -96,24 +96,25 @@ protected: * since Qt::FixedPixmap will not scroll with the list view. */ virtual void paintEmptyArea( QPainter * p, const QRect & rect ); virtual void contentsMousePressEvent(QMouseEvent*); void contentsMouseMoveEvent( QMouseEvent *e ); void contentsDropEvent( QDropEvent *e ); virtual bool acceptDrag(QDropEvent *e) const; protected slots: void itemDropped(QDropEvent *e); public slots: + void printMe(); signals: void startAddresseeDrag(); void addresseeDropped(QDropEvent *); private: KAddressBookTableView *pabWidget; int oldColumn; int column; bool ascending; bool mABackground; 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 @@ -29,24 +29,25 @@ #include <qregexp.h> #include <qapplication.h> #include <kabc/addressbook.h> #include <kabc/addressee.h> #include <kconfig.h> #include <kdebug.h> #include <klocale.h> #include "kabprefs.h" #include "viewmanager.h" + #include "kaddressbookcardview.h" #ifndef KAB_EMBEDDED extern "C" { void *init_libkaddrbk_cardview() { return ( new CardViewFactory ); } } #endif //KAB_EMBEDDED //////////////////////////////// @@ -107,24 +108,50 @@ class AddresseeCardViewItem : public CardViewItem /////////////////////////////// // AddresseeCardView AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name) : CardView(parent, 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)) e->accept(); #else //KAB_EMBEDDED qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented"); #endif //KAB_EMBEDDED } @@ -155,24 +182,26 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, mCardView->setSelectionMode(CardView::Extended); layout->addWidget(mCardView); // Connect up the signals connect(mCardView, SIGNAL(executed(CardViewItem *)), this, SLOT(addresseeExecuted(CardViewItem *))); 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() { if ( mCardView ) mCardView->setFocus(); } void KAddressBookCardView::scrollUP() 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 @@ -76,24 +76,26 @@ class KAddressBookCardView : public KAddressBookView private: AddresseeCardView *mCardView; bool mShowEmptyFields; }; 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: virtual void dragEnterEvent(QDragEnterEvent *); virtual void dropEvent(QDropEvent *); virtual void startDrag(); }; 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 @@ -80,24 +80,26 @@ void KAddressBookTableView::reconstructListView() disconnect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 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; int c = 0; for( it = fieldList.begin(); it != fieldList.end(); ++it ) { mListView->addColumn( (*it)->label() ); mListView->setColumnWidthMode(c++, QListView::Manual); //US diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp index 8d40ffe..89a2626 100644 --- a/kaddressbook/xxportmanager.cpp +++ b/kaddressbook/xxportmanager.cpp @@ -219,24 +219,24 @@ void XXPortManager::loadPlugins() } } PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent, const char *name ) : 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 ); } #ifndef KAB_EMBEDDED #include "xxportmanager.moc" #endif //KAB_EMBEDDED diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index cee0466..5de667e 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp @@ -78,25 +78,25 @@ void KOEventViewer::setSource(const QString& n) KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); KABC::AddressBook::Iterator it; for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { // LR I do not understand, why the uid string is different on zaurus and desktop QString uid = "uid://"+(*it).uid(); //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); if (n == uid ) { //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); QDialog dia( this,"dia123", true ); dia.setCaption( i18n("Details of attendee") ); QVBoxLayout lay ( &dia ); - KPIM::AddresseeView av ( &dia ); + KABC::AddresseeView av ( &dia ); av.setAddressee( (*it) ); lay.addWidget( &av ); if ( QApplication::desktop()->width() < 480 ) dia.resize( 220, 240); else { dia.resize( 400,400); } dia.exec(); break; } } return; diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 219f7c3..7166a01 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp @@ -15,25 +15,27 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qlayout.h> #include <qtextbrowser.h> #include <qtextcodec.h> #include <qfileinfo.h> #include <qlabel.h> #include <qapplication.h> - +#ifdef DESKTOP_VERSION +#include <qpaintdevicemetrics.h> +#endif #include <kglobal.h> #include <klocale.h> #include <kdebug.h> #include <kiconloader.h> #include <kmessagebox.h> #include <libkcal/calendar.h> #ifndef KORG_NOPRINTER #include "calprinter.h" #endif #include "koglobals.h" @@ -47,24 +49,49 @@ void WhatsNextTextBrowser::setSource(const QString& n) { if (n.startsWith("event:")) { emit showIncidence(n); return; } else if (n.startsWith("todo:")) { emit showIncidence(n); return; } else { QTextBrowser::setSource(n); } } +void WhatsNextTextBrowser::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 +} KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, const char *name) : KOrg::BaseView(calendar, parent, name) { // mDateLabel = // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); // mDateLabel->setMargin(2); // mDateLabel->setAlignment(AlignCenter); setFont( KOPrefs::instance()->mWhatsNextFont ); mView = new WhatsNextTextBrowser(this); connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); @@ -105,36 +132,25 @@ int KOWhatsNextView::currentDateCount() } QPtrList<Incidence> KOWhatsNextView::selectedIncidences() { QPtrList<Incidence> eventList; return eventList; } void KOWhatsNextView::printMe() { #ifdef DESKTOP_VERSION - QPrinter printer; - if (!printer.setup() ) - return; - QTextBrowser tb; - tb.setFixedSize( 600, 4000 ); - QPainter::redirect ( tb.viewport(), &printer ); - updateView(); - tb.setText( mText ); - tb.show(); - tb.repaint(); - tb.hide(); - KMessageBox::information( this, i18n("Printing What's Next View!\n\nPlease close after\nprinting is finished.")); + mView->printMe(); #endif } void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Day, fd, td); #endif } void KOWhatsNextView::updateConfig() { setFont( KOPrefs::instance()->mWhatsNextFont ); diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h index 0231cf2..715037f 100644 --- a/korganizer/kowhatsnextview.h +++ b/korganizer/kowhatsnextview.h @@ -25,27 +25,28 @@ #include <korganizer/baseview.h> class QListView; class QLabel; class KOEventViewerDialog; #include <qpainter.h> #include <qwidget.h> class WhatsNextTextBrowser : public QTextBrowser { Q_OBJECT public: - WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {} + WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {}; void setSource(const QString &); + void printMe(); signals: void showIncidence(const QString &uid); }; /** This class provides a view of the next events and todos */ class KOWhatsNextView : public KOrg::BaseView { Q_OBJECT @@ -79,21 +80,21 @@ class KOWhatsNextView : public KOrg::BaseView QDate mEventDate; virtual void showEvent ( QShowEvent * ); virtual void hideEvent ( QHideEvent * ); private slots: void showIncidence(const QString &); void restartTimer(); private: //void createEventViewer(); QTimer* mTimer; - QTextBrowser *mView; + WhatsNextTextBrowser *mView; QString mText; // QLabel *mDateLabel; KOEventViewerDialog *mEventViewer; QValueList<Incidence *> mTodos; }; #endif |