This commit is contained in:
Arin Alexander 2017-04-21 23:04:25 +03:00
commit 27a88969b0
5 changed files with 17 additions and 25 deletions

View File

@ -78,7 +78,7 @@ public:
explicit ReportEngine(QObject *parent = 0);
~ReportEngine();
bool printReport(QPrinter *printer=0);
bool printPages(ReportPages pages, QPrinter *printer, PrintRange printRange = PrintRange());
bool printPages(ReportPages pages, QPrinter *printer);
void printToFile(const QString& fileName);
PageDesignIntf *createPreviewScene(QObject *parent = 0);
bool printToPDF(const QString& fileName);

View File

@ -175,8 +175,7 @@ void PreviewReportWidget::print()
if (!d_ptr->m_reportPages.isEmpty())
ReportEnginePrivate::printReport(
d_ptr->m_reportPages,
printer,
PrintRange(dialog.printRange(),dialog.fromPage(),dialog.toPage())
printer
);
foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){
d_ptr->m_previewPage->reactivatePageItem(pageItem);
@ -196,7 +195,7 @@ void PreviewReportWidget::printToPDF()
printer.setOutputFileName(fileName);
printer.setOutputFormat(QPrinter::PdfFormat);
if (!d_ptr->m_reportPages.isEmpty()){
ReportEnginePrivate::printReport(d_ptr->m_reportPages,printer,PrintRange());
ReportEnginePrivate::printReport(d_ptr->m_reportPages,printer);
}
foreach(PageItemDesignIntf::Ptr pageItem, d_ptr->m_reportPages){
d_ptr->m_previewPage->reactivatePageItem(pageItem);

View File

@ -209,7 +209,7 @@ void ReportEnginePrivate::printReport(ItemsReaderIntf::Ptr reader, QPrinter& pri
}
}
void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer, const PrintRange& printRange)
void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer)
{
LimeReport::PageDesignIntf renderPage;
renderPage.setItemMode(PrintMode);
@ -217,13 +217,13 @@ void ReportEnginePrivate::printReport(ReportPages pages, QPrinter &printer, cons
bool isFirst = true;
int currenPage = 1;
foreach(PageItemDesignIntf::Ptr page,pages){
foreach(PageItemDesignIntf::Ptr page, pages){
if (
(printRange.rangeType()==QPrintDialog::AllPages) ||
( (printRange.rangeType()==QPrintDialog::PageRange) &&
(currenPage>=printRange.fromPage()) &&
(currenPage<=printRange.toPage())
(printer.printRange() == QPrinter::AllPages) ||
( (printer.printRange()==QPrinter::PageRange) &&
(currenPage>=printer.fromPage()) &&
(currenPage<=printer.toPage())
)
)
{
@ -295,7 +295,7 @@ bool ReportEnginePrivate::printReport(QPrinter* printer)
ReportPages pages = renderToPages();
dataManager()->setDesignTime(true);
if (pages.count()>0){
printReport(pages,*printer,PrintRange());
printReport(pages,*printer);
}
} catch(ReportError &exception){
saveError(exception.what());
@ -304,7 +304,7 @@ bool ReportEnginePrivate::printReport(QPrinter* printer)
} else return false;
}
bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer, PrintRange printRange)
bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer)
{
if (!printer&&!m_printerSelected){
QPrinterInfo pi;
@ -317,12 +317,6 @@ bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer, Print
#endif
QPrintDialog dialog(m_printer.data(),QApplication::activeWindow());
m_printerSelected = dialog.exec()!=QDialog::Rejected;
if (m_printerSelected){
printRange.setRangeType(dialog.printRange());
printRange.setFromPage(dialog.fromPage());
printRange.setToPage(dialog.toPage());
}
}
if (!printer&&!m_printerSelected) return false;
@ -332,8 +326,7 @@ bool ReportEnginePrivate::printPages(ReportPages pages, QPrinter *printer, Print
if (pages.count()>0){
printReport(
pages,
*printer,
printRange
*printer
);
}
} catch(ReportError &exception){
@ -859,9 +852,9 @@ bool ReportEngine::printReport(QPrinter *printer)
return d->printReport(printer);
}
bool ReportEngine::printPages(ReportPages pages, QPrinter *printer, PrintRange printRange){
bool ReportEngine::printPages(ReportPages pages, QPrinter *printer){
Q_D(ReportEngine);
return d->printPages(pages,printer, printRange);
return d->printPages(pages,printer);
}
void ReportEngine::printToFile(const QString &fileName)

View File

@ -78,7 +78,7 @@ public:
explicit ReportEngine(QObject *parent = 0);
~ReportEngine();
bool printReport(QPrinter *printer=0);
bool printPages(ReportPages pages, QPrinter *printer, PrintRange printRange = PrintRange());
bool printPages(ReportPages pages, QPrinter *printer);
void printToFile(const QString& fileName);
PageDesignIntf *createPreviewScene(QObject *parent = 0);
bool printToPDF(const QString& fileName);

View File

@ -63,7 +63,7 @@ class ReportEnginePrivate : public QObject, public ICollectionContainer
friend class PreviewReportWidget;
public:
static void printReport(ItemsReaderIntf::Ptr reader, QPrinter &printer);
static void printReport(ReportPages pages, QPrinter &printer, const PrintRange &printRange);
static void printReport(ReportPages pages, QPrinter &printer);
public:
explicit ReportEnginePrivate(QObject *parent = 0);
virtual ~ReportEnginePrivate();
@ -85,7 +85,7 @@ public:
void clearReport();
bool printReport(QPrinter *printer=0);
bool printPages(ReportPages pages, QPrinter *printer, PrintRange printRange = PrintRange());
bool printPages(ReportPages pages, QPrinter *printer);
void printToFile(const QString& fileName);
bool printToPDF(const QString& fileName);
void previewReport(PreviewHints hints = PreviewBarsUserSetting);