diff --git a/include/lrglobal.h b/include/lrglobal.h index be094a4..0894ee0 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -80,12 +80,14 @@ namespace Const{ QString extractClassName(QString className); enum RenderPass {FirstPass, SecondPass}; enum ArrangeType {AsNeeded, Force}; - enum PreviewHint{ShowAllPreviewBars=0, - HidePreviewToolBar=1, - HidePreviewMenuBar=2, - HidePreviewStatusBar=4, - HideAllPreviewBar=7}; + enum PreviewHint{ShowAllPreviewBars = 0, + HidePreviewToolBar = 1, + HidePreviewMenuBar = 2, + HidePreviewStatusBar = 4, + HideAllPreviewBar = 7, + PreviewBarsUserSetting = 8}; Q_DECLARE_FLAGS(PreviewHints, PreviewHint) + Q_FLAGS(PreviewHints) class ReportError : public std::runtime_error{ public: diff --git a/include/lrreportengine.h b/include/lrreportengine.h index c2cdfe8..814d831 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -77,7 +77,7 @@ public: void printToFile(const QString& fileName); PageDesignIntf *createPreviewScene(QObject *parent = 0); bool printToPDF(const QString& fileName); - void previewReport(PreviewHints hints = ShowAllPreviewBars); + void previewReport(PreviewHints hints = PreviewBarsUserSetting); void designReport(); void setShowProgressDialog(bool value); IDataSourceManager* dataManager(); diff --git a/limereport/images/checked.png b/limereport/images/checked.png new file mode 100644 index 0000000..e505891 Binary files /dev/null and b/limereport/images/checked.png differ diff --git a/limereport/images/not_checked.png b/limereport/images/not_checked.png new file mode 100644 index 0000000..daf1aa3 Binary files /dev/null and b/limereport/images/not_checked.png differ diff --git a/limereport/images/toolbar.png b/limereport/images/toolbar.png new file mode 100644 index 0000000..06e6300 Binary files /dev/null and b/limereport/images/toolbar.png differ diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 0e6cb13..c9864b8 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -448,9 +448,11 @@ BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGrap } else if (item->canBeSplitted(sliceHeight)){ upperItem = item->cloneUpperPart(sliceHeight,upperPart,upperPart); if (maxBottomgeometry().bottom()) maxBottom = upperItem->geometry().bottom(); + m_slicedItems.insert(upperItem->objectName(),upperItem); } else { item->cloneEmpty(sliceHeight,upperPart,upperPart); //for table - qgItem->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top())); + moveItemsDown(item->pos().y(),(height+1)-item->geometry().top()); + //qgItem->setPos(item->pos().x(),item->pos().y()+((height+1)-item->geometry().top())); } } } @@ -460,12 +462,20 @@ BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGrap return upperPart; } +bool itemLessThen(QGraphicsItem* i1, QGraphicsItem* i2){ + return i1->pos().y()pos().y(); +} + BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent) { BandDesignIntf* bottomPart = dynamic_cast(createSameTypeItem(owner,parent)); bottomPart->initFromItem(this); - foreach(QGraphicsItem* qgItem,childItems()){ + QList bandItems; + bandItems = childItems(); + std::sort(bandItems.begin(),bandItems.end(), itemLessThen); + + foreach(QGraphicsItem* qgItem, bandItems){ BaseDesignIntf* item = dynamic_cast(qgItem); if (item){ @@ -479,6 +489,9 @@ BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGra BaseDesignIntf* tmpItem=item->cloneBottomPart(sliceHeight,bottomPart,bottomPart); tmpItem->setPos(tmpItem->pos().x(),0); if (tmpItem->pos().y()<0) tmpItem->setPos(tmpItem->pos().x(),0); + qreal sizeOffset = (m_slicedItems.value(tmpItem->objectName())->height()+tmpItem->height()) - item->height(); + qreal bottomOffset = (height - m_slicedItems.value(tmpItem->objectName())->pos().y())-m_slicedItems.value(tmpItem->objectName())->height(); + moveItemsDown(item->pos().y()+item->height(), sizeOffset + bottomOffset); } else if (item->isSplittable()){ BaseDesignIntf* tmpItem = item->cloneItem(item->itemMode(),bottomPart,bottomPart); diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 6b7fb06..d78b82d 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -268,6 +268,7 @@ private: bool m_startFromNewPage; bool m_printAlways; bool m_repeatOnEachRow; + QMap m_slicedItems; }; class DataBandDesignIntf : public BandDesignIntf{ diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index be094a4..0894ee0 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -80,12 +80,14 @@ namespace Const{ QString extractClassName(QString className); enum RenderPass {FirstPass, SecondPass}; enum ArrangeType {AsNeeded, Force}; - enum PreviewHint{ShowAllPreviewBars=0, - HidePreviewToolBar=1, - HidePreviewMenuBar=2, - HidePreviewStatusBar=4, - HideAllPreviewBar=7}; + enum PreviewHint{ShowAllPreviewBars = 0, + HidePreviewToolBar = 1, + HidePreviewMenuBar = 2, + HidePreviewStatusBar = 4, + HideAllPreviewBar = 7, + PreviewBarsUserSetting = 8}; Q_DECLARE_FLAGS(PreviewHints, PreviewHint) + Q_FLAGS(PreviewHints) class ReportError : public std::runtime_error{ public: diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index ea106a4..dc75b5c 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -83,6 +83,7 @@ PreviewReportWindow::PreviewReportWindow(ReportEnginePrivate *report,QWidget *pa connect(m_previewReportWidget, SIGNAL(scalePercentChanged(int)), this, SLOT(slotScalePercentChanged(int))); connect(m_scalePercent, SIGNAL(currentIndexChanged(QString)), this, SLOT(scaleComboboxChanged(QString))); restoreSetting(); + selectStateIcon(); } void PreviewReportWindow::writeSetting() @@ -151,7 +152,8 @@ void PreviewReportWindow::setErrorMessages(const QStringList &value){ void PreviewReportWindow::setToolBarVisible(bool value) { - ui->toolBar->setVisible(value); + ui->toolBar->setHidden(value); + selectStateIcon(); } void PreviewReportWindow::setStatusBarVisible(bool value) @@ -242,6 +244,14 @@ void PreviewReportWindow::showEvent(QShowEvent *) m_fontEditor->setVisible(ui->actionEdit_Mode->isChecked()); m_textAlignmentEditor->setVisible(ui->actionEdit_Mode->isChecked()); } +void PreviewReportWindow::selectStateIcon() +{ + if (ui->toolBar->isHidden()){ + ui->actionShow_Toolbar->setIcon(QIcon(":/report/images/not_checked.png")); + } else { + ui->actionShow_Toolbar->setIcon(QIcon(":/report/images/checked.png")); + } +} void PreviewReportWindow::slotPrint() { @@ -368,4 +378,13 @@ void PreviewReportWindow::on_actionShowMessages_toggled(bool value) m_previewReportWidget->setErrorsMesagesVisible(value); } +void PreviewReportWindow::on_actionShow_Toolbar_triggered() +{ + setToolBarVisible(!ui->toolBar->isHidden()); + writeSetting(); +} + }// namespace LimeReport + + + diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index 8f5a1d1..26cf181 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -73,6 +73,7 @@ protected: void resizeEvent(QResizeEvent *e); void moveEvent(QMoveEvent *e); void showEvent(QShowEvent *); + void selectStateIcon(); public slots: void slotPrint(); void slotPriorPage(); @@ -95,6 +96,7 @@ private slots: void scaleComboboxChanged(QString text); void slotScalePercentChanged(int percent); void on_actionShowMessages_toggled(bool value); + void on_actionShow_Toolbar_triggered(); private: ItemsReaderIntf* reader(); diff --git a/limereport/lrpreviewreportwindow.ui b/limereport/lrpreviewreportwindow.ui index 816ea1f..bca9861 100644 --- a/limereport/lrpreviewreportwindow.ui +++ b/limereport/lrpreviewreportwindow.ui @@ -35,7 +35,7 @@ 0 0 800 - 21 + 20 @@ -44,6 +44,8 @@ + + @@ -256,6 +258,24 @@ One to one + + + false + + + false + + + + :/report/images/toolbar:/report/images/toolbar + + + Show Toolbar + + + Show toolbar + + diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index c6ba750..315b4a9 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -376,9 +376,11 @@ void ReportEnginePrivate::previewReport(PreviewHints hints) w->setErrorMessages(dataManager()->errorsList()); } - w->setMenuVisible(!hints.testFlag(HidePreviewMenuBar)); - w->setStatusBarVisible(!hints.testFlag(HidePreviewStatusBar)); - w->setToolBarVisible(!hints.testFlag(HidePreviewToolBar)); + if (!hints.testFlag(PreviewBarsUserSetting)){ + w->setMenuVisible(!hints.testFlag(HidePreviewMenuBar)); + w->setStatusBarVisible(!hints.testFlag(HidePreviewStatusBar)); + w->setToolBarVisible(!hints.testFlag(HidePreviewToolBar)); + } m_activePreview = w; connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroed(QObject*))); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index c2cdfe8..814d831 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -77,7 +77,7 @@ public: void printToFile(const QString& fileName); PageDesignIntf *createPreviewScene(QObject *parent = 0); bool printToPDF(const QString& fileName); - void previewReport(PreviewHints hints = ShowAllPreviewBars); + void previewReport(PreviewHints hints = PreviewBarsUserSetting); void designReport(); void setShowProgressDialog(bool value); IDataSourceManager* dataManager(); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 818f52e..614bc88 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -86,7 +86,7 @@ public: bool printPages(ReportPages pages, QPrinter *printer, PrintRange printRange = PrintRange()); void printToFile(const QString& fileName); bool printToPDF(const QString& fileName); - void previewReport(PreviewHints hints = ShowAllPreviewBars); + void previewReport(PreviewHints hints = PreviewBarsUserSetting); void designReport(); void setSettings(QSettings* value); void setShowProgressDialog(bool value){m_showProgressDialog = value;} diff --git a/limereport/report.qrc b/limereport/report.qrc index a2c526c..6dfc6fe 100644 --- a/limereport/report.qrc +++ b/limereport/report.qrc @@ -167,5 +167,8 @@ images/logo_32x32.png images/addPage1.png images/deletePage1.png + images/toolbar.png + images/not_checked.png + images/checked.png