[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kplato/libs/ui
From: Dag Andersen <danders () get2net ! dk>
Date: 2010-04-08 7:32:46
Message-ID: 20100408073246.E1F32AC88F () svn ! kde ! org
[Download RAW message or body]
SVN commit 1112442 by danders:
Printing: Use the KoPageLayout framework.
Position printout correctly on paper and use the margins other settings.
M +9 -1 kptdependencyeditor.cpp
M +2 -0 kptdependencyeditor.h
M +10 -10 kptganttview.cpp
M +0 -1 kptganttview.h
M +74 -0 kptviewbase.cpp
M +17 -0 kptviewbase.h
--- trunk/koffice/kplato/libs/ui/kptdependencyeditor.cpp #1112441:1112442
@@ -66,6 +66,14 @@
return documentFirstPage();
}
+QList<QWidget*> DependecyViewPrintingDialog::createOptionWidgets() const
+{
+ QList<QWidget*> lst;
+ lst << createPageLayoutWidget();
+ lst += PrintingDialog::createOptionWidgets();
+ return lst;
+}
+
void DependecyViewPrintingDialog::printPage( int page, QPainter &painter )
{
painter.save();
@@ -73,7 +81,7 @@
QRect hRect = headerRect();
QRect fRect = footerRect();
QRect pageRect = printer().pageRect();
-
+ pageRect.moveTo( 0, 0 );
kDebug()<<pageRect<<hRect<<fRect;
painter.translate( pageRect.topLeft() );
--- trunk/koffice/kplato/libs/ui/kptdependencyeditor.h #1112441:1112442
@@ -65,6 +65,8 @@
int documentLastPage() const;
void printPage( int page, QPainter &painter );
+ QList<QWidget*> createOptionWidgets() const;
+
private:
DependencyView *m_depview;
};
--- trunk/koffice/kplato/libs/ui/kptganttview.cpp #1112441:1112442
@@ -42,6 +42,7 @@
#include <kdgantttreeviewrowcontroller.h>
#include <KoDocument.h>
+#include <KoPageLayoutWidget.h>
#include <kdebug.h>
@@ -141,22 +142,21 @@
m_singlePage( true ),
m_printRowLabels( true )
{
- m_pageRect = printer().pageRect();
m_headerHeight = gantt->graphicsView()->headerHeight();
m_sceneRect = m_gantt->graphicsView()->printRect();
m_horPages = 1;
- qreal c = m_sceneRect.width() - m_pageRect.width();
+ qreal c = m_sceneRect.width() - printer().pageRect().width();
while ( c > 0 ) {
++m_horPages;
- c -= m_pageRect.width();
+ c -= printer().pageRect().width();
}
m_vertPages = 1;
- c = m_sceneRect.height() - m_pageRect.height() - m_headerHeight;
+ c = m_sceneRect.height() - printer().pageRect().height() - m_headerHeight;
while ( c > 0 ) {
++m_vertPages;
- c -= m_pageRect.height();
+ c -= printer().pageRect().height();
}
- kDebug()<<m_sceneRect<<m_pageRect<<m_horPages<<m_vertPages;
+ kDebug()<<m_sceneRect<<printer().pageRect()<<m_horPages<<m_vertPages;
printer().setFromTo( documentFirstPage(), documentLastPage() );
}
@@ -166,7 +166,7 @@
m_singlePage = m_options->singlePage();
//m_printRowLabels = m_options->printRowLabels();
}
- KoPrintingDialog::startPrinting( removePolicy );
+ PrintingDialog::startPrinting( removePolicy );
}
QList<QWidget*> GanttPrintingDialog::createOptionWidgets() const
@@ -178,7 +178,7 @@
const_cast<GanttPrintingDialog*>( this )->m_options = w;
- return QList<QWidget*>() << m_options;
+ return QList<QWidget*>() << createPageLayoutWidget() << m_options;
}
int GanttPrintingDialog::documentLastPage() const
@@ -192,7 +192,8 @@
{
QRectF sourceRect = m_sceneRect;
int p = page - documentFirstPage();
- QRectF pageRect = m_pageRect;
+ QRectF pageRect = printer().pageRect();
+ pageRect.moveTo( 0, 0 );
int vert = m_singlePage ? 0 : p / m_horPages;
int hor = m_singlePage ? 0 : p % m_horPages;
if ( ! m_singlePage && documentLastPage() > documentFirstPage() ) {
@@ -205,7 +206,6 @@
m_gantt->print( &painter, pageRect, sourceRect, m_printRowLabels, vert == 0 );
}
-
//---------------------
class HeaderView : public QHeaderView
{
--- trunk/koffice/kplato/libs/ui/kptganttview.h #1112441:1112442
@@ -125,7 +125,6 @@
GanttPrintingOptions *m_options;
bool m_singlePage;
bool m_printRowLabels;
- QRectF m_pageRect;
};
class GanttTreeView : public TreeViewBase
--- trunk/koffice/kplato/libs/ui/kptviewbase.cpp #1112441:1112442
@@ -29,6 +29,9 @@
#include <KoDocument.h>
#include <KoShape.h>
+#include <KoPageLayoutWidget.h>
+#include <KoPagePreviewWidget.h>
+#include <KoPageLayoutDialog.h>
#include <QAbstractItemModel>
#include <QAbstractProxyModel>
@@ -97,8 +100,17 @@
m_view( view ),
m_widget( 0 )
{
+ setPrinterPageLayout();
}
+QAbstractPrintDialog::PrintDialogOptions PrintingDialog::printDialogOptions() const
+{
+ return QAbstractPrintDialog::PrintToFile |
+ QAbstractPrintDialog::PrintPageRange |
+ QAbstractPrintDialog::PrintCollateCopies |
+ QAbstractPrintDialog::DontUseSheet;
+}
+
PrintingOptions PrintingDialog::printingOptions() const
{
return m_view->printingOptions();
@@ -109,6 +121,21 @@
return m_view->setPrintingOptions( opt );
}
+void PrintingDialog::setPrinterPageLayout()
+{
+ QPrinter &p = printer();
+ KoPageLayout l = m_view->pageLayout();
+ QPrinter::Orientation o;
+ switch ( l.orientation ) {
+ case KoPageFormat::Portrait: o = QPrinter::Portrait; break;
+ case KoPageFormat::Landscape: o = QPrinter::Landscape; break;
+ default: o = QPrinter::Portrait; break;
+ }
+ p.setOrientation( o );
+ p.setPaperSize( KoPageFormat::printerPageSize( l.format ) );
+ p.setPageMargins( l.leftMargin, l.topMargin, l.rightMargin, l.bottomMargin, \
QPrinter::Point ); +}
+
void PrintingDialog::startPrinting(RemovePolicy removePolicy )
{
PrintingOptions opt;
@@ -116,9 +143,38 @@
opt = m_widget->options();
}
setPrintingOptions( opt );
+ setPrinterPageLayout();
KoPrintingDialog::startPrinting( removePolicy );
}
+QWidget *PrintingDialog::createPageLayoutWidget() const
+{
+ QWidget *widget = new QWidget();
+ //FIXME change when allowed by i18n (also #include)
+ //widget->setWindowTitle( i18nc( "@title:tab", "Page Layout" ) );
+ KoPageLayoutDialog dummy( 0, m_view->pageLayout() );
+ widget->setWindowTitle( dummy.windowTitle() );
+
+ QHBoxLayout *lay = new QHBoxLayout(widget);
+ lay->setMargin(0);
+ widget->setLayout(lay);
+
+ KoPageLayoutWidget *w = new KoPageLayoutWidget( widget, m_view->pageLayout() );
+ w->showPageSpread( false );
+ w->layout()->setMargin( 0 );
+ lay->addWidget( w );
+
+ KoPagePreviewWidget *prev = new KoPagePreviewWidget( widget );
+ prev->setPageLayout( m_view->pageLayout() );
+ lay->addWidget( prev );
+
+ connect(w, SIGNAL(layoutChanged(const KoPageLayout&)), m_view, \
SLOT(setPageLayout(const KoPageLayout&))); +
+ connect (w, SIGNAL(layoutChanged(const KoPageLayout&)), prev, \
SLOT(setPageLayout(const KoPageLayout&))); +
+ return widget;
+}
+
QList<QWidget*> PrintingDialog::createOptionWidgets() const
{
//kDebug();
@@ -439,6 +495,14 @@
return row;
}
+QList<QWidget*> TreeViewPrintingDialog::createOptionWidgets() const
+{
+ QList<QWidget*> lst;
+ lst << createPageLayoutWidget();
+ lst += PrintingDialog::createOptionWidgets();
+ return lst;
+}
+
void TreeViewPrintingDialog::printPage( int page, QPainter &painter )
{
painter.save();
@@ -451,6 +515,7 @@
QRect hRect = headerRect();
QRect fRect = footerRect();
QRect pageRect = printer().pageRect();
+ pageRect.moveTo( 0, 0 );
QRect paperRect = printer().paperRect();
QAbstractItemModel *model = m_tree->model();
@@ -1227,6 +1292,14 @@
return row;
}
+QList<QWidget*> DoubleTreeViewPrintingDialog::createOptionWidgets() const
+{
+ QList<QWidget*> lst;
+ lst << createPageLayoutWidget();
+ lst += PrintingDialog::createOptionWidgets();
+ return lst;
+}
+
void DoubleTreeViewPrintingDialog::printPage( int page, QPainter &painter )
{
painter.save();
@@ -1240,6 +1313,7 @@
QRect hRect = headerRect();
QRect fRect = footerRect();
QRect pageRect = printer().pageRect();
+ pageRect.moveTo( 0, 0 );
QRect paperRect = printer().paperRect();
QAbstractItemModel *model = m_tree->model();
--- trunk/koffice/kplato/libs/ui/kptviewbase.h #1112441:1112442
@@ -28,6 +28,7 @@
#include <KoView.h>
#include <KoPrintingDialog.h>
+#include <KoPageLayout.h>
#include <QMap>
#include <QTreeView>
@@ -43,6 +44,7 @@
class KoDocument;
class KoPrintJob;
+class KoPageLayoutWidget;
/// The main namespace
namespace KPlato
@@ -124,6 +126,9 @@
PrintingOptions printingOptions() const;
void setPrintingOptions( const PrintingOptions &opt);
+ QWidget *createPageLayoutWidget() const;
+ QAbstractPrintDialog::PrintDialogOptions printDialogOptions() const;
+
signals:
void changed ( const PrintingOptions &opt );
@@ -135,6 +140,8 @@
int headerFooterHeight( const PrintingOptions::Data &options ) const;
void drawBottomRect( QPainter &p, const QRect &r );
+ void setPrinterPageLayout();
+
protected:
ViewBase *m_view;
QPointer<PrintingHeaderFooter> m_widget;
@@ -232,6 +239,8 @@
void addAction( const QString list, QAction *action ) { \
ViewActionLists::addAction( list, action ); }
+ KoPageLayout pageLayout() const { return m_pagelayout; }
+
public slots:
/// Activate/deactivate the gui
virtual void setGuiActive( bool activate );
@@ -244,6 +253,8 @@
virtual void slotEditPaste() {}
virtual void slotRefreshView() {}
+ void setPageLayout( const KoPageLayout &layout ) { m_pagelayout = layout; }
+
signals:
/// Emitted when the gui has been activated or deactivated
void guiActivated( ViewBase*, bool );
@@ -265,6 +276,8 @@
Project *m_proj;
ScheduleManager *m_schedulemanager;
+
+ KoPageLayout m_pagelayout;
};
//------------------
@@ -278,6 +291,8 @@
virtual int documentFirstPage() const { return 1; }
virtual int documentLastPage() const;
+ QList<QWidget*> createOptionWidgets() const;
+
protected:
virtual void printPage( int pageNumber, QPainter &painter );
@@ -422,6 +437,8 @@
virtual int documentFirstPage() const { return 1; }
virtual int documentLastPage() const;
+ QList<QWidget*> createOptionWidgets() const;
+
protected:
virtual void printPage( int pageNumber, QPainter &painter );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic