From 3f96bf298e3a64ab427d7b2c4a926f62e1828afe Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Thu, 15 Mar 2018 23:35:29 +0300 Subject: [PATCH] Context items added to pagefooter band --- limereport/bands/lrpagefooter.cpp | 39 ++++++++++++++++++++++++++++--- limereport/bands/lrpagefooter.h | 4 +++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/limereport/bands/lrpagefooter.cpp b/limereport/bands/lrpagefooter.cpp index c5be0fb..a6b304f 100644 --- a/limereport/bands/lrpagefooter.cpp +++ b/limereport/bands/lrpagefooter.cpp @@ -30,6 +30,7 @@ #include "lrpagefooter.h" #include "lrdesignelementsfactory.h" #include "lrglobal.h" +#include "lrpagedesignintf.h" const QString xmlTag ="PageFooter"; @@ -62,7 +63,29 @@ BaseDesignIntf *PageFooter::createSameTypeItem(QObject *owner, QGraphicsItem *pa QColor PageFooter::bandColor() const { - return QColor(246,120,12); + return QColor(246,120,12); +} + +void PageFooter::preparePopUpMenu(QMenu &menu) +{ + QAction* action = menu.addAction(tr("Print on first page")); + action->setCheckable(true); + action->setChecked(printOnFirstPage()); + + action = menu.addAction(tr("Print on last page")); + action->setCheckable(true); + action->setChecked(printOnLastPage()); + +} + +void PageFooter::processPopUpAction(QAction *action) +{ + if (action->text().compare(tr("Print on first page")) == 0){ + page()->setPropertyToSelectedItems("printOnFirstPage",action->isChecked()); + } + if (action->text().compare(tr("Print on last page")) == 0){ + page()->setPropertyToSelectedItems("printOnLastPage",action->isChecked()); + } } bool PageFooter::printOnFirstPage() const @@ -72,7 +95,12 @@ bool PageFooter::printOnFirstPage() const void PageFooter::setPrintOnFirstPage(bool printOnFirstPage) { - m_printOnFirstPage = printOnFirstPage; + if (m_printOnFirstPage != printOnFirstPage){ + bool oldValue = m_printOnFirstPage; + m_printOnFirstPage = printOnFirstPage; + update(); + notify("printOnFirstPage",oldValue,printOnFirstPage); + } } bool PageFooter::printOnLastPage() const @@ -82,7 +110,12 @@ bool PageFooter::printOnLastPage() const void PageFooter::setPrintOnLastPage(bool printOnLastPage) { - m_printOnLastPage = printOnLastPage; + if (m_printOnLastPage != printOnLastPage){ + bool oldValue = m_printOnLastPage; + m_printOnLastPage = printOnLastPage; + update(); + notify("printOnLastPage",oldValue,printOnLastPage); + } } } // namespace LimeReport diff --git a/limereport/bands/lrpagefooter.h b/limereport/bands/lrpagefooter.h index d6678a3..2f634a5 100644 --- a/limereport/bands/lrpagefooter.h +++ b/limereport/bands/lrpagefooter.h @@ -50,7 +50,9 @@ public: void setPrintOnFirstPage(bool printOnFirstPage); protected: - QColor bandColor() const; + QColor bandColor() const; + void preparePopUpMenu(QMenu &menu); + void processPopUpAction(QAction *action); private: bool m_printOnFirstPage; bool m_printOnLastPage;