diff --git a/.travis.yml b/.travis.yml index dadebf9..39dedbc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ install: script: - - qmake -r + - qmake -r limereport.pro - make - make check diff --git a/common.pri b/common.pri index 6a8f275..f10eaf8 100644 --- a/common.pri +++ b/common.pri @@ -1,4 +1,18 @@ -CONFIG += build_translations +#BINARY_RESULT_DIR = $${TOP_BUILD_DIR} + +isEmpty(BINARY_RESULT_DIR) { + BINARY_RESULT_DIR = $${PWD} +} + +message(TOP_BUILD_DIR: $$TOP_BUILD_DIR) + +#!contains(CONFIG, config_build_dir){ +# TOP_BUILD_DIR = $${PWD} +#} + +!contains(CONFIG, no_build_translations){ + CONFIG += build_translations +} !contains(CONFIG, no_zint){ CONFIG += zint @@ -24,7 +38,8 @@ CONFIG(release, debug|release){ BUILD_TYPE = debug } -BUILD_DIR = $$PWD/build/$${QT_VERSION} +BUILD_DIR = $${BINARY_RESULT_DIR}/build/$${QT_VERSION} + DEST_INCLUDE_DIR = $$PWD/include unix{ ARCH_DIR = $${OUT_PWD}/unix @@ -62,7 +77,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 4 -LIMEREPORT_VERSION_RELEASE = 78 +LIMEREPORT_VERSION_RELEASE = 123 LIMEREPORT_VERSION = '\\"$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}\\"' DEFINES += LIMEREPORT_VERSION_STR=\"$${LIMEREPORT_VERSION}\" diff --git a/demo_r1/demo_r1.pro b/demo_r1/demo_r1.pro index 71c0821..8c09816 100644 --- a/demo_r1/demo_r1.pro +++ b/demo_r1/demo_r1.pro @@ -26,27 +26,10 @@ macx{ } unix:{ - LIBS += -L$${DEST_LIBS} - CONFIG(debug, debug|release) { - LIBS += -llimereportd - } else { - LIBS += -llimereport - } - !contains(CONFIG, static_build){ - contains(CONFIG,zint){ - LIBS += -L$${DEST_LIBS} - - CONFIG(debug, debug|release) { - LIBS += -lQtZintd - } else { - LIBS += -lQtZint - } - } - } DESTDIR = $$DEST_DIR # QMAKE_POST_LINK += mkdir -p $$quote($$REPORTS_DIR) | - QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$REPORTS_DIR) $$escape_expand(\n\t) + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$REPORTS_DIR) $$escape_expand(\n\t) linux{ #Link share lib to ../lib rpath @@ -60,32 +43,36 @@ unix:{ } win32 { - EXTRA_DIR ~= s,/,\\,g - DEST_DIR ~= s,/,\\,g - REPORTS_DIR ~= s,/,\\,g - DESTDIR = $$DEST_DIR - RC_FILE += mainicon.rc + contains(QMAKE_HOST.os, Linux){ + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$REPORTS_DIR) $$escape_expand(\n\t) + } else { + EXTRA_DIR ~= s,/,\\,g + DEST_DIR ~= s,/,\\,g + REPORTS_DIR ~= s,/,\\,g - QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR\\*) $$quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) - !contains(CONFIG, static_build){ - - contains(CONFIG,zint){ - LIBS += -L$${DEST_LIBS} - CONFIG(debug, debug|release) { - LIBS += -lQtZintd - } else { - LIBS += -lQtZint - } - } + RC_FILE += mainicon.rc + + QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$$EXTRA_DIR\" \"$$REPORTS_DIR\\demo_reports\" $$escape_expand(\\n\\t) + #QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR\\*) $$quote($$REPORTS_DIR\\demo_reports) $$escape_expand(\\n\\t) } - - LIBS += -L$${DEST_LIBS} - CONFIG(debug, debug|release) { - LIBS += -llimereportd - } else { - LIBS += -llimereport - } +} + +LIBS += -L$${DEST_LIBS} +CONFIG(debug, debug|release) { + LIBS += -llimereportd +} else { + LIBS += -llimereport } +!contains(CONFIG, static_build){ + contains(CONFIG,zint){ + LIBS += -L$${DEST_LIBS} + CONFIG(debug, debug|release) { + LIBS += -lQtZintd + } else { + LIBS += -lQtZint + } + } +} diff --git a/demo_r2/demo_r2.pro b/demo_r2/demo_r2.pro index 8ff5356..707649b 100644 --- a/demo_r2/demo_r2.pro +++ b/demo_r2/demo_r2.pro @@ -26,22 +26,6 @@ macx{ } unix:{ - LIBS += -L$${DEST_LIBS} - CONFIG(debug, debug|release) { - LIBS += -llimereportd - } else { - LIBS += -llimereport - } - !contains(CONFIG, static_build){ - contains(CONFIG,zint){ - LIBS += -L$${DEST_LIBS} - CONFIG(debug, debug|release) { - LIBS += -lQtZintd - } else { - LIBS += -lQtZint - } - } - } DESTDIR = $$DEST_DIR QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$REPORTS_DIR) $$escape_expand(\n\t) linux{ @@ -56,30 +40,34 @@ unix:{ } win32 { - EXTRA_DIR ~= s,/,\\,g - DEST_DIR ~= s,/,\\,g - REPORTS_DIR ~= s,/,\\,g - DESTDIR = $$DEST_DIR - RC_FILE += mainicon.rc - !contains(CONFIG, static_build){ - contains(CONFIG,zint){ - LIBS += -L$${DEST_LIBS} - CONFIG(debug, debug|release) { - LIBS += -lQtZintd - } else { - LIBS += -lQtZint - } - } - } - LIBS += -L$${DEST_LIBS} - - CONFIG(debug, debug|release) { - LIBS += -llimereportd + contains(QMAKE_HOST.os, Linux){ + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$REPORTS_DIR) $$escape_expand(\n\t) } else { - LIBS += -llimereport + EXTRA_DIR ~= s,/,\\,g + DEST_DIR ~= s,/,\\,g + REPORTS_DIR ~= s,/,\\,g + + RC_FILE += mainicon.rc + + QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$$EXTRA_DIR\" \"$$REPORTS_DIR\\demo_reports\" $$escape_expand(\\n\\t) } - - QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$$EXTRA_DIR\" \"$$REPORTS_DIR\\demo_reports\" $$escape_expand(\\n\\t) } +LIBS += -L$${DEST_LIBS} +CONFIG(debug, debug|release) { + LIBS += -llimereportd +} else { + LIBS += -llimereport +} + +!contains(CONFIG, static_build){ + contains(CONFIG,zint){ + LIBS += -L$${DEST_LIBS} + CONFIG(debug, debug|release) { + LIBS += -lQtZintd + } else { + LIBS += -lQtZint + } + } +} diff --git a/include/lrglobal.h b/include/lrglobal.h index f2c866f..ea8b279 100644 --- a/include/lrglobal.h +++ b/include/lrglobal.h @@ -78,15 +78,7 @@ namespace Const{ const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}"; const QString NAMED_VARIABLE_RX = "\\$V\\s*\\{\\s*(%1)\\s*\\}"; const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}"; - - //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)"; - //const int DATASOURCE_INDEX = 6; - //const int VALUE_INDEX = 2; - - //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"?\\$S\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)"; - //const QString GROUP_FUNCTION_PARAM_RX = "\\((?:(.+),(.+))|(?:\\\"(\\w+)\\\")\\)"; - //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:)))|(?:(?:(?:\\\")|(?:))(\\s*\\$\\w\\s*\\{.+\\}\\s*)(?:(?:\\\")|(?:))\\s*,\\s*(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:))))\\)"; - const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*.\\w*\\s*\\})|(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))\\)"; + const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*..*\\})|(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))(?:(?:\\s*,\\s*(?:(\\w*)))|(?:))\\)"; const int DATASOURCE_INDEX = 3;//4; const int VALUE_INDEX = 2; //2; const int EXPRESSION_ARGUMENT_INDEX = 1;//3; @@ -103,6 +95,7 @@ namespace Const{ enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum RenderPass {FirstPass, SecondPass}; enum ArrangeType {AsNeeded, Force}; + enum ScaleType {FitWidth, FitPage, OneToOne, Percents}; enum PreviewHint{ShowAllPreviewBars = 0, HidePreviewToolBar = 1, HidePreviewMenuBar = 2, diff --git a/include/lrpreviewreportwidget.h b/include/lrpreviewreportwidget.h index 4e35ea6..d66ac70 100644 --- a/include/lrpreviewreportwidget.h +++ b/include/lrpreviewreportwidget.h @@ -2,6 +2,7 @@ #define LRPREVIEWREPORTWIDGET_H #include +#include #include "lrglobal.h" namespace LimeReport { @@ -22,6 +23,9 @@ class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget public: explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0); ~PreviewReportWidget(); + ScaleType scaleType() const; + int scalePercent() const; + void setScaleType(const ScaleType &scaleType, int percent = 0); public slots: void refreshPages(); void zoomIn(); @@ -39,6 +43,8 @@ public slots: void setScalePercent(int percent); void fitWidth(); void fitPage(); +protected: + void resizeEvent(QResizeEvent *); signals: void pageChanged(int page); void scalePercentChanged(int percent); @@ -47,6 +53,7 @@ private slots: void slotSliderMoved(int value); void reportEngineDestroyed(QObject* object); void slotZoomed(double); + void resizeDone(); private: void initPreview(); void setErrorsMesagesVisible(bool visible); @@ -55,6 +62,9 @@ private: private: Ui::PreviewReportWidget *ui; PreviewReportWidgetPrivate* d_ptr; + ScaleType m_scaleType; + int m_scalePercent; + QTimer m_resizeTimer; }; } // namespace LimeReport diff --git a/include/lrreportengine.h b/include/lrreportengine.h index 746712e..f935b80 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -104,6 +104,9 @@ public: void setPassPharse(QString& passPharse); Qt::LayoutDirection previewLayoutDirection(); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); + ScaleType previewScaleType(); + int previewScalePercent(); + void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0); signals: void renderStarted(); void renderFinished(); diff --git a/limereport.pro b/limereport.pro index 84179ac..f954fae 100644 --- a/limereport.pro +++ b/limereport.pro @@ -10,12 +10,11 @@ contains(CONFIG, zint){ } export($$CONFIG) + +CONFIG += ordered SUBDIRS += \ - limereport - -CONFIG += ordered - -SUBDIRS += demo_r1 demo_r2 designer - - + limereport \ + demo_r1 \ + demo_r2 \ + designer diff --git a/limereport/bands/lrdataband.cpp b/limereport/bands/lrdataband.cpp index 342622a..29cea5e 100644 --- a/limereport/bands/lrdataband.cpp +++ b/limereport/bands/lrdataband.cpp @@ -84,6 +84,58 @@ QColor DataBand::bandColor() const return QColor(Qt::darkGreen); } +void DataBand::preparePopUpMenu(QMenu &menu) +{ + BandDesignIntf::preparePopUpMenu(menu); + QAction* currAction = menu.addAction(tr("Keep footer together")); + currAction->setCheckable(true); + currAction->setChecked(keepFooterTogether()); + + currAction = menu.addAction(tr("Keep subdetail together")); + currAction->setCheckable(true); + currAction->setChecked(tryToKeepTogether()); + + currAction = menu.addAction(tr("Slice last row")); + currAction->setCheckable(true); + currAction->setChecked(sliceLastRow()); + + currAction = menu.addAction(tr("Start from new page")); + currAction->setCheckable(true); + currAction->setChecked(startFromNewPage()); + + currAction = menu.addAction(tr("Start new page")); + currAction->setCheckable(true); + currAction->setChecked(startNewPage()); + + + +} + +void DataBand::processPopUpAction(QAction *action) +{ + BandDesignIntf::processPopUpAction(action); + if (action->text().compare(tr("Keep footer together")) == 0){ + setProperty("keepFooterTogether",action->isChecked()); + } + + if (action->text().compare(tr("Keep subdetail together")) == 0){ + setProperty("keepSubdetailTogether",action->isChecked()); + } + + if (action->text().compare(tr("Slice last row")) == 0){ + setProperty("sliceLastRow",action->isChecked()); + } + + if (action->text().compare(tr("Start new page")) == 0){ + setProperty("startNewPage",action->isChecked()); + } + + if (action->text().compare(tr("Start from new page")) == 0){ + setProperty("startFromNewPage",action->isChecked()); + } + +} + BaseDesignIntf *DataBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent) { return new DataBand(owner,parent); @@ -96,6 +148,38 @@ DataHeaderBand::DataHeaderBand(QObject *owner, QGraphicsItem *parent) setMarkerColor(bandColor()); } +void DataHeaderBand::preparePopUpMenu(QMenu &menu) +{ + BandDesignIntf::preparePopUpMenu(menu); + QAction* currAction = menu.addAction(tr("Reprint on each page")); + currAction->setCheckable(true); + currAction->setChecked(reprintOnEachPage()); + + currAction = menu.addAction(tr("Repeat on each row")); + currAction->setCheckable(true); + currAction->setChecked(repeatOnEachRow()); + + currAction = menu.addAction(tr("Print always")); + currAction->setCheckable(true); + currAction->setChecked(printAlways()); +} + +void DataHeaderBand::processPopUpAction(QAction *action) +{ + BandDesignIntf::processPopUpAction(action); + if (action->text().compare(tr("Reprint on each page")) == 0){ + setProperty("reprintOnEachPage",action->isChecked()); + } + + if (action->text().compare(tr("Repeat on each row")) == 0){ + setProperty("repeatOnEachRow",action->isChecked()); + } + + if (action->text().compare(tr("Print always")) == 0){ + setProperty("printAlways",action->isChecked()); + } +} + DataFooterBand::DataFooterBand(QObject *owner, QGraphicsItem *parent) :BandDesignIntf(BandDesignIntf::DataFooter,xmlTagFooter,owner,parent) { @@ -103,5 +187,21 @@ DataFooterBand::DataFooterBand(QObject *owner, QGraphicsItem *parent) setMarkerColor(bandColor()); } +void DataFooterBand::preparePopUpMenu(QMenu &menu) +{ + BandDesignIntf::preparePopUpMenu(menu); + QAction* currAction = menu.addAction(tr("Print always")); + currAction->setCheckable(true); + currAction->setChecked(printAlways()); +} + +void DataFooterBand::processPopUpAction(QAction *action) +{ + BandDesignIntf::processPopUpAction(action); + if (action->text().compare(tr("Print always")) == 0){ + setProperty("printAlways",action->isChecked()); + } +} + } diff --git a/limereport/bands/lrdataband.h b/limereport/bands/lrdataband.h index fd180e8..4045d3a 100644 --- a/limereport/bands/lrdataband.h +++ b/limereport/bands/lrdataband.h @@ -54,6 +54,8 @@ public: bool isData() const {return true;} protected: QColor bandColor() const; + void preparePopUpMenu(QMenu &menu); + void processPopUpAction(QAction *action); private: BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); }; @@ -71,6 +73,9 @@ public: bool isUnique() const {return false;} bool isHeader() const {return true;} QColor bandColor() const {return QColor(Qt::darkGreen);} +protected: + void preparePopUpMenu(QMenu &menu); + void processPopUpAction(QAction *action); private: BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){ return new DataHeaderBand(owner,parent); @@ -88,6 +93,9 @@ public: bool isUnique() const {return false;} bool isFooter() const {return true;} QColor bandColor() const{return QColor(Qt::darkGreen);} +protected: + void preparePopUpMenu(QMenu &menu); + void processPopUpAction(QAction *action); private: BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){ return new DataFooterBand(owner,parent); diff --git a/limereport/bands/lrpagefooter.cpp b/limereport/bands/lrpagefooter.cpp index c5be0fb..2b1c3b1 100644 --- a/limereport/bands/lrpagefooter.cpp +++ b/limereport/bands/lrpagefooter.cpp @@ -53,6 +53,7 @@ PageFooter::PageFooter(QObject *owner, QGraphicsItem *parent) { setBandTypeText( tr("Page Footer") ); setMarkerColor(bandColor()); + setAutoHeight(false); } BaseDesignIntf *PageFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent) diff --git a/limereport/bands/lrtearoffband.h b/limereport/bands/lrtearoffband.h index 1366aa6..5c8c17c 100644 --- a/limereport/bands/lrtearoffband.h +++ b/limereport/bands/lrtearoffband.h @@ -12,7 +12,8 @@ public: virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); protected: QColor bandColor() const; - virtual bool isUnique() const {return true;} + bool isUnique() const {return true;} + bool isFooter() const{ return true;} }; } // namespace LimeReport diff --git a/limereport/databrowser/lrsqleditdialog.cpp b/limereport/databrowser/lrsqleditdialog.cpp index 05e3267..90ad426 100644 --- a/limereport/databrowser/lrsqleditdialog.cpp +++ b/limereport/databrowser/lrsqleditdialog.cpp @@ -113,8 +113,8 @@ void SQLEditDialog::accept() if (ui->fieldsMap->rowCount()>0){ for(int i=0;ifieldsMap->rowCount();++i){ LimeReport::FieldsCorrelation fieldsCorrelation; - fieldsCorrelation.master=ui->fieldsMap->item(i,0)->data(Qt::DisplayRole).toString(); - fieldsCorrelation.detail=ui->fieldsMap->item(i,1)->data(Qt::DisplayRole).toString(); + fieldsCorrelation.master = ui->fieldsMap->item(i,0) ? ui->fieldsMap->item(i,0)->data(Qt::DisplayRole).toString() : ""; + fieldsCorrelation.detail = ui->fieldsMap->item(i,1) ? ui->fieldsMap->item(i,1)->data(Qt::DisplayRole).toString() : ""; result.fieldMap.append(fieldsCorrelation); } } @@ -351,4 +351,13 @@ void SQLEditDialog::hidePreview() ui->pbHidePreview->setVisible(false); } +void SQLEditDialog::on_pbDelField_clicked() +{ + ui->fieldsMap->removeRow(ui->fieldsMap->currentRow()); +} + } // namespace LimeReport + + + + diff --git a/limereport/databrowser/lrsqleditdialog.h b/limereport/databrowser/lrsqleditdialog.h index 269f3f4..7773acd 100644 --- a/limereport/databrowser/lrsqleditdialog.h +++ b/limereport/databrowser/lrsqleditdialog.h @@ -73,6 +73,7 @@ private slots: void on_rbProxy_clicked(bool checked); void on_rbSubQuery_clicked(bool checked); void on_pbAddField_clicked(); + void on_pbDelField_clicked(); void initQueryMode(); void initSubQueryMode(); void initProxyMode(); diff --git a/limereport/items/images/DataFooterBand.png b/limereport/items/images/DataFooterBand.png new file mode 100644 index 0000000..d68293c Binary files /dev/null and b/limereport/items/images/DataFooterBand.png differ diff --git a/limereport/items/images/DataHeaderBand.png b/limereport/items/images/DataHeaderBand.png new file mode 100644 index 0000000..c8731f5 Binary files /dev/null and b/limereport/items/images/DataHeaderBand.png differ diff --git a/limereport/items/items.qrc b/limereport/items/items.qrc index 8b0a351..99c7d25 100644 --- a/limereport/items/items.qrc +++ b/limereport/items/items.qrc @@ -41,5 +41,7 @@ images/imageItem4.png images/shapes7.png images/barcode5.png + images/DataHeaderBand.png + images/DataFooterBand.png diff --git a/limereport/items/lrbarcodeitem.cpp b/limereport/items/lrbarcodeitem.cpp index 7af23bf..fac67d7 100644 --- a/limereport/items/lrbarcodeitem.cpp +++ b/limereport/items/lrbarcodeitem.cpp @@ -73,6 +73,7 @@ void BarcodeItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *opti bc.setWidth(m_barcodeWidth); bc.setSecurityLevel(m_securityLevel); bc.setPdf417CodeWords(m_pdf417CodeWords); + bc.setHideText(m_hideText); if (isSelected()) ppainter->setOpacity(Const::SELECTION_OPACITY); @@ -249,6 +250,22 @@ void BarcodeItem::setInputMode(const InputMode &inputMode) } } +bool BarcodeItem::hideText() const +{ + return m_hideText; +} + +void BarcodeItem::setHideText(bool hideText) +{ + if (m_hideText != hideText){ + m_hideText = hideText; + if (!isLoading()){ + update(); + notify("hideText",!m_hideText,m_hideText); + } + } +} + void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { switch(pass){ diff --git a/limereport/items/lrbarcodeitem.h b/limereport/items/lrbarcodeitem.h index 3f56c59..cfd6265 100644 --- a/limereport/items/lrbarcodeitem.h +++ b/limereport/items/lrbarcodeitem.h @@ -50,6 +50,7 @@ class BarcodeItem : public LimeReport::ContentItemDesignIntf { Q_PROPERTY(int securityLevel READ securityLevel WRITE setSecurityLevel) Q_PROPERTY(int pdf417CodeWords READ pdf417CodeWords WRITE setPdf417CodeWords) Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode) + Q_PROPERTY(bool hideText READ hideText WRITE setHideText) public: // enum BarcodeType {QRCODE=58,CODE128=20,DATAMATRIX=71,MAXICODE=57,MICROPDF417=84}; // enum BarcodeType {CODE_11=1,C25MATRIX=2,QRCODE=58,CODE128=20,DATAMATRIX=71,MAXICODE=57,MICROPDF417=84, @@ -167,6 +168,9 @@ public: InputMode inputMode() const; void setInputMode(const InputMode &inputMode); + bool hideText() const; + void setHideText(bool hideText); + private: Zint::QZint m_bc; QString m_content; @@ -180,6 +184,7 @@ private: int m_securityLevel; int m_pdf417CodeWords; InputMode m_inputMode; + bool m_hideText; }; } diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index 15e5809..eae907f 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -59,7 +59,8 @@ namespace LimeReport{ TextItem::TextItem(QObject *owner, QGraphicsItem *parent) : ContentItemDesignIntf(xmlTag,owner,parent), m_angle(Angle0), m_trimValue(true), m_allowHTML(false), - m_allowHTMLInFields(false), m_followTo(""), m_follower(0), m_textIndent(0), m_textLayoutDirection(Qt::LayoutDirectionAuto) + m_allowHTMLInFields(false), m_replaceCarriageReturns(false), m_followTo(""), m_follower(0), m_textIndent(0), + m_textLayoutDirection(Qt::LayoutDirectionAuto) { PageItemDesignIntf* pageItem = dynamic_cast(parent); BaseDesignIntf* parentItem = dynamic_cast(parent); @@ -112,17 +113,19 @@ void TextItem::processPopUpAction(QAction *action) if (action->text().compare(tr("Edit")) == 0){ this->showEditorDialog(); } - if (action->text().compare(tr("Auto height")) == 0){ - page()->setPropertyToSelectedItems("autoHeight",action->isChecked()); - } - if (action->text().compare(tr("Allow HTML")) == 0){ - page()->setPropertyToSelectedItems("allowHTML",action->isChecked()); - } - if (action->text().compare(tr("Allow HTML in fields")) == 0){ - page()->setPropertyToSelectedItems("allowHTMLInFields",action->isChecked()); - } - if (action->text().compare(tr("Stretch to max height")) == 0){ - page()->setPropertyToSelectedItems("stretchToMaxHeight",action->isChecked()); + if (page()){ + if (action->text().compare(tr("Auto height")) == 0){ + page()->setPropertyToSelectedItems("autoHeight",action->isChecked()); + } + if (action->text().compare(tr("Allow HTML")) == 0){ + page()->setPropertyToSelectedItems("allowHTML",action->isChecked()); + } + if (action->text().compare(tr("Allow HTML in fields")) == 0){ + page()->setPropertyToSelectedItems("allowHTMLInFields",action->isChecked()); + } + if (action->text().compare(tr("Stretch to max height")) == 0){ + page()->setPropertyToSelectedItems("stretchToMaxHeight",action->isChecked()); + } } } @@ -289,8 +292,10 @@ void TextItem::setContent(const QString &value) void TextItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { + if (isNeedExpandContent()) expandContent(dataManager, pass); + if (!isLoading() && (autoHeight() || autoWidth() || hasFollower()) ) initTextSizes(); @@ -331,12 +336,12 @@ bool TextItem::isNeedExpandContent() const return content().contains(rx); } -QString TextItem::replaceBR(QString text) +QString TextItem::replaceBR(QString text) const { return text.replace("
","\n"); } -QString TextItem::replaceReturns(QString text) +QString TextItem::replaceReturns(QString text) const { QString result = text.replace("\r\n","
"); result = result.replace("\n","
"); @@ -465,7 +470,11 @@ TextItem::TextPtr TextItem::textDocument() const TextPtr text(new QTextDocument); if (allowHTML()) - text->setHtml(m_strText); + if (isReplaceCarriageReturns()){ + text->setHtml(replaceReturns(m_strText)); + } else { + text->setHtml(m_strText); + } else text->setPlainText(m_strText); @@ -513,6 +522,21 @@ TextItem::TextPtr TextItem::textDocument() const } +bool TextItem::isReplaceCarriageReturns() const +{ + return m_replaceCarriageReturns; +} + +void TextItem::setReplaceCarriageReturns(bool replaceCarriageReturns) +{ + if (replaceCarriageReturns != m_replaceCarriageReturns){ + m_replaceCarriageReturns = replaceCarriageReturns; + update(); + notify("replaceCRwithBR",!replaceCarriageReturns, replaceCarriageReturns); + } + +} + qreal TextItem::textIndent() const { return m_textIndent; diff --git a/limereport/items/lrtextitem.h b/limereport/items/lrtextitem.h index 5bc82fb..d8fa8cc 100644 --- a/limereport/items/lrtextitem.h +++ b/limereport/items/lrtextitem.h @@ -72,6 +72,7 @@ class TextItem : public LimeReport::ContentItemDesignIntf, IPageInit { Q_PROPERTY(qreal textIndent READ textIndent WRITE setTextIndent) Q_PROPERTY(Qt::LayoutDirection textLayoutDirection READ textLayoutDirection WRITE setTextLayoutDirection) Q_PROPERTY(bool watermark READ isWatermark WRITE setWatermark) + Q_PROPERTY(bool replaceCRwithBR READ isReplaceCarriageReturns WRITE setReplaceCarriageReturns) public: enum AutoWidth{NoneAutoWidth,MaxWordLength,MaxStringLength}; @@ -167,11 +168,14 @@ public: void setWatermark(bool watermark); + bool isReplaceCarriageReturns() const; + void setReplaceCarriageReturns(bool isReplaceCarriageReturns); + protected: void updateLayout(); bool isNeedExpandContent() const; - QString replaceBR(QString text); - QString replaceReturns(QString text); + QString replaceBR(QString text) const; + QString replaceReturns(QString text) const; int fakeMarginSize() const; QString getTextPart(int height, int skipHeight); void restoreLinksEvent(); @@ -204,6 +208,7 @@ private: int m_underlineLineSize; bool m_allowHTML; bool m_allowHTMLInFields; + bool m_replaceCarriageReturns; QString m_format; ValueType m_valueType; diff --git a/limereport/limereport.prf b/limereport/limereport.prf new file mode 100644 index 0000000..98acf6c --- /dev/null +++ b/limereport/limereport.prf @@ -0,0 +1,22 @@ +QT += xml sql script + +greaterThan(QT_MAJOR_VERSION, 4) { +QT += widgets printsupport +} + +INCLUDEPATH += $$[QT_INSTALL_HEADERS]/LimeReport + +CONFIG(debug, debug|release) { +LIB_NAME = limereportd +} else { +LIB_NAME = limereport +} + +greaterThan(QT_MAJOR_VERSION, 4) { + LIBS += -l$${LIB_NAME} +} else { + qtAddLibrary($${LIB_NAME}) +} + +DEFINES += LIMEREPORT +DEFINES -= NO_LIMEREPORT diff --git a/limereport/limereport.pro b/limereport/limereport.pro index b05ac00..3aa045c 100644 --- a/limereport/limereport.pro +++ b/limereport/limereport.pro @@ -37,7 +37,6 @@ contains(CONFIG, staticlib){ } EXTRA_FILES += \ - $$PWD/lrglobal.cpp \ $$PWD/lrglobal.h \ $$PWD/lrdatasourcemanagerintf.h \ $$PWD/lrreportengine.h \ @@ -65,17 +64,25 @@ unix:{ } win32 { - EXTRA_FILES ~= s,/,\\,g - BUILD_DIR ~= s,/,\\,g DESTDIR = $${DEST_LIBS} - DEST_DIR = $$DESTDIR/include - DEST_DIR ~= s,/,\\,g - DEST_INCLUDE_DIR ~= s,/,\\,g + contains(QMAKE_HOST.os, Linux){ + QMAKE_POST_LINK += mkdir -p $$quote($${DEST_INCLUDE_DIR}) $$escape_expand(\\n\\t) # qmake need make mkdir -p on subdirs more than root/ + for(FILE,EXTRA_FILES){ + QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($${DEST_INCLUDE_DIR}) $$escape_expand(\\n\\t) # inside of libs make /include/files + } + QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($${DEST_INCLUDE_DIR}) $$quote($${DESTDIR}) + } else { + EXTRA_FILES ~= s,/,\\,g + BUILD_DIR ~= s,/,\\,g + DEST_DIR = $$DESTDIR/include + DEST_DIR ~= s,/,\\,g + DEST_INCLUDE_DIR ~= s,/,\\,g - for(FILE,EXTRA_FILES){ - QMAKE_POST_LINK += $$QMAKE_COPY \"$$FILE\" \"$${DEST_INCLUDE_DIR}\" $$escape_expand(\\n\\t) + for(FILE,EXTRA_FILES){ + QMAKE_POST_LINK += $$QMAKE_COPY \"$$FILE\" \"$${DEST_INCLUDE_DIR}\" $$escape_expand(\\n\\t) + } + QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$${DEST_INCLUDE_DIR}\" \"$${DEST_DIR}\" } - QMAKE_POST_LINK += $$QMAKE_COPY_DIR \"$${DEST_INCLUDE_DIR}\" \"$${DEST_DIR}\" } contains(CONFIG,zint){ @@ -92,6 +99,20 @@ contains(CONFIG,zint){ } + +#### Install mkspecs, headers and libs to QT_INSTALL_DIR + +headerFiles.path = $$[QT_INSTALL_HEADERS]/LimeReport/ +headerFiles.files = $${DEST_INCLUDE_DIR}/* +INSTALLS += headerFiles + +mkspecs.path = $$[QT_INSTALL_DATA]/mkspecs/features +mkspecs.files = limereport.prf +INSTALLS += mkspecs + +target.path = $$[QT_INSTALL_LIBS] +INSTALLS += target + ####### ####Automatically build required translation files (*.qm) diff --git a/limereport/lrbanddesignintf.cpp b/limereport/lrbanddesignintf.cpp index 4e3b5fc..fbef4f0 100644 --- a/limereport/lrbanddesignintf.cpp +++ b/limereport/lrbanddesignintf.cpp @@ -128,7 +128,7 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q m_startFromNewPage(false), m_printAlways(false), m_repeatOnEachRow(false), - m_bottomSpace() + m_bottomSpace(0) { setPossibleResizeDirectionFlags(ResizeBottom); setPossibleMoveFlags(TopBotom); @@ -372,7 +372,7 @@ int BandDesignIntf::maxChildIndex(BandDesignIntf::BandsType bandType) const{ int BandDesignIntf::maxChildIndex(QSet ignoredBands) const{ int curIndex = bandIndex(); foreach(BandDesignIntf* childBand, childBands()){ - if (!ignoredBands.contains(childBand->bandType()) && childBand->bandIndex()>bandIndex()){ + if (!ignoredBands.contains(childBand->bandType())){ curIndex = std::max(curIndex,childBand->maxChildIndex(ignoredBands)); } } @@ -389,6 +389,19 @@ int BandDesignIntf::minChildIndex(BandDesignIntf::BandsType bandType){ return curIndex; } +int BandDesignIntf::minChildIndex(QSet ignoredBands) +{ + int curIndex = bandIndex(); + foreach(BandDesignIntf* childBand, childBands()){ + if (!ignoredBands.contains(childBand->bandType()) && childBand->bandIndex() < bandIndex()){ + curIndex = std::min(curIndex, childBand->maxChildIndex(ignoredBands)); + } + } + return curIndex; +} + + + QList BandDesignIntf::childrenByType(BandDesignIntf::BandsType type) { QList resList; @@ -428,7 +441,11 @@ bool BandDesignIntf::isNeedRender() const void BandDesignIntf::setTryToKeepTogether(bool value) { - m_tryToKeepTogether=value; + if (m_tryToKeepTogether != value){ + m_tryToKeepTogether = value; + if (!isLoading()) + notify("keepSubdetailTogether", !value, value); + } } bool BandDesignIntf::tryToKeepTogether() @@ -485,10 +502,15 @@ void BandDesignIntf::moveItemsDown(qreal startPos, qreal offset){ void BandDesignIntf::preparePopUpMenu(QMenu &menu) { + + QList disabledActions; + disabledActions << tr("Bring to top") << + tr("Send to back") << + tr("Cut") << + tr("Copy"); + foreach (QAction* action, menu.actions()) { - if (action->text().compare(tr("Bring to top")) == 0 || - action->text().compare(tr("Send to back")) == 0 ) - action->setEnabled(false); + action->setEnabled(!disabledActions.contains(action->text())); } menu.addSeparator(); @@ -497,6 +519,7 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu) currAction->setChecked(autoHeight()); currAction = menu.addAction(tr("Splittable")); + currAction->setEnabled(metaObject()->indexOfProperty("splittable") != -1); currAction->setCheckable(true); currAction->setChecked(isSplittable()); @@ -504,13 +527,10 @@ void BandDesignIntf::preparePopUpMenu(QMenu &menu) currAction->setCheckable(true); currAction->setChecked(keepBottomSpaceOption()); - currAction = menu.addAction(tr("Start from new page")); + currAction = menu.addAction(tr("Print if empty")); currAction->setCheckable(true); - currAction->setChecked(startFromNewPage()); + currAction->setChecked(printIfEmpty()); - currAction = menu.addAction(tr("Start new page")); - currAction->setCheckable(true); - currAction->setChecked(startNewPage()); } void BandDesignIntf::processPopUpAction(QAction *action) @@ -524,19 +544,16 @@ void BandDesignIntf::processPopUpAction(QAction *action) if (action->text().compare(tr("Keep bottom space")) == 0){ setProperty("keepBottomSpace",action->isChecked()); } - if (action->text().compare(tr("Start new page")) == 0){ - setProperty("startNewPage",action->isChecked()); - } - if (action->text().compare(tr("Start from new page")) == 0){ - setProperty("startFromNewPage",action->isChecked()); + if (action->text().compare(tr("Print if empty")) == 0){ + setProperty("printIfEmpty",action->isChecked()); } + } BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent) { int maxBottom = 0; BandDesignIntf* upperPart = dynamic_cast(createSameTypeItem(owner,parent)); - upperPart->m_bottomSpace = this->bottomSpace(); BaseDesignIntf* upperItem = 0; upperPart->initFromItem(this); @@ -583,7 +600,6 @@ bool itemLessThen(QGraphicsItem* i1, QGraphicsItem* i2){ BaseDesignIntf *BandDesignIntf::cloneBottomPart(int height, QObject *owner, QGraphicsItem *parent) { BandDesignIntf* bottomPart = dynamic_cast(createSameTypeItem(owner,parent)); - bottomPart->m_bottomSpace = this->bottomSpace(); bottomPart->initFromItem(this); QList bandItems; @@ -781,7 +797,7 @@ void BandDesignIntf::setAlternateBackgroundColor(const QColor &alternateBackgrou qreal BandDesignIntf::bottomSpace() const { - return m_bottomSpace.isValid() ? m_bottomSpace.value() : height()-findMaxBottom(); + return height()-findMaxBottom(); } void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QString& newName) @@ -791,6 +807,16 @@ void BandDesignIntf::slotPropertyObjectNameChanged(const QString &, const QStrin m_bandNameLabel->updateLabel(newName); } +int BandDesignIntf::bootomSpace() const +{ + return m_bottomSpace; +} + +void BandDesignIntf::setBootomSpace(int bootomSpace) +{ + m_bottomSpace = bootomSpace; +} + bool BandDesignIntf::repeatOnEachRow() const { return m_repeatOnEachRow; @@ -798,7 +824,11 @@ bool BandDesignIntf::repeatOnEachRow() const void BandDesignIntf::setRepeatOnEachRow(bool repeatOnEachRow) { - m_repeatOnEachRow = repeatOnEachRow; + if (m_repeatOnEachRow != repeatOnEachRow){ + m_repeatOnEachRow = repeatOnEachRow; + if (!isLoading()) + notify("repeatOnEachRow", !m_repeatOnEachRow, m_repeatOnEachRow); + } } bool BandDesignIntf::printAlways() const @@ -808,7 +838,11 @@ bool BandDesignIntf::printAlways() const void BandDesignIntf::setPrintAlways(bool printAlways) { - m_printAlways = printAlways; + if (m_printAlways != printAlways){ + m_printAlways = printAlways; + if (!isLoading()) + notify("printAlways", !m_printAlways, m_printAlways); + } } bool BandDesignIntf::startFromNewPage() const @@ -854,7 +888,11 @@ bool BandDesignIntf::reprintOnEachPage() const void BandDesignIntf::setReprintOnEachPage(bool reprintOnEachPage) { - m_reprintOnEachPage = reprintOnEachPage; + if (m_reprintOnEachPage != reprintOnEachPage){ + m_reprintOnEachPage = reprintOnEachPage; + if (!isLoading()) + notify("reprintOnEachPage", !m_reprintOnEachPage, m_reprintOnEachPage); + } } int BandDesignIntf::columnIndex() const @@ -874,14 +912,21 @@ bool BandDesignIntf::printIfEmpty() const void BandDesignIntf::setPrintIfEmpty(bool printIfEmpty) { - m_printIfEmpty = printIfEmpty; + if (m_printIfEmpty != printIfEmpty){ + m_printIfEmpty = printIfEmpty; + if (!isLoading()) + notify("printIfEmpty", !m_printIfEmpty, m_printIfEmpty); + } + } BandDesignIntf *BandDesignIntf::bandHeader() { foreach (BandDesignIntf* band, childBands()) { - if (band->isHeader() && !band->isGroupHeader()) + if (band->isHeader() && !band->isGroupHeader()){ + if (band->columnsCount() > 1) band->setColumnsFillDirection(this->columnsFillDirection()); return band; + } } return 0; } @@ -901,7 +946,11 @@ bool BandDesignIntf::sliceLastRow() const void BandDesignIntf::setSliceLastRow(bool sliceLastRow) { - m_sliceLastRow = sliceLastRow; + if (m_sliceLastRow != sliceLastRow){ + m_sliceLastRow = sliceLastRow; + if (!isLoading()) + notify("sliceLastRow", !sliceLastRow, sliceLastRow); + } } int BandDesignIntf::maxScalePercent() const @@ -938,6 +987,8 @@ void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass p if (borderLines()!=0){ spaceBorder += borderLineSize(); } + + spaceBorder += m_bottomSpace; restoreLinks(); snapshotItemsLayout(); arrangeSubItems(pass, dataManager); diff --git a/limereport/lrbanddesignintf.h b/limereport/lrbanddesignintf.h index 7bf8401..b8f47c5 100644 --- a/limereport/lrbanddesignintf.h +++ b/limereport/lrbanddesignintf.h @@ -167,6 +167,7 @@ public: bool isConnectedToBand(BandDesignIntf::BandsType bandType) const; int minChildIndex(BandsType bandType); + int minChildIndex(QSet ignoredBands = QSet()); int maxChildIndex(BandDesignIntf::BandsType bandType) const; int maxChildIndex(QSet ignoredBands = QSet()) const; @@ -239,8 +240,10 @@ public: qreal bottomSpace() const; void setBackgroundModeProperty(BGMode value); void setBackgroundOpacity(int value); + int bootomSpace() const; + void setBootomSpace(int bootomSpace); signals: - void bandRendered(BandDesignIntf* band); + void bandRendered(BandDesignIntf* band); protected: void trimToMaxHeight(int maxHeight); void setBandTypeText(const QString& value); @@ -294,7 +297,7 @@ private: bool m_repeatOnEachRow; QMap m_slicedItems; QColor m_alternateBackgroundColor; - InitializedValue m_bottomSpace; + int m_bottomSpace; }; class DataBandDesignIntf : public BandDesignIntf{ diff --git a/limereport/lrbasedesignintf.cpp b/limereport/lrbasedesignintf.cpp index 61c7283..898c9a7 100644 --- a/limereport/lrbasedesignintf.cpp +++ b/limereport/lrbasedesignintf.cpp @@ -544,10 +544,12 @@ void BaseDesignIntf::mouseMoveEvent(QGraphicsSceneMouseEvent *event) setItemPos(QPointF(div(m_startPos.x(), hStep).quot * hStep, div(m_startPos.y(), vStep).quot * vStep) - delta); - if (!isBand() && scene()->selectedItems().count()>1) - moveSelectedItems(tmpPos - pos()); - if (scene()->selectedItems().count()==1 && (page()->magneticMovement())) - page()->itemMoved(this); + if (page()){ + if (!isBand() && page()->selectedItems().count()>1) + moveSelectedItems(tmpPos - pos()); + if (page()->selectedItems().count()==1 && (page()->magneticMovement())) + page()->itemMoved(this); + } } } @@ -806,29 +808,29 @@ void BaseDesignIntf::setBorderLineSize(int value) void BaseDesignIntf::moveRight() { - if (!m_fixedPos) setItemPos(pos().x() + page()->horizontalGridStep(), pos().y()); + if (!m_fixedPos && page()) setItemPos(pos().x() + page()->horizontalGridStep(), pos().y()); } void BaseDesignIntf::moveLeft() { - if (!m_fixedPos) setItemPos(pos().x() - page()->horizontalGridStep(), pos().y()); + if (!m_fixedPos && page()) setItemPos(pos().x() - page()->horizontalGridStep(), pos().y()); } void BaseDesignIntf::moveDown() { - if (!m_fixedPos) setItemPos(pos().x(), pos().y() + page()->verticalGridStep()); + if (!m_fixedPos && page()) setItemPos(pos().x(), pos().y() + page()->verticalGridStep()); } void BaseDesignIntf::moveUp() { - if (!m_fixedPos) setItemPos(pos().x(), pos().y() - page()->verticalGridStep()); + if (!m_fixedPos && page()) setItemPos(pos().x(), pos().y() - page()->verticalGridStep()); } void BaseDesignIntf::sizeRight() { if ((m_possibleResizeDirectionFlags & ResizeLeft) || (m_possibleResizeDirectionFlags & ResizeRight)) { - setWidth(width() + page()->horizontalGridStep()); + if (page()) setWidth(width() + page()->horizontalGridStep()); } } @@ -836,7 +838,7 @@ void BaseDesignIntf::sizeLeft() { if ((m_possibleResizeDirectionFlags & ResizeLeft) || (m_possibleResizeDirectionFlags & ResizeRight)) { - setWidth(width() - page()->horizontalGridStep()); + if(page()) setWidth(width() - page()->horizontalGridStep()); } } @@ -844,7 +846,7 @@ void BaseDesignIntf::sizeUp() { if ((m_possibleResizeDirectionFlags & ResizeTop) || (m_possibleResizeDirectionFlags & ResizeBottom)) { - setHeight(height() - page()->verticalGridStep()); + if (page()) setHeight(height() - page()->verticalGridStep()); } } @@ -852,7 +854,7 @@ void BaseDesignIntf::sizeDown() { if ((m_possibleResizeDirectionFlags & ResizeTop) || (m_possibleResizeDirectionFlags & ResizeBottom)) { - setHeight(height() + page()->verticalGridStep()); + if (page()) setHeight(height() + page()->verticalGridStep()); } } @@ -964,7 +966,9 @@ void BaseDesignIntf::setGeometryProperty(QRectF rect) setWidth(rect.width()); if (rect.height() != geometry().height()) setHeight(rect.height()); - if (!isLoading()) notify("geometry",oldValue,rect); + if (!isLoading()) { + notify("geometry",oldValue,rect); + } } } @@ -1022,6 +1026,7 @@ QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co if (change == QGraphicsItem::ItemPositionHasChanged) { updateSelectionMarker(); } + if (change == QGraphicsItem::ItemSelectedChange) { turnOnSelectionMarker(value.toBool()); emit itemSelectedHasBeenChanged(this, value.toBool()); @@ -1116,30 +1121,23 @@ void BaseDesignIntf::setItemPos(const QPointF &newPos) QPointF oldPos = pos(); QPointF finalPos = modifyPosForAlignedItem(newPos); QGraphicsItem::setPos(finalPos); - emit posChanged(this, finalPos, oldPos); + emit posChanging(this, finalPos, oldPos); } void BaseDesignIntf::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { - QGraphicsItem::mouseReleaseEvent(event); QRectF newGeometry = geometry(); if (newGeometry != m_oldGeometry) { geometryChangedEvent(newGeometry, m_oldGeometry); updateSelectionMarker(); - emit(geometryChanged(this, newGeometry, m_oldGeometry)); + emit(posChanged(this, newGeometry.topLeft(), m_oldGeometry.topLeft())); } + QGraphicsItem::mouseReleaseEvent(event); } void BaseDesignIntf::showEditorDialog(){ QWidget *editor = defaultEditor(); if (editor) { - -#ifdef Q_OS_WIN - editor->setAttribute(Qt::WA_DeleteOnClose); - editor->setWindowFlags(Qt::Dialog); - editor->setWindowModality(Qt::ApplicationModal); - editor->show(); -#else QDialog* dialog = new QDialog(QApplication::activeWindow()); dialog->setAttribute(Qt::WA_DeleteOnClose); #ifdef Q_OS_MAC @@ -1153,7 +1151,6 @@ void BaseDesignIntf::showEditorDialog(){ dialog->layout()->addWidget(editor); connect(editor,SIGNAL(destroyed()),dialog,SLOT(close())); dialog->exec(); -#endif } } @@ -1337,7 +1334,7 @@ void BaseDesignIntf::collectionLoadFinished(const QString &collectionName) foreach(QObject * obj, QObject::children()) { #endif BaseDesignIntf *item = dynamic_cast(obj); - if (item) { + if (item && page()) { page()->registerItem(item); } } diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 904b64e..313c0f4 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -401,6 +401,7 @@ private: bool m_watermark; signals: void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); + void posChanging(QObject* object, QPointF newPos, QPointF oldPos); void posChanged(QObject* object, QPointF newPos, QPointF oldPos); void itemSelected(LimeReport::BaseDesignIntf *item); void itemSelectedHasBeenChanged(BaseDesignIntf *item, bool value); @@ -412,7 +413,6 @@ signals: void propertyesChanged(QVector propertyNames); void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue); void itemVisibleHasChanged(BaseDesignIntf* item); - void beforeRender(); void afterData(); void afterRender(); diff --git a/limereport/lrdatadesignintf.cpp b/limereport/lrdatadesignintf.cpp index 18e0d49..b98c4aa 100644 --- a/limereport/lrdatadesignintf.cpp +++ b/limereport/lrdatadesignintf.cpp @@ -628,14 +628,17 @@ QVariant MasterDetailProxyModel::sourceData(QString fieldName, int row) const QVariant MasterDetailProxyModel::masterData(QString fieldName) const { IDataSource* master = dataManager()->dataSource(m_masterName); - int columnIndex = master->columnIndexByName(fieldName); - if (columnIndex!=-1){ - return master->data(fieldName); - } else { - throw ReportError( - tr("Field: \"%1\" not found in \"%2\" master datasource").arg(fieldName).arg(m_masterName) - ); + if (master){ + int columnIndex = master->columnIndexByName(fieldName); + if (columnIndex!=-1){ + return master->data(fieldName); + } else { + throw ReportError( + tr("Field: \"%1\" not found in \"%2\" master datasource").arg(fieldName).arg(m_masterName) + ); + } } + return QVariant(); } bool CallbackDatasource::next(){ @@ -689,6 +692,7 @@ bool CallbackDatasource::prior(){ void CallbackDatasource::first(){ m_currentRow = 0; + m_getDataFromCache = false; m_eof=checkIfEmpty(); bool result=false; diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index c7950f2..20ff3fb 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -217,7 +217,8 @@ void DataSourceModel::updateModel() } DataSourceManager::DataSourceManager(QObject *parent) : - QObject(parent), m_lastError(""), m_designTime(true), m_needUpdate(false), m_dbCredentialsProvider(0) + QObject(parent), m_lastError(""), m_designTime(true), m_needUpdate(false), + m_dbCredentialsProvider(0), m_hasChanges(false) { m_groupFunctionFactory.registerFunctionCreator(QLatin1String("COUNT"),new ConstructorGroupFunctionCreator); m_groupFunctionFactory.registerFunctionCreator(QLatin1String("SUM"),new ConstructorGroupFunctionCreator); @@ -230,11 +231,11 @@ DataSourceManager::DataSourceManager(QObject *parent) : setSystemVariable(QLatin1String("#IS_FIRST_PAGEFOOTER"),false,FirstPass); connect(&m_reportVariables, SIGNAL(variableHasBeenAdded(QString)), - this, SLOT(slotVariableHasBeenAdded(QString)) ); + this, SLOT(slotVariableHasBeenAdded(QString))); connect(&m_reportVariables, SIGNAL(variableHasBeenChanged(QString)), this, SLOT(slotVariableHasBeenChanged(QString))); connect(&m_userVariables, SIGNAL(variableHasBeenAdded(QString)), - this, SLOT(slotVariableHasBeenAdded(QString)) ); + this, SLOT(slotVariableHasBeenAdded(QString))); connect(&m_userVariables, SIGNAL(variableHasBeenChanged(QString)), this, SLOT(slotVariableHasBeenChanged(QString))); @@ -499,6 +500,7 @@ void DataSourceManager::addQuery(const QString &name, const QString &sqlText, co QueryDesc *queryDecs = new QueryDesc(name,sqlText,connectionName); putQueryDesc(queryDecs); putHolder(name,new QueryHolder(sqlText, connectionName, this)); + m_hasChanges = true; emit datasourcesChanged(); } @@ -507,6 +509,7 @@ void DataSourceManager::addSubQuery(const QString &name, const QString &sqlText, SubQueryDesc *subQueryDesc = new SubQueryDesc(name.toLower(),sqlText,connectionName,masterDatasource); putSubQueryDesc(subQueryDesc); putHolder(name,new SubQueryHolder(sqlText, connectionName, masterDatasource, this)); + m_hasChanges = true; emit datasourcesChanged(); } @@ -521,6 +524,7 @@ void DataSourceManager::addProxy(const QString &name, QString master, QString de } putProxyDesc(proxyDesc); putHolder(name,new ProxyHolder(proxyDesc, this)); + m_hasChanges = true; emit datasourcesChanged(); } @@ -643,6 +647,7 @@ void DataSourceManager::removeDatasource(const QString &name) delete m_proxies.at(proxyIndex); m_proxies.removeAt(proxyIndex); } + m_hasChanges = true; emit datasourcesChanged(); } @@ -663,6 +668,7 @@ void DataSourceManager::removeConnection(const QString &connectionName) cit++; } } + m_hasChanges = true; emit datasourcesChanged(); } @@ -671,6 +677,7 @@ void DataSourceManager::addConnectionDesc(ConnectionDesc * connection) if (!isConnection(connection->name())) { connect(connection,SIGNAL(nameChanged(QString,QString)),this,SLOT(slotConnectionRenamed(QString,QString))); m_connections.append(connection); + m_hasChanges = true; if (connection->autoconnect()){ try{ connectConnection(connection); @@ -1025,6 +1032,7 @@ QStringList DataSourceManager::fieldNames(const QString &datasourceName) void DataSourceManager::addConnection(const QString &connectionName) { addConnectionDesc(new ConnectionDesc(QSqlDatabase::database(connectionName))); + m_hasChanges = true; emit datasourcesChanged(); } @@ -1189,8 +1197,10 @@ void DataSourceManager::deleteVariable(const QString& name) m_userVariables.deleteVariable(name); if (m_reportVariables.containsVariable(name)&&m_reportVariables.variableType(name)==VarDesc::Report){ m_reportVariables.deleteVariable(name); - if (designTime()) - emit datasourcesChanged(); + if (designTime()){ + m_hasChanges = true; + emit datasourcesChanged(); + } } } @@ -1266,14 +1276,16 @@ void DataSourceManager::invalidateQueriesContainsVariable(const QString& variabl void DataSourceManager::slotVariableHasBeenAdded(const QString& variableName) { - //qDebug()<< "variable has been added"<< variableName; invalidateQueriesContainsVariable(variableName); + if (variableType(variableName) == VarDesc::Report) + m_hasChanges = true; } void DataSourceManager::slotVariableHasBeenChanged(const QString& variableName) { - //qDebug()<< "variable has been changed"<< variableName; invalidateQueriesContainsVariable(variableName); + if (variableType(variableName) == VarDesc::Report) + m_hasChanges = true; } void DataSourceManager::clear(ClearMethod method) diff --git a/limereport/lrdatasourcemanager.h b/limereport/lrdatasourcemanager.h index fabb694..32e1168 100644 --- a/limereport/lrdatasourcemanager.h +++ b/limereport/lrdatasourcemanager.h @@ -201,6 +201,8 @@ public: ReportSettings *reportSettings() const; void setReportSettings(ReportSettings *reportSettings); + bool isHasChanges(){ return m_hasChanges; } + void dropChanges(){ m_hasChanges = false; } signals: void loadCollectionFinished(const QString& collectionName); void cleared(); @@ -256,6 +258,7 @@ private: QHash m_groupFunctionsExpressionsMap; QVector m_groupFunctionsExpressions; IDbCredentialsProvider* m_dbCredentialsProvider; + bool m_hasChanges; }; } diff --git a/limereport/lrglobal.h b/limereport/lrglobal.h index f2c866f..ea8b279 100644 --- a/limereport/lrglobal.h +++ b/limereport/lrglobal.h @@ -78,15 +78,7 @@ namespace Const{ const QString VARIABLE_RX = "\\$V\\s*\\{\\s*([^{}]*)\\s*\\}"; const QString NAMED_VARIABLE_RX = "\\$V\\s*\\{\\s*(%1)\\s*\\}"; const QString SCRIPT_RX = "\\$S\\s*\\{(.*)\\}"; - - //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(((?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"))(\\w+\\.?\\w+)((?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,\\s*\\\"(\\w+)\\\"\\s*\\)"; - //const int DATASOURCE_INDEX = 6; - //const int VALUE_INDEX = 2; - - //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:((?:(?:\\\"?\\$D\\s*\\{\\s*)|(?:\\\"?\\$V\\s*\\{\\s*)|(?:\\\"?\\$S\\s*\\{\\s*)|(?:\\\"))((?:\\w+\\.?\\w+)|(?:\\w+))(?:(?:\\\")|(?:\\s*\\}\\\"?\\s*)))\\s*,)|(?:))\\s*\\\"(\\w+)\\\"\\s*\\)"; - //const QString GROUP_FUNCTION_PARAM_RX = "\\((?:(.+),(.+))|(?:\\\"(\\w+)\\\")\\)"; - //const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*(?:(?:(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:)))|(?:(?:(?:\\\")|(?:))(\\s*\\$\\w\\s*\\{.+\\}\\s*)(?:(?:\\\")|(?:))\\s*,\\s*(?:(?:\\\")|(?:))(\\w+)(?:(?:\\\")|(?:))))\\)"; - const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*.\\w*\\s*\\})|(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))\\)"; + const QString GROUP_FUNCTION_PARAM_RX = "\\(\\s*((?:(?:\\\")|(?:))(?:(?:\\$(?:(?:D\\{\\s*\\w*..*\\})|(?:V\\{\\s*\\w*\\s*\\})|(?:S\\{.+\\})))|(?:\\w*))(?:(?:\\\")|(?:)))(?:(?:\\s*,\\s*(?:\\\"(\\w*)\\\"))|(?:))(?:(?:\\s*,\\s*(?:(\\w*)))|(?:))\\)"; const int DATASOURCE_INDEX = 3;//4; const int VALUE_INDEX = 2; //2; const int EXPRESSION_ARGUMENT_INDEX = 1;//3; @@ -103,6 +95,7 @@ namespace Const{ enum ExpandType {EscapeSymbols, NoEscapeSymbols, ReplaceHTMLSymbols}; enum RenderPass {FirstPass, SecondPass}; enum ArrangeType {AsNeeded, Force}; + enum ScaleType {FitWidth, FitPage, OneToOne, Percents}; enum PreviewHint{ShowAllPreviewBars = 0, HidePreviewToolBar = 1, HidePreviewMenuBar = 2, diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 67d8408..a241adc 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -67,8 +67,6 @@ bool bandSortBandLessThen(const BandDesignIntf *c1, const BandDesignIntf *c2) PageDesignIntf::PageDesignIntf(QObject *parent): QGraphicsScene(parent), - m_pageSize(A4), - m_orientation(Portrait), m_pageItem(0), m_insertMode(false), m_itemInsertRect(0), @@ -79,13 +77,11 @@ PageDesignIntf::PageDesignIntf(QObject *parent): m_changePosMode(false), m_changePosOrSizeMode(false), m_executingCommand(false), - m_hasHanges(false), + m_hasChanges(false), m_isLoading(false), m_executingGroupCommand(false), m_settings(0), m_selectionRect(0), - //m_verticalGridStep(1*Const::mmFACTOR), - //m_horizontalGridStep(1*Const::mmFACTOR) m_verticalGridStep(2), m_horizontalGridStep(2), m_updating(false), @@ -134,22 +130,22 @@ void PageDesignIntf::updatePageRect() emit sceneRectChanged(sceneRect()); } -PageDesignIntf::Orientation PageDesignIntf::getOrientation() -{ - return m_orientation; -} +//PageDesignIntf::Orientation PageDesignIntf::getOrientation() +//{ +// return m_orientation; +//} -void PageDesignIntf::setPageSize(PageDesignIntf::PageSize sizeType, QSizeF sizeValue) -{ - m_pageSize = sizeType; - m_pageSizeValue = sizeValue; - updatePageRect(); -} +//void PageDesignIntf::setPageSize(PageDesignIntf::PageSize sizeType, QSizeF sizeValue) +//{ +// m_pageSize = sizeType; +// m_pageSizeValue = sizeValue; +// updatePageRect(); +//} -PageDesignIntf::PageSize PageDesignIntf::pageSize() const -{ - return m_pageSize; -} +//PageDesignIntf::PageSize PageDesignIntf::pageSize() const +//{ +// return m_pageSize; +//} void PageDesignIntf::keyPressEvent(QKeyEvent *event) { @@ -612,7 +608,7 @@ bool PageDesignIntf::saveCommand(CommandIf::Ptr command, bool runCommand) m_commandsList.push_back(command); m_currentCommand = m_commandsList.count() - 1; - m_hasHanges = true; + m_hasChanges = true; emit commandHistoryChanged(); return true; } @@ -629,7 +625,7 @@ bool PageDesignIntf::isCanUndo() bool PageDesignIntf::isHasChanges() { - return (m_commandsList.count() > 0) && m_hasHanges; + return (m_commandsList.count() > 0) && m_hasChanges; } bool PageDesignIntf::isItemInsertMode() @@ -672,22 +668,22 @@ bool PageDesignIntf::isExistsObjectName(const QString &objectName, QList 0) && (m_positionStamp.count() > 0)) { - if (m_positionStamp[0].pos != selectedItems().at(0)->pos()) { + bool bandFound = false; + foreach(QGraphicsItem* item, selectedItems()){ + BandDesignIntf* band = dynamic_cast(item); + if (band){ + bandFound = true; + break; + } + } + if (!bandFound && (m_positionStamp[0].pos != selectedItems().at(0)->pos())) { posCommand = createChangePosCommand(); } m_positionStamp.clear(); @@ -909,16 +912,14 @@ CommandIf::Ptr PageDesignIntf::createChangePosCommand() QVector newPoses; foreach(ReportItemPos itemPos, m_positionStamp) { BaseDesignIntf *reportItem = reportItemByName(itemPos.objectName); - if (reportItem) { ReportItemPos newPos; newPos.objectName = reportItem->objectName(); newPos.pos = reportItem->pos(); newPoses.append(newPos); } - } + } return PosChangedCommand::create(this, m_positionStamp, newPoses); - } CommandIf::Ptr PageDesignIntf::createChangeSizeCommand() @@ -1200,7 +1201,7 @@ void PageDesignIntf::undo() m_executingCommand = true; m_commandsList.at(m_currentCommand)->undoIt(); m_currentCommand--; - m_hasHanges = true; + m_hasChanges = true; m_executingCommand = false; } } @@ -1211,7 +1212,7 @@ void PageDesignIntf::redo() m_executingCommand = true; m_currentCommand++; m_commandsList.at(m_currentCommand)->doIt(); - m_hasHanges = true; + m_hasChanges = true; m_executingCommand = false; } } @@ -1321,7 +1322,7 @@ void PageDesignIntf::cut() void PageDesignIntf::setToSaved() { - m_hasHanges = false; + m_hasChanges = false; } void PageDesignIntf::bringToFront() @@ -1854,7 +1855,7 @@ CommandIf::Ptr CutCommand::create(PageDesignIntf *page) ItemsWriterIntf *writer = new XMLWriter(); foreach(QGraphicsItem * item, page->selectedItems()) { if (!dynamic_cast(item)){ - BaseDesignIntf *reportItem = dynamic_cast(item); + ItemDesignIntf *reportItem = dynamic_cast(item); if (reportItem) { command->m_itemNames.push_back(reportItem->objectName()); @@ -2240,7 +2241,58 @@ qreal ItemProjections::square(QRectF rect) qreal ItemProjections::square(BaseDesignIntf *item) { - return square(QRectF(item->pos().x(),item->pos().y(),item->width(),item->height())); + return square(QRectF(item->pos().x(),item->pos().y(),item->width(),item->height())); +} + +CommandIf::Ptr BandSwapCommand::create(PageDesignIntf *page, const QString &bandName, const QString &bandToSwapName) +{ + BandSwapCommand *command = new BandSwapCommand(); + command->setPage(page); + command->bandName = bandName; + command->bandToSwapName = bandToSwapName; + return CommandIf::Ptr(command); +} + +bool BandSwapCommand::doIt() +{ + BandDesignIntf* band = dynamic_cast(page()->reportItemByName(bandName)); + BandDesignIntf* bandToSwap = dynamic_cast(page()->reportItemByName(bandToSwapName)); + if (page() && band && bandToSwap){ + page()->pageItem()->swapBands(band, bandToSwap); + return true; + } + return false; +} + +void BandSwapCommand::undoIt() +{ + BandDesignIntf* band = dynamic_cast(page()->reportItemByName(bandName)); + BandDesignIntf* bandToSwap = dynamic_cast(page()->reportItemByName(bandToSwapName)); + if (page() && band && bandToSwap) + page()->pageItem()->swapBands(bandToSwap, band); +} + +CommandIf::Ptr BandMoveFromToCommand::create(PageDesignIntf* page, int from, int to) +{ + BandMoveFromToCommand* command = new BandMoveFromToCommand(); + command->setPage(page); + command->from = from; + command->to = to; + return CommandIf::Ptr(command); +} + +bool BandMoveFromToCommand::doIt() +{ + if (page() && from != to) { + page()->pageItem()->moveBandFromTo(from, to); + return true; + } + return false; +} + +void BandMoveFromToCommand::undoIt() +{ + if (page()) page()->pageItem()->moveBandFromTo(to, from); } } diff --git a/limereport/lrpagedesignintf.h b/limereport/lrpagedesignintf.h index 684df0b..7688838 100644 --- a/limereport/lrpagedesignintf.h +++ b/limereport/lrpagedesignintf.h @@ -99,223 +99,203 @@ namespace LimeReport { class PageDesignIntf : public QGraphicsScene, public ObjectLoadingStateIntf{ Q_OBJECT Q_PROPERTY(QObject* pageItem READ pageItem()) - public: - friend class PropertyChangedCommand; - friend class InsertHLayoutCommand; - enum Orientation {Portrait, Landscape}; - enum PageSize {A4, B5, Letter, Legal, Executive, - A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1, - B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E, - DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom - }; + public: + friend class PropertyChangedCommand; + friend class InsertHLayoutCommand; + explicit PageDesignIntf(QObject* parent = 0); + ~PageDesignIntf(); + void updatePageRect(); - explicit PageDesignIntf(QObject* parent = 0); - ~PageDesignIntf(); - void updatePageRect(); - Orientation getOrientation(); + void startInsertMode(const QString& ItemType); + void startEditMode(); - void setPageSize(PageSize sizeType, QSizeF sizeValue=QSizeF()); - PageSize pageSize() const; + PageItemDesignIntf *pageItem(); + void setPageItem(PageItemDesignIntf::Ptr pageItem); + void setPageItems(QList pages); + QList pageItems(){return m_reportPages;} - void startInsertMode(const QString& ItemType); - void startEditMode(); + bool isItemInsertMode(); + ReportEnginePrivate* reportEditor(); + void setReportEditor(ReportEnginePrivate* value){m_reportEditor=value;} - PageItemDesignIntf *pageItem(); - void setPageItem(PageItemDesignIntf::Ptr pageItem); - void setPageItems(QList pages); - QList pageItems(){return m_reportPages;} + QStringList possibleParentItems(); + void registerItem(BaseDesignIntf* item); + void registerBand(BandDesignIntf* band); + void removeAllItems(); - bool isItemInsertMode(); - ReportEnginePrivate* reportEditor(); - void setReportEditor(ReportEnginePrivate* value){m_reportEditor=value;} + void setItemMode(BaseDesignIntf::ItemMode state); + BaseDesignIntf::ItemMode itemMode(){return m_itemMode;} + BaseDesignIntf* reportItemByName(const QString& name); + QList reportItemsByName(const QString &name); + BaseDesignIntf* addReportItem(const QString& itemType, QPointF pos, QSizeF size); + BaseDesignIntf* addReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0); + BaseDesignIntf* createReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0); + void removeReportItem(BaseDesignIntf* item, bool createComand = true); + CommandIf::Ptr removeReportItemCommand(BaseDesignIntf *item); + bool saveCommand(CommandIf::Ptr command, bool runCommand = true); - QStringList possibleParentItems(); - void registerItem(BaseDesignIntf* item); - void registerBand(BandDesignIntf* band); - void removeAllItems(); + bool isCanRedo(); + bool isCanUndo(); + bool isHasChanges(); - void setItemMode(BaseDesignIntf::ItemMode state); - BaseDesignIntf::ItemMode itemMode(){return m_itemMode;} - BaseDesignIntf* reportItemByName(const QString& name); - QList reportItemsByName(const QString &name); - BaseDesignIntf* addReportItem(const QString& itemType, QPointF pos, QSizeF size); - BaseDesignIntf* addReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0); - BaseDesignIntf* createReportItem(const QString& itemType, QObject *owner=0, BaseDesignIntf *parent=0); - void removeReportItem(BaseDesignIntf* item, bool createComand = true); - CommandIf::Ptr removeReportItemCommand(BaseDesignIntf *item); - bool saveCommand(CommandIf::Ptr command, bool runCommand = true); + void reactivatePageItem(PageItemDesignIntf::Ptr pageItem); - bool isCanRedo(); - bool isCanUndo(); - bool isHasChanges(); + void setSettings(QSettings* settings){ m_settings = settings;} + QSettings* settings(){ return m_settings;} - void reactivatePageItem(PageItemDesignIntf::Ptr pageItem); + QString genObjectName(const QObject& object); - void setSettings(QSettings* settings){ m_settings = settings;} - QSettings* settings(){ return m_settings;} + void animateItem(BaseDesignIntf* item); + void setSelectionRect(QRectF selectionRect); + void emitRegisterdItem(BaseDesignIntf *item); + void emitItemRemoved(BaseDesignIntf* item); - QString genObjectName(const QObject& object); + DataSourceManager* datasourceManager(); + bool isSaved(){ return !m_hasChanges;} + void changeSelectedGrpoupTextAlignPropperty(const bool& horizontalAlign, Qt::AlignmentFlag flag); - void animateItem(BaseDesignIntf* item); - void setSelectionRect(QRectF selectionRect); - void emitRegisterdItem(BaseDesignIntf *item); - void emitItemRemoved(BaseDesignIntf* item); + int verticalGridStep() const; + void setVerticalGridStep(int verticalGridStep); - DataSourceManager* datasourceManager(); - bool isSaved(){ return !m_hasHanges;} - void changeSelectedGrpoupTextAlignPropperty(const bool& horizontalAlign, Qt::AlignmentFlag flag); + int horizontalGridStep() const; + void setHorizontalGridStep(int horizontalGridStep); - int verticalGridStep() const; - void setVerticalGridStep(int verticalGridStep); + void beginUpdate(){m_updating = true;} + bool isUpdating(){return m_updating;} + void endUpdate(); - int horizontalGridStep() const; - void setHorizontalGridStep(int horizontalGridStep); - - void beginUpdate(){m_updating = true;} - bool isUpdating(){return m_updating;} - void endUpdate(); - - void itemMoved(BaseDesignIntf* item); - bool magneticMovement() const; - void setMagneticMovement(bool magneticMovement); - - ReportSettings *getReportSettings() const; - void setReportSettings(ReportSettings *reportSettings); - - void setPropertyToSelectedItems(const char *name, const QVariant &value); + void itemMoved(BaseDesignIntf* item); + bool magneticMovement() const; + void setMagneticMovement(bool magneticMovement); + ReportSettings *getReportSettings() const; + void setReportSettings(ReportSettings *reportSettings); + void setPropertyToSelectedItems(const char *name, const QVariant &value); protected: + virtual void keyPressEvent(QKeyEvent *event); + virtual void keyReleaseEvent(QKeyEvent *event); + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void keyPressEvent(QKeyEvent *event); - virtual void keyReleaseEvent(QKeyEvent *event); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event); + virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *); + virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); + virtual void dropEvent(QGraphicsSceneDragDropEvent *event); - virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event); - virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *); - virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); - virtual void dropEvent(QGraphicsSceneDragDropEvent *event); + LimeReport::BandDesignIntf::BandsType findPriorType(LimeReport::BandDesignIntf::BandsType bandType); + BaseDesignIntf *findDestObject(BaseDesignIntf *item); - LimeReport::BandDesignIntf::BandsType findPriorType(LimeReport::BandDesignIntf::BandsType bandType); - BaseDesignIntf *findDestObject(BaseDesignIntf *item); + bool isExistsObjectName (const QString& objectName, QList &itemsList) const; - bool isExistsObjectName (const QString& objectName, QList &itemsList) const; - QRectF getRectByPageSize(PageSize pageSize); + bool isLoading(); + void objectLoadStarted(); + void objectLoadFinished(); - bool isLoading(); - void objectLoadStarted(); - void objectLoadFinished(); - - HorizontalLayout* internalAddHLayout(); - QPointF placePosOnGrid(QPointF point); - QSizeF placeSizeOnGrid(QSizeF size); + HorizontalLayout* internalAddHLayout(); + QPointF placePosOnGrid(QPointF point); + QSizeF placeSizeOnGrid(QSizeF size); signals: - void geometryChanged(QRectF newGeometry); - void insertModeStarted(); - void itemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType); - void itemInsertCanceled(const QString& ItemType); - void itemSelected(LimeReport::BaseDesignIntf *item); - void multiItemsSelected(QList* objectsList); - void miltiItemsSelectionFinished(); - void commandHistoryChanged(); - void itemPropertyChanged(const QString& objectName, const QString& propertyName, const QVariant& oldValue, const QVariant& newValue); - void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); - void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); - void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band); - void bandRemoved(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band); - void pageUpdateFinished(LimeReport::PageDesignIntf* page); - public slots: - BaseDesignIntf* addBand(const QString& bandType); - BaseDesignIntf* addBand(BandDesignIntf::BandsType bandType); - void removeBand(LimeReport::BandDesignIntf* band); - void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); - void bandPosChanged(QObject* object, QPointF newPos, QPointF oldPos); - void slotUpdateItemSize(); - void undo(); - void redo(); - void copy(); - void paste(); - void deleteSelected(); - void cut(); - void setToSaved(); - void bringToFront(); - void sendToBack(); - void alignToLeft(); - void alignToRigth(); - void alignToVCenter(); - void alignToTop(); - void alignToBottom(); - void alignToHCenter(); - void sameWidth(); - void sameHeight(); - void addHLayout(); - void setFont(const QFont &font); - void setTextAlign(const Qt::Alignment& alignment); - void setBorders(const BaseDesignIntf::BorderLines& border); - private slots: - void slotPageGeometryChanged(QObject*, QRectF, QRectF ); - void slotItemPropertyChanged(QString propertyName, const QVariant &oldValue, const QVariant &newValue); - void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName); - void bandDeleted(QObject* band); - void slotPageItemLoaded(QObject *); - void slotSelectionChanged(); - void slotAnimationStoped(QObject *animation); - private: - template - BaseDesignIntf* internalAddBand(T bandType); - void finalizeInsertMode(); - void saveSelectedItemsPos(); - void saveSelectedItemsGeometry(); - void checkSizeOrPosChanges(); - CommandIf::Ptr createChangePosCommand(); - CommandIf::Ptr createChangeSizeCommand(); - void saveChangeProppertyCommand(const QString& objectName, const QString& propertyName, const QVariant& oldPropertyValue, const QVariant& newPropertyValue); - void changeSelectedGroupProperty(const QString& name,const QVariant& value); - - private: - enum JoinType{Width, Height}; - PageSize m_pageSize; - QSizeF m_pageSizeValue; - Orientation m_orientation; - QRectF m_geometry; - LimeReport::PageItemDesignIntf::Ptr m_pageItem; - QList m_reportPages; - ReportEnginePrivate* m_reportEditor; - bool m_insertMode; - QGraphicsItem * m_itemInsertRect; - QString m_insertItemType; - BaseDesignIntf::ItemMode m_itemMode; - QGraphicsRectItem* m_cutterBorder; - QGraphicsRectItem* m_pageRect; - QVector m_commandsList; - QVector m_positionStamp; - QVector m_geometryStamp; - BaseDesignIntf* m_firstSelectedItem; - int m_currentCommand; - bool m_changeSizeMode; - bool m_changePosMode; - bool m_changePosOrSizeMode; - bool m_executingCommand; - bool m_hasHanges; - bool m_isLoading; - bool m_executingGroupCommand; - QSettings* m_settings; - QList m_animationList; - QPointF m_startSelectionPoint; - QGraphicsRectItem* m_selectionRect; - int m_verticalGridStep; - int m_horizontalGridStep; - bool m_updating; - int m_currentObjectIndex; - bool m_multiSelectStarted; - QList m_projections; - BaseDesignIntf* m_movedItem; - BaseDesignIntf* m_movedItemContainer; - BaseDesignIntf* m_joinItem; - JoinType m_joinType; - bool m_magneticMovement; - ReportSettings* m_reportSettings; + void geometryChanged(QRectF newGeometry); + void insertModeStarted(); + void itemInserted(LimeReport::PageDesignIntf* report, QPointF pos, const QString& ItemType); + void itemInsertCanceled(const QString& ItemType); + void itemSelected(LimeReport::BaseDesignIntf *item); + void multiItemsSelected(QList* objectsList); + void miltiItemsSelectionFinished(); + void commandHistoryChanged(); + void itemPropertyChanged(const QString& objectName, const QString& propertyName, const QVariant& oldValue, const QVariant& newValue); + void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); + void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item); + void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band); + void bandRemoved(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band); + void pageUpdateFinished(LimeReport::PageDesignIntf* page); + public slots: + BaseDesignIntf* addBand(const QString& bandType); + BaseDesignIntf* addBand(BandDesignIntf::BandsType bandType); + void removeBand(LimeReport::BandDesignIntf* band); + void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); + void bandPosChanged(QObject* object, QPointF newPos, QPointF oldPos); + void slotUpdateItemSize(); + void undo(); + void redo(); + void copy(); + void paste(); + void deleteSelected(); + void cut(); + void setToSaved(); + void bringToFront(); + void sendToBack(); + void alignToLeft(); + void alignToRigth(); + void alignToVCenter(); + void alignToTop(); + void alignToBottom(); + void alignToHCenter(); + void sameWidth(); + void sameHeight(); + void addHLayout(); + void setFont(const QFont &font); + void setTextAlign(const Qt::Alignment& alignment); + void setBorders(const BaseDesignIntf::BorderLines& border); + private slots: + void slotPageGeometryChanged(QObject*, QRectF, QRectF ); + void slotItemPropertyChanged(QString propertyName, const QVariant &oldValue, const QVariant &newValue); + void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName); + void bandDeleted(QObject* band); + void slotPageItemLoaded(QObject *); + void slotSelectionChanged(); + void slotAnimationStoped(QObject *animation); + private: + template + BaseDesignIntf* internalAddBand(T bandType); + void finalizeInsertMode(); + void saveSelectedItemsPos(); + void saveSelectedItemsGeometry(); + void checkSizeOrPosChanges(); + CommandIf::Ptr createChangePosCommand(); + CommandIf::Ptr createChangeSizeCommand(); + void saveChangeProppertyCommand(const QString& objectName, const QString& propertyName, const QVariant& oldPropertyValue, const QVariant& newPropertyValue); + void changeSelectedGroupProperty(const QString& name,const QVariant& value); + private: + enum JoinType{Width, Height}; + LimeReport::PageItemDesignIntf::Ptr m_pageItem; + QList m_reportPages; + ReportEnginePrivate* m_reportEditor; + bool m_insertMode; + QGraphicsItem * m_itemInsertRect; + QString m_insertItemType; + BaseDesignIntf::ItemMode m_itemMode; + QGraphicsRectItem* m_cutterBorder; + QGraphicsRectItem* m_pageRect; + QVector m_commandsList; + QVector m_positionStamp; + QVector m_geometryStamp; + BaseDesignIntf* m_firstSelectedItem; + int m_currentCommand; + bool m_changeSizeMode; + bool m_changePosMode; + bool m_changePosOrSizeMode; + bool m_executingCommand; + bool m_hasChanges; + bool m_isLoading; + bool m_executingGroupCommand; + QSettings* m_settings; + QList m_animationList; + QPointF m_startSelectionPoint; + QGraphicsRectItem* m_selectionRect; + int m_verticalGridStep; + int m_horizontalGridStep; + bool m_updating; + int m_currentObjectIndex; + bool m_multiSelectStarted; + QList m_projections; + BaseDesignIntf* m_movedItem; + BaseDesignIntf* m_movedItemContainer; + BaseDesignIntf* m_joinItem; + JoinType m_joinType; + bool m_magneticMovement; + ReportSettings* m_reportSettings; }; class AbstractPageCommand : public CommandIf{ @@ -435,6 +415,27 @@ namespace LimeReport { QVector m_newPos; }; + class BandSwapCommand : public AbstractPageCommand{ + public: + static CommandIf::Ptr create(PageDesignIntf* page, const QString& bandName, const QString& bandToSwapName); + bool doIt(); + void undoIt(); + private: + QString bandName; + QString bandToSwapName; + }; + + class BandMoveFromToCommand : public AbstractPageCommand{ + public: + static CommandIf::Ptr create(PageDesignIntf* page, int from, int to); + bool doIt(); + void undoIt(); + private: + int from; + int to; + }; + + class SizeChangedCommand : public AbstractPageCommand{ public: static CommandIf::Ptr create(PageDesignIntf* page, QVector& oldSize, QVector& newSize); diff --git a/limereport/lrpageitemdesignintf.cpp b/limereport/lrpageitemdesignintf.cpp index 2e8de0b..21e9c81 100644 --- a/limereport/lrpageitemdesignintf.cpp +++ b/limereport/lrpageitemdesignintf.cpp @@ -201,17 +201,22 @@ int PageItemDesignIntf::calcBandIndex(BandDesignIntf::BandsType bandType, BandDe int bandIndex=-1; qSort(m_bands.begin(),m_bands.end(),bandSortBandLessThenByIndex); - foreach(BandDesignIntf* band,m_bands){ - if ((band->bandType() == BandDesignIntf::GroupHeader) && ( band->bandType() > bandType)) break; - if ((band->bandType() <= bandType)){ - if (bandIndex <= band->bandIndex()) { - if (bandType != BandDesignIntf::Data){ + if (bandType != BandDesignIntf::Data){ + foreach(BandDesignIntf* band,m_bands){ + if ((band->bandType() == BandDesignIntf::GroupHeader) && ( band->bandType() > bandType)) break; + if ((band->bandType() <= bandType)){ + if (bandIndex <= band->bandIndex()) { bandIndex=band->maxChildIndex(bandType)+1; - } else { - bandIndex=band->maxChildIndex()+1; } - } - } else { increaseBandIndex = true; break;} + } else { increaseBandIndex = true; break;} + } + } else { + int maxChildIndex = 0; + foreach(BandDesignIntf* band, m_bands){ + if (band->bandType() == BandDesignIntf::Data) + maxChildIndex = std::max(maxChildIndex, band->maxChildIndex()); + } + bandIndex = std::max(bandIndex, maxChildIndex+1); } if (bandIndex==-1) { @@ -298,7 +303,11 @@ void PageItemDesignIntf::registerBand(BandDesignIntf *band) band->setParentItem(this); band->setWidth(pageRect().width()/band->columnsCount()); connect(band, SIGNAL(destroyed(QObject*)),this,SLOT(bandDeleted(QObject*))); - connect(band, SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),this,SLOT(bandGeometryChanged(QObject*,QRectF,QRectF))); + connect(band, SIGNAL(posChanged(QObject*, QPointF, QPointF)), + this, SLOT(bandPositionChanged(QObject*, QPointF, QPointF))); + connect(band, SIGNAL(geometryChanged(QObject*, QRectF, QRectF)), + this, SLOT(bandGeometryChanged(QObject*, QRectF, QRectF))); + } } @@ -396,8 +405,16 @@ void PageItemDesignIntf::relocateBands() m_bands[i+1]->columnsCount()); } if (m_bands[i+1]->columnIndex()==0){ - m_bands[i+1]->setPos(pageRect().x(),posByColumn[0]); - posByColumn[0] += m_bands[i+1]->height()+bandSpace; + if ( ((m_bands[i]->borderLines() & BandDesignIntf::BottomLine) && + (m_bands[i+1]->borderLines() & BandDesignIntf::TopLine)) || + (!(m_bands[i]->borderLines() & BandDesignIntf::BottomLine) && + !(m_bands[i+1]->borderLines() & BandDesignIntf::TopLine)) ){ + m_bands[i+1]->setPos(pageRect().x(),posByColumn[0]); + posByColumn[0] += m_bands[i+1]->height()+bandSpace; + } else { + m_bands[i+1]->setPos(pageRect().x(),posByColumn[0]+2); + posByColumn[0] += m_bands[i+1]->height()+bandSpace+2; + } } else { m_bands[i+1]->setPos(m_bands[i+1]->pos().x(),posByColumn[m_bands[i+1]->columnIndex()]); posByColumn[m_bands[i+1]->columnIndex()] += m_bands[i+1]->height()+bandSpace; @@ -568,39 +585,127 @@ void PageItemDesignIntf::bandDeleted(QObject *band) relocateBands(); } -void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry) +void PageItemDesignIntf::swapBands(BandDesignIntf* band, BandDesignIntf* bandToSwap){ + + int firstIndex = std::min(band->minChildIndex(), bandToSwap->minChildIndex()); + int secondIndex = std::max(band->minChildIndex(), bandToSwap->minChildIndex()); + int moveIndex = std::min(band->maxChildIndex(), bandToSwap->maxChildIndex()); + + QList bandToMove; + foreach(BandDesignIntf* curBand, m_bands){ + if ( curBand->bandIndex() > moveIndex && curBand->bandIndex() < secondIndex && + curBand->bandType() == band->bandType() && + curBand != band && curBand != bandToSwap + ) + bandToMove.append(curBand); + } + + BandDesignIntf* firstMoveBand = (bandToSwap->bandIndex() > band->bandIndex()) ? bandToSwap: band; + + firstMoveBand->changeBandIndex(firstIndex, true); + moveIndex = firstMoveBand->maxChildIndex() + 1; + moveIndex = firstIndex; + qSort(bandToMove.begin(), bandToMove.end(), bandIndexLessThen); + + foreach(BandDesignIntf* curBand, bandToMove){ + curBand->changeBandIndex(moveIndex,true); + moveIndex = curBand->maxChildIndex() + 1; + } + + if (firstMoveBand == band){ + bandToSwap->changeBandIndex(moveIndex,true); + } else { + band->changeBandIndex(moveIndex, true); + } + relocateBands(); + +} + +void PageItemDesignIntf::moveBandFromTo(int from, int to) { - BandDesignIntf* band = dynamic_cast(object); - int curIndex = band->bandIndex(); - BandDesignIntf* bandToSwap = 0; - foreach(BandDesignIntf* curBand, bands()){ - if (newGeometry.y()>oldGeometry.y()) { - if (curBand->bandType() == band->bandType() - && curIndexbandIndex() - && (curBand->pos().y()+(curBand->height()/2))parentBand() == band->parentBand()) - { - curIndex = curBand->bandIndex(); - bandToSwap = curBand; - } - } else { - if (curBand->bandType() == band->bandType() - && curIndex>curBand->bandIndex() - && (curBand->pos().y()+(curBand->height()/2))>newGeometry.y() - && curBand->parentBand() == band->parentBand()) - { - curIndex = curBand->bandIndex(); - bandToSwap = curBand; - } + BandDesignIntf* firstBand = 0; + BandDesignIntf* secondBand = 0; + + int firstIndex = std::min(from,to); + int secondIndex = std::max(from,to); + QList bandsToMove; + int moveIndex = 0; + + foreach(BandDesignIntf* band, bands()){ + if (band->bandIndex() == from){ + firstBand = band; + } + if (band->bandIndex() == to){ + secondBand = band; + bandsToMove.append(band); } } - if (curIndex != band->bandIndex()){ - int swapIndex = bandToSwap->maxChildIndex(); - bandToSwap->changeBandIndex(band->bandIndex(),true); - band->changeBandIndex(swapIndex,true); + + foreach(BandDesignIntf* curBand, m_bands){ + if ( curBand->bandIndex() > firstIndex && curBand->bandIndex() < secondIndex && + curBand->bandType() == firstBand->bandType() && + curBand != firstBand + ) + bandsToMove.append(curBand); + } + qSort(bandsToMove.begin(), bandsToMove.end(), bandIndexLessThen); + + + if (from > to){ + firstBand->changeBandIndex(secondBand->minChildIndex(), true); + moveIndex = firstBand->maxChildIndex()+1; + } else { + moveIndex = firstBand->minChildIndex(); + firstBand->changeBandIndex(secondBand->minChildIndex(), true); + } + + foreach(BandDesignIntf* curBand, bandsToMove){ + curBand->changeBandIndex(moveIndex,true); + moveIndex = curBand->maxChildIndex() + 1; } relocateBands(); + +} + +void PageItemDesignIntf::bandPositionChanged(QObject* object, QPointF newPos, QPointF oldPos) +{ + if (itemMode() == DesignMode){ + BandDesignIntf* band = dynamic_cast(object); + int curIndex = band->bandIndex(); + BandDesignIntf* bandToSwap = 0; + foreach(BandDesignIntf* curBand, bands()){ + if (newPos.y() > oldPos.y()) { + if (curBand->bandType() == band->bandType() + && curIndex < curBand->bandIndex() + && (curBand->pos().y() + (curBand->height()/2)) < newPos.y() + && curBand->parentBand() == band->parentBand()) + { + curIndex = curBand->bandIndex(); + bandToSwap = curBand; + } + } else { + if (curBand->bandType() == band->bandType() + && curIndex>curBand->bandIndex() + && (curBand->pos().y() + (curBand->height()/2)) > newPos.y() + && curBand->parentBand() == band->parentBand()) + { + curIndex = curBand->bandIndex(); + bandToSwap = curBand; + } + } + } + if (curIndex != band->bandIndex() && itemMode() == DesignMode){ + if (page()) + page()->saveCommand(BandMoveFromToCommand::create(page(), band->bandIndex(), bandToSwap->bandIndex()), true); + } + } + relocateBands(); +} + +void PageItemDesignIntf::bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry) +{ + bandPositionChanged(object, newGeometry.topLeft(), oldGeometry.topLeft()); } void PageItemDesignIntf::collectionLoadFinished(const QString &collectionName) diff --git a/limereport/lrpageitemdesignintf.h b/limereport/lrpageitemdesignintf.h index ef9b06d..e24556a 100644 --- a/limereport/lrpageitemdesignintf.h +++ b/limereport/lrpageitemdesignintf.h @@ -34,6 +34,7 @@ #include "lritemscontainerdesignitf.h" #include #include +#include namespace LimeReport{ @@ -55,12 +56,19 @@ class PageItemDesignIntf : public LimeReport::ItemsContainerDesignInft Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber) friend class ReportRender; public: - enum Orientation { Portrait, Landscape }; - enum PageSize {A4, B5, Letter, Legal, Executive, - A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1, - B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E, - DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom - }; + enum Orientation { Portrait = QPrinter::Portrait, Landscape = QPrinter::Landscape }; + enum PageSize { + A4 = QPrinter::A4, B5 = QPrinter::B5, Letter = QPrinter::Letter, + Legal = QPrinter::Legal, Executive = QPrinter::Executive, + A0 = QPrinter::A0, A1 = QPrinter::A1, A2 = QPrinter::A2, A3 = QPrinter::A3, + A5 = QPrinter::A5, A6 = QPrinter::A6, A7 = QPrinter::A7, A8 = QPrinter::A8, + A9 = QPrinter::A9, B0 = QPrinter::B0, B1 = QPrinter::B1, B10 = QPrinter::B10, + B2 = QPrinter::B2, B3 = QPrinter::B3, B4 = QPrinter::B4, B6 = QPrinter::B6, + B7 = QPrinter::B7, B8 = QPrinter::B8, B9 = QPrinter::B9, C5E = QPrinter::C5E, + Comm10E = QPrinter::Comm10E, DLE = QPrinter::DLE, Folio = QPrinter::Folio, + Ledger = QPrinter::Ledger, Tabloid = QPrinter::Tabloid, Custom = QPrinter::Custom, + NPageSize = Custom + }; typedef QList BandsList; typedef QList::const_iterator BandsIterator; typedef QSharedPointer Ptr; @@ -116,10 +124,13 @@ public: bool canContainChildren(){ return true;} bool resetPageNumber() const; void setResetPageNumber(bool resetPageNumber); - void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager); + void updateSubItemsSize(RenderPass pass, DataSourceManager *dataManager); + void swapBands(BandDesignIntf *band, BandDesignIntf *bandToSwap); + void moveBandFromTo(int from, int to); protected slots: void bandDeleted(QObject* band); + void bandPositionChanged(QObject* object, QPointF newPos, QPointF oldPos); void bandGeometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry); protected: void collectionLoadFinished(const QString& collectionName); diff --git a/limereport/lrpreviewreportwidget.cpp b/limereport/lrpreviewreportwidget.cpp index 4e36335..2776aeb 100644 --- a/limereport/lrpreviewreportwidget.cpp +++ b/limereport/lrpreviewreportwidget.cpp @@ -61,18 +61,21 @@ PageItemDesignIntf::Ptr PreviewReportWidgetPrivate::currentPage() PreviewReportWidget::PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent) : QWidget(parent), - ui(new Ui::PreviewReportWidget), d_ptr(new PreviewReportWidgetPrivate(this)) + ui(new Ui::PreviewReportWidget), d_ptr(new PreviewReportWidgetPrivate(this)), + m_scaleType(FitWidth), m_scalePercent(0) { ui->setupUi(this); d_ptr->m_previewPage = report->createPreviewPage(); d_ptr->m_previewPage->setItemMode( LimeReport::PreviewMode ); d_ptr->m_report = report; + m_resizeTimer.setSingleShot(true); ui->errorsView->setVisible(false); connect(ui->graphicsView->verticalScrollBar(),SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int))); connect(d_ptr->m_report, SIGNAL(destroyed(QObject*)), this, SLOT(reportEngineDestroyed(QObject*))); d_ptr->m_zoomer = new GraphicsViewZoomer(ui->graphicsView); connect(d_ptr->m_zoomer, SIGNAL(zoomed(double)), this, SLOT(slotZoomed(double))); + connect(&m_resizeTimer, SIGNAL(timeout()), this, SLOT(resizeDone())); } PreviewReportWidget::~PreviewReportWidget() @@ -221,6 +224,12 @@ void PreviewReportWidget::setScalePercent(int percent) qreal scaleSize = percent/100.0; ui->graphicsView->scale(scaleSize, scaleSize); emit scalePercentChanged(percent); + if (percent == 100){ + m_scaleType = OneToOne; + } else { + m_scaleType = Percents; + m_scalePercent = percent; + } } void PreviewReportWidget::fitWidth() @@ -228,6 +237,7 @@ void PreviewReportWidget::fitWidth() if (d_ptr->currentPage()){ qreal scalePercent = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width(); setScalePercent(scalePercent*100); + m_scaleType = FitWidth; } } @@ -237,9 +247,15 @@ void PreviewReportWidget::fitPage() qreal vScale = ui->graphicsView->viewport()->width() / ui->graphicsView->scene()->width(); qreal hScale = ui->graphicsView->viewport()->height() / d_ptr->currentPage()->height(); setScalePercent(qMin(vScale,hScale)*100); + m_scaleType = FitPage; } } +void PreviewReportWidget::resizeEvent(QResizeEvent *) +{ + m_resizeTimer.start(100); +} + void PreviewReportWidget::setErrorMessages(const QStringList &value) { foreach (QString line, value) { @@ -252,6 +268,22 @@ void PreviewReportWidget::emitPageSet() emit pagesSet(d_ptr->m_reportPages.count()); } +ScaleType PreviewReportWidget::scaleType() const +{ + return m_scaleType; +} + +int PreviewReportWidget::scalePercent() const +{ + return m_scalePercent; +} + +void PreviewReportWidget::setScaleType(const ScaleType &scaleType, int percent) +{ + m_scaleType = scaleType; + m_scalePercent = percent; +} + void PreviewReportWidget::refreshPages() { if (d_ptr->m_report){ @@ -305,6 +337,23 @@ void PreviewReportWidget::slotZoomed(double ) emit scalePercentChanged(d_ptr->m_scalePercent); } +void PreviewReportWidget::resizeDone() +{ + switch (m_scaleType) { + case FitPage: + fitPage(); + break; + case FitWidth: + fitWidth(); + break; + case OneToOne: + setScalePercent(100); + break; + case Percents: + setScalePercent(m_scalePercent); + break; + } +} } diff --git a/limereport/lrpreviewreportwidget.h b/limereport/lrpreviewreportwidget.h index 4e35ea6..d66ac70 100644 --- a/limereport/lrpreviewreportwidget.h +++ b/limereport/lrpreviewreportwidget.h @@ -2,6 +2,7 @@ #define LRPREVIEWREPORTWIDGET_H #include +#include #include "lrglobal.h" namespace LimeReport { @@ -22,6 +23,9 @@ class LIMEREPORT_EXPORT PreviewReportWidget : public QWidget public: explicit PreviewReportWidget(ReportEnginePrivate *report, QWidget *parent = 0); ~PreviewReportWidget(); + ScaleType scaleType() const; + int scalePercent() const; + void setScaleType(const ScaleType &scaleType, int percent = 0); public slots: void refreshPages(); void zoomIn(); @@ -39,6 +43,8 @@ public slots: void setScalePercent(int percent); void fitWidth(); void fitPage(); +protected: + void resizeEvent(QResizeEvent *); signals: void pageChanged(int page); void scalePercentChanged(int percent); @@ -47,6 +53,7 @@ private slots: void slotSliderMoved(int value); void reportEngineDestroyed(QObject* object); void slotZoomed(double); + void resizeDone(); private: void initPreview(); void setErrorsMesagesVisible(bool visible); @@ -55,6 +62,9 @@ private: private: Ui::PreviewReportWidget *ui; PreviewReportWidgetPrivate* d_ptr; + ScaleType m_scaleType; + int m_scalePercent; + QTimer m_resizeTimer; }; } // namespace LimeReport diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index 47c4ec0..d58678e 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -45,7 +45,7 @@ namespace LimeReport{ PreviewReportWindow::PreviewReportWindow(ReportEnginePrivate *report,QWidget *parent, QSettings *settings, Qt::WindowFlags flags) : QMainWindow(parent,flags), - ui(new Ui::PreviewReportWindow), m_settings(settings), m_ownedSettings(false) + ui(new Ui::PreviewReportWindow), m_settings(settings), m_ownedSettings(false), m_scalePercentChanging(false) { ui->setupUi(this); setWindowTitle("Lime Report Preview"); @@ -253,7 +253,22 @@ void PreviewReportWindow::showEvent(QShowEvent *) { m_fontEditor->setVisible(ui->actionEdit_Mode->isChecked()); m_textAlignmentEditor->setVisible(ui->actionEdit_Mode->isChecked()); + switch (m_previewScaleType) { + case FitWidth: + m_previewReportWidget->fitWidth(); + break; + case FitPage: + m_previewReportWidget->fitPage(); + break; + case OneToOne: + m_previewReportWidget->setScalePercent(100); + break; + case Percents: + m_previewReportWidget->setScalePercent(m_previewScalePercent); + + } } + void PreviewReportWindow::selectStateIcon() { if (ui->toolBar->isHidden()){ @@ -333,6 +348,18 @@ void PreviewReportWindow::initPercentCombobox() m_scalePercent->setCurrentIndex(4); } +ScaleType PreviewReportWindow::previewScaleType() const +{ + return m_previewScaleType; +} + +void PreviewReportWindow::setPreviewScaleType(const ScaleType &previewScaleType, int percent) +{ + m_previewScaleType = previewScaleType; + m_previewScalePercent = percent; + m_previewReportWidget->setScaleType(previewScaleType, percent); +} + void PreviewReportWindow::on_actionSaveToFile_triggered() { m_previewReportWidget->saveToFile(); @@ -375,12 +402,20 @@ void PreviewReportWindow::on_actionOne_to_one_triggered() void PreviewReportWindow::scaleComboboxChanged(QString text) { + if (m_scalePercentChanging) return; + m_scalePercentChanging = true; m_previewReportWidget->setScalePercent(text.remove(text.count()-1,1).toInt()); + m_scalePercentChanging = false; } void PreviewReportWindow::slotScalePercentChanged(int percent) { + if (m_scalePercentChanging) return; + m_scalePercentChanging = true; + if (m_scalePercent->findText(QString("%1%").arg(percent)) == -1) + m_scalePercent->setCurrentIndex(-1); m_scalePercent->setEditText(QString("%1%").arg(percent)); + m_scalePercentChanging = false; } void PreviewReportWindow::on_actionShowMessages_toggled(bool value) diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index 78e4c07..bc6da16 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -68,6 +68,9 @@ public: void setMenuVisible(bool value); void setHideResultEditButton(bool value); QSettings* settings(); + ScaleType previewScaleType() const; + void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0); + protected: void writeSetting(); void restoreSetting(); @@ -115,6 +118,10 @@ private: int m_priorScrolValue; PreviewReportWidget* m_previewReportWidget; QComboBox* m_scalePercent; + ScaleType m_previewScaleType; + int m_previewScalePercent; + bool m_scalePercentChanging; + }; } //namespace LimeReport #endif // LRPREVIEWREPORTWINDOW_H diff --git a/limereport/lrreportdesignwindow.cpp b/limereport/lrreportdesignwindow.cpp index cffe165..7b4ee68 100644 --- a/limereport/lrreportdesignwindow.cpp +++ b/limereport/lrreportdesignwindow.cpp @@ -78,7 +78,10 @@ ReportDesignWindow::ReportDesignWindow(ReportEnginePrivate *report, QWidget *par m_lblReportName = new QLabel(report->reportFileName(),this); m_statusBar->insertWidget(0,m_lblReportName); setStatusBar(m_statusBar); - setWindowTitle("Lime Report Designer"); + QString windowTitle = "Lime Report Designer"; + if (!report->reportName().isEmpty()) + windowTitle = report->reportName() + " - " + windowTitle; + setWindowTitle(windowTitle); restoreSetting(); m_hideLeftPanel->setChecked(isDockAreaVisible(Qt::LeftDockWidgetArea)); m_hideRightPanel->setChecked(isDockAreaVisible(Qt::RightDockWidgetArea)); @@ -544,6 +547,7 @@ void ReportDesignWindow::startNewReport() m_newPageFooter->setEnabled(true); m_newReportHeader->setEnabled(true); m_newReportFooter->setEnabled(true); + m_reportDesignWidget->report()->dataManager()->dropChanges(); } void ReportDesignWindow::writePosition() @@ -742,6 +746,7 @@ void ReportDesignWindow::slotNewReport() m_lblReportName->setText(""); startNewReport(); m_deletePageAction->setEnabled(false); + setWindowTitle("Lime Report Designer"); } } @@ -931,7 +936,6 @@ void ReportDesignWindow::slotLoadReport() m_lblReportName->setText(fileName); m_propertyModel->setObject(0); updateRedoUndo(); - setWindowTitle(m_reportDesignWidget->report()->reportName() + " - Lime Report Designer"); if (!m_recentFiles.contains(fileName)){ if (m_recentFiles.count()==10){ QMap::const_iterator it = m_recentFiles.constBegin(); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index adb9e73..7a9c52f 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -63,7 +63,8 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) : m_showProgressDialog(true), m_reportName(""), m_activePreview(0), m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")), m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"), - m_fileWatcher( new QFileSystemWatcher( this ) ) + m_fileWatcher( new QFileSystemWatcher( this ) ), m_previewLayoutDirection(Qt::LayoutDirectionAuto), + m_previewScaleType(FitWidth), m_previewScalePercent(0) { #ifdef HAVE_STATIC_BUILD initResources(); @@ -381,6 +382,7 @@ void ReportEnginePrivate::previewReport(PreviewHints hints) w->setSettings(settings()); w->setPages(pages); w->setLayoutDirection(m_previewLayoutDirection); + if (!dataManager()->errorsList().isEmpty()){ w->setErrorMessages(dataManager()->errorsList()); } @@ -394,6 +396,9 @@ void ReportEnginePrivate::previewReport(PreviewHints hints) w->setHideResultEditButton(resultIsEditable()); m_activePreview = w; + + w->setPreviewScaleType(m_previewScaleType, m_previewScalePercent); + connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*))); w->exec(); } @@ -508,7 +513,7 @@ bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName) } dataManager()->connectAutoConnections(); - + dataManager()->dropChanges(); if ( hasActivePreview() ) { currentPreview->reloadPreview(); @@ -661,6 +666,7 @@ bool ReportEnginePrivate::saveToFile(const QString &fileName) page->setToSaved(); } } + m_datasources->dropChanges(); return saved; } @@ -675,6 +681,7 @@ QByteArray ReportEnginePrivate::saveToByteArray() page->setToSaved(); } } + m_datasources->dropChanges(); return result; } @@ -688,6 +695,7 @@ QString ReportEnginePrivate::saveToString(){ page->setToSaved(); } } + m_datasources->dropChanges(); return result; } @@ -696,6 +704,9 @@ bool ReportEnginePrivate::isNeedToSave() foreach(PageDesignIntf* page, m_pages){ if (page->isHasChanges()) return true; } + if (dataManager()->isHasChanges()){ + return true; + } return false; } @@ -714,7 +725,23 @@ QString ReportEnginePrivate::renderToString() render.setDatasources(dataManager()); render.setScriptContext(scriptContext()); return render.renderPageToString(m_pages.at(0)); - }else return QString(); + } else return QString(); +} + +ScaleType ReportEnginePrivate::previewScaleType() +{ + return m_previewScaleType; +} + +int ReportEnginePrivate::previewScalePercent() +{ + return m_previewScalePercent; +} + +void ReportEnginePrivate::setPreviewScaleType(const ScaleType &scaleType, int percent) +{ + m_previewScaleType = scaleType; + m_previewScalePercent = percent; } Qt::LayoutDirection ReportEnginePrivate::previewLayoutDirection() @@ -945,6 +972,25 @@ void ReportEngine::setPreviewLayoutDirection(const Qt::LayoutDirection& layoutDi return d->setPreviewLayoutDirection(layoutDirection); } +ScaleType ReportEngine::previewScaleType() +{ + Q_D(ReportEngine); + return d->previewScaleType(); +} + +int ReportEngine::previewScalePercent() +{ + Q_D(ReportEngine); + return d->previewScalePercent(); +} + +void ReportEngine::setPreviewScaleType(const ScaleType &previewScaleType, int percent) +{ + Q_D(ReportEngine); + d->setPreviewScaleType(previewScaleType, percent); +} + + void ReportEngine::setShowProgressDialog(bool value) { Q_D(ReportEngine); diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index 746712e..f935b80 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -104,6 +104,9 @@ public: void setPassPharse(QString& passPharse); Qt::LayoutDirection previewLayoutDirection(); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); + ScaleType previewScaleType(); + int previewScalePercent(); + void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0); signals: void renderStarted(); void renderFinished(); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 7d47e90..7784479 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -132,6 +132,10 @@ public: void clearSelection(); Qt::LayoutDirection previewLayoutDirection(); void setPreviewLayoutDirection(const Qt::LayoutDirection& previewLayoutDirection); + ScaleType previewScaleType(); + int previewScalePercent(); + void setPreviewScaleType(const ScaleType &previewScaleType, int percent = 0); + signals: void pagesLoadFinished(); void datasourceCollectionLoadFinished(const QString& collectionName); @@ -186,6 +190,8 @@ private: QString m_passPhrase; QFileSystemWatcher *m_fileWatcher; Qt::LayoutDirection m_previewLayoutDirection; + ScaleType m_previewScaleType; + int m_previewScalePercent; }; } diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index ed72282..e0bc4e1 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -48,6 +48,7 @@ void ReportRender::initColumns(){ m_currentStartDataPos.clear(); m_maxHeightByColumn.append(0); m_currentStartDataPos.append(0); + m_currentColumn = 0; } bool ReportRender::isNeedToRearrangeColumnsItems() @@ -88,11 +89,11 @@ void ReportRender::rearrangeColumnsItems() { if (isNeedToRearrangeColumnsItems()){ qreal startHeight = columnHeigth(0); - int avg = m_columnedBandItems.size()/m_columnedBandItems[0]->columnsCount(); - for (int i=1;icolumnsCount();++i){ - if (columnItemsCount(i)columnsCount(); + for (int i = 1; i < m_columnedBandItems[0]->columnsCount(); ++i){ + if (columnItemsCount(i) < avg){ int getCount = avg * (m_columnedBandItems[0]->columnsCount()-i) - columnItemsCount(i); - for (int j=0;jsetPos(band->pos().x()+band->width(),m_columnedBandItems[0]->pos().y()); band->setColumnIndex(i); @@ -142,13 +143,13 @@ qreal ReportRender::maxColumnHeight() void ReportRender::renameChildItems(BaseDesignIntf *item){ foreach(BaseDesignIntf* child, item->childBaseItems()){ if (!child->childBaseItems().isEmpty()) renameChildItems(child); - child->setObjectName(child->metaObject()->className()+QString::number(++m_curentNameIndex)); + child->setObjectName(child->metaObject()->className()+QString::number(++m_currentNameIndex)); } } ReportRender::ReportRender(QObject *parent) :QObject(parent), m_renderPageItem(0), m_pageCount(0), - m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0), m_newPageStarted(false) + m_lastRenderedHeader(0), m_lastDataBand(0), m_lastRenderedFooter(0), m_currentColumn(0), m_newPageStarted(false) { initColumns(); } @@ -207,7 +208,7 @@ void ReportRender::initDatasource(const QString& name){ void ReportRender::renderPage(PageDesignIntf* patternPage) { - m_curentNameIndex = 0; + m_currentNameIndex = 0; m_patternPageItem = patternPage->pageItem(); @@ -250,11 +251,11 @@ void ReportRender::renderPage(PageDesignIntf* patternPage) renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader), 0, StartNewPageAsNeeded); BandDesignIntf* lastRenderedBand = 0; - for (int i=0;idataBandCount() && !m_renderCanceled;i++){ + for (int i=0; i < m_patternPageItem->dataBandCount() && !m_renderCanceled; i++){ lastRenderedBand = m_patternPageItem->dataBandAt(i); initDatasource(lastRenderedBand->datasourceName()); renderDataBand(lastRenderedBand); - if (idataBandCount()-1) closeFooterGroup(lastRenderedBand); + if ( i < m_patternPageItem->dataBandCount()-1) closeFooterGroup(lastRenderedBand); } if (reportFooter) @@ -416,6 +417,9 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign QApplication::processEvents(); if (patternBand){ + if (patternBand->isHeader()) + m_lastRenderedHeader = patternBand; + BandDesignIntf* bandClone = 0; if (bandData){ @@ -424,6 +428,8 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign bandClone=renderData(patternBand); } + if (isLast) bandClone->setBootomSpace(1); + if (mode == ForcedStartPage){ savePage(); startNewPage(); @@ -472,6 +478,9 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign bandClone->columnsFillDirection()==BandDesignIntf::VerticalUniform)) { startNewColumn(); + if (patternBand->bandHeader() && patternBand->bandHeader()->columnsCount()>1){ + renderBand(patternBand->bandHeader(), 0, mode); + } } else { savePage(); startNewPage(); @@ -515,7 +524,7 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand) BandDesignIntf* header = dataBand->bandHeader(); BandDesignIntf* footer = dataBand->bandFooter(); - if (header && header->printAlways()) renderBand(header, 0); + if (header && header->printAlways()) renderBand(header, 0, StartNewPageAsNeeded); if(bandDatasource && !bandDatasource->eof() && !m_renderCanceled){ @@ -523,12 +532,11 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand) datasources()->setReportVariable(varName,1); if (header && !header->printAlways()) - renderBand(header, 0); + renderBand(header, 0, StartNewPageAsNeeded); if (dataBand->bandHeader() && dataBand->bandHeader()->reprintOnEachPage()) m_reprintableBands.append(dataBand->bandHeader()); - //renderChildHeader(dataBand,PrintNotAlwaysPrintable); renderGroupHeader(dataBand, bandDatasource, true); bool firstTime = true; @@ -577,15 +585,19 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand) firstTime = false; } - m_reprintableBands.removeOne(dataBand->bandHeader()); + if (!dataBand->keepFooterTogether()) + m_reprintableBands.removeOne(dataBand->bandHeader()); if (bandDatasource->prior()){ renderGroupFooter(dataBand); bandDatasource->next(); } - if (footer && !footer->printAlways()) + if (footer && !footer->printAlways()){ renderBand(footer, 0, StartNewPageAsNeeded); + if (dataBand->keepFooterTogether()) + m_reprintableBands.removeOne(dataBand); + } datasources()->deleteVariable(varName); @@ -593,8 +605,11 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand) renderBand(dataBand, 0, StartNewPageAsNeeded); } - if (footer && footer->printAlways()) + if (footer && footer->printAlways()){ renderBand(footer, 0, StartNewPageAsNeeded); + if (dataBand->keepFooterTogether()) + m_reprintableBands.removeOne(dataBand); + } } void ReportRender::renderPageHeader(PageItemDesignIntf *patternPage) @@ -634,7 +649,6 @@ void ReportRender::renderPageItems(PageItemDesignIntf* patternPage) m_renderPageItem, m_renderPageItem); pageItems.append(cloneItem); - //cloneItem->updateItemSize(m_datasources); } } m_renderPageItem->restoreLinks(); @@ -691,9 +705,7 @@ void ReportRender::renderChildBands(BandDesignIntf *parentBand) if (!band->datasourceName().isEmpty()) ds = m_datasources->dataSource(band->datasourceName()); if (ds) ds->first(); - //renderChildHeader(band,PrintAlwaysPrintable); renderDataBand(band); - //renderChildFooter(band,PrintAlwaysPrintable); closeFooterGroup(band); } } @@ -705,26 +717,12 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da if (gb&&gb->isNeedToClose(m_datasources)){ if (band->childBands().count()>0){ bool didGoBack = dataSource->prior(); - foreach (BandDesignIntf* subBand, band->childrenByType(BandDesignIntf::GroupHeader)) { - foreach(BandDesignIntf* footer, subBand->childrenByType(BandDesignIntf::GroupFooter)){ - renderBand(footer, 0); - } - closeDataGroup(subBand); - } - - foreach (BandDesignIntf* footer, band->childrenByType(BandDesignIntf::GroupFooter)) { - renderBand(footer, 0, StartNewPageAsNeeded); - } - + renderGroupFooterByHeader(band); if (didGoBack){ dataSource->next(); } } closeDataGroup(band); -// if (gb->isNeedToStartNewPage()){ -// savePage(); -// startNewPage(); -// } } if (gb && !gb->isStarted()){ @@ -751,12 +749,14 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da } void ReportRender::renderGroupFooterByHeader(BandDesignIntf* groupHeader){ + if (groupHeader->reprintOnEachPage()) m_reprintableBands.removeOne(groupHeader); foreach (BandDesignIntf* header, groupHeader->childrenByType(BandDesignIntf::GroupHeader)){ renderGroupFooterByHeader(header); } foreach (BandDesignIntf* footer, groupHeader->childrenByType(BandDesignIntf::GroupFooter)){ renderBand(footer, 0, StartNewPageAsNeeded); } + closeDataGroup(groupHeader); } void ReportRender::renderGroupFooter(BandDesignIntf *parentBand) @@ -764,14 +764,7 @@ void ReportRender::renderGroupFooter(BandDesignIntf *parentBand) foreach(BandDesignIntf* band,parentBand->childrenByType(BandDesignIntf::GroupHeader)){ IGroupBand* gb = dynamic_cast(band); if (gb && gb->isStarted()){ - if (band->reprintOnEachPage()) m_reprintableBands.removeOne(band); - foreach(BandDesignIntf* header, band->childrenByType(BandDesignIntf::GroupHeader)){ - renderGroupFooterByHeader(header); - } - foreach(BandDesignIntf* footer, band->childrenByType(BandDesignIntf::GroupFooter)){ - renderBand(footer, 0, StartNewPageAsNeeded); - } - closeDataGroup(band); + renderGroupFooterByHeader(band); } } } @@ -887,10 +880,31 @@ qreal minVectorValue(QVector vector){ return curValue; } +void ReportRender::placeBandOnPage(BandDesignIntf* band, int columnIndex){ + + qreal bandPos = m_currentStartDataPos[columnIndex]; + + m_currentStartDataPos[columnIndex] += band->height(); + m_maxHeightByColumn[columnIndex] -= band->height(); + band->setPos(m_renderPageItem->pageRect().x()+band->width()*columnIndex, bandPos); + band->setBandIndex(++m_currentIndex); + band->setColumnIndex(columnIndex); + + m_renderPageItem->registerBand(band); + m_currentColumn = columnIndex; +} + +bool isMultiColumnHeader(BandDesignIntf* band){ + return ( (band->columnsCount() > 1 ) && + (band->isHeader() && + ((band->bandNestingLevel() == 0) || (band->columnsFillDirection() == BandDesignIntf::Horizontal)))); +} + bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren) { - if (band->columnsCount()==1 && m_maxHeightByColumn.size()>1){ - if (band->bandType()!=BandDesignIntf::PageFooter){ + + if (band->columnsCount() == 1 && m_maxHeightByColumn.size() > 1 ){ + if (band->bandType() != BandDesignIntf::PageFooter){ rearrangeColumnsItems(); m_currentColumn = 0; qreal minValue = minVectorValue(m_maxHeightByColumn); @@ -902,63 +916,66 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren) } } - if ( (band->columnsCount()>1) && - (!band->isHeader() || (band->bandNestingLevel()>0 && band->columnsFillDirection() != BandDesignIntf::Horizontal ))){ - - if (m_maxHeightByColumn.size()!=band->columnsCount()){ - for(int i=1;icolumnsCount();++i){ - m_maxHeightByColumn.append(m_maxHeightByColumn[0]); - m_currentStartDataPos.append(m_currentStartDataPos[0]); - } - m_currentColumn = 0; - } else { - if (band->columnsFillDirection()==BandDesignIntf::Horizontal){ - if (m_currentColumncolumnsCount()-1) - m_currentColumn = m_currentColumn+1; - else - m_currentColumn = 0; - } + if (band->columnsCount() != m_maxHeightByColumn.size()){ + for(int i=1;icolumnsCount();++i){ + m_maxHeightByColumn.append(m_maxHeightByColumn[0]); + m_currentStartDataPos.append(m_currentStartDataPos[0]); } - + m_currentColumn = -1; } - if (band->height()<=m_maxHeightByColumn[m_currentColumn]){ + if ( (band->columnsCount() > 1) && + (!band->isHeader() || (band->bandNestingLevel() > 0 && band->columnsFillDirection() != BandDesignIntf::Horizontal ))){ - if (band->bandType()==BandDesignIntf::PageFooter){ - for (int i=0;iheight(); + if (band->columnsFillDirection() == BandDesignIntf::Horizontal){ + if (m_currentColumn < band->columnsCount()-1) + m_currentColumn = m_currentColumn+1; + else + m_currentColumn = 0; } else { - m_maxHeightByColumn[m_currentColumn]-=band->height(); + m_currentColumn = m_currentColumn == -1 ? 0: m_currentColumn; + if ((m_currentColumn !=0) && + (m_maxHeightByColumn[0] == m_maxHeightByColumn[m_currentColumn]) && + (m_maxHeightByColumn[0] >= band->height()) + ){ + m_currentColumn = 0; + } + } + } + + m_currentColumn = m_currentColumn == -1 ? 0: m_currentColumn; + + if ( (isMultiColumnHeader(band) && band->height() <= m_maxHeightByColumn[0]) || + (band->height() <= m_maxHeightByColumn[m_currentColumn])){ + + if ( (band->bandType() == BandDesignIntf::PageFooter) ){ + for (int i=0; i < m_maxHeightByColumn.size(); ++i) + m_maxHeightByColumn[i]+=band->height(); } - if ( (band->columnsCount()>1) && - (band->isHeader() && (band->bandNestingLevel()==0 || band->columnsFillDirection()==BandDesignIntf::Horizontal))){ + if ( isMultiColumnHeader(band)){ - qreal bandPos = m_currentStartDataPos[m_currentColumn]; - m_currentStartDataPos[m_currentColumn]+=band->height(); - for (int i=0;icolumnsCount();++i){ - if (i!=0) band = dynamic_cast(band->cloneItem(PreviewMode)); - band->setPos(m_renderPageItem->pageRect().x()+band->width()*i,bandPos); - band->setBandIndex(++m_currentIndex); - band->setColumnIndex(i); - m_renderPageItem->registerBand(band); + if (!band->parent()){ + for (int i = 0; i < band->columnsCount(); ++i){ + m_currentColumn = i; + if (i != 0) band = dynamic_cast(band->cloneItem(PreviewMode)); + placeBandOnPage(band, i); + } + } else { + placeBandOnPage(band, band->columnIndex()); } + } else { - if (band->bandType()!=BandDesignIntf::PageFooter){ - band->setPos(m_renderPageItem->pageRect().x()+band->width()*m_currentColumn, - m_currentStartDataPos[m_currentColumn]); - m_currentStartDataPos[m_currentColumn]+=band->height(); - band->setBandIndex(++m_currentIndex); - band->setColumnIndex(m_currentColumn); + if (band->bandType() != BandDesignIntf::PageFooter){ + placeBandOnPage(band, m_currentColumn); } - if (band->columnsCount()>1){ + if (band->columnsCount() > 1){ m_columnedBandItems.append(band); } - m_renderPageItem->registerBand(band); } foreach(QList* list,m_childBands.values()){ @@ -974,7 +991,7 @@ bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren) } if (band->isData()) m_renderedDataBandCount++; - band->setObjectName(band->objectName()+QString::number(++m_curentNameIndex)); + band->setObjectName(band->objectName()+QString::number(++m_currentNameIndex)); renameChildItems(band); return true; } else return false; @@ -1090,9 +1107,7 @@ void ReportRender::startNewColumn(){ void ReportRender::startNewPage() { m_renderPageItem = 0; - m_currentColumn = 0; m_newPageStarted = true; - initColumns(); initRenderPage(); @@ -1107,7 +1122,7 @@ void ReportRender::startNewPage() renderPageHeader(m_patternPageItem); - m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem); + m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem)+2; m_maxHeightByColumn[m_currentColumn] -= m_pageFooterHeight; m_currentIndex=10; m_dataAreaSize = m_maxHeightByColumn[m_currentColumn]; @@ -1192,8 +1207,14 @@ void ReportRender::pasteGroups() m_popupedValues.clear(); } +bool bandLessThen(BandDesignIntf* b1, BandDesignIntf* b2){ + return b1->bandIndex() < b2->bandIndex(); +} + void ReportRender::checkLostHeadersOnPrevPage() { + QVector lostHeaders; + if (m_renderedPages.isEmpty()) return; PageItemDesignIntf::Ptr page = m_renderedPages.last(); if (page->bands().isEmpty()) return; @@ -1212,12 +1233,19 @@ void ReportRender::checkLostHeadersOnPrevPage() if (it.value()->isHeader()){ if (it.value()->reprintOnEachPage()){ delete it.value(); - } else { registerBand(it.value());} + } else { lostHeaders.append(it.value());} it.remove(); it.previous(); } else break; } + if (lostHeaders.size() > 0){ + qSort(lostHeaders.begin(), lostHeaders.end(), bandLessThen); + foreach(BandDesignIntf* header, lostHeaders){ + registerBand(header); + } + } + } BandDesignIntf* ReportRender::findEnclosingGroup() diff --git a/limereport/lrreportrender.h b/limereport/lrreportrender.h index 3e9f26f..7f3bcef 100644 --- a/limereport/lrreportrender.h +++ b/limereport/lrreportrender.h @@ -154,6 +154,8 @@ private: qreal maxColumnHeight(); void renameChildItems(BaseDesignIntf *item); void renderGroupFooterByHeader(BandDesignIntf *groupHeader); + void placeBandOnPage(BandDesignIntf *band, int columnIndex); + private: DataSourceManager* m_datasources; ScriptEngineContext* m_scriptEngineContext; @@ -176,6 +178,7 @@ private: qreal m_dataAreaSize; qreal m_reportFooterHeight; int m_renderedDataBandCount; + BandDesignIntf* m_lastRenderedHeader; BandDesignIntf* m_lastDataBand; BandDesignIntf* m_lastRenderedFooter; bool m_renderCanceled; @@ -184,10 +187,9 @@ private: int m_currentColumn; QList m_ranges; QVector m_columnedBandItems; - unsigned long long m_curentNameIndex; + unsigned long long m_currentNameIndex; bool m_newPageStarted; - }; } // namespace LimeReport #endif // LRREPORTRENDER_H diff --git a/limereport/objectinspector/lrobjectitemmodel.cpp b/limereport/objectinspector/lrobjectitemmodel.cpp index 71b3adb..42b52fa 100644 --- a/limereport/objectinspector/lrobjectitemmodel.cpp +++ b/limereport/objectinspector/lrobjectitemmodel.cpp @@ -135,6 +135,7 @@ void QObjectPropertyModel::translatePropertyName() tr("groupFieldName"); tr("keepGroupTogether"); tr("watermark"); + tr("replaceCRwithBR"); } void QObjectPropertyModel::clearObjectsList() diff --git a/limereport/objectinspector/propertyItems/lrcontentpropitem.cpp b/limereport/objectinspector/propertyItems/lrcontentpropitem.cpp index 1b49128..53c9806 100644 --- a/limereport/objectinspector/propertyItems/lrcontentpropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrcontentpropitem.cpp @@ -30,6 +30,7 @@ void ContentEditor::editButtonClicked() dialog->setWindowTitle(propertyName()); QWidget* editor = dynamic_cast(m_object)->defaultEditor(); dialog->layout()->addWidget(editor); + dialog->resize(editor->size()); connect(editor,SIGNAL(destroyed()),dialog,SLOT(close())); connect(editor,SIGNAL(destroyed()),this,SIGNAL(editingFinished())); dialog->exec(); diff --git a/limereport/objectinspector/propertyItems/lrfontpropitem.cpp b/limereport/objectinspector/propertyItems/lrfontpropitem.cpp index 1c8b506..3e14fea 100644 --- a/limereport/objectinspector/propertyItems/lrfontpropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrfontpropitem.cpp @@ -82,7 +82,14 @@ void FontPropItem::setPropertyEditorData(QWidget* propertyEditor, const QModelIn void FontPropItem::setModelData(QWidget* propertyEditor, QAbstractItemModel* model, const QModelIndex &index) { - model->setData(index,qobject_cast(propertyEditor)->fontValue()); + + QFont tmpFont = qobject_cast(propertyEditor)->fontValue(); + QFont font(tmpFont.family()); + font.setBold(tmpFont.bold()); + font.setPointSize(tmpFont.pointSize()); + font.setItalic(tmpFont.italic()); + font.setUnderline(tmpFont.underline()); + model->setData(index,font); setValueToObject(propertyName(),propertyValue()); } diff --git a/limereport/serializators/lrxmlbasetypesserializators.cpp b/limereport/serializators/lrxmlbasetypesserializators.cpp index c0c2ce7..559bee9 100644 --- a/limereport/serializators/lrxmlbasetypesserializators.cpp +++ b/limereport/serializators/lrxmlbasetypesserializators.cpp @@ -179,9 +179,9 @@ void XmlFontSerializator::save(const QVariant &value, QString name) _node.setAttribute("Type","QFont"); _node.setAttribute("family",font.family()); _node.setAttribute("pointSize",font.pointSize()); -#if QT_VERSION>0x040800 - _node.setAttribute("stylename",font.styleName()); -#endif +//#if QT_VERSION>0x040800 +// _node.setAttribute("stylename",font.styleName()); +//#endif _node.setAttribute("weight",font.weight()); //saveBool(_node,"bold",font.bold()); saveBool(_node,"italic",font.italic()); @@ -194,9 +194,9 @@ QVariant XmlFontSerializator::loadValue() QFont font; font.setFamily(node()->attribute("family")); font.setPointSize(node()->attribute("pointSize").toInt()); -#if QT_VERSION>0x040800 - font.setStyleName(node()->attribute("stylename")); -#endif +//#if QT_VERSION>0x040800 +// font.setStyleName(node()->attribute("stylename")); +//#endif font.setWeight(node()->attribute("weight").toInt()); if (!node()->attribute("bold").isEmpty()) font.setBold(node()->attribute("bold").toInt()); diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts index 7fbb600..ef748e7 100644 --- a/translations/limereport_ru.ts +++ b/translations/limereport_ru.ts @@ -275,10 +275,6 @@ p, li { white-space: pre-wrap; } PageFooter Нижний колонтитул - - Subdetail - Подчиненный - DataHeaderBand Заголовок данных @@ -287,18 +283,6 @@ p, li { white-space: pre-wrap; } DataFooterBand Завершение данных - - SubdetailBand - Подчиненные данные - - - SubdetailHeaderBand - Заголовок подчиненных данных - - - SubdetailFooterBand - Завершение подчиненных данных - GroupBandHeader Заголовок группы @@ -325,15 +309,11 @@ p, li { white-space: pre-wrap; } Keep bottom space - + Сохранять нижний отступ - Start from new page - - - - Start new page - + Print if empty + Печатать если пустой @@ -458,14 +438,7 @@ p, li { white-space: pre-wrap; } Port - - - - - LimeReport::ContentItemDesignIntf - - Variable %1 not found - Переменная %1 не найдена + Порт @@ -475,8 +448,24 @@ p, li { white-space: pre-wrap; } Данные - useAlternateBackgroundColor - Использовать альтернативный цвет фона + Keep footer together + Привязать колонтитул к данными + + + Keep subdetail together + Привязать подчиненные данные + + + Slice last row + Разрезать последнюю запись + + + Start from new page + Начинать с новой страницы + + + Start new page + Начинать новую станицу @@ -533,10 +522,6 @@ p, li { white-space: pre-wrap; } System variables Системные переменные - - User variables - Пользовательские переменные - Error Ошибка @@ -576,6 +561,10 @@ p, li { white-space: pre-wrap; } DataFooter Подвал данных + + Print always + Печатать всегда + LimeReport::DataHeaderBand @@ -583,6 +572,18 @@ p, li { white-space: pre-wrap; } DataHeader Заголовок данных + + Reprint on each page + Печать на каждой странице + + + Repeat on each row + Повторять на каждой строке + + + Print always + Печатать всегда + LimeReport::DataSourceManager @@ -606,14 +607,6 @@ p, li { white-space: pre-wrap; } Datasource "%1" not found! Источник данных "%1" не найден! - - connection with name "%1" already exists! - соединение "%1" уже существует! - - - datasource with name "%1" already exists! - источник данных "%1" уже существует! - Connection with name "%1" already exists! Соединение "%1" уже существует! @@ -638,37 +631,6 @@ p, li { white-space: pre-wrap; } Внешние переменные - - LimeReport::DialogDesignerManager - - Edit Widgets - Редактировать виджеты - - - Widget Box - Панель виджетов - - - Object Inspector - Инспектор объектов - - - Property Editor - Редактор свойств - - - Signals && Slots Editor - Редактор сигналов и слотов - - - Resource Editor - Редактор ресурсов - - - Action Editor - Редактор действий - - LimeReport::EnumPropItem @@ -685,15 +647,15 @@ p, li { white-space: pre-wrap; } NoneAutoWidth - Нет + Нет MaxWordLength - По ширине слова + По ширине слова MaxStringLength - По ширине строки + По ширине строки TransparentMode @@ -1559,14 +1521,6 @@ p, li { white-space: pre-wrap; } columnCount Количество колонок - - alternateBackgroundMode - Альтернативный цвет фона - - - textIdent - Параграф - securityLevel Уровень безопасности @@ -1635,6 +1589,14 @@ p, li { white-space: pre-wrap; } repeatOnEachRow Печатать на каждой странице + + watermark + Водяной знак + + + replaceCRwithBR + Заменять CR на BR + LimeReport::RectMMPropItem @@ -1664,10 +1626,6 @@ p, li { white-space: pre-wrap; } Report file name Файл отчета - - Page - Страница - Script Скрипт @@ -1771,14 +1729,6 @@ p, li { white-space: pre-wrap; } About О программе - - Hide left panel - Спрятать левую панель - - - Hide right panel - Спрятать правую панель - Report Tools Элементы отчета @@ -1919,49 +1869,17 @@ p, li { white-space: pre-wrap; } File "%1" not found! Файл "%1" не найден! - - Delete dialog - Удалить диалог - - - Add new dialog - Добавить диалог - - - Widget Box - Панель виджетов - - - Property Editor - Редактор свойств - - - Action Editor - Редактор действий - - - Resource Editor - Редактор ресурсов - - - SignalSlot Editor - Редактор сигналов и слотов - - - Dialog Designer Tools - Инструменты создания диалогов - Report has been modified! Do you want save the report? Отчет был изменен! Хотите его сохранить? Hide left panel | Alt+L - + Скрыть левую панель | Alt+L Hide right panel | Alt+R - + Скрыть правую панель | Alt+R @@ -1972,7 +1890,7 @@ p, li { white-space: pre-wrap; } Preview - Предосмотр + Предпросмотр Report File Change @@ -2094,7 +2012,7 @@ This preview is no longer valid. Preview - Предосмотр + Предпросмотр ... @@ -2174,17 +2092,9 @@ This preview is no longer valid. Dialog with name: %1 can`t be created Диалог с именем: %1 не может быть создан - - Error - Ошибка - LimeReport::ScriptEngineManager - - FieldName - Имя поля - BandName Имя банда @@ -2239,7 +2149,7 @@ This preview is no longer valid. Seconds - + Секунды @@ -2359,10 +2269,6 @@ This preview is no longer valid. TextItem " %1 " not found! Текстовый элемент "%1" не найден! - - Transparent - Прозрачный - LimeReport::TextItemEditor @@ -2528,10 +2434,6 @@ This preview is no longer valid. Selected elements have different parent containers Выделенные элементы имеют различные родительские контейнеры - - Object with name %1 already exists - Объект с именем %1 уже существует - Function %1 not found or have wrong arguments Функция %1 не найдена или вызвана с неверными аргументами @@ -2568,10 +2470,6 @@ This preview is no longer valid. content содержимое - - Master datasource "%1" not found!!! - Главный источник данных "%1" не найден! - Master datasouce "%1" not found! Главный источник данных "%1" не найден! @@ -2628,10 +2526,6 @@ This preview is no longer valid. Wrong file format Неправильный формат файла - - Datasource manager not found - Менеджер источников данных не найден - Master datasource "%1" not found! Главный источник данных "%1" не найден!