diff --git a/include/lrdatasourceintf.h b/include/lrdatasourceintf.h index 26f7a65..481787c 100644 --- a/include/lrdatasourceintf.h +++ b/include/lrdatasourceintf.h @@ -18,9 +18,12 @@ public: virtual bool eof() = 0; virtual QVariant data(const QString& columnName) = 0; virtual QVariant dataByRowIndex(const QString& columnName, int rowIndex) = 0; + virtual QVariant dataByRowIndex(const QString &columnName, int rowIndex, int roleName) = 0; + virtual QVariant dataByRowIndex(const QString &columnName, int rowIndex, const QString &roleName) = 0; virtual QVariant dataByKeyField(const QString& columnName, const QString& keyColumnName, QVariant keyData) = 0; virtual int columnCount() = 0; virtual QString columnNameByIndex(int columnIndex) = 0; + virtual QVariant headerData(const QString &columnName, const QString &roleName) = 0; virtual int columnIndexByName(QString name) = 0; virtual bool isInvalid() const = 0; virtual QString lastError() = 0; diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index e5c3ddc..7659288 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -29,8 +29,6 @@ ****************************************************************************/ #include "lrpreviewreportwindow.h" #include "ui_lrpreviewreportwindow.h" -#include "serializators/lrxmlreader.h" -#include "serializators/lrxmlwriter.h" #include "lrreportengine_p.h" #include "lrpreviewreportwidget.h" #include "lrpreviewreportwidget_p.h" @@ -179,7 +177,6 @@ PreviewReportWindow::~PreviewReportWindow() { if (m_ownedSettings) delete m_settings; - //delete m_previewPage; delete ui; } @@ -266,17 +263,6 @@ QSettings*PreviewReportWindow::settings() } } -void PreviewReportWindow::setReportReader(ItemsReaderIntf::Ptr /*reader*/) -{ -// m_reader=reader; -// if (!reader.isNull()){ -// if (reader->first()) reader->readItem(m_previewPage->pageItem()); -// int pagesCount = reader->firstLevelItemsCount(); -// m_previewPage->pageItem()->setItemMode(PreviewMode); -// initPreview(pagesCount); -// } -} - void PreviewReportWindow::setPages(ReportPages pages) { m_previewReportWidget->d_ptr->setPages(pages); diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index 68b58ad..be84775 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -62,7 +62,6 @@ class PreviewReportWindow : public QMainWindow public: explicit PreviewReportWindow(ReportEngine *report, QWidget *parent = 0, QSettings* settings=0, Qt::WindowFlags flags=Qt::WindowFlags()); ~PreviewReportWindow(); - void setReportReader(ItemsReaderIntf::Ptr reader); void setPages(ReportPages pages); void setDefaultPrinter(QPrinter* printer); void exec(); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 0fc7d08..0c00103 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -1818,7 +1818,7 @@ PrintProcessor::PrintProcessor(QPrinter* printer) bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page) { -#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) + if (!m_firstPage && !m_painter->isActive()) return false; PageDesignIntf* backupPage = dynamic_cast(page->scene()); @@ -1836,91 +1836,47 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page) m_firstPage = false; } +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) qreal leftMargin, topMargin, rightMargin, bottomMargin; m_printer->getPageMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin, QPrinter::Millimeter); - - QRectF printerPageRect = m_printer->pageRect(QPrinter::Millimeter); - printerPageRect = QRectF(0,0,(printerPageRect.size().width() + rightMargin + leftMargin) * page->unitFactor(), - (printerPageRect.size().height() + bottomMargin +topMargin) * page->unitFactor()); - - if (page->printBehavior() == PageItemDesignIntf::Split && m_printer->pageSize() != static_cast(page->pageSize()) && - printerPageRect.width() < page->geometry().width()) - { - qreal pageWidth = page->geometry().width(); - qreal pageHeight = page->geometry().height(); - QRectF currentPrintingRect = printerPageRect; - qreal curHeight = 0; - qreal curWidth = 0; - bool first = true; - while (pageHeight > 0){ - while (curWidth < pageWidth){ - if (!first) m_printer->newPage(); else first = false; - m_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 { - if (page->getSetPageSizeToPrinter()){ - QRectF source = page->geometry(); - QSizeF inchSize = source.size() / (100 * 2.54); - QRectF target = QRectF(QPoint(0,0), inchSize * m_printer->resolution()); - m_renderPage.render(m_painter, target, source); - } else { - m_renderPage.render(m_painter); - } - } - page->setPos(backupPagePos); - m_renderPage.removePageItem(page); - if (backupPage) backupPage->reactivatePageItem(page); #else - if (!m_firstPage && !m_painter->isActive()) return false; - PageDesignIntf* backupPage = dynamic_cast(page->scene()); - - QPointF backupPagePos = page->pos(); - page->setPos(0,0); - 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(); - } else { - m_painter = new QPainter(m_printer); - if (!m_painter->isActive()) return false; - m_firstPage = false; - } - qreal leftMargin = m_printer->pageLayout().margins().left(); qreal topMargin = m_printer->pageLayout().margins().top(); qreal rightMargin = m_printer->pageLayout().margins().right(); qreal bottomMargin = m_printer->pageLayout().margins().bottom(); +#endif QRectF printerPageRect = m_printer->pageRect(QPrinter::Millimeter); printerPageRect = QRectF(0,0,(printerPageRect.size().width() + rightMargin + leftMargin) * page->unitFactor(), (printerPageRect.size().height() + bottomMargin + topMargin) * page->unitFactor()); - if (page->printBehavior() == PageItemDesignIntf::Split && m_printer->pageLayout().pageSize() != QPageSize((QPageSize::PageSizeId)page->pageSize()) && +#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 1)) + if (page->printBehavior() == PageItemDesignIntf::Split && + m_printer->pageSize() != static_cast(page->pageSize()) && printerPageRect.width() < page->geometry().width()) { +#else + if ( + page->printBehavior() == PageItemDesignIntf::Split && + m_printer->pageLayout().pageSize() != QPageSize((QPageSize::PageSizeId)page->pageSize()) && + printerPageRect.width() < page->geometry().width() + ){ +#endif qreal pageWidth = page->geometry().width(); qreal pageHeight = page->geometry().height(); - QRectF currentPrintingRect = printerPageRect; qreal curHeight = 0; qreal curWidth = 0; + QRectF currentPrintingRect = printerPageRect; + bool first = true; while (pageHeight > 0){ while (curWidth < pageWidth){ if (!first) m_printer->newPage(); else first = false; - m_renderPage.render(m_painter, m_printer->pageRect(QPrinter::Millimeter), currentPrintingRect); - currentPrintingRect.adjust(printerPageRect.size().width(), 0, printerPageRect.size().width(), 0); + m_renderPage.render(m_painter, QRectF(), currentPrintingRect); curWidth += printerPageRect.size().width(); + currentPrintingRect = QRectF( + curWidth, 0, + printerPageRect.size().width() > (pageWidth - curWidth) ? (pageWidth - curWidth) : printerPageRect.size().width(), pageHeight + ); } pageHeight -= printerPageRect.size().height(); @@ -1943,7 +1899,6 @@ bool PrintProcessor::printPage(PageItemDesignIntf::Ptr page) page->setPos(backupPagePos); m_renderPage.removePageItem(page); if (backupPage) backupPage->reactivatePageItem(page); -#endif return true; }