Don't rely on QPrinter in widgets
Use the QPagedPaintDevice instead for the current print() methods. Like this we can move the whole printing system into it's own library. Change-Id: I5e23fb3a9304eb3d12aa54959893601566249e23 Reviewed-on: http://codereview.qt.nokia.com/3208 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
This commit is contained in:
parent
699e8fe3a6
commit
a1016213d0
@ -54,6 +54,7 @@ QT_MODULE(Gui)
|
||||
|
||||
class QGraphicsView;
|
||||
class QPrintPreviewDialogPrivate;
|
||||
class QPrinter;
|
||||
|
||||
class Q_WIDGETS_EXPORT QPrintPreviewDialog : public QDialog
|
||||
{
|
||||
|
@ -2512,7 +2512,6 @@ bool QPlainTextEdit::canPaste() const
|
||||
return d->control->canPaste();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
/*!
|
||||
Convenience function to print the text edit's document to the given \a printer. This
|
||||
is equivalent to calling the print method on the document directly except that this
|
||||
@ -2520,12 +2519,11 @@ bool QPlainTextEdit::canPaste() const
|
||||
|
||||
\sa QTextDocument::print()
|
||||
*/
|
||||
void QPlainTextEdit::print(QPrinter *printer) const
|
||||
void QPlainTextEdit::print(QPagedPaintDevice *printer) const
|
||||
{
|
||||
Q_D(const QPlainTextEdit);
|
||||
d->control->print(printer);
|
||||
}
|
||||
#endif // QT _NO_PRINTER
|
||||
|
||||
/*! \property QPlainTextEdit::tabChangesFocus
|
||||
\brief whether \gui Tab changes focus or is accepted as input
|
||||
|
@ -64,7 +64,7 @@ class QTextDocument;
|
||||
class QMenu;
|
||||
class QPlainTextEditPrivate;
|
||||
class QMimeData;
|
||||
|
||||
class QPagedPaintDevice;
|
||||
|
||||
class Q_WIDGETS_EXPORT QPlainTextEdit : public QAbstractScrollArea
|
||||
{
|
||||
@ -177,9 +177,7 @@ public:
|
||||
|
||||
bool canPaste() const;
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void print(QPrinter *printer) const;
|
||||
#endif
|
||||
void print(QPagedPaintDevice *printer) const;
|
||||
|
||||
int blockCount() const;
|
||||
|
||||
|
@ -2285,7 +2285,6 @@ bool QTextEdit::canPaste() const
|
||||
return d->control->canPaste();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
/*!
|
||||
\since 4.3
|
||||
Convenience function to print the text edit's document to the given \a printer. This
|
||||
@ -2294,12 +2293,11 @@ bool QTextEdit::canPaste() const
|
||||
|
||||
\sa QTextDocument::print()
|
||||
*/
|
||||
void QTextEdit::print(QPrinter *printer) const
|
||||
void QTextEdit::print(QPagedPaintDevice *printer) const
|
||||
{
|
||||
Q_D(const QTextEdit);
|
||||
d->control->print(printer);
|
||||
}
|
||||
#endif // QT _NO_PRINTER
|
||||
|
||||
/*! \property QTextEdit::tabChangesFocus
|
||||
\brief whether \gui Tab changes focus or is accepted as input
|
||||
|
@ -66,6 +66,7 @@ class QTextDocument;
|
||||
class QMenu;
|
||||
class QTextEditPrivate;
|
||||
class QMimeData;
|
||||
class QPagedPaintDevice;
|
||||
|
||||
class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea
|
||||
{
|
||||
@ -232,9 +233,7 @@ public:
|
||||
|
||||
bool canPaste() const;
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void print(QPrinter *printer) const;
|
||||
#endif
|
||||
void print(QPagedPaintDevice *printer) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setFontPointSize(qreal s);
|
||||
|
@ -62,7 +62,7 @@
|
||||
#include "qtextlist.h"
|
||||
#include "private/qwidgettextcontrol_p.h"
|
||||
#include "qgraphicssceneevent.h"
|
||||
#include "qprinter.h"
|
||||
#include "qpagedpaintdevice.h"
|
||||
#include "qtextdocumentwriter.h"
|
||||
#include "private/qtextcursor_p.h"
|
||||
|
||||
@ -2423,14 +2423,15 @@ bool QWidgetTextControl::isWordSelectionEnabled() const
|
||||
return d->wordSelectionEnabled;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void QWidgetTextControl::print(QPrinter *printer) const
|
||||
void QWidgetTextControl::print(QPagedPaintDevice *printer) const
|
||||
{
|
||||
Q_D(const QWidgetTextControl);
|
||||
if (!printer || !printer->isValid())
|
||||
if (!printer)
|
||||
return;
|
||||
QTextDocument *tempDoc = 0;
|
||||
const QTextDocument *doc = d->doc;
|
||||
#if 0
|
||||
// ####
|
||||
if (printer->printRange() == QPrinter::Selection) {
|
||||
if (!d->cursor.hasSelection())
|
||||
return;
|
||||
@ -2445,10 +2446,10 @@ void QWidgetTextControl::print(QPrinter *printer) const
|
||||
// copy the custom object handlers
|
||||
doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers;
|
||||
}
|
||||
#endif
|
||||
doc->print(printer);
|
||||
delete tempDoc;
|
||||
}
|
||||
#endif // QT_NO_PRINTER
|
||||
|
||||
QMimeData *QWidgetTextControl::createMimeDataFromSelection() const
|
||||
{
|
||||
|
@ -176,9 +176,7 @@ public:
|
||||
bool isWordSelectionEnabled() const;
|
||||
void setWordSelectionEnabled(bool enabled);
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void print(QPrinter *printer) const;
|
||||
#endif
|
||||
void print(QPagedPaintDevice *printer) const;
|
||||
|
||||
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;
|
||||
virtual QRectF blockBoundingRect(const QTextBlock &block) const;
|
||||
|
Loading…
Reference in New Issue
Block a user