0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 16:44:39 +03:00

Some band improvements have been added. Printing signals have been added. Render & printing speed little bit has been increased

This commit is contained in:
Arin Alexander 2019-10-12 22:31:35 +03:00
parent 9756ddde9c
commit 5a6ee275a7
13 changed files with 145 additions and 102 deletions

View File

@ -52,6 +52,7 @@ namespace LimeReport {
namespace Const{ namespace Const{
int const DEFAULT_GRID_STEP = 1;
int const RESIZE_HANDLE_SIZE = 5; int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 1; int const SELECTION_PEN_SIZE = 1;
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;

View File

@ -212,6 +212,11 @@ signals:
void renderStarted(); void renderStarted();
void renderFinished(); void renderFinished();
void renderPageFinished(int renderedPageCount); void renderPageFinished(int renderedPageCount);
void printingStarted(int pageCount);
void printingFinished();
void pagePrintingFinished(int index);
void onSave(bool& saved); void onSave(bool& saved);
void onSaveAs(bool& saved); void onSaveAs(bool& saved);
void onLoad(bool& loaded); void onLoad(bool& loaded);

View File

@ -27,7 +27,7 @@ bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const
printer.setOutputFileName(fileName); printer.setOutputFileName(fileName);
printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFormat(QPrinter::PdfFormat);
if (!pages.isEmpty()){ if (!pages.isEmpty()){
m_reportEngine->printReport(pages, printer); m_reportEngine->printPages(pages, &printer);
} }
m_reportEngine->emitPrintedToPDF(fileName); m_reportEngine->emitPrintedToPDF(fileName);
return true; return true;

View File

@ -166,7 +166,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_printAlways(false), m_printAlways(false),
m_repeatOnEachRow(false), m_repeatOnEachRow(false),
m_useAlternateBackgroundColor(false), m_useAlternateBackgroundColor(false),
m_bottomSpace(0) m_bottomSpace(0),
m_shiftItems(0)
{ {
setPossibleResizeDirectionFlags(ResizeBottom); setPossibleResizeDirectionFlags(ResizeBottom);
setPossibleMoveFlags(TopBotom); setPossibleMoveFlags(TopBotom);
@ -277,6 +278,11 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
BaseDesignIntf::paint(painter,option,widget); BaseDesignIntf::paint(painter,option,widget);
} }
QRectF BandDesignIntf::boundingRect() const
{
return ItemsContainerDesignInft::boundingRect().adjusted(0,-4,0,4);
}
void BandDesignIntf::translateBandsName() void BandDesignIntf::translateBandsName()
{ {
tr("DataBand"); tr("DataBand");
@ -582,6 +588,10 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu)
currAction->setCheckable(true); currAction->setCheckable(true);
currAction->setChecked(isSplittable()); currAction->setChecked(isSplittable());
currAction = menu.addAction(tr("Keep top space"));
currAction->setCheckable(true);
currAction->setChecked(keepBottomSpaceOption());
currAction = menu.addAction(tr("Keep bottom space")); currAction = menu.addAction(tr("Keep bottom space"));
currAction->setCheckable(true); currAction->setCheckable(true);
currAction->setChecked(keepBottomSpaceOption()); currAction->setChecked(keepBottomSpaceOption());
@ -597,9 +607,15 @@ void BandDesignIntf::processPopUpAction(QAction *action)
if (action->text().compare(tr("Auto height")) == 0){ if (action->text().compare(tr("Auto height")) == 0){
setProperty("autoHeight", action->isChecked()); setProperty("autoHeight", action->isChecked());
} }
if (action->text().compare(tr("Splittable")) == 0){ if (action->text().compare(tr("Splittable")) == 0){
setProperty("splittable", action->isChecked()); setProperty("splittable", action->isChecked());
} }
if (action->text().compare(tr("Keep top space")) == 0){
setProperty("keepTopSpace", action->isChecked());
}
if (action->text().compare(tr("Keep bottom space")) == 0){ if (action->text().compare(tr("Keep bottom space")) == 0){
setProperty("keepBottomSpace", action->isChecked()); setProperty("keepBottomSpace", action->isChecked());
} }
@ -903,6 +919,16 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin
m_bandNameLabel->updateLabel(newName); m_bandNameLabel->updateLabel(newName);
} }
int BandDesignIntf::shiftItems() const
{
return m_shiftItems;
}
void BandDesignIntf::setShiftItems(int shiftItems)
{
m_shiftItems = shiftItems;
}
bool BandDesignIntf::keepTopSpace() const bool BandDesignIntf::keepTopSpace() const
{ {
return m_keepTopSpace; return m_keepTopSpace;
@ -1105,7 +1131,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
arrangeSubItems(pass, dataManager); arrangeSubItems(pass, dataManager);
if (autoHeight()){ if (autoHeight()){
if (!keepTopSpace()) { if (!keepTopSpace()) {
qreal minTop = findMinTop(); qreal minTop = findMinTop() + m_shiftItems;
foreach (BaseDesignIntf* item, childBaseItems()) { foreach (BaseDesignIntf* item, childBaseItems()) {
item->setY(item->y() - minTop); item->setY(item->y() - minTop);
} }

View File

@ -113,6 +113,7 @@ class BandDesignIntf : public ItemsContainerDesignInft
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty) Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
Q_PROPERTY(BGMode backgroundMode READ backgroundMode WRITE setBackgroundModeProperty) Q_PROPERTY(BGMode backgroundMode READ backgroundMode WRITE setBackgroundModeProperty)
Q_PROPERTY(int backgroundOpacity READ opacity WRITE setBackgroundOpacity) Q_PROPERTY(int backgroundOpacity READ opacity WRITE setBackgroundOpacity)
Q_PROPERTY(int shiftItems READ shiftItems WRITE setShiftItems)
Q_ENUMS(BandColumnsLayoutType) Q_ENUMS(BandColumnsLayoutType)
friend class BandMarker; friend class BandMarker;
friend class BandNameLabel; friend class BandNameLabel;
@ -142,6 +143,7 @@ public:
~BandDesignIntf(); ~BandDesignIntf();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const;
void translateBandsName(); void translateBandsName();
virtual BandsType bandType() const; virtual BandsType bandType() const;
virtual QString bandTitle() const; virtual QString bandTitle() const;
@ -260,6 +262,8 @@ public:
int bootomSpace() const; int bootomSpace() const;
void setBootomSpace(int bootomSpace); void setBootomSpace(int bootomSpace);
void updateBandMarkerGeometry(); void updateBandMarkerGeometry();
int shiftItems() const;
void setShiftItems(int shiftItems);
signals: signals:
void bandRendered(BandDesignIntf* band); void bandRendered(BandDesignIntf* band);
@ -323,6 +327,7 @@ private:
bool m_useAlternateBackgroundColor; bool m_useAlternateBackgroundColor;
int m_bottomSpace; int m_bottomSpace;
QMap<QString,QVariant> m_bookmarks; QMap<QString,QVariant> m_bookmarks;
int m_shiftItems;
}; };
class DataBandDesignIntf : public BandDesignIntf{ class DataBandDesignIntf : public BandDesignIntf{

View File

@ -52,6 +52,7 @@ namespace LimeReport {
namespace Const{ namespace Const{
int const DEFAULT_GRID_STEP = 1;
int const RESIZE_HANDLE_SIZE = 5; int const RESIZE_HANDLE_SIZE = 5;
int const SELECTION_PEN_SIZE = 1; int const SELECTION_PEN_SIZE = 1;
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE; int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;

View File

@ -83,8 +83,8 @@ PageDesignIntf::PageDesignIntf(QObject *parent):
m_executingGroupCommand(false), m_executingGroupCommand(false),
m_settings(0), m_settings(0),
m_selectionRect(0), m_selectionRect(0),
m_verticalGridStep(2), m_verticalGridStep(Const::DEFAULT_GRID_STEP),
m_horizontalGridStep(2), m_horizontalGridStep(Const::DEFAULT_GRID_STEP),
m_updating(false), m_updating(false),
m_currentObjectIndex(1), m_currentObjectIndex(1),
m_multiSelectStarted(false), m_multiSelectStarted(false),

View File

@ -1011,7 +1011,7 @@ void PageItemDesignIntf::setGridStep(int value)
int PageItemDesignIntf::gridStep() int PageItemDesignIntf::gridStep()
{ {
if (page()) return page()->horizontalGridStep(); if (page()) return page()->horizontalGridStep();
else return 2; else return Const::DEFAULT_GRID_STEP;
} }
void PageItemDesignIntf::objectLoadFinished() void PageItemDesignIntf::objectLoadFinished()

View File

@ -222,9 +222,9 @@ void PreviewReportWidget::lastPage()
void PreviewReportWidget::printPages(QPrinter* printer) void PreviewReportWidget::printPages(QPrinter* printer)
{ {
if (!d_ptr->m_reportPages.isEmpty()) if (!d_ptr->m_reportPages.isEmpty())
ReportEnginePrivate::printReport( d_ptr->m_report->printPages(
d_ptr->m_reportPages, d_ptr->m_reportPages,
*printer printer
); );
foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){ foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){
d_ptr->m_previewPage->reactivatePageItem(pageItem); d_ptr->m_previewPage->reactivatePageItem(pageItem);

View File

@ -820,8 +820,8 @@ void ReportDesignWidget::editSetting()
void ReportDesignWidget::applyUseGrid() void ReportDesignWidget::applyUseGrid()
{ {
int hGridStep = m_useGrid ? m_horizontalGridStep : 2; int hGridStep = m_useGrid ? m_horizontalGridStep : Const::DEFAULT_GRID_STEP;
int vGridStep = m_useGrid ? m_verticalGridStep : 2; int vGridStep = m_useGrid ? m_verticalGridStep : Const::DEFAULT_GRID_STEP;
for(int i = 0; i < m_report->pageCount(); ++i){ for(int i = 0; i < m_report->pageCount(); ++i){
m_report->pageAt(i)->setVerticalGridStep(hGridStep); m_report->pageAt(i)->setVerticalGridStep(hGridStep);
m_report->pageAt(i)->setHorizontalGridStep(vGridStep); m_report->pageAt(i)->setHorizontalGridStep(vGridStep);

View File

@ -264,62 +264,74 @@ void ReportEnginePrivate::clearReport()
emit cleared(); emit cleared();
} }
void ReportEnginePrivate::printReport(ItemsReaderIntf::Ptr reader, QPrinter& printer) bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
{ {
LimeReport::PageDesignIntf renderPage; if (!printer&&!m_printerSelected){
renderPage.setItemMode(PrintMode); QPrinterInfo pi;
if (reader->first()){ if (!pi.defaultPrinter().isNull())
reader->readItem(renderPage.pageItem()); #ifdef HAVE_QT4
printer.setFullPage(renderPage.pageItem()->fullPage()); m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation()); #endif
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect()); #ifdef HAVE_QT5
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected;
}
if (!printer&&!m_printerSelected) return false;
if (renderPage.pageItem()->pageSize()==PageItemDesignIntf::Custom){ printer =(printer)?printer:m_printer.data();
QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)? if (printer&&printer->isValid()){
QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()): try{
renderPage.pageItem()->sizeMM(); if (pages.count()>0){
printer.setPaperSize(pageSize,QPrinter::Millimeter); internalPrintPages(
} else { pages,
printer.setPaperSize((QPrinter::PageSize)renderPage.pageItem()->pageSize()); *printer
);
}
} catch(ReportError &exception){
saveError(exception.what());
}
return true;
} else return false;
} }
QPainter painter(&printer); void ReportEnginePrivate::internalPrintPages(ReportPages pages, QPrinter &printer)
renderPage.render(&painter);
while (reader->next()){
printer.newPage();
renderPage.removeAllItems();
reader->readItem(renderPage.pageItem());
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
renderPage.render(&painter);
}
}
}
void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer)
{ {
m_cancelPrinting = false;
int currenPage = 1; int currenPage = 1;
QMap<QString, QSharedPointer<PrintProcessor>> printProcessors; QMap<QString, QSharedPointer<PrintProcessor>> printProcessors;
printProcessors.insert("default",QSharedPointer<PrintProcessor>(new PrintProcessor(&printer))); printProcessors.insert("default",QSharedPointer<PrintProcessor>(new PrintProcessor(&printer)));
emit printingStarted(printer.toPage() - printer.fromPage());
foreach(PageItemDesignIntf::Ptr page, pages){ foreach(PageItemDesignIntf::Ptr page, pages){
if ( if ( !m_cancelPrinting &&
(printer.printRange() == QPrinter::AllPages) || ((printer.printRange() == QPrinter::AllPages) ||
( (printer.printRange()==QPrinter::PageRange) && ( (printer.printRange()==QPrinter::PageRange) &&
(currenPage>=printer.fromPage()) && (currenPage>=printer.fromPage()) &&
(currenPage<=printer.toPage()) (currenPage<=printer.toPage())
) ))
) )
{ {
printProcessors["default"]->printPage(page); printProcessors["default"]->printPage(page);
}
currenPage++; currenPage++;
} emit pagePrintingFinished(currenPage);
QApplication::processEvents();
} }
void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*> printers, bool printToAllPrinters)
}
emit printingFinished();
}
void ReportEnginePrivate::printPages(ReportPages pages, QMap<QString, QPrinter*> printers, bool printToAllPrinters)
{ {
if (printers.values().isEmpty()) return; if (printers.values().isEmpty()) return;
int currenPage = 1; m_cancelPrinting = false;
QMap<QString, QSharedPointer<PrintProcessor>> printProcessors; QMap<QString, QSharedPointer<PrintProcessor>> printProcessors;
for (int i = 0; i < printers.keys().count(); ++i) { for (int i = 0; i < printers.keys().count(); ++i) {
printProcessors.insert(printers.keys()[i],QSharedPointer<PrintProcessor>(new PrintProcessor(printers[printers.keys()[i]]))); printProcessors.insert(printers.keys()[i],QSharedPointer<PrintProcessor>(new PrintProcessor(printers[printers.keys()[i]])));
@ -329,7 +341,12 @@ void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*
int currentPrinter = 0; int currentPrinter = 0;
if (printProcessors.contains("default")) defaultProcessor = printProcessors["default"].data(); if (printProcessors.contains("default")) defaultProcessor = printProcessors["default"].data();
else defaultProcessor = printProcessors.values().at(0).data(); else defaultProcessor = printProcessors.values().at(0).data();
foreach(PageItemDesignIntf::Ptr page, pages){
emit printingStarted(pages.size());
for(int i = 0; i < pages.size(); ++i){
if (m_cancelPrinting) break;
PageItemDesignIntf::Ptr page = pages.at(i);
if (!printToAllPrinters){ if (!printToAllPrinters){
if (printProcessors.contains(page->printerName())) if (printProcessors.contains(page->printerName()))
printProcessors[page->printerName()]->printPage(page); printProcessors[page->printerName()]->printPage(page);
@ -340,9 +357,11 @@ void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*
currentPrinter++; currentPrinter++;
else currentPrinter = 0; else currentPrinter = 0;
} }
emit pagePrintingFinished(i+1);
currenPage++; QApplication::processEvents();
} }
emit printingFinished();
} }
QStringList ReportEnginePrivate::aviableReportTranslations() QStringList ReportEnginePrivate::aviableReportTranslations()
@ -391,7 +410,7 @@ bool ReportEnginePrivate::printReport(QPrinter* printer)
ReportPages pages = renderToPages(); ReportPages pages = renderToPages();
dataManager()->setDesignTime(designTime); dataManager()->setDesignTime(designTime);
if (pages.count()>0){ if (pages.count()>0){
printReport(pages,*printer); internalPrintPages(pages, *printer);
} }
} catch(ReportError &exception){ } catch(ReportError &exception){
saveError(exception.what()); saveError(exception.what());
@ -408,7 +427,7 @@ bool ReportEnginePrivate::printReport(QMap<QString, QPrinter*> printers, bool pr
ReportPages pages = renderToPages(); ReportPages pages = renderToPages();
dataManager()->setDesignTime(designTime); dataManager()->setDesignTime(designTime);
if (pages.count()>0){ if (pages.count()>0){
printReport(pages, printers, printToAllPrinters); printPages(pages, printers, printToAllPrinters);
} }
} catch(ReportError &exception){ } catch(ReportError &exception){
saveError(exception.what()); saveError(exception.what());
@ -417,42 +436,6 @@ bool ReportEnginePrivate::printReport(QMap<QString, QPrinter*> printers, bool pr
return true; return true;
} }
bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
{
if (!printer&&!m_printerSelected){
QPrinterInfo pi;
if (!pi.defaultPrinter().isNull())
#ifdef HAVE_QT4
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#ifdef HAVE_QT5
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
m_printer.data()->setPrinterName(pi.defaultPrinterName());
#else
m_printer.data()->setPrinterName(pi.defaultPrinter().printerName());
#endif
#endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected;
}
if (!printer&&!m_printerSelected) return false;
printer =(printer)?printer:m_printer.data();
if (printer&&printer->isValid()){
try{
if (pages.count()>0){
printReport(
pages,
*printer
);
}
} catch(ReportError &exception){
saveError(exception.what());
}
return true;
} else return false;
}
void ReportEnginePrivate::printToFile(const QString &fileName) void ReportEnginePrivate::printToFile(const QString &fileName)
{ {
if (!fileName.isEmpty()){ if (!fileName.isEmpty()){
@ -739,6 +722,11 @@ void ReportEnginePrivate::cancelRender()
m_reportRendering = false; m_reportRendering = false;
} }
void ReportEnginePrivate::cancelPrinting()
{
m_cancelPrinting = true;
}
QGraphicsScene* ReportEngine::createPreviewScene(QObject* parent){ QGraphicsScene* ReportEngine::createPreviewScene(QObject* parent){
Q_D(ReportEngine); Q_D(ReportEngine);
return d->createPreviewScene(parent); return d->createPreviewScene(parent);
@ -1387,6 +1375,12 @@ ReportEngine::ReportEngine(QObject *parent)
connect(d, SIGNAL(renderPageFinished(int)), connect(d, SIGNAL(renderPageFinished(int)),
this, SIGNAL(renderPageFinished(int))); this, SIGNAL(renderPageFinished(int)));
connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished())); connect(d, SIGNAL(renderFinished()), this, SIGNAL(renderFinished()));
connect(d, SIGNAL(printingStarted(int)), this, SIGNAL(printingStarted(int)));
connect(d, SIGNAL(pagePrintingFinished(int)),
this, SIGNAL(pagePrintingFinished(int)));
connect(d, SIGNAL(printingFinished()), this, SIGNAL(printingFinished()));
connect(d, SIGNAL(onSave(bool&)), this, SIGNAL(onSave(bool&))); connect(d, SIGNAL(onSave(bool&)), this, SIGNAL(onSave(bool&)));
connect(d, SIGNAL(onSaveAs(bool&)), this, SIGNAL(onSaveAs(bool&))); connect(d, SIGNAL(onSaveAs(bool&)), this, SIGNAL(onSaveAs(bool&)));
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&))); connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
@ -1766,21 +1760,21 @@ ScriptEngineManager*LimeReport::ReportEnginePrivate::scriptManager(){
PrintProcessor::PrintProcessor(QPrinter* printer) PrintProcessor::PrintProcessor(QPrinter* printer)
: m_printer(printer), m_painter(0), m_firstPage(true) : m_printer(printer), m_painter(0), m_firstPage(true)
{} {m_renderPage.setItemMode(PrintMode);}
bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page) bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
{ {
if (!m_firstPage && !m_painter->isActive()) return false; if (!m_firstPage && !m_painter->isActive()) return false;
LimeReport::PageDesignIntf renderPage; //LimeReport::PageDesignIntf m_renderPage;
renderPage.setItemMode(PrintMode); //m_renderPage.setItemMode(PrintMode);
QPointF backupPagePos = page->pos(); QPointF backupPagePos = page->pos();
page->setPos(0,0); page->setPos(0,0);
renderPage.setPageItem(page); m_renderPage.setPageItem(page);
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect()); m_renderPage.setSceneRect(m_renderPage.pageItem()->mapToScene(m_renderPage.pageItem()->rect()).boundingRect());
initPrinter(renderPage.pageItem()); initPrinter(m_renderPage.pageItem());
if (!m_firstPage){ if (!m_firstPage){
m_printer->newPage(); m_printer->newPage();
@ -1809,7 +1803,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
while (pageHeight > 0){ while (pageHeight > 0){
while (curWidth < pageWidth){ while (curWidth < pageWidth){
if (!first) m_printer->newPage(); else first = false; if (!first) m_printer->newPage(); else first = false;
renderPage.render(m_painter, m_printer->pageRect(), currentPrintingRect); m_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);
curWidth += printerPageRect.size().width(); curWidth += printerPageRect.size().width();
@ -1822,7 +1816,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
} }
} else { } else {
renderPage.render(m_painter); m_renderPage.render(m_painter);
} }
page->setPos(backupPagePos); page->setPos(backupPagePos);
return true; return true;

View File

@ -212,6 +212,11 @@ signals:
void renderStarted(); void renderStarted();
void renderFinished(); void renderFinished();
void renderPageFinished(int renderedPageCount); void renderPageFinished(int renderedPageCount);
void printingStarted(int pageCount);
void printingFinished();
void pagePrintingFinished(int index);
void onSave(bool& saved); void onSave(bool& saved);
void onSaveAs(bool& saved); void onSaveAs(bool& saved);
void onLoad(bool& loaded); void onLoad(bool& loaded);

View File

@ -122,6 +122,7 @@ private:
private: private:
QPrinter* m_printer; QPrinter* m_printer;
QPainter* m_painter; QPainter* m_painter;
LimeReport::PageDesignIntf m_renderPage;
bool m_firstPage; bool m_firstPage;
}; };
@ -141,9 +142,8 @@ class ReportEnginePrivate : public QObject,
friend class PreviewReportWidget; friend class PreviewReportWidget;
public: public:
static void printReport(ItemsReaderIntf::Ptr reader, QPrinter &printer); bool printPages(ReportPages pages, QPrinter *printer);
static void printReport(ReportPages pages, QPrinter &printer); void printPages(ReportPages pages, QMap<QString,QPrinter*>printers, bool printToAllPrinters = false);
static void printReport(ReportPages pages, QMap<QString,QPrinter*>printers, bool printToAllPrinters = false);
Q_INVOKABLE QStringList aviableReportTranslations(); Q_INVOKABLE QStringList aviableReportTranslations();
Q_INVOKABLE void setReportTranslation(const QString& languageName); Q_INVOKABLE void setReportTranslation(const QString& languageName);
public: public:
@ -168,7 +168,7 @@ public:
void clearReport(); void clearReport();
bool printReport(QPrinter* printer=0); bool printReport(QPrinter* printer=0);
bool printReport(QMap<QString, QPrinter*>printers, bool printToAllPrinters); bool printReport(QMap<QString, QPrinter*>printers, bool printToAllPrinters);
bool printPages(ReportPages pages, QPrinter *printer);
void printToFile(const QString& fileName); void printToFile(const QString& fileName);
bool printToPDF(const QString& fileName); bool printToPDF(const QString& fileName);
bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>()); bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
@ -268,13 +268,18 @@ signals:
void currentDefaultDesignerLanguageChanged(QLocale::Language); void currentDefaultDesignerLanguageChanged(QLocale::Language);
QLocale::Language getCurrentDefaultDesignerLanguage(); QLocale::Language getCurrentDefaultDesignerLanguage();
void externalPaint(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*); void externalPaint(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*);
void printingStarted(int pageCount);
void printingFinished();
void pagePrintingFinished(int index);
public slots: public slots:
bool slotLoadFromFile(const QString& fileName); bool slotLoadFromFile(const QString& fileName);
void cancelRender(); void cancelRender();
void cancelPrinting();
protected: protected:
PageDesignIntf* createPage(const QString& pageName="", bool preview = false); PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer); bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer);
void internalPrintPages(ReportPages pages, QPrinter &printer);
protected slots: protected slots:
void slotDataSourceCollectionLoaded(const QString& collectionName); void slotDataSourceCollectionLoaded(const QString& collectionName);
private slots: private slots:
@ -344,6 +349,7 @@ private:
bool m_saveToFileVisible; bool m_saveToFileVisible;
bool m_printToPdfVisible; bool m_printToPdfVisible;
bool m_printVisible; bool m_printVisible;
bool m_cancelPrinting;
}; };
} }