0
0
mirror of https://github.com/fralx/LimeReport.git synced 2025-01-11 09:08:09 +03:00

Merge pull request #4 from fralx/master

Update from source
This commit is contained in:
wartime 2019-02-16 14:01:22 +08:00 committed by GitHub
commit de6c806e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 1290 additions and 754 deletions

View File

@ -18,7 +18,7 @@ install:
script:
- qmake -r
- qmake -r limereport.pro
- make
- make check

View File

@ -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}\"

View File

@ -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
}
}
}

View File

@ -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
}
}
}

View File

@ -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,

View File

@ -2,6 +2,7 @@
#define LRPREVIEWREPORTWIDGET_H
#include <QWidget>
#include <QTimer>
#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

View File

@ -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();

View File

@ -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

View File

@ -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());
}
}
}

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -113,8 +113,8 @@ void SQLEditDialog::accept()
if (ui->fieldsMap->rowCount()>0){
for(int i=0;i<ui->fieldsMap->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

View File

@ -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();

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

View File

@ -41,5 +41,7 @@
<file alias="ImageItem">images/imageItem4.png</file>
<file alias="ShapeItem">images/shapes7.png</file>
<file alias="BarcodeItem">images/barcode5.png</file>
<file alias="DataHeaderBand">images/DataHeaderBand.png</file>
<file alias="DataFooterBand">images/DataFooterBand.png</file>
</qresource>
</RCC>

View File

@ -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){

View File

@ -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;
};
}

View File

@ -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<PageItemDesignIntf*>(parent);
BaseDesignIntf* parentItem = dynamic_cast<BaseDesignIntf*>(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("<br/>","\n");
}
QString TextItem::replaceReturns(QString text)
QString TextItem::replaceReturns(QString text) const
{
QString result = text.replace("\r\n","<br/>");
result = result.replace("\n","<br/>");
@ -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;

View File

@ -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;

22
limereport/limereport.prf Normal file
View File

@ -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

View File

@ -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)

View File

@ -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<BandDesignIntf::BandsType> 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<BandDesignIntf::BandsType> 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 *> BandDesignIntf::childrenByType(BandDesignIntf::BandsType type)
{
QList<BandDesignIntf*> 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<QString> 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<BandDesignIntf*>(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<BandDesignIntf*>(createSameTypeItem(owner,parent));
bottomPart->m_bottomSpace = this->bottomSpace();
bottomPart->initFromItem(this);
QList<QGraphicsItem*> 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);

View File

@ -167,6 +167,7 @@ public:
bool isConnectedToBand(BandDesignIntf::BandsType bandType) const;
int minChildIndex(BandsType bandType);
int minChildIndex(QSet<BandsType> ignoredBands = QSet<BandDesignIntf::BandsType>());
int maxChildIndex(BandDesignIntf::BandsType bandType) const;
int maxChildIndex(QSet<BandsType> ignoredBands = QSet<BandDesignIntf::BandsType>()) 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<QString,BaseDesignIntf*> m_slicedItems;
QColor m_alternateBackgroundColor;
InitializedValue m_bottomSpace;
int m_bottomSpace;
};
class DataBandDesignIntf : public BandDesignIntf{

View File

@ -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<BaseDesignIntf *>(obj);
if (item) {
if (item && page()) {
page()->registerItem(item);
}
}

View File

@ -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<QString> propertyNames);
void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue);
void itemVisibleHasChanged(BaseDesignIntf* item);
void beforeRender();
void afterData();
void afterRender();

View File

@ -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;

View File

@ -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<CountGroupFunction>);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("SUM"),new ConstructorGroupFunctionCreator<SumGroupFunction>);
@ -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)

View File

@ -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<QString,int> m_groupFunctionsExpressionsMap;
QVector<QString> m_groupFunctionsExpressions;
IDbCredentialsProvider* m_dbCredentialsProvider;
bool m_hasChanges;
};
}

View File

@ -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,

View File

@ -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<QGraphi
return false;
}
QRectF PageDesignIntf::getRectByPageSize(PageDesignIntf::PageSize pageSize)
{
if (m_pageSize != Custom) {
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation((QPrinter::Orientation)getOrientation());
printer.setPageSize((QPrinter::PageSize)pageSize);
return QRectF(0, 0, printer.paperRect(QPrinter::Millimeter).width() * 10,
printer.paperSize(QPrinter::Millimeter).height() * 10);
}
//QRectF PageDesignIntf::getRectByPageSize(PageDesignIntf::PageSize pageSize)
//{
// if (m_pageSize != PageSize::Custom) {
// QPrinter printer;
// printer.setOutputFormat(QPrinter::PdfFormat);
// printer.setOrientation((QPrinter::Orientation)getOrientation());
// printer.setPageSize((QPrinter::PageSize)pageSize);
// return QRectF(0, 0, printer.paperRect(QPrinter::Millimeter).width() * 10,
// printer.paperSize(QPrinter::Millimeter).height() * 10);
// }
else {
return QRectF(0, 0, m_pageSizeValue.width() * 10,
m_pageSizeValue.height() * 10);
}
}
// else {
// return QRectF(0, 0, m_pageSizeValue.width() * 10,
// m_pageSizeValue.height() * 10);
// }
//}
bool PageDesignIntf::isLoading()
{
@ -870,10 +866,17 @@ void PageDesignIntf::saveSelectedItemsGeometry()
void PageDesignIntf::checkSizeOrPosChanges()
{
CommandIf::Ptr posCommand;
if ((selectedItems().count() > 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<BandDesignIntf*>(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<ReportItemPos> 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<PageItemDesignIntf*>(item)){
BaseDesignIntf *reportItem = dynamic_cast<BaseDesignIntf *>(item);
ItemDesignIntf *reportItem = dynamic_cast<ItemDesignIntf *>(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<BandDesignIntf*>(page()->reportItemByName(bandName));
BandDesignIntf* bandToSwap = dynamic_cast<BandDesignIntf*>(page()->reportItemByName(bandToSwapName));
if (page() && band && bandToSwap){
page()->pageItem()->swapBands(band, bandToSwap);
return true;
}
return false;
}
void BandSwapCommand::undoIt()
{
BandDesignIntf* band = dynamic_cast<BandDesignIntf*>(page()->reportItemByName(bandName));
BandDesignIntf* bandToSwap = dynamic_cast<BandDesignIntf*>(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);
}
}

View File

@ -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<PageItemDesignIntf::Ptr> pages);
QList<PageItemDesignIntf::Ptr> 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<PageItemDesignIntf::Ptr> pages);
QList<PageItemDesignIntf::Ptr> 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<BaseDesignIntf *> 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<BaseDesignIntf *> 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<QGraphicsItem *> &itemsList) const;
bool isExistsObjectName (const QString& objectName, QList<QGraphicsItem *> &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<QObject*>* 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 <typename T>
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<PageItemDesignIntf::Ptr> 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<CommandIf::Ptr> m_commandsList;
QVector<ReportItemPos> m_positionStamp;
QVector<ReportItemSize> 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<QObject*> m_animationList;
QPointF m_startSelectionPoint;
QGraphicsRectItem* m_selectionRect;
int m_verticalGridStep;
int m_horizontalGridStep;
bool m_updating;
int m_currentObjectIndex;
bool m_multiSelectStarted;
QList<ItemProjections> 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<QObject*>* 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 <typename T>
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<PageItemDesignIntf::Ptr> 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<CommandIf::Ptr> m_commandsList;
QVector<ReportItemPos> m_positionStamp;
QVector<ReportItemSize> 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<QObject*> m_animationList;
QPointF m_startSelectionPoint;
QGraphicsRectItem* m_selectionRect;
int m_verticalGridStep;
int m_horizontalGridStep;
bool m_updating;
int m_currentObjectIndex;
bool m_multiSelectStarted;
QList<ItemProjections> 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<ReportItemPos> 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<ReportItemSize>& oldSize, QVector<ReportItemSize>& newSize);

View File

@ -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<BandDesignIntf*> 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<BandDesignIntf*>(object);
int curIndex = band->bandIndex();
BandDesignIntf* bandToSwap = 0;
foreach(BandDesignIntf* curBand, bands()){
if (newGeometry.y()>oldGeometry.y()) {
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;
}
} 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<BandDesignIntf*> 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<BandDesignIntf*>(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)

View File

@ -34,6 +34,7 @@
#include "lritemscontainerdesignitf.h"
#include <QList>
#include <QColor>
#include <QPrinter>
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<BandDesignIntf*> BandsList;
typedef QList<BandDesignIntf*>::const_iterator BandsIterator;
typedef QSharedPointer<PageItemDesignIntf> 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);

View File

@ -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;
}
}
}

View File

@ -2,6 +2,7 @@
#define LRPREVIEWREPORTWIDGET_H
#include <QWidget>
#include <QTimer>
#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

View File

@ -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)

View File

@ -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

View File

@ -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<QString, QDateTime>::const_iterator it = m_recentFiles.constBegin();

View File

@ -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);

View File

@ -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();

View File

@ -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;
};
}

View File

@ -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;i<m_columnedBandItems[0]->columnsCount();++i){
if (columnItemsCount(i)<avg){
int avg = m_columnedBandItems.size() / m_columnedBandItems[0]->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;j<getCount;++j){
for (int j = 0; j < getCount; ++j){
BandDesignIntf* band = lastColumnItem(i-1);
band->setPos(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;i<m_patternPageItem->dataBandCount() && !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 (i<m_patternPageItem->dataBandCount()-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<IGroupBand*>(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<qreal> 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;i<band->columnsCount();++i){
m_maxHeightByColumn.append(m_maxHeightByColumn[0]);
m_currentStartDataPos.append(m_currentStartDataPos[0]);
}
m_currentColumn = 0;
} else {
if (band->columnsFillDirection()==BandDesignIntf::Horizontal){
if (m_currentColumn<band->columnsCount()-1)
m_currentColumn = m_currentColumn+1;
else
m_currentColumn = 0;
}
if (band->columnsCount() != m_maxHeightByColumn.size()){
for(int i=1;i<band->columnsCount();++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;i<m_maxHeightByColumn.size();++i)
m_maxHeightByColumn[i]+=band->height();
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;i<band->columnsCount();++i){
if (i!=0) band = dynamic_cast<BandDesignIntf*>(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<BandDesignIntf*>(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<BandDesignIntf*>* 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<BandDesignIntf*> 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()

View File

@ -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<PagesRange> m_ranges;
QVector<BandDesignIntf*> m_columnedBandItems;
unsigned long long m_curentNameIndex;
unsigned long long m_currentNameIndex;
bool m_newPageStarted;
};
} // namespace LimeReport
#endif // LRREPORTRENDER_H

View File

@ -135,6 +135,7 @@ void QObjectPropertyModel::translatePropertyName()
tr("groupFieldName");
tr("keepGroupTogether");
tr("watermark");
tr("replaceCRwithBR");
}
void QObjectPropertyModel::clearObjectsList()

View File

@ -30,6 +30,7 @@ void ContentEditor::editButtonClicked()
dialog->setWindowTitle(propertyName());
QWidget* editor = dynamic_cast<BaseDesignIntf*>(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();

View File

@ -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<FontEditor*>(propertyEditor)->fontValue());
QFont tmpFont = qobject_cast<FontEditor*>(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());
}

View File

@ -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());

View File

@ -275,10 +275,6 @@ p, li { white-space: pre-wrap; }
<source>PageFooter</source>
<translation>Нижний колонтитул</translation>
</message>
<message>
<source>Subdetail</source>
<translation type="obsolete">Подчиненный</translation>
</message>
<message>
<source>DataHeaderBand</source>
<translation>Заголовок данных</translation>
@ -287,18 +283,6 @@ p, li { white-space: pre-wrap; }
<source>DataFooterBand</source>
<translation>Завершение данных</translation>
</message>
<message>
<source>SubdetailBand</source>
<translation type="vanished">Подчиненные данные</translation>
</message>
<message>
<source>SubdetailHeaderBand</source>
<translation type="vanished">Заголовок подчиненных данных</translation>
</message>
<message>
<source>SubdetailFooterBand</source>
<translation type="vanished">Завершение подчиненных данных</translation>
</message>
<message>
<source>GroupBandHeader</source>
<translation>Заголовок группы</translation>
@ -325,15 +309,11 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>Keep bottom space</source>
<translation type="unfinished"></translation>
<translation>Сохранять нижний отступ</translation>
</message>
<message>
<source>Start from new page</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Start new page</source>
<translation type="unfinished"></translation>
<source>Print if empty</source>
<translation>Печатать если пустой</translation>
</message>
</context>
<context>
@ -458,14 +438,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>Port</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LimeReport::ContentItemDesignIntf</name>
<message>
<source>Variable %1 not found</source>
<translation type="vanished">Переменная %1 не найдена</translation>
<translation>Порт</translation>
</message>
</context>
<context>
@ -475,8 +448,24 @@ p, li { white-space: pre-wrap; }
<translation>Данные</translation>
</message>
<message>
<source>useAlternateBackgroundColor</source>
<translation type="vanished">Использовать альтернативный цвет фона</translation>
<source>Keep footer together</source>
<translation>Привязать колонтитул к данными</translation>
</message>
<message>
<source>Keep subdetail together</source>
<translation>Привязать подчиненные данные</translation>
</message>
<message>
<source>Slice last row</source>
<translation>Разрезать последнюю запись</translation>
</message>
<message>
<source>Start from new page</source>
<translation>Начинать с новой страницы</translation>
</message>
<message>
<source>Start new page</source>
<translation>Начинать новую станицу</translation>
</message>
</context>
<context>
@ -533,10 +522,6 @@ p, li { white-space: pre-wrap; }
<source>System variables</source>
<translation>Системные переменные</translation>
</message>
<message>
<source>User variables</source>
<translation type="vanished">Пользовательские переменные</translation>
</message>
<message>
<source>Error</source>
<translation>Ошибка</translation>
@ -576,6 +561,10 @@ p, li { white-space: pre-wrap; }
<source>DataFooter</source>
<translation>Подвал данных</translation>
</message>
<message>
<source>Print always</source>
<translation>Печатать всегда</translation>
</message>
</context>
<context>
<name>LimeReport::DataHeaderBand</name>
@ -583,6 +572,18 @@ p, li { white-space: pre-wrap; }
<source>DataHeader</source>
<translation>Заголовок данных</translation>
</message>
<message>
<source>Reprint on each page</source>
<translation>Печать на каждой странице</translation>
</message>
<message>
<source>Repeat on each row</source>
<translation>Повторять на каждой строке</translation>
</message>
<message>
<source>Print always</source>
<translation>Печатать всегда</translation>
</message>
</context>
<context>
<name>LimeReport::DataSourceManager</name>
@ -606,14 +607,6 @@ p, li { white-space: pre-wrap; }
<source>Datasource &quot;%1&quot; not found!</source>
<translation>Источник данных &quot;%1&quot; не найден!</translation>
</message>
<message>
<source>connection with name &quot;%1&quot; already exists!</source>
<translation type="vanished">соединение &quot;%1&quot; уже существует!</translation>
</message>
<message>
<source>datasource with name &quot;%1&quot; already exists!</source>
<translation type="vanished">источник данных &quot;%1&quot; уже существует!</translation>
</message>
<message>
<source>Connection with name &quot;%1&quot; already exists!</source>
<translation>Соединение &quot;%1&quot; уже существует!</translation>
@ -638,37 +631,6 @@ p, li { white-space: pre-wrap; }
<translation>Внешние переменные</translation>
</message>
</context>
<context>
<name>LimeReport::DialogDesignerManager</name>
<message>
<source>Edit Widgets</source>
<translation type="vanished">Редактировать виджеты</translation>
</message>
<message>
<source>Widget Box</source>
<translation type="vanished">Панель виджетов</translation>
</message>
<message>
<source>Object Inspector</source>
<translation type="vanished">Инспектор объектов</translation>
</message>
<message>
<source>Property Editor</source>
<translation type="vanished">Редактор свойств</translation>
</message>
<message>
<source>Signals &amp;&amp; Slots Editor</source>
<translation type="vanished">Редактор сигналов и слотов</translation>
</message>
<message>
<source>Resource Editor</source>
<translation type="vanished">Редактор ресурсов</translation>
</message>
<message>
<source>Action Editor</source>
<translation type="vanished">Редактор действий</translation>
</message>
</context>
<context>
<name>LimeReport::EnumPropItem</name>
<message>
@ -685,15 +647,15 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>NoneAutoWidth</source>
<translation type="unfinished">Нет</translation>
<translation>Нет</translation>
</message>
<message>
<source>MaxWordLength</source>
<translation type="unfinished">По ширине слова</translation>
<translation>По ширине слова</translation>
</message>
<message>
<source>MaxStringLength</source>
<translation type="unfinished">По ширине строки</translation>
<translation>По ширине строки</translation>
</message>
<message>
<source>TransparentMode</source>
@ -1559,14 +1521,6 @@ p, li { white-space: pre-wrap; }
<source>columnCount</source>
<translation>Количество колонок</translation>
</message>
<message>
<source>alternateBackgroundMode</source>
<translation type="obsolete">Альтернативный цвет фона</translation>
</message>
<message>
<source>textIdent</source>
<translation type="obsolete">Параграф</translation>
</message>
<message>
<source>securityLevel</source>
<translation>Уровень безопасности</translation>
@ -1635,6 +1589,14 @@ p, li { white-space: pre-wrap; }
<source>repeatOnEachRow</source>
<translation>Печатать на каждой странице</translation>
</message>
<message>
<source>watermark</source>
<translation>Водяной знак</translation>
</message>
<message>
<source>replaceCRwithBR</source>
<translation>Заменять CR на BR</translation>
</message>
</context>
<context>
<name>LimeReport::RectMMPropItem</name>
@ -1664,10 +1626,6 @@ p, li { white-space: pre-wrap; }
<source>Report file name</source>
<translation>Файл отчета</translation>
</message>
<message>
<source>Page</source>
<translation type="vanished">Страница</translation>
</message>
<message>
<source>Script</source>
<translation>Скрипт</translation>
@ -1771,14 +1729,6 @@ p, li { white-space: pre-wrap; }
<source>About</source>
<translation>О программе</translation>
</message>
<message>
<source>Hide left panel</source>
<translation type="vanished">Спрятать левую панель</translation>
</message>
<message>
<source>Hide right panel</source>
<translation type="vanished">Спрятать правую панель</translation>
</message>
<message>
<source>Report Tools</source>
<translation>Элементы отчета</translation>
@ -1919,49 +1869,17 @@ p, li { white-space: pre-wrap; }
<source>File &quot;%1&quot; not found!</source>
<translation>Файл &quot;%1&quot; не найден!</translation>
</message>
<message>
<source>Delete dialog</source>
<translation type="vanished">Удалить диалог</translation>
</message>
<message>
<source>Add new dialog</source>
<translation type="vanished">Добавить диалог</translation>
</message>
<message>
<source>Widget Box</source>
<translation type="vanished">Панель виджетов</translation>
</message>
<message>
<source>Property Editor</source>
<translation type="vanished">Редактор свойств</translation>
</message>
<message>
<source>Action Editor</source>
<translation type="vanished">Редактор действий</translation>
</message>
<message>
<source>Resource Editor</source>
<translation type="vanished">Редактор ресурсов</translation>
</message>
<message>
<source>SignalSlot Editor</source>
<translation type="vanished">Редактор сигналов и слотов</translation>
</message>
<message>
<source>Dialog Designer Tools</source>
<translation type="vanished">Инструменты создания диалогов</translation>
</message>
<message>
<source>Report has been modified! Do you want save the report?</source>
<translation>Отчет был изменен! Хотите его сохранить?</translation>
</message>
<message>
<source>Hide left panel | Alt+L</source>
<translation type="unfinished"></translation>
<translation>Скрыть левую панель | Alt+L</translation>
</message>
<message>
<source>Hide right panel | Alt+R</source>
<translation type="unfinished"></translation>
<translation>Скрыть правую панель | Alt+R</translation>
</message>
</context>
<context>
@ -1972,7 +1890,7 @@ p, li { white-space: pre-wrap; }
</message>
<message>
<source>Preview</source>
<translation>Предосмотр</translation>
<translation>Предпросмотр</translation>
</message>
<message>
<source>Report File Change</source>
@ -2094,7 +2012,7 @@ This preview is no longer valid.</source>
</message>
<message>
<source>Preview</source>
<translation>Предосмотр</translation>
<translation>Предпросмотр</translation>
</message>
<message>
<source>...</source>
@ -2174,17 +2092,9 @@ This preview is no longer valid.</source>
<source>Dialog with name: %1 can`t be created</source>
<translation>Диалог с именем: %1 не может быть создан</translation>
</message>
<message>
<source>Error</source>
<translation type="vanished">Ошибка</translation>
</message>
</context>
<context>
<name>LimeReport::ScriptEngineManager</name>
<message>
<source>FieldName</source>
<translation type="vanished">Имя поля</translation>
</message>
<message>
<source>BandName</source>
<translation>Имя банда</translation>
@ -2239,7 +2149,7 @@ This preview is no longer valid.</source>
</message>
<message>
<source>Seconds</source>
<translation type="unfinished"></translation>
<translation>Секунды</translation>
</message>
</context>
<context>
@ -2359,10 +2269,6 @@ This preview is no longer valid.</source>
<source>TextItem &quot; %1 &quot; not found!</source>
<translation>Текстовый элемент &quot;%1&quot; не найден!</translation>
</message>
<message>
<source>Transparent</source>
<translation type="vanished">Прозрачный</translation>
</message>
</context>
<context>
<name>LimeReport::TextItemEditor</name>
@ -2528,10 +2434,6 @@ This preview is no longer valid.</source>
<source>Selected elements have different parent containers</source>
<translation>Выделенные элементы имеют различные родительские контейнеры</translation>
</message>
<message>
<source>Object with name %1 already exists</source>
<translation type="vanished">Объект с именем %1 уже существует</translation>
</message>
<message>
<source>Function %1 not found or have wrong arguments</source>
<translation>Функция %1 не найдена или вызвана с неверными аргументами</translation>
@ -2568,10 +2470,6 @@ This preview is no longer valid.</source>
<source>content</source>
<translation>содержимое</translation>
</message>
<message>
<source>Master datasource &quot;%1&quot; not found!!!</source>
<translation type="vanished">Главный источник данных &quot;%1&quot; не найден!</translation>
</message>
<message>
<source>Master datasouce &quot;%1&quot; not found!</source>
<translation>Главный источник данных &quot;%1&quot; не найден!</translation>
@ -2628,10 +2526,6 @@ This preview is no longer valid.</source>
<source>Wrong file format</source>
<translation>Неправильный формат файла</translation>
</message>
<message>
<source>Datasource manager not found</source>
<translation type="vanished">Менеджер источников данных не найден</translation>
</message>
<message>
<source>Master datasource &quot;%1&quot; not found!</source>
<translation>Главный источник данных &quot;%1&quot; не найден!</translation>