Commit c09ad029 authored by Michael Winkelmann's avatar Michael Winkelmann

Remove support for custom printable items

parent 2a82bd02
/*
* Copyright (c) 2014 Taneli Peltoniemi <taneli.peltoniemi@gmail.com>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "qmlprinter.h" #include "qmlprinter.h"
#include <QLoggingCategory>
#include <QAbstractTextDocumentLayout> #include <QAbstractTextDocumentLayout>
#include <QPainter> #include <QPainter>
#include <QPrinter> #include <QPrinter>
...@@ -15,6 +8,8 @@ ...@@ -15,6 +8,8 @@
#include <QQuickWindow> #include <QQuickWindow>
#include <QtMath> #include <QtMath>
Q_LOGGING_CATEGORY(lc, "qt.qmlprinter")
QmlPrinter::QmlPrinter() {} QmlPrinter::QmlPrinter() {}
QmlPrinter::~QmlPrinter() {} QmlPrinter::~QmlPrinter() {}
...@@ -126,20 +121,6 @@ void QmlPrinter::paintItem(QQuickItem *item, QQuickWindow *window, ...@@ -126,20 +121,6 @@ void QmlPrinter::paintItem(QQuickItem *item, QQuickWindow *window,
} }
} }
} }
} else if (isCustomPrintItem(item->metaObject()->className())) {
const int boundingMargin = 5;
QRectF boundingRect;
boundingRect.setTop(item->boundingRect().top() - boundingMargin);
boundingRect.setLeft(item->boundingRect().left() - boundingMargin);
boundingRect.setHeight(item->boundingRect().height() + boundingMargin * 2);
boundingRect.setWidth(item->boundingRect().width() + boundingMargin * 2);
const QRect rect(0,0,int(item->width()),int(item->height()));
QImage image = window->grabWindow();
painter->drawImage(0, 0, image, 0, 0, rect.width(), rect.height());
painter->restore();
drawChildren = false;
} else if (item->flags().testFlag(QQuickItem::ItemHasContents)) { } else if (item->flags().testFlag(QQuickItem::ItemHasContents)) {
if (inherits(item->metaObject(), "QQuickRectangle")) { if (inherits(item->metaObject(), "QQuickRectangle")) {
...@@ -305,20 +286,6 @@ bool QmlPrinter::inherits(const QMetaObject *metaObject, const QString &name) { ...@@ -305,20 +286,6 @@ bool QmlPrinter::inherits(const QMetaObject *metaObject, const QString &name) {
return false; return false;
} }
void QmlPrinter::addPrintableItem(const QString &item) {
printableItems.push_back(item);
}
bool QmlPrinter::isCustomPrintItem(const QString &item) {
QListIterator<QString> it(printableItems);
while (it.hasNext()) {
QString printableItem = it.next();
if (item.contains(printableItem))
return true;
}
return false;
}
QMatrix QmlPrinter::transformMatrix(QQuickItem *item) { QMatrix QmlPrinter::transformMatrix(QQuickItem *item) {
QTransform t; QTransform t;
......
/*
* Copyright (c) 2014 Taneli Peltoniemi <taneli.peltoniemi@gmail.com>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef QMLPRINTER_H #ifndef QMLPRINTER_H
#define QMLPRINTER_H #define QMLPRINTER_H
...@@ -38,7 +31,6 @@ private: ...@@ -38,7 +31,6 @@ private:
QPainter *painter); QPainter *painter);
bool inherits(const QMetaObject *metaObject, const QString &name); bool inherits(const QMetaObject *metaObject, const QString &name);
bool isCustomPrintItem(const QString &item);
void changePrinterOrientation(QPrinter &printer, const int &width, void changePrinterOrientation(QPrinter &printer, const int &width,
const int &height); const int &height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment