mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2024-12-23 20:22:58 +03:00
Print process has been changed and printBehavior property has been added.
This commit is contained in:
parent
f7e1a383e9
commit
9bf0ba0ded
@ -51,7 +51,7 @@ PageItemDesignIntf::PageItemDesignIntf(QObject *owner, QGraphicsItem *parent) :
|
||||
m_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false),
|
||||
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
||||
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false),
|
||||
m_endlessHeight(false), m_printable(true), m_pageFooter(0)
|
||||
m_endlessHeight(false), m_printable(true), m_pageFooter(0), m_printBehavior(Split)
|
||||
{
|
||||
setFixedPos(true);
|
||||
setPossibleResizeDirectionFlags(Fixed);
|
||||
@ -65,7 +65,7 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
|
||||
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false),
|
||||
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
||||
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(false),
|
||||
m_endlessHeight(false), m_printable(true), m_pageFooter(0)
|
||||
m_endlessHeight(false), m_printable(true), m_pageFooter(0), m_printBehavior(Split)
|
||||
{
|
||||
setFixedPos(true);
|
||||
setPossibleResizeDirectionFlags(Fixed);
|
||||
@ -344,6 +344,16 @@ void PageItemDesignIntf::initColumnsPos(QVector<qreal> &posByColumns, qreal pos,
|
||||
}
|
||||
}
|
||||
|
||||
void PageItemDesignIntf::setPrintBehavior(const PrintBehavior &printBehavior)
|
||||
{
|
||||
m_printBehavior = printBehavior;
|
||||
}
|
||||
|
||||
PageItemDesignIntf::PrintBehavior PageItemDesignIntf::printBehavior() const
|
||||
{
|
||||
return m_printBehavior;
|
||||
}
|
||||
|
||||
QString PageItemDesignIntf::printerName() const
|
||||
{
|
||||
return m_printerName;
|
||||
|
@ -44,6 +44,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Orientation)
|
||||
Q_ENUMS(PageSize)
|
||||
Q_ENUMS(PrintBehavior)
|
||||
Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin)
|
||||
Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin)
|
||||
Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin)
|
||||
@ -62,9 +63,11 @@ class PageItemDesignIntf : public ItemsContainerDesignInft
|
||||
Q_PROPERTY(bool printable READ isPrintable WRITE setPrintable)
|
||||
Q_PROPERTY(QString printerName READ printerName WRITE setPrinterName)
|
||||
Q_PROPERTY(UnitType units READ unitType WRITE setUnitTypeProperty)
|
||||
Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior)
|
||||
friend class ReportRender;
|
||||
public:
|
||||
enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
|
||||
enum PrintBehavior {Scale, Split};
|
||||
enum PageSize {
|
||||
A4 = QPrinter::A4, B5 = QPrinter::B5, Letter = QPrinter::Letter,
|
||||
Legal = QPrinter::Legal, Executive = QPrinter::Executive,
|
||||
@ -163,6 +166,9 @@ public:
|
||||
BandDesignIntf *pageFooter() const;
|
||||
void setPageFooter(BandDesignIntf *pageFooter);
|
||||
|
||||
PrintBehavior printBehavior() const;
|
||||
void setPrintBehavior(const PrintBehavior &printBehavior);
|
||||
|
||||
signals:
|
||||
void beforeFirstPageRendered();
|
||||
void afterLastPageRendered();
|
||||
@ -205,6 +211,9 @@ private:
|
||||
bool m_printable;
|
||||
QString m_printerName;
|
||||
BandDesignIntf* m_pageFooter;
|
||||
PrintBehavior m_printBehavior;
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef QList<PageItemDesignIntf::Ptr> ReportPages;
|
||||
|
@ -1790,16 +1790,28 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
|
||||
printerPageRect = QRectF(0,0,(printerPageRect.size().width() + rightMargin + leftMargin) * page->unitFactor(),
|
||||
(printerPageRect.size().height() + bottomMargin +topMargin) * page->unitFactor());
|
||||
|
||||
if (m_printer->pageSize() != static_cast<QPrinter::PageSize>(page->pageSize()) &&
|
||||
if (page->printBehavior() == PageItemDesignIntf::Split && m_printer->pageSize() != static_cast<QPrinter::PageSize>(page->pageSize()) &&
|
||||
printerPageRect.width() < page->geometry().width())
|
||||
{
|
||||
qreal pageWidth = page->geometry().width();
|
||||
qreal pageHeight = page->geometry().height();
|
||||
QRectF currentPrintingRect = printerPageRect;
|
||||
while (pageWidth>0){
|
||||
renderPage.render(m_painter, m_printer->pageRect(), currentPrintingRect);
|
||||
currentPrintingRect.adjust(printerPageRect.size().width(),0,printerPageRect.size().width(),0);
|
||||
pageWidth -= printerPageRect.size().width();
|
||||
if (pageWidth>0) m_printer->newPage();
|
||||
qreal curHeight = 0;
|
||||
qreal curWidth = 0;
|
||||
bool first = true;
|
||||
while (pageHeight > 0){
|
||||
while (curWidth < pageWidth){
|
||||
if (!first) m_printer->newPage(); else first = false;
|
||||
renderPage.render(m_painter, m_printer->pageRect(), currentPrintingRect);
|
||||
currentPrintingRect.adjust(printerPageRect.size().width(), 0, printerPageRect.size().width(), 0);
|
||||
curWidth += printerPageRect.size().width();
|
||||
|
||||
}
|
||||
pageHeight -= printerPageRect.size().height();
|
||||
curHeight += printerPageRect.size().height();
|
||||
currentPrintingRect = printerPageRect;
|
||||
currentPrintingRect.adjust(0, curHeight, 0, curHeight);
|
||||
curWidth = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -162,6 +162,7 @@ void QObjectPropertyModel::translatePropertyName()
|
||||
tr("option3");
|
||||
tr("units");
|
||||
tr("geometryLocked");
|
||||
tr("printBehavior");
|
||||
}
|
||||
|
||||
void QObjectPropertyModel::clearObjectsList()
|
||||
|
@ -145,6 +145,8 @@ void EnumPropItem::translateEnumItemName()
|
||||
tr("Table");
|
||||
tr("Millimeters");
|
||||
tr("Inches");
|
||||
tr("Scale");
|
||||
tr("Split");
|
||||
}
|
||||
|
||||
void EnumPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
||||
|
Binary file not shown.
@ -1001,6 +1001,14 @@ p, li { white-space: pre-wrap; }
|
||||
<source>Inches</source>
|
||||
<translation>Дюймы</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Scale</source>
|
||||
<translation>Масштабировать</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Split</source>
|
||||
<translation>Разделять на части</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LimeReport::FlagsPropItem</name>
|
||||
@ -1873,7 +1881,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<source>setPageSizeToPrinter</source>
|
||||
<translation>Оправитьпараметры страницы в принтер</translation>
|
||||
<translation>Отправить параметры страницы в принтер</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>fillInSecondPass</source>
|
||||
@ -1963,6 +1971,10 @@ p, li { white-space: pre-wrap; }
|
||||
<source>geometryLocked</source>
|
||||
<translation>Геометрия заблокирована</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>printBehavior</source>
|
||||
<translation>Режим печати</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>LimeReport::RectPropItem</name>
|
||||
|
Loading…
Reference in New Issue
Block a user