mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 00:33:02 +03:00
Finish 1.5.14
This commit is contained in:
commit
1c7a06a410
@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
|
||||
|
||||
LIMEREPORT_VERSION_MAJOR = 1
|
||||
LIMEREPORT_VERSION_MINOR = 5
|
||||
LIMEREPORT_VERSION_RELEASE = 13
|
||||
LIMEREPORT_VERSION_RELEASE = 14
|
||||
|
||||
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
|
||||
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
|
||||
|
@ -52,6 +52,7 @@ namespace LimeReport {
|
||||
|
||||
|
||||
namespace Const{
|
||||
int const DEFAULT_GRID_STEP = 1;
|
||||
int const RESIZE_HANDLE_SIZE = 5;
|
||||
int const SELECTION_PEN_SIZE = 1;
|
||||
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
|
||||
|
@ -212,6 +212,11 @@ signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
void renderPageFinished(int renderedPageCount);
|
||||
|
||||
void printingStarted(int pageCount);
|
||||
void printingFinished();
|
||||
void pagePrintingFinished(int index);
|
||||
|
||||
void onSave(bool& saved);
|
||||
void onSaveAs(bool& saved);
|
||||
void onLoad(bool& loaded);
|
||||
|
@ -27,7 +27,7 @@ bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const
|
||||
printer.setOutputFileName(fileName);
|
||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||
if (!pages.isEmpty()){
|
||||
m_reportEngine->printReport(pages, printer);
|
||||
m_reportEngine->printPages(pages, &printer);
|
||||
}
|
||||
m_reportEngine->emitPrintedToPDF(fileName);
|
||||
return true;
|
||||
|
@ -166,7 +166,8 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
|
||||
m_printAlways(false),
|
||||
m_repeatOnEachRow(false),
|
||||
m_useAlternateBackgroundColor(false),
|
||||
m_bottomSpace(0)
|
||||
m_bottomSpace(0),
|
||||
m_shiftItems(0)
|
||||
{
|
||||
setPossibleResizeDirectionFlags(ResizeBottom);
|
||||
setPossibleMoveFlags(TopBotom);
|
||||
@ -277,6 +278,11 @@ void BandDesignIntf::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
BaseDesignIntf::paint(painter,option,widget);
|
||||
}
|
||||
|
||||
QRectF BandDesignIntf::boundingRect() const
|
||||
{
|
||||
return ItemsContainerDesignInft::boundingRect().adjusted(0,-4,0,4);
|
||||
}
|
||||
|
||||
void BandDesignIntf::translateBandsName()
|
||||
{
|
||||
tr("DataBand");
|
||||
@ -582,14 +588,14 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu)
|
||||
currAction->setCheckable(true);
|
||||
currAction->setChecked(isSplittable());
|
||||
|
||||
currAction = menu.addAction(tr("Keep bottom space"));
|
||||
currAction->setCheckable(true);
|
||||
currAction->setChecked(keepBottomSpace());
|
||||
|
||||
currAction = menu.addAction(tr("Keep top space"));
|
||||
currAction->setCheckable(true);
|
||||
currAction->setChecked(keepTopSpace());
|
||||
|
||||
currAction = menu.addAction(tr("Keep bottom space"));
|
||||
currAction->setCheckable(true);
|
||||
currAction->setChecked(keepBottomSpace());
|
||||
|
||||
currAction = menu.addAction(tr("Print if empty"));
|
||||
currAction->setCheckable(true);
|
||||
currAction->setChecked(printIfEmpty());
|
||||
@ -599,20 +605,26 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu)
|
||||
void BandDesignIntf::processPopUpAction(QAction *action)
|
||||
{
|
||||
if (action->text().compare(tr("Auto height")) == 0){
|
||||
setProperty("autoHeight",action->isChecked());
|
||||
setProperty("autoHeight", action->isChecked());
|
||||
}
|
||||
|
||||
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){
|
||||
setProperty("keepBottomSpace",action->isChecked());
|
||||
setProperty("keepBottomSpace", action->isChecked());
|
||||
}
|
||||
if (action->text().compare(tr("Keep top space")) == 0){
|
||||
setProperty("keepTopSpace",action->isChecked());
|
||||
}
|
||||
|
||||
if (action->text().compare(tr("Print if empty")) == 0){
|
||||
setProperty("printIfEmpty",action->isChecked());
|
||||
setProperty("printIfEmpty", action->isChecked());
|
||||
}
|
||||
ItemsContainerDesignInft::processPopUpAction(action);
|
||||
}
|
||||
@ -910,6 +922,16 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin
|
||||
m_bandNameLabel->updateLabel(newName);
|
||||
}
|
||||
|
||||
int BandDesignIntf::shiftItems() const
|
||||
{
|
||||
return m_shiftItems;
|
||||
}
|
||||
|
||||
void BandDesignIntf::setShiftItems(int shiftItems)
|
||||
{
|
||||
m_shiftItems = shiftItems;
|
||||
}
|
||||
|
||||
bool BandDesignIntf::keepTopSpace() const
|
||||
{
|
||||
return m_keepTopSpace;
|
||||
@ -1112,7 +1134,7 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p
|
||||
arrangeSubItems(pass, dataManager);
|
||||
if (autoHeight()){
|
||||
if (!keepTopSpace()) {
|
||||
qreal minTop = findMinTop() - spaceBorder;
|
||||
qreal minTop = findMinTop() + m_shiftItems;
|
||||
foreach (BaseDesignIntf* item, childBaseItems()) {
|
||||
item->setY(item->y() - minTop);
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ class BandDesignIntf : public ItemsContainerDesignInft
|
||||
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
|
||||
Q_PROPERTY(BGMode backgroundMode READ backgroundMode WRITE setBackgroundModeProperty)
|
||||
Q_PROPERTY(int backgroundOpacity READ opacity WRITE setBackgroundOpacity)
|
||||
Q_PROPERTY(int shiftItems READ shiftItems WRITE setShiftItems)
|
||||
Q_ENUMS(BandColumnsLayoutType)
|
||||
friend class BandMarker;
|
||||
friend class BandNameLabel;
|
||||
@ -142,6 +143,7 @@ public:
|
||||
~BandDesignIntf();
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
QRectF boundingRect() const;
|
||||
void translateBandsName();
|
||||
virtual BandsType bandType() const;
|
||||
virtual QString bandTitle() const;
|
||||
@ -260,6 +262,8 @@ public:
|
||||
int bootomSpace() const;
|
||||
void setBootomSpace(int bootomSpace);
|
||||
void updateBandMarkerGeometry();
|
||||
int shiftItems() const;
|
||||
void setShiftItems(int shiftItems);
|
||||
|
||||
signals:
|
||||
void bandRendered(BandDesignIntf* band);
|
||||
@ -323,6 +327,7 @@ private:
|
||||
bool m_useAlternateBackgroundColor;
|
||||
int m_bottomSpace;
|
||||
QMap<QString,QVariant> m_bookmarks;
|
||||
int m_shiftItems;
|
||||
};
|
||||
|
||||
class DataBandDesignIntf : public BandDesignIntf{
|
||||
|
@ -52,6 +52,7 @@ namespace LimeReport {
|
||||
|
||||
|
||||
namespace Const{
|
||||
int const DEFAULT_GRID_STEP = 1;
|
||||
int const RESIZE_HANDLE_SIZE = 5;
|
||||
int const SELECTION_PEN_SIZE = 1;
|
||||
int const MINIMUM_ITEM_WIDTH = 2*RESIZE_HANDLE_SIZE;
|
||||
|
@ -83,8 +83,8 @@ PageDesignIntf::PageDesignIntf(QObject *parent):
|
||||
m_executingGroupCommand(false),
|
||||
m_settings(0),
|
||||
m_selectionRect(0),
|
||||
m_verticalGridStep(2),
|
||||
m_horizontalGridStep(2),
|
||||
m_verticalGridStep(Const::DEFAULT_GRID_STEP),
|
||||
m_horizontalGridStep(Const::DEFAULT_GRID_STEP),
|
||||
m_updating(false),
|
||||
m_currentObjectIndex(1),
|
||||
m_multiSelectStarted(false),
|
||||
|
@ -1011,7 +1011,7 @@ void PageItemDesignIntf::setGridStep(int value)
|
||||
int PageItemDesignIntf::gridStep()
|
||||
{
|
||||
if (page()) return page()->horizontalGridStep();
|
||||
else return 2;
|
||||
else return Const::DEFAULT_GRID_STEP;
|
||||
}
|
||||
|
||||
void PageItemDesignIntf::objectLoadFinished()
|
||||
|
@ -222,9 +222,9 @@ void PreviewReportWidget::lastPage()
|
||||
void PreviewReportWidget::printPages(QPrinter* printer)
|
||||
{
|
||||
if (!d_ptr->m_reportPages.isEmpty())
|
||||
ReportEnginePrivate::printReport(
|
||||
d_ptr->m_report->printPages(
|
||||
d_ptr->m_reportPages,
|
||||
*printer
|
||||
printer
|
||||
);
|
||||
foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){
|
||||
d_ptr->m_previewPage->reactivatePageItem(pageItem);
|
||||
|
@ -820,8 +820,8 @@ void ReportDesignWidget::editSetting()
|
||||
|
||||
void ReportDesignWidget::applyUseGrid()
|
||||
{
|
||||
int hGridStep = m_useGrid ? m_horizontalGridStep : 2;
|
||||
int vGridStep = m_useGrid ? m_verticalGridStep : 2;
|
||||
int hGridStep = m_useGrid ? m_horizontalGridStep : Const::DEFAULT_GRID_STEP;
|
||||
int vGridStep = m_useGrid ? m_verticalGridStep : Const::DEFAULT_GRID_STEP;
|
||||
for(int i = 0; i < m_report->pageCount(); ++i){
|
||||
m_report->pageAt(i)->setVerticalGridStep(hGridStep);
|
||||
m_report->pageAt(i)->setHorizontalGridStep(vGridStep);
|
||||
|
@ -264,63 +264,75 @@ void ReportEnginePrivate::clearReport()
|
||||
emit cleared();
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::printReport(ItemsReaderIntf::Ptr reader, QPrinter& printer)
|
||||
bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
|
||||
{
|
||||
LimeReport::PageDesignIntf renderPage;
|
||||
renderPage.setItemMode(PrintMode);
|
||||
if (reader->first()){
|
||||
reader->readItem(renderPage.pageItem());
|
||||
printer.setFullPage(renderPage.pageItem()->fullPage());
|
||||
printer.setOrientation((QPrinter::Orientation)renderPage.pageItem()->pageOrientation());
|
||||
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
|
||||
|
||||
if (renderPage.pageItem()->pageSize()==PageItemDesignIntf::Custom){
|
||||
QSizeF pageSize = (renderPage.pageItem()->pageOrientation()==PageItemDesignIntf::Landscape)?
|
||||
QSizeF(renderPage.pageItem()->sizeMM().height(),renderPage.pageItem()->sizeMM().width()):
|
||||
renderPage.pageItem()->sizeMM();
|
||||
printer.setPaperSize(pageSize,QPrinter::Millimeter);
|
||||
} else {
|
||||
printer.setPaperSize((QPrinter::PageSize)renderPage.pageItem()->pageSize());
|
||||
}
|
||||
|
||||
QPainter painter(&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);
|
||||
}
|
||||
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){
|
||||
internalPrintPages(
|
||||
pages,
|
||||
*printer
|
||||
);
|
||||
}
|
||||
} catch(ReportError &exception){
|
||||
saveError(exception.what());
|
||||
}
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer)
|
||||
void ReportEnginePrivate::internalPrintPages(ReportPages pages, QPrinter &printer)
|
||||
{
|
||||
m_cancelPrinting = false;
|
||||
int currenPage = 1;
|
||||
QMap<QString, QSharedPointer<PrintProcessor> > printProcessors;
|
||||
printProcessors.insert("default",QSharedPointer<PrintProcessor>(new PrintProcessor(&printer)));
|
||||
emit printingStarted(printer.toPage() - printer.fromPage());
|
||||
foreach(PageItemDesignIntf::Ptr page, pages){
|
||||
if (
|
||||
(printer.printRange() == QPrinter::AllPages) ||
|
||||
if ( !m_cancelPrinting &&
|
||||
((printer.printRange() == QPrinter::AllPages) ||
|
||||
( (printer.printRange()==QPrinter::PageRange) &&
|
||||
(currenPage>=printer.fromPage()) &&
|
||||
(currenPage<=printer.toPage())
|
||||
)
|
||||
))
|
||||
)
|
||||
{
|
||||
printProcessors["default"]->printPage(page);
|
||||
currenPage++;
|
||||
emit pagePrintingFinished(currenPage);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
currenPage++;
|
||||
|
||||
|
||||
}
|
||||
emit printingFinished();
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*> printers, bool printToAllPrinters)
|
||||
void ReportEnginePrivate::printPages(ReportPages pages, QMap<QString, QPrinter*> printers, bool printToAllPrinters)
|
||||
{
|
||||
if (printers.values().isEmpty()) return;
|
||||
int currenPage = 1;
|
||||
QMap<QString, QSharedPointer<PrintProcessor> > printProcessors;
|
||||
m_cancelPrinting = false;
|
||||
|
||||
QMap<QString, QSharedPointer<PrintProcessor>> printProcessors;
|
||||
for (int i = 0; i < printers.keys().count(); ++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;
|
||||
if (printProcessors.contains("default")) defaultProcessor = printProcessors["default"].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 (printProcessors.contains(page->printerName()))
|
||||
printProcessors[page->printerName()]->printPage(page);
|
||||
@ -340,9 +357,11 @@ void ReportEnginePrivate::printReport(ReportPages pages, QMap<QString, QPrinter*
|
||||
currentPrinter++;
|
||||
else currentPrinter = 0;
|
||||
}
|
||||
|
||||
currenPage++;
|
||||
emit pagePrintingFinished(i+1);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
emit printingFinished();
|
||||
}
|
||||
|
||||
QStringList ReportEnginePrivate::aviableReportTranslations()
|
||||
@ -391,7 +410,7 @@ bool ReportEnginePrivate::printReport(QPrinter* printer)
|
||||
ReportPages pages = renderToPages();
|
||||
dataManager()->setDesignTime(designTime);
|
||||
if (pages.count()>0){
|
||||
printReport(pages,*printer);
|
||||
internalPrintPages(pages, *printer);
|
||||
}
|
||||
} catch(ReportError &exception){
|
||||
saveError(exception.what());
|
||||
@ -408,7 +427,7 @@ bool ReportEnginePrivate::printReport(QMap<QString, QPrinter*> printers, bool pr
|
||||
ReportPages pages = renderToPages();
|
||||
dataManager()->setDesignTime(designTime);
|
||||
if (pages.count()>0){
|
||||
printReport(pages, printers, printToAllPrinters);
|
||||
printPages(pages, printers, printToAllPrinters);
|
||||
}
|
||||
} catch(ReportError &exception){
|
||||
saveError(exception.what());
|
||||
@ -417,42 +436,6 @@ bool ReportEnginePrivate::printReport(QMap<QString, QPrinter*> printers, bool pr
|
||||
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)
|
||||
{
|
||||
if (!fileName.isEmpty()){
|
||||
@ -739,6 +722,11 @@ void ReportEnginePrivate::cancelRender()
|
||||
m_reportRendering = false;
|
||||
}
|
||||
|
||||
void ReportEnginePrivate::cancelPrinting()
|
||||
{
|
||||
m_cancelPrinting = true;
|
||||
}
|
||||
|
||||
QGraphicsScene* ReportEngine::createPreviewScene(QObject* parent){
|
||||
Q_D(ReportEngine);
|
||||
return d->createPreviewScene(parent);
|
||||
@ -1387,6 +1375,12 @@ ReportEngine::ReportEngine(QObject *parent)
|
||||
connect(d, SIGNAL(renderPageFinished(int)),
|
||||
this, SIGNAL(renderPageFinished(int)));
|
||||
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(onSaveAs(bool&)), this, SIGNAL(onSaveAs(bool&)));
|
||||
connect(d, SIGNAL(onLoad(bool&)), this, SIGNAL(onLoad(bool&)));
|
||||
@ -1766,21 +1760,21 @@ ScriptEngineManager*LimeReport::ReportEnginePrivate::scriptManager(){
|
||||
|
||||
PrintProcessor::PrintProcessor(QPrinter* printer)
|
||||
: m_printer(printer), m_painter(0), m_firstPage(true)
|
||||
{}
|
||||
{m_renderPage.setItemMode(PrintMode);}
|
||||
|
||||
|
||||
bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
|
||||
{
|
||||
if (!m_firstPage && !m_painter->isActive()) return false;
|
||||
|
||||
LimeReport::PageDesignIntf renderPage;
|
||||
renderPage.setItemMode(PrintMode);
|
||||
//LimeReport::PageDesignIntf m_renderPage;
|
||||
//m_renderPage.setItemMode(PrintMode);
|
||||
|
||||
QPointF backupPagePos = page->pos();
|
||||
page->setPos(0,0);
|
||||
renderPage.setPageItem(page);
|
||||
renderPage.setSceneRect(renderPage.pageItem()->mapToScene(renderPage.pageItem()->rect()).boundingRect());
|
||||
initPrinter(renderPage.pageItem());
|
||||
m_renderPage.setPageItem(page);
|
||||
m_renderPage.setSceneRect(m_renderPage.pageItem()->mapToScene(m_renderPage.pageItem()->rect()).boundingRect());
|
||||
initPrinter(m_renderPage.pageItem());
|
||||
|
||||
if (!m_firstPage){
|
||||
m_printer->newPage();
|
||||
@ -1809,7 +1803,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
|
||||
while (pageHeight > 0){
|
||||
while (curWidth < pageWidth){
|
||||
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);
|
||||
curWidth += printerPageRect.size().width();
|
||||
|
||||
@ -1822,7 +1816,7 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page)
|
||||
}
|
||||
|
||||
} else {
|
||||
renderPage.render(m_painter);
|
||||
m_renderPage.render(m_painter);
|
||||
}
|
||||
page->setPos(backupPagePos);
|
||||
return true;
|
||||
|
@ -212,6 +212,11 @@ signals:
|
||||
void renderStarted();
|
||||
void renderFinished();
|
||||
void renderPageFinished(int renderedPageCount);
|
||||
|
||||
void printingStarted(int pageCount);
|
||||
void printingFinished();
|
||||
void pagePrintingFinished(int index);
|
||||
|
||||
void onSave(bool& saved);
|
||||
void onSaveAs(bool& saved);
|
||||
void onLoad(bool& loaded);
|
||||
|
@ -122,6 +122,7 @@ private:
|
||||
private:
|
||||
QPrinter* m_printer;
|
||||
QPainter* m_painter;
|
||||
LimeReport::PageDesignIntf m_renderPage;
|
||||
bool m_firstPage;
|
||||
};
|
||||
|
||||
@ -141,9 +142,8 @@ class ReportEnginePrivate : public QObject,
|
||||
|
||||
friend class PreviewReportWidget;
|
||||
public:
|
||||
static void printReport(ItemsReaderIntf::Ptr reader, QPrinter &printer);
|
||||
static void printReport(ReportPages pages, QPrinter &printer);
|
||||
static void printReport(ReportPages pages, QMap<QString,QPrinter*>printers, bool printToAllPrinters = false);
|
||||
bool printPages(ReportPages pages, QPrinter *printer);
|
||||
void printPages(ReportPages pages, QMap<QString,QPrinter*>printers, bool printToAllPrinters = false);
|
||||
Q_INVOKABLE QStringList aviableReportTranslations();
|
||||
Q_INVOKABLE void setReportTranslation(const QString& languageName);
|
||||
public:
|
||||
@ -168,7 +168,7 @@ public:
|
||||
void clearReport();
|
||||
bool printReport(QPrinter* printer=0);
|
||||
bool printReport(QMap<QString, QPrinter*>printers, bool printToAllPrinters);
|
||||
bool printPages(ReportPages pages, QPrinter *printer);
|
||||
|
||||
void printToFile(const QString& fileName);
|
||||
bool printToPDF(const QString& fileName);
|
||||
bool exportReport(QString exporterName, const QString &fileName = "", const QMap<QString, QVariant>& params = QMap<QString, QVariant>());
|
||||
@ -268,13 +268,18 @@ signals:
|
||||
void currentDefaultDesignerLanguageChanged(QLocale::Language);
|
||||
QLocale::Language getCurrentDefaultDesignerLanguage();
|
||||
void externalPaint(const QString& objectName, QPainter* painter, const QStyleOptionGraphicsItem*);
|
||||
void printingStarted(int pageCount);
|
||||
void printingFinished();
|
||||
void pagePrintingFinished(int index);
|
||||
|
||||
public slots:
|
||||
bool slotLoadFromFile(const QString& fileName);
|
||||
void cancelRender();
|
||||
void cancelPrinting();
|
||||
protected:
|
||||
PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
|
||||
bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer);
|
||||
void internalPrintPages(ReportPages pages, QPrinter &printer);
|
||||
protected slots:
|
||||
void slotDataSourceCollectionLoaded(const QString& collectionName);
|
||||
private slots:
|
||||
@ -344,6 +349,7 @@ private:
|
||||
bool m_saveToFileVisible;
|
||||
bool m_printToPdfVisible;
|
||||
bool m_printVisible;
|
||||
bool m_cancelPrinting;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -189,11 +189,46 @@ void ReportRender::initDatasource(const QString& name){
|
||||
}
|
||||
}
|
||||
|
||||
void ReportRender::analizeItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
||||
if (contentItem){
|
||||
QString content = contentItem->content();
|
||||
QVector<QString> functions;
|
||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setMinimal(true);
|
||||
if (rx.indexIn(content)>=0){
|
||||
functions.append(functionName);
|
||||
}
|
||||
}
|
||||
if (functions.size()>0)
|
||||
m_groupfunctionItems.insert(contentItem->patternName(), functions);
|
||||
}
|
||||
}
|
||||
|
||||
void ReportRender::analizeContainer(BaseDesignIntf* item, BandDesignIntf* band){
|
||||
foreach(BaseDesignIntf* child, item->childBaseItems()){
|
||||
ContentItemDesignIntf* contentItem = dynamic_cast<ContentItemDesignIntf*>(child);
|
||||
if (contentItem) analizeItem(contentItem, band);
|
||||
else analizeContainer(child, band);
|
||||
}
|
||||
}
|
||||
|
||||
void ReportRender::analizePage(PageItemDesignIntf* patternPage){
|
||||
m_groupfunctionItems.clear();
|
||||
foreach(BandDesignIntf* band, patternPage->bands()){
|
||||
if (band->isFooter() || band->isHeader()){
|
||||
analizeContainer(band,band);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool /*isFirst*/, bool /*resetPageNumbers*/)
|
||||
{
|
||||
m_currentNameIndex = 0;
|
||||
m_patternPageItem = patternPage;
|
||||
|
||||
analizePage(patternPage);
|
||||
|
||||
if (m_patternPageItem->resetPageNumber() && m_pageCount>0 && !isTOC) {
|
||||
resetPageNumber(PageReset);
|
||||
}
|
||||
@ -380,33 +415,34 @@ void ReportRender::extractGroupFunctions(BandDesignIntf *band)
|
||||
extractGroupFunctionsFromContainer(band, band);
|
||||
}
|
||||
|
||||
|
||||
void ReportRender::replaceGroupFunctionsInItem(ContentItemDesignIntf* contentItem, BandDesignIntf* band){
|
||||
if (contentItem){
|
||||
QString content = contentItem->content();
|
||||
foreach(const QString &functionName, m_datasources->groupFunctionNames()){
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setMinimal(true);
|
||||
if (rx.indexIn(content)>=0){
|
||||
int pos = 0;
|
||||
while ( (pos = rx.indexIn(content,pos))!= -1 ){
|
||||
QVector<QString> captures = normalizeCaptures(rx);
|
||||
if (captures.size() >= 3){
|
||||
QString expressionIndex = datasources()->putGroupFunctionsExpressions(captures.at(Const::VALUE_INDEX));
|
||||
if (captures.size()<5){
|
||||
content.replace(captures.at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"'));
|
||||
} else {
|
||||
content.replace(captures.at(0),QString("%1(%2,%3,%4)")
|
||||
.arg(functionName)
|
||||
.arg('"'+expressionIndex+'"')
|
||||
.arg('"'+band->objectName()+'"')
|
||||
.arg(captures.at(4)));
|
||||
if (m_groupfunctionItems.contains(contentItem->patternName())){
|
||||
QString content = contentItem->content();
|
||||
foreach(QString functionName, m_groupfunctionItems.value(contentItem->patternName())){
|
||||
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
|
||||
rx.setMinimal(true);
|
||||
if (rx.indexIn(content)>=0){
|
||||
int pos = 0;
|
||||
while ( (pos = rx.indexIn(content,pos))!= -1 ){
|
||||
QVector<QString> captures = normalizeCaptures(rx);
|
||||
if (captures.size() >= 3){
|
||||
QString expressionIndex = datasources()->putGroupFunctionsExpressions(captures.at(Const::VALUE_INDEX));
|
||||
if (captures.size()<5){
|
||||
content.replace(captures.at(0),QString("%1(%2,%3)").arg(functionName).arg('"'+expressionIndex+'"').arg('"'+band->objectName()+'"'));
|
||||
} else {
|
||||
content.replace(captures.at(0),QString("%1(%2,%3,%4)")
|
||||
.arg(functionName)
|
||||
.arg('"'+expressionIndex+'"')
|
||||
.arg('"'+band->objectName()+'"')
|
||||
.arg(captures.at(4)));
|
||||
}
|
||||
}
|
||||
pos += rx.matchedLength();
|
||||
}
|
||||
pos += rx.matchedLength();
|
||||
}
|
||||
contentItem->setContent(content);
|
||||
}
|
||||
contentItem->setContent(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ private:
|
||||
int m_TOCRangeIndex;
|
||||
};
|
||||
|
||||
|
||||
class ReportRender: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -109,6 +110,10 @@ signals:
|
||||
public slots:
|
||||
void cancelRender();
|
||||
private:
|
||||
void analizeContainer(BaseDesignIntf *item, BandDesignIntf *band);
|
||||
void analizeItem(ContentItemDesignIntf *item, BandDesignIntf *band);
|
||||
void analizePage(PageItemDesignIntf *patternPage);
|
||||
|
||||
void initDatasources();
|
||||
void initDatasource(const QString &name);
|
||||
void initRenderPage();
|
||||
@ -193,7 +198,7 @@ private:
|
||||
QMultiMap< BandDesignIntf*, GroupBandsHolder* > m_childBands;
|
||||
QList<BandDesignIntf*> m_reprintableBands;
|
||||
QList<BandDesignIntf*> m_recalcBands;
|
||||
|
||||
QMap<QString, QVector<QString>> m_groupfunctionItems;
|
||||
int m_currentIndex;
|
||||
int m_pageCount;
|
||||
|
||||
@ -217,6 +222,7 @@ private:
|
||||
bool m_newPageStarted;
|
||||
bool m_lostHeadersMoved;
|
||||
|
||||
|
||||
};
|
||||
} // namespace LimeReport
|
||||
#endif // LRREPORTRENDER_H
|
||||
|
Loading…
Reference in New Issue
Block a user