mirror of
https://github.com/fralx/LimeReport.git
synced 2025-01-11 17:18:10 +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_pageOrientaion(Portrait), m_pageSize(A4), m_sizeChainging(false),
|
||||||
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
||||||
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(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);
|
setFixedPos(true);
|
||||||
setPossibleResizeDirectionFlags(Fixed);
|
setPossibleResizeDirectionFlags(Fixed);
|
||||||
@ -65,7 +65,7 @@ PageItemDesignIntf::PageItemDesignIntf(const PageSize pageSize, const QRectF &re
|
|||||||
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false),
|
m_pageOrientaion(Portrait), m_pageSize(pageSize), m_sizeChainging(false),
|
||||||
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
m_fullPage(false), m_oldPrintMode(false), m_resetPageNumber(false),
|
||||||
m_isExtendedInDesignMode(false), m_extendedHeight(1000), m_isTOC(false), m_setPageSizeToPrinter(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);
|
setFixedPos(true);
|
||||||
setPossibleResizeDirectionFlags(Fixed);
|
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
|
QString PageItemDesignIntf::printerName() const
|
||||||
{
|
{
|
||||||
return m_printerName;
|
return m_printerName;
|
||||||
|
@ -44,6 +44,7 @@ class PageItemDesignIntf : public ItemsContainerDesignInft
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_ENUMS(Orientation)
|
Q_ENUMS(Orientation)
|
||||||
Q_ENUMS(PageSize)
|
Q_ENUMS(PageSize)
|
||||||
|
Q_ENUMS(PrintBehavior)
|
||||||
Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin)
|
Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin)
|
||||||
Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin)
|
Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin)
|
||||||
Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin)
|
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(bool printable READ isPrintable WRITE setPrintable)
|
||||||
Q_PROPERTY(QString printerName READ printerName WRITE setPrinterName)
|
Q_PROPERTY(QString printerName READ printerName WRITE setPrinterName)
|
||||||
Q_PROPERTY(UnitType units READ unitType WRITE setUnitTypeProperty)
|
Q_PROPERTY(UnitType units READ unitType WRITE setUnitTypeProperty)
|
||||||
|
Q_PROPERTY(PrintBehavior printBehavior READ printBehavior WRITE setPrintBehavior)
|
||||||
friend class ReportRender;
|
friend class ReportRender;
|
||||||
public:
|
public:
|
||||||
enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
|
enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape };
|
||||||
|
enum PrintBehavior {Scale, Split};
|
||||||
enum PageSize {
|
enum PageSize {
|
||||||
A4 = QPrinter::A4, B5 = QPrinter::B5, Letter = QPrinter::Letter,
|
A4 = QPrinter::A4, B5 = QPrinter::B5, Letter = QPrinter::Letter,
|
||||||
Legal = QPrinter::Legal, Executive = QPrinter::Executive,
|
Legal = QPrinter::Legal, Executive = QPrinter::Executive,
|
||||||
@ -163,6 +166,9 @@ public:
|
|||||||
BandDesignIntf *pageFooter() const;
|
BandDesignIntf *pageFooter() const;
|
||||||
void setPageFooter(BandDesignIntf *pageFooter);
|
void setPageFooter(BandDesignIntf *pageFooter);
|
||||||
|
|
||||||
|
PrintBehavior printBehavior() const;
|
||||||
|
void setPrintBehavior(const PrintBehavior &printBehavior);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void beforeFirstPageRendered();
|
void beforeFirstPageRendered();
|
||||||
void afterLastPageRendered();
|
void afterLastPageRendered();
|
||||||
@ -205,6 +211,9 @@ private:
|
|||||||
bool m_printable;
|
bool m_printable;
|
||||||
QString m_printerName;
|
QString m_printerName;
|
||||||
BandDesignIntf* m_pageFooter;
|
BandDesignIntf* m_pageFooter;
|
||||||
|
PrintBehavior m_printBehavior;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QList<PageItemDesignIntf::Ptr> ReportPages;
|
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 = QRectF(0,0,(printerPageRect.size().width() + rightMargin + leftMargin) * page->unitFactor(),
|
||||||
(printerPageRect.size().height() + bottomMargin +topMargin) * 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())
|
printerPageRect.width() < page->geometry().width())
|
||||||
{
|
{
|
||||||
qreal pageWidth = page->geometry().width();
|
qreal pageWidth = page->geometry().width();
|
||||||
|
qreal pageHeight = page->geometry().height();
|
||||||
QRectF currentPrintingRect = printerPageRect;
|
QRectF currentPrintingRect = printerPageRect;
|
||||||
while (pageWidth>0){
|
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);
|
renderPage.render(m_painter, m_printer->pageRect(), currentPrintingRect);
|
||||||
currentPrintingRect.adjust(printerPageRect.size().width(), 0, printerPageRect.size().width(), 0);
|
currentPrintingRect.adjust(printerPageRect.size().width(), 0, printerPageRect.size().width(), 0);
|
||||||
pageWidth -= printerPageRect.size().width();
|
curWidth += printerPageRect.size().width();
|
||||||
if (pageWidth>0) m_printer->newPage();
|
|
||||||
|
}
|
||||||
|
pageHeight -= printerPageRect.size().height();
|
||||||
|
curHeight += printerPageRect.size().height();
|
||||||
|
currentPrintingRect = printerPageRect;
|
||||||
|
currentPrintingRect.adjust(0, curHeight, 0, curHeight);
|
||||||
|
curWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -162,6 +162,7 @@ void QObjectPropertyModel::translatePropertyName()
|
|||||||
tr("option3");
|
tr("option3");
|
||||||
tr("units");
|
tr("units");
|
||||||
tr("geometryLocked");
|
tr("geometryLocked");
|
||||||
|
tr("printBehavior");
|
||||||
}
|
}
|
||||||
|
|
||||||
void QObjectPropertyModel::clearObjectsList()
|
void QObjectPropertyModel::clearObjectsList()
|
||||||
|
@ -145,6 +145,8 @@ void EnumPropItem::translateEnumItemName()
|
|||||||
tr("Table");
|
tr("Table");
|
||||||
tr("Millimeters");
|
tr("Millimeters");
|
||||||
tr("Inches");
|
tr("Inches");
|
||||||
|
tr("Scale");
|
||||||
|
tr("Split");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
|
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>
|
<source>Inches</source>
|
||||||
<translation>Дюймы</translation>
|
<translation>Дюймы</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Scale</source>
|
||||||
|
<translation>Масштабировать</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Split</source>
|
||||||
|
<translation>Разделять на части</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>LimeReport::FlagsPropItem</name>
|
<name>LimeReport::FlagsPropItem</name>
|
||||||
@ -1873,7 +1881,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>setPageSizeToPrinter</source>
|
<source>setPageSizeToPrinter</source>
|
||||||
<translation>Оправитьпараметры страницы в принтер</translation>
|
<translation>Отправить параметры страницы в принтер</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>fillInSecondPass</source>
|
<source>fillInSecondPass</source>
|
||||||
@ -1963,6 +1971,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
<source>geometryLocked</source>
|
<source>geometryLocked</source>
|
||||||
<translation>Геометрия заблокирована</translation>
|
<translation>Геометрия заблокирована</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>printBehavior</source>
|
||||||
|
<translation>Режим печати</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>LimeReport::RectPropItem</name>
|
<name>LimeReport::RectPropItem</name>
|
||||||
|
Loading…
Reference in New Issue
Block a user