diff --git a/demo/r1/demo_reports/columns_demo.lrxml b/demo/r1/demo_reports/columns_demo.lrxml
new file mode 100644
index 0000000..ad8a2ec
--- /dev/null
+++ b/demo/r1/demo_reports/columns_demo.lrxml
@@ -0,0 +1,245 @@
+
+
+
diff --git a/demo/r1/demo_reports/ordres_by_date.lrxml b/demo/r1/demo_reports/ordres_by_date.lrxml
new file mode 100644
index 0000000..baf2cf9
--- /dev/null
+++ b/demo/r1/demo_reports/ordres_by_date.lrxml
@@ -0,0 +1,168 @@
+
+
+
diff --git a/demo/r1/mainwindow.cpp b/demo/r1/mainwindow.cpp
index cb28e42..6b8b8fc 100644
--- a/demo/r1/mainwindow.cpp
+++ b/demo/r1/mainwindow.cpp
@@ -115,6 +115,9 @@ void MainWindow::on_pushButton_2_clicked()
QString fileName = QFileDialog::getOpenFileName(this,"Select report file",QApplication::applicationDirPath()+"/demo_reports/","*.lrxml");
if (!fileName.isEmpty()) {
report->loadFromFile(fileName);
+ if (!ui->leVariableName->text().isEmpty() && !ui->leVariableValue->text().isEmpty()){
+ report->dataManager()->setReportVariable(ui->leVariableName->text(), ui->leVariableValue->text());
+ }
report->previewReport();
}
}
diff --git a/demo/r1/r1.pro b/demo/r1/r1.pro
index 36665f2..33cfd0e 100644
--- a/demo/r1/r1.pro
+++ b/demo/r1/r1.pro
@@ -14,11 +14,16 @@ win32 {
EXTRA_DIR ~= s,/,\\,g
DEST_DIR ~= s,/,\\,g
QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$DEST_DIR) $$escape_expand(\\n\\t)
+ CONFIG(release, debug|release) {
+ DEST_DIR = $$OUT_PWD/release/demo_reports/
+ DEST_DIR ~= s,/,\\,g
+ QMAKE_POST_LINK += $$QMAKE_COPY_DIR $$quote($$EXTRA_DIR) $$quote($$DEST_DIR) $$escape_expand(\\n\\t)
+ }
}
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
-TARGET = r1
+TARGET = LRDemo
TEMPLATE = app
SOURCES += main.cpp\
@@ -41,4 +46,4 @@ RESOURCES += \
win32 {
RC_FILE += mainicon.rc
-}
\ No newline at end of file
+}
diff --git a/limereport.pro b/limereport.pro
index 6ae3a53..9bc8022 100644
--- a/limereport.pro
+++ b/limereport.pro
@@ -43,3 +43,8 @@ INCLUDEPATH += report report/bands report/base report/databrowser report/items r
CONFIG(release, debug|release): DESTDIR = $$PWD/lib/release/
else:CONFIG(debug, debug|release): DESTDIR = $$PWD/lib/debug/
+#win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../zint-2.4.3/build-backend_dll-Desktop_Qt_5_5_0_MSVC2010_32bit-Release/release/ -lQtZint22
+#else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../zint-2.4.3/build-backend_dll-Desktop_Qt_5_5_0_MSVC2010_32bit-Release/debug/ -lQtZint22
+
+#INCLUDEPATH += $$PWD/../zint-2.4.3/backend $$PWD/../zint-2.4.3/backend_qt4
+#DEPENDPATH += $$PWD/../zint-2.4.3/backend $$PWD/../zint-2.4.3/backend_qt4
diff --git a/report-lib_ru.ts b/report-lib_ru.ts
deleted file mode 100644
index bc69495..0000000
--- a/report-lib_ru.ts
+++ /dev/null
@@ -1,1466 +0,0 @@
-
-
-
-
- ConnectionDialog
-
-
-
-
- Подключение
-
-
-
-
- Название соединения
-
-
-
-
- Драйвер
-
-
-
-
- Сервер
-
-
-
-
- Пользователь
-
-
-
-
- Пароль
-
-
-
-
- База данных
-
-
-
-
-
-
-
-
-
- Авто соединение
-
-
-
-
- Проверить соединение
-
-
-
-
- Отмена
-
-
-
-
-
-
-
-
-
-
- Ошибка
-
-
-
-
- Соединение успешно установлено !
-
-
-
-
- Название соединения не указано
-
-
-
-
- Соединение с названием
-
-
-
-
- уже существует
-
-
-
- DataBrowser
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LRVariableDialog
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::AVariablesHolder
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::AlignmentPropItem
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ContentItemDesignIntf
-
-
-
-
-
-
-
- LimeReport::DataBand
-
-
-
-
-
-
-
- LimeReport::DataBrowser
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::DataSourceManager
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::DataSourceModel
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::FontEditorWidget
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::FontPropItem
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::GroupBandFooter
-
-
-
-
-
-
-
- LimeReport::GroupBandHeader
-
-
-
-
-
-
-
- LimeReport::GroupFunction
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ItemsAlignmentEditorWidget
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ItemsBordersEditorWidget
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::MasterDetailProxyModel
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ModelToDataSource
-
-
-
-
-
-
-
- LimeReport::ObjectBrowser
-
-
-
-
-
-
-
- LimeReport::PageDesignIntf
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::PageFooter
-
-
-
-
-
-
-
- LimeReport::PageHeader
-
-
-
-
-
-
-
- LimeReport::QObjectPropertyModel
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::RectMMPropItem
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::RectPropItem
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ReportDesignIntfPrivate
-
-
-
-
-
-
-
- LimeReport::ReportDesignWidget
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ReportDesignWindow
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ReportFooter
-
-
-
-
-
-
-
- LimeReport::ReportHeader
-
-
-
-
-
-
-
- LimeReport::ReportRender
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ScriptBrowser
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- LimeReport::ScriptEngineContext
-
-
-
-
-
-
-
- LimeReport::SubDetailBand
-
-
-
-
-
-
-
- LimeReport::TextAlignmentEditorWidget
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreviewReportWindow
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- QObject
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- SQLEditDialog
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ScriptBrowser
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TextItemEditor
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- WaitForm
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/bands/lrdataband.h b/src/bands/lrdataband.h
index e08214a..8288279 100644
--- a/src/bands/lrdataband.h
+++ b/src/bands/lrdataband.h
@@ -43,6 +43,8 @@ class DataBand : public DataBandDesignIntf
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable )
Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether)
Q_PROPERTY(bool sliceLastRow READ sliceLastRow WRITE setSliceLastRow)
+ Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
+ Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
public:
DataBand(QObject* owner = 0, QGraphicsItem* parent=0);
bool isUnique() const;
diff --git a/src/bands/lrgroupbands.cpp b/src/bands/lrgroupbands.cpp
index 01a7856..3702d73 100644
--- a/src/bands/lrgroupbands.cpp
+++ b/src/bands/lrgroupbands.cpp
@@ -63,7 +63,7 @@ namespace LimeReport{
GroupBandHeader::GroupBandHeader(QObject *owner, QGraphicsItem *parent)
: BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner,parent),
- m_groupFiledName(""), m_groupStarted(false)
+ m_groupFiledName(""), m_groupStarted(false), m_startNewPage(false), m_resetPageNumber(false)
{
setBandTypeText(tr("GroupHeader"));
setFixedPos(false);
@@ -85,16 +85,15 @@ BaseDesignIntf *GroupBandHeader::createSameTypeItem(QObject *owner, QGraphicsIte
return new GroupBandHeader(owner, parent);
}
-void GroupBandHeader::startGroup()
+void GroupBandHeader::startGroup(DataSourceManager* dataManager)
{
m_groupStarted=true;
- DataSourceManager* dm = DataSourceManager::instance();
QString lineVar = QLatin1String("line_")+objectName().toLower();
- dm->setReportVariable(lineVar,1);
+ dataManager->setReportVariable(lineVar,1);
- if ((dm->dataSource(parentBand()->datasourceName()))){
- IDataSource* ds = dm->dataSource(parentBand()->datasourceName());
+ if ((dataManager->dataSource(parentBand()->datasourceName()))){
+ IDataSource* ds = dataManager->dataSource(parentBand()->datasourceName());
if (ds->columnIndexByName(m_groupFiledName)!=-1)
m_groupFieldValue=ds->data(m_groupFiledName);
}
@@ -105,16 +104,20 @@ QColor GroupBandHeader::bandColor() const
return QColor(Qt::darkBlue);
}
-bool GroupBandHeader::isNeedToClose()
+void GroupBandHeader::setStartNewPage(bool value)
+{
+ m_startNewPage = value;
+}
+
+bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
{
//if (m_groupFieldValue.isNull()) return false;
if (!m_groupStarted) return false;
- DataSourceManager* dm = DataSourceManager::instance();
if (m_groupFiledName.isNull() || m_groupFiledName.isEmpty())
- dm->putError("Group Field Not found");
- if ((dm->dataSource(parentBand()->datasourceName()))){
- IDataSource* ds = dm->dataSource(parentBand()->datasourceName());
+ dataManager->putError("Group Field Not found");
+ if ((dataManager->dataSource(parentBand()->datasourceName()))){
+ IDataSource* ds = dataManager->dataSource(parentBand()->datasourceName());
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull()) return false;
return ds->data(m_groupFiledName)!=m_groupFieldValue;
}
@@ -138,6 +141,16 @@ int GroupBandHeader::index()
return bandIndex();
}
+bool GroupBandHeader::resetPageNumber() const
+{
+ return m_resetPageNumber;
+}
+
+void GroupBandHeader::setResetPageNumber(bool resetPageNumber)
+{
+ m_resetPageNumber = resetPageNumber;
+}
+
GroupBandFooter::GroupBandFooter(QObject *owner, QGraphicsItem *parent)
:BandDesignIntf(BandDesignIntf::GroupFooter, xmlTagFooter, owner,parent)
{
diff --git a/src/bands/lrgroupbands.h b/src/bands/lrgroupbands.h
index 56c7127..59b0475 100644
--- a/src/bands/lrgroupbands.h
+++ b/src/bands/lrgroupbands.h
@@ -40,6 +40,8 @@ class GroupBandHeader : public BandDesignIntf, public IGroupBand{
Q_PROPERTY(QString groupFieldName READ groupFieldName WRITE setGroupFieldName)
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable )
Q_PROPERTY(bool keepGroupTogether READ tryToKeepTogether WRITE setTryToKeepTogether)
+ Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage)
+ Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber)
public:
GroupBandHeader(QObject* owner = 0, QGraphicsItem* parent=0);
virtual bool isUnique() const;
@@ -48,17 +50,23 @@ public:
QString groupFieldName(){return m_groupFiledName;}
void setGroupFieldName(QString fieldName){m_groupFiledName=fieldName;}
QColor bandColor() const;
+ bool startNewPage() const {return m_startNewPage;}
+ void setStartNewPage(bool value);
+ bool resetPageNumber() const;
+ void setResetPageNumber(bool resetPageNumber);
private:
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
- virtual void startGroup();
- virtual bool isNeedToClose();
- virtual bool isStarted();
- virtual void closeGroup();
- virtual int index();
+ void startGroup(DataSourceManager* dataManager);
+ bool isNeedToClose(DataSourceManager *dataManager);
+ bool isStarted();
+ void closeGroup();
+ int index();
private:
QVariant m_groupFieldValue;
QString m_groupFiledName;
bool m_groupStarted;
+ bool m_startNewPage;
+ bool m_resetPageNumber;
};
class GroupBandFooter : public BandDesignIntf{
diff --git a/src/bands/lrsubdetailband.h b/src/bands/lrsubdetailband.h
index a18dee7..f93f8e1 100644
--- a/src/bands/lrsubdetailband.h
+++ b/src/bands/lrsubdetailband.h
@@ -39,6 +39,8 @@ class SubDetailBand : public DataBandDesignIntf
{
Q_OBJECT
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
+ Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
+ Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
public:
SubDetailBand(QObject* owner = 0, QGraphicsItem* parent=0);
bool isUnique() const {return false;}
diff --git a/src/databrowser/lrdatabrowser.cpp b/src/databrowser/lrdatabrowser.cpp
index c44aae8..aa80064 100644
--- a/src/databrowser/lrdatabrowser.cpp
+++ b/src/databrowser/lrdatabrowser.cpp
@@ -131,7 +131,7 @@ void DataBrowser::slotDeleteConnection()
QMessageBox::critical(
this,
tr("Attention"),
- tr("Do you really want delete \"%1\" connection ?").arg(getConnectionName()),
+ tr("Do you really want to delete \"%1\" connection ?").arg(getConnectionName()),
QMessageBox::Ok|QMessageBox::No,
QMessageBox::No
)==QMessageBox::Ok
@@ -366,7 +366,7 @@ void DataBrowser::slotDeleteDatasource()
QMessageBox::critical(
this,
tr("Attention"),
- tr("Do you really want delete \"%1\" datasource ?").arg(datasourceName),
+ tr("Do you really want to delete \"%1\" datasource ?").arg(datasourceName),
QMessageBox::Ok|QMessageBox::No,
QMessageBox::No
)==QMessageBox::Ok
@@ -668,7 +668,7 @@ void DataBrowser::on_deleteVariable_clicked()
{
QString varName = getVariable();
if (!varName.isEmpty()){
- if (QMessageBox::critical(this,tr("Attention"),QString(tr("Do you really want delete variable \"%1\" ?")).arg(varName),
+ if (QMessageBox::critical(this,tr("Attention"),QString(tr("Do you really want to delete variable \"%1\" ?")).arg(varName),
QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel
)==QMessageBox::Ok){
m_report->dataManager()->deleteVariable(varName);
diff --git a/src/items/editors/lritemsborderseditorwidget.cpp b/src/items/editors/lritemsborderseditorwidget.cpp
index 4597b06..afdf766 100644
--- a/src/items/editors/lritemsborderseditorwidget.cpp
+++ b/src/items/editors/lritemsborderseditorwidget.cpp
@@ -97,19 +97,19 @@ void ItemsBordersEditorWidget::initEditor()
connect(m_topLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
addAction(m_topLine);
- m_bottomLine = new QAction(tr("Top line"),this);
+ m_bottomLine = new QAction(tr("Bottom line"),this);
m_bottomLine->setIcon(QIcon(":/report/images/bottomLine"));
m_bottomLine->setCheckable(true);
connect(m_bottomLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
addAction(m_bottomLine);
- m_leftLine = new QAction(tr("Top line"),this);
+ m_leftLine = new QAction(tr("Left line"),this);
m_leftLine->setIcon(QIcon(":/report/images/leftLine"));
m_leftLine->setCheckable(true);
connect(m_leftLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
addAction(m_leftLine);
- m_rightLine = new QAction(tr("Top line"),this);
+ m_rightLine = new QAction(tr("Right line"),this);
m_rightLine->setIcon(QIcon(":/report/images/rightLine"));
m_rightLine->setCheckable(true);
connect(m_rightLine,SIGNAL(toggled(bool)),this,SLOT(buttonClicked(bool)));
diff --git a/src/items/lrbarcodeitem.cpp b/src/items/lrbarcodeitem.cpp
index 14dc8f8..751c16e 100644
--- a/src/items/lrbarcodeitem.cpp
+++ b/src/items/lrbarcodeitem.cpp
@@ -231,15 +231,16 @@ void BarcodeItem::setPdf417CodeWords(int pdf417CodeWords)
}
}
-void BarcodeItem::updateItemSize(RenderPass pass, int)
+void BarcodeItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{
switch(pass){
case FirstPass:
- setContent(expandUserVariables(content(),pass,NoEscapeSymbols));
- setContent(expandDataFields(content(),NoEscapeSymbols));
+ setContent(expandUserVariables(content(),pass,NoEscapeSymbols, dataManager));
+ setContent(expandDataFields(content(), NoEscapeSymbols, dataManager));
break;
default:;
}
+ BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
bool BarcodeItem::isNeedUpdateSize(RenderPass pass) const
diff --git a/src/items/lrbarcodeitem.h b/src/items/lrbarcodeitem.h
index 001aec0..b79351b 100644
--- a/src/items/lrbarcodeitem.h
+++ b/src/items/lrbarcodeitem.h
@@ -132,7 +132,7 @@ public:
~BarcodeItem();
virtual BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget);
- virtual void updateItemSize(RenderPass pass, int);
+ virtual void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
virtual bool isNeedUpdateSize(RenderPass pass) const;
void setContent(const QString& content);
QString content() const {return m_content;}
diff --git a/src/items/lrhorizontallayout.cpp b/src/items/lrhorizontallayout.cpp
index 4e645e2..bc764f6 100644
--- a/src/items/lrhorizontallayout.cpp
+++ b/src/items/lrhorizontallayout.cpp
@@ -61,7 +61,7 @@ bool lessThen(BaseDesignIntf *c1, BaseDesignIntf* c2){
HorizontalLayout::HorizontalLayout(QObject *owner, QGraphicsItem *parent)
- : LayoutDesignIntf(xmlTag, owner, parent),m_isRelocating(false)
+ : LayoutDesignIntf(xmlTag, owner, parent),m_isRelocating(false),m_layoutType(Layout)
{
setPosibleResizeDirectionFlags(ResizeBottom);
m_layoutMarker = new LayoutMarker(this);
@@ -101,6 +101,9 @@ void HorizontalLayout::geometryChangedEvent(QRectF newRect, QRectF )
{
m_layoutMarker->setHeight(newRect.height());
relocateChildren();
+ if (m_layoutType == Table && !m_isRelocating){
+ divideSpace();
+ }
}
void HorizontalLayout::setChildVisibility(bool value){
@@ -186,6 +189,13 @@ BaseDesignIntf *HorizontalLayout::cloneBottomPart(int height, QObject *owner, QG
return bottomPart;
}
+void HorizontalLayout::setItemAlign(const BaseDesignIntf::ItemAlign &itemAlign)
+{
+ if (itemAlign == ParentWidthItemAlign)
+ setLayoutType(Table);
+ BaseDesignIntf::setItemAlign(itemAlign);
+}
+
void HorizontalLayout::restoreChild(BaseDesignIntf* item){
if (m_children.contains(item)) return;
@@ -200,7 +210,11 @@ void HorizontalLayout::restoreChild(BaseDesignIntf* item){
}
connect(item,SIGNAL(destroyed(QObject*)),this,SLOT(slotOnChildDestroy(QObject*)));
- connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF)));
+ connect(item,SIGNAL(geometryChanged(QObject*,QRectF,QRectF)),
+ this,SLOT(slotOnChildGeometryChanged(QObject*,QRectF,QRectF)));
+ connect(item, SIGNAL(itemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)),
+ this, SLOT(slotOnChildItemAlignChanged(BaseDesignIntf*,ItemAlign,ItemAlign)));
+
item->setFixedPos(true);
item->setPosibleResizeDirectionFlags(ResizeRight | ResizeBottom);
item->setParent(this);
@@ -319,17 +333,18 @@ void HorizontalLayout::beforeDelete()
}
}
-void HorizontalLayout::updateItemSize(RenderPass pass, int maxHeight)
+void HorizontalLayout::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{
m_isRelocating=true;
- ItemDesignIntf::updateItemSize(pass,maxHeight);
+ ItemDesignIntf::updateItemSize(dataManager, pass, maxHeight);
foreach(QGraphicsItem *child, childItems()){
BaseDesignIntf* item = dynamic_cast(child);
- if (item) item->updateItemSize(pass,maxHeight);
+ if (item) item->updateItemSize(dataManager, pass, maxHeight);
}
updateLayoutSize();
relocateChildren();
m_isRelocating=false;
+ BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
bool HorizontalLayout::isNeedUpdateSize(RenderPass pass) const
@@ -359,15 +374,89 @@ void HorizontalLayout::slotOnChildDestroy(QObject* child)
}
}
-void HorizontalLayout::slotOnChildGeometryChanged(QObject *, QRectF newGeometry, QRectF)
+BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){
+ if (m_children.count()i+1){ return m_children[i+1];}
+ }
+ return 0;
+}
+
+BaseDesignIntf* HorizontalLayout::findPrior(BaseDesignIntf* item){
+ if (m_children.count()width();
+ }
+ qreal delta = (width() - itemsSumSize)/m_children.size();
+ for (int i=0; isetWidth(m_children[i]->width()+(delta));
+ if ((i+1)setPos(m_children[i+1]->pos().x()+delta*(i+1),m_children[i+1]->pos().y());
+ }
+ m_isRelocating = false;
+}
+void HorizontalLayout::slotOnChildGeometryChanged(QObject *item, QRectF newGeometry, QRectF oldGeometry)
{
if (!m_isRelocating){
setHeight(newGeometry.height());
- relocateChildren();
- updateLayoutSize();
+ if (m_layoutType == Layout){
+ relocateChildren();
+ updateLayoutSize();
+ } else {
+ m_isRelocating = true;
+ qreal delta = newGeometry.width()-oldGeometry.width();
+ BaseDesignIntf* resizingItem = findNext(dynamic_cast(item));
+ if (resizingItem) {
+ resizingItem->setWidth(resizingItem->width()-delta);
+ resizingItem->setPos(resizingItem->pos().x()+delta,resizingItem->pos().y());
+ }
+ updateLayoutSize();
+ m_isRelocating = false;
+ }
}
}
+void HorizontalLayout::slotOnChildItemAlignChanged(BaseDesignIntf *item, const BaseDesignIntf::ItemAlign &, const BaseDesignIntf::ItemAlign&)
+{
+ item->setPosibleResizeDirectionFlags(ResizeBottom | ResizeRight);
+}
+
+HorizontalLayout::LayoutType HorizontalLayout::layoutType() const
+{
+ return m_layoutType;
+}
+
+void HorizontalLayout::setLayoutType(const LayoutType &layoutType)
+{
+ if (m_layoutType != layoutType){
+ LayoutType oldValue = m_layoutType;
+ m_layoutType = layoutType;
+ notify("layoutType",oldValue,layoutType);
+ }
+
+}
+
LayoutMarker::LayoutMarker(HorizontalLayout *layout, QGraphicsItem *parent)
:QGraphicsItem(parent), m_rect(0,0,30,30), m_color(Qt::red), m_layout(layout){
setFlag(QGraphicsItem::ItemIsMovable);
diff --git a/src/items/lrhorizontallayout.h b/src/items/lrhorizontallayout.h
index 5e480be..c00b92b 100644
--- a/src/items/lrhorizontallayout.h
+++ b/src/items/lrhorizontallayout.h
@@ -57,7 +57,11 @@ private:
class HorizontalLayout : public LayoutDesignIntf
{
Q_OBJECT
+ Q_ENUMS(LayoutType)
+ Q_PROPERTY(LayoutType layoutType READ layoutType WRITE setLayoutType)
public:
+ friend class LayoutMarker;
+ enum LayoutType{Layout,Table};
HorizontalLayout(QObject *owner = 0, QGraphicsItem *parent = 0);
~HorizontalLayout();
BaseDesignIntf *createSameTypeItem(QObject *owner = 0, QGraphicsItem *parent = 0);
@@ -68,13 +72,17 @@ public:
friend class BaseDesignIntf;
void restoreChild(BaseDesignIntf *item);
bool isEmpty() const;
+ LayoutType layoutType() const;
+ void setLayoutType(const LayoutType &layoutType);
protected:
void collectionLoadFinished(const QString &collectionName);
void objectLoadFinished();
void updateLayoutSize();
void relocateChildren();
+ BaseDesignIntf *findNext(BaseDesignIntf *item);
+ BaseDesignIntf *findPrior(BaseDesignIntf *item);
void beforeDelete();
- void updateItemSize(RenderPass pass, int maxHeight);
+ void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
bool isNeedUpdateSize(RenderPass pass) const;
void childAddedEvent(BaseDesignIntf *child);
void setChildVisibility(bool value);
@@ -85,16 +93,19 @@ protected:
BaseDesignIntf* cloneUpperPart(int height, QObject* owner=0, QGraphicsItem* parent=0);
BaseDesignIntf* cloneBottomPart(int height, QObject *owner=0, QGraphicsItem *parent=0);
+ void setItemAlign(const ItemAlign &itemAlign);
private slots:
void slotOnChildDestroy(QObject *child);
- void slotOnChildGeometryChanged(QObject*, QRectF newGeometry, QRectF);
+ void slotOnChildGeometryChanged(QObject*item, QRectF newGeometry, QRectF oldGeometry);
+ void slotOnChildItemAlignChanged(BaseDesignIntf* item, const ItemAlign&, const ItemAlign&);
//void slotOnPosChanged(QObject*, QPointF newPos, QPointF );
+private:
+ void divideSpace();
private:
QList m_children;
bool m_isRelocating;
LayoutMarker* m_layoutMarker;
-
- friend class LayoutMarker;
+ LayoutType m_layoutType;
};
} //namespace LimeReport
diff --git a/src/items/lrimageitem.cpp b/src/items/lrimageitem.cpp
index 674186a..472f363 100644
--- a/src/items/lrimageitem.cpp
+++ b/src/items/lrimageitem.cpp
@@ -54,11 +54,10 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par
return new ImageItem(owner,parent);
}
-void ImageItem::updateItemSize(RenderPass , int )
+void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{
if (!m_datasource.isEmpty() && !m_field.isEmpty() && m_picture.isNull()){
- DataSourceManager* dm = DataSourceManager::instance();
- IDataSource* ds = dm->dataSource(m_datasource);
+ IDataSource* ds = dataManager->dataSource(m_datasource);
if (ds) {
QVariant data = ds->data(m_field);
if (data.isValid()){
@@ -73,6 +72,7 @@ void ImageItem::updateItemSize(RenderPass , int )
setWidth(m_picture.width());
setHeight(m_picture.height());
}
+ BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
bool ImageItem::isNeedUpdateSize(RenderPass) const
diff --git a/src/items/lrimageitem.h b/src/items/lrimageitem.h
index f9e6e7e..4e3fa23 100644
--- a/src/items/lrimageitem.h
+++ b/src/items/lrimageitem.h
@@ -68,7 +68,7 @@ public:
protected:
BaseDesignIntf* createSameTypeItem(QObject *owner, QGraphicsItem *parent);
- void updateItemSize(RenderPass, int);
+ void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
bool isNeedUpdateSize(RenderPass) const;
bool drawDesignBorders() const {return m_picture.isNull();}
private:
diff --git a/src/items/lrtextitem.cpp b/src/items/lrtextitem.cpp
index 1a83a14..f533f67 100644
--- a/src/items/lrtextitem.cpp
+++ b/src/items/lrtextitem.cpp
@@ -173,10 +173,10 @@ void TextItem::setContent(const QString &value)
}
}
-void TextItem::updateItemSize(RenderPass pass, int /*maxHeight*/)
+void TextItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{
if (isNeedExpandContent())
- expandContent(pass);
+ expandContent(dataManager, pass);
if (!isLoading())
initText();
@@ -187,6 +187,7 @@ void TextItem::updateItemSize(RenderPass pass, int /*maxHeight*/)
if ((m_textSize.height()>height()) && (m_autoHeight) ){
setHeight(m_textSize.height()+5);
}
+ BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
void TextItem::updateLayout()
@@ -298,18 +299,18 @@ void TextItem::setAlignment(Qt::Alignment value)
}
}
-void TextItem::expandContent(RenderPass pass)
+void TextItem::expandContent(DataSourceManager* dataManager, RenderPass pass)
{
QString context=content();
switch(pass){
case FirstPass:
- context=expandUserVariables(context, pass, NoEscapeSymbols);
- context=expandScripts(context);
- context=expandDataFields(context, NoEscapeSymbols);
+ context=expandUserVariables(context, pass, NoEscapeSymbols, dataManager);
+ context=expandScripts(context, dataManager);
+ context=expandDataFields(context, NoEscapeSymbols, dataManager);
break;
case SecondPass:;
- context=expandUserVariables(context, pass, NoEscapeSymbols);
- context=expandScripts(context);
+ context=expandUserVariables(context, pass, NoEscapeSymbols, dataManager);
+ context=expandScripts(context, dataManager);
}
setContent(context);
diff --git a/src/items/lrtextitem.h b/src/items/lrtextitem.h
index 1d73401..7b5069e 100644
--- a/src/items/lrtextitem.h
+++ b/src/items/lrtextitem.h
@@ -77,10 +77,10 @@ public:
void setAlignment(Qt::Alignment value);
Qt::Alignment alignment(){return m_alignment;}
- virtual void geometryChangedEvent(QRectF, QRectF);
- virtual bool isNeedUpdateSize(RenderPass) const;
- virtual void updateItemSize(RenderPass pass, int);
- void expandContent(RenderPass pass);
+ void geometryChangedEvent(QRectF, QRectF);
+ bool isNeedUpdateSize(RenderPass) const;
+ void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight);
+ void expandContent(DataSourceManager *dataManager, RenderPass pass);
void setAutoHeight(bool value);
bool autoHeight() const {return m_autoHeight;}
diff --git a/src/items/lrtextitemeditor.cpp b/src/items/lrtextitemeditor.cpp
index 55b0f52..527e66f 100644
--- a/src/items/lrtextitemeditor.cpp
+++ b/src/items/lrtextitemeditor.cpp
@@ -34,6 +34,7 @@
#include "lrscriptenginemanager.h"
#include "lrdatadesignintf.h"
#include "lrdatasourcemanager.h"
+
#include
#include
@@ -111,10 +112,13 @@ void TextItemEditor::initUI()
m_datasourcesMenu = new QMenu(this);
- LimeReport::DataSourceManager* dm = LimeReport::DataSourceManager::instance();
+ LimeReport::DataSourceManager* dm = m_page->datasourceManager();
+ LimeReport::ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
+ se.setDataManager(dm);
+
if (dm){
ui->twData->setModel(dm->datasourcesModel());
- ui->twScriptEngine->setModel(LimeReport::ScriptEngineManager::instance().model());
+ ui->twScriptEngine->setModel(se.model());
foreach(QString dsName,dm->dataSourceNames()){
foreach(QString field, dm->fieldNames(dsName)){
@@ -125,8 +129,6 @@ void TextItemEditor::initUI()
ui->tabWidget->setVisible(false);
}
- LimeReport::ScriptEngineManager& se = LimeReport::ScriptEngineManager::instance();
-
foreach (LimeReport::ScriptFunctionDesc functionDesc, se.functionsDescriber()) {
dataWords<datasourceManager();
QStringList dataSources;
foreach(QString dsName,dm->dataSourceNames()){
dataSources<datasourceManager();
foreach(QString field, dm->fieldNames(datasource)){
fields<0){
+ qreal oldValue = m_columnsCount;
+ qreal fullWidth = m_columnsCount * width();
+ m_columnsCount = value;
+ if (!isLoading()){
+ setWidth(fullWidth/m_columnsCount);
+ notify("columnsCount",oldValue,value);
+ }
+ }
+}
+
+void BandDesignIntf::setColumnsFillDirection(BandDesignIntf::BandColumnsLayoutType value)
+{
+ if (m_columnsFillDirection!=value){
+ qreal oldValue = m_columnsFillDirection;
+ m_columnsFillDirection = value;
+ if (!isLoading())
+ notify("columnsFillDirection",oldValue,value);
+ }
+
+}
+
BaseDesignIntf* BandDesignIntf::cloneUpperPart(int height, QObject *owner, QGraphicsItem *parent)
{
int maxBottom = 0;
@@ -473,6 +500,15 @@ void BandDesignIntf::emitBandRendered(BandDesignIntf* band)
emit bandRendered(band);
}
+void BandDesignIntf::setSplittable(bool value){
+ if (m_splitable!=value){
+ bool oldValue = m_splitable;
+ m_splitable = value;
+ if (!isLoading())
+ notify("splittable",oldValue,value);
+ }
+}
+
bool itemSortContainerLessThen(const PItemSortContainer c1, const PItemSortContainer c2)
{
VSegment vS1(c1->m_rect),vS2(c2->m_rect);
@@ -496,13 +532,13 @@ void BandDesignIntf::snapshotItemsLayout()
qSort(m_bandItems.begin(),m_bandItems.end(),itemSortContainerLessThen);
}
-void BandDesignIntf::arrangeSubItems(RenderPass pass, ArrangeType type)
+void BandDesignIntf::arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type)
{
bool needArrage=(type==Force);
foreach (PItemSortContainer item, m_bandItems) {
if (item->m_item->isNeedUpdateSize(pass)){
- item->m_item->updateItemSize(pass);
+ item->m_item->updateItemSize(dataManager, pass);
needArrage=true;
}
}
@@ -656,6 +692,16 @@ void BandDesignIntf::childBandDeleted(QObject *band)
m_childBands.removeAt(m_childBands.indexOf(reinterpret_cast(band)));
}
+int BandDesignIntf::columnIndex() const
+{
+ return m_columnIndex;
+}
+
+void BandDesignIntf::setColumnIndex(int columnIndex)
+{
+ m_columnIndex = columnIndex;
+}
+
bool BandDesignIntf::printIfEmpty() const
{
return m_printIfEmpty;
@@ -707,24 +753,29 @@ bool BandDesignIntf::keepFooterTogether() const
return m_keepFooterTogether;
}
-void BandDesignIntf::setKeepFooterTogether(bool keepFooterTogether)
+void BandDesignIntf::setKeepFooterTogether(bool value)
{
- m_keepFooterTogether = keepFooterTogether;
+ if (m_keepFooterTogether!=value){
+ bool oldValue = m_keepFooterTogether;
+ m_keepFooterTogether = value;
+ if (!isLoading())
+ notify("keepFooterTogether",oldValue,value);
+ }
}
-void BandDesignIntf::updateItemSize(RenderPass pass,int maxHeight)
+void BandDesignIntf::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight)
{
qreal spaceBorder=0;
if (keepBottomSpaceOption()) spaceBorder=height()-findMaxBottom();
snapshotItemsLayout();
- arrangeSubItems(pass);
+ arrangeSubItems(pass, dataManager);
if (autoHeight() && height()0)&&(height()>maxHeight)){
trimToMaxHeight(maxHeight);
setHeight(maxHeight);
}
- BaseDesignIntf::updateItemSize(pass,maxHeight);
+ BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
QColor BandDesignIntf::selectionColor() const
diff --git a/src/lrbanddesignintf.h b/src/lrbanddesignintf.h
index fbf3f3f..b190a75 100644
--- a/src/lrbanddesignintf.h
+++ b/src/lrbanddesignintf.h
@@ -30,6 +30,7 @@
#ifndef LRBANDDESIGNINTF_H
#define LRBANDDESIGNINTF_H
#include "lrbasedesignintf.h"
+#include "lrdatasourcemanager.h"
#include
namespace LimeReport {
@@ -37,11 +38,13 @@ namespace LimeReport {
class IGroupBand
{
public:
- virtual void startGroup()=0;
- virtual bool isNeedToClose()=0;
- virtual bool isStarted()=0;
- virtual void closeGroup()=0;
- virtual int index()=0;
+ virtual void startGroup(DataSourceManager* dataManager) = 0;
+ virtual bool isNeedToClose(DataSourceManager* dataManager) = 0;
+ virtual bool isStarted() = 0;
+ virtual void closeGroup() = 0;
+ virtual int index() = 0;
+ virtual bool startNewPage()const = 0 ;
+ virtual bool resetPageNumber()const = 0 ;
virtual ~IGroupBand(){}
};
@@ -89,6 +92,7 @@ class BandDesignIntf : public BaseDesignIntf
Q_PROPERTY(QString parentBand READ parentBandName WRITE setParentBandName DESIGNABLE false )
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
Q_PROPERTY(bool printIfEmpty READ printIfEmpty WRITE setPrintIfEmpty)
+ Q_ENUMS(BandColumnsLayoutType)
friend class BandMarker;
friend class BandNameLabel;
public:
@@ -108,6 +112,10 @@ public:
PageFooter=11
};
+ enum BandColumnsLayoutType{
+ Horizontal, Vertical
+ };
+
BandDesignIntf(BandsType bandType, const QString& xmlTypeName, QObject* owner = 0, QGraphicsItem* parent=0);
~BandDesignIntf();
@@ -116,7 +124,7 @@ public:
virtual QString bandTitle() const;
virtual QIcon bandIcon() const;
virtual bool isUnique() const;
- virtual void updateItemSize(RenderPass pass=FirstPass, int maxHeight=0);
+ virtual void updateItemSize(DataSourceManager *dataManager, RenderPass pass=FirstPass, int maxHeight=0);
virtual QColor selectionColor() const;
int bandIndex() const;
@@ -165,10 +173,10 @@ public:
void emitBandRendered(BandDesignIntf *band);
bool isSplittable() const {return m_splitable;}
- void setSplittable(bool value){m_splitable=value;}
+ void setSplittable(bool value);
bool keepFooterTogether() const;
- void setKeepFooterTogether(bool keepFooterTogether);
+ void setKeepFooterTogether(bool value);
int maxScalePercent() const;
void setMaxScalePercent(int maxScalePercent);
@@ -182,11 +190,16 @@ public:
virtual BandDesignIntf* bandHeader();
virtual BandDesignIntf* bandFooter();
+ int columnsCount() const {return m_columnsCount;}
+ BandColumnsLayoutType columnsFillDirection(){ return m_columnsFillDirection;}
+ int columnIndex() const;
+ void setColumnIndex(int columnIndex);
+
signals:
void bandRendered(BandDesignIntf* band);
protected:
void snapshotItemsLayout();
- void arrangeSubItems(RenderPass pass, ArrangeType type = AsNeeded);
+ void arrangeSubItems(RenderPass pass, DataSourceManager *dataManager, ArrangeType type = AsNeeded);
qreal findMaxBottom();
qreal findMaxHeight();
void trimToMaxHeight(int maxHeight);
@@ -207,6 +220,8 @@ protected:
virtual QColor bandColor() const;
void setMarkerColor(QColor color);
void checkEmptyTable();
+ void setColumnsCount(int value);
+ void setColumnsFillDirection(BandColumnsLayoutType value);
private slots:
void childBandDeleted(QObject* band);
private:
@@ -228,6 +243,9 @@ private:
bool m_sliceLastRow;
bool m_printIfEmpty;
BandNameLabel* m_bandNameLabel;
+ int m_columnsCount;
+ int m_columnIndex;
+ BandColumnsLayoutType m_columnsFillDirection;
};
class DataBandDesignIntf : public BandDesignIntf{
diff --git a/src/lrbasedesignintf.cpp b/src/lrbasedesignintf.cpp
index bbc3395..6de3689 100644
--- a/src/lrbasedesignintf.cpp
+++ b/src/lrbasedesignintf.cpp
@@ -70,7 +70,9 @@ BaseDesignIntf::BaseDesignIntf(const QString &storageTypeName, QObject *owner, Q
m_selectionMarker(0),
m_backgroundBrush(Solid),
m_backgroundBrushcolor(Qt::white),
- m_margin(4)
+ m_margin(4),
+ m_itemAlign(DesignedItemAlign),
+ m_changingItemAlign(false)
{
setGeometry(QRectF(0, 0, m_width, m_height));
if (BaseDesignIntf *item = dynamic_cast(parent)) {
@@ -164,6 +166,8 @@ qreal BaseDesignIntf::width() const
void BaseDesignIntf::setWidth(qreal width)
{
setGeometry(QRectF(rect().x(), rect().y(), width, rect().height()));
+ if (!m_changingItemAlign)
+ updateItemAlign();
}
qreal BaseDesignIntf::height() const
@@ -493,17 +497,83 @@ void BaseDesignIntf::setZValueProperty(qreal value)
}
}
-//void BaseDesignIntf::slotObjectNameChanged(const QString &newName)
-//{
-// if (!isLoading() && page() && this->itemMode()==LimeReport::DesignMode){
-// QList list = page()->reportItemsByName(newName);
-// if (list.size()>1){
-// setObjectName(page()->genObjectName(*this));
-// notify("objectName",newName,objectName());
-// }
+BaseDesignIntf::ItemAlign BaseDesignIntf::itemAlign() const
+{
+ return m_itemAlign;
+}
-// }
-//}
+QPointF BaseDesignIntf::modifyPosForAlignedItem(const QPointF& pos){
+ QPointF result = pos;
+ BaseDesignIntf* parent = dynamic_cast(parentItem());
+ PageItemDesignIntf* parentPage = dynamic_cast(parentItem());
+ if (parent){
+ qreal leftBorder = parentPage?parentPage->leftMargin()*mmFactor():0;
+ qreal rightBorder = parentPage?parentPage->rightMargin()*mmFactor():0;
+ qreal aviableSpace = parent->width()-(leftBorder+rightBorder);
+
+ switch(m_itemAlign){
+ case LeftItemAlign:
+ result.setX(leftBorder);
+ break;
+ case RightItemAlign:
+ result.setX(parent->width()-rightBorder);
+ break;
+ case CenterItemAlign:
+ result.setX((aviableSpace-width())/2);
+ break;
+ case ParentWidthItemAlign:
+ result.setX(leftBorder);
+ case DesignedItemAlign:
+ break;
+ }
+ }
+ return result;
+}
+
+void BaseDesignIntf::updateItemAlign(){
+ BaseDesignIntf* parent = dynamic_cast(parentItem());
+ PageItemDesignIntf* parentPage = dynamic_cast(parentItem());
+ m_changingItemAlign = true;
+ if (parent){
+ qreal leftBorder = parentPage?parentPage->leftMargin()*mmFactor():0;
+ qreal rightBorder = parentPage?parentPage->rightMargin()*mmFactor():0;
+ qreal aviableSpace = parent->width()-(leftBorder+rightBorder);
+
+ setPos(modifyPosForAlignedItem(pos()));
+ if (m_itemAlign == ParentWidthItemAlign)
+ setWidth(aviableSpace);
+ }
+ m_changingItemAlign = false;
+}
+
+void BaseDesignIntf::updatePosibleDirectionFlags(){
+ setPosibleResizeDirectionFlags(AllDirections);
+ switch(m_itemAlign){
+ case LeftItemAlign:
+ setPosibleResizeDirectionFlags(AllDirections^ResizeLeft);
+ break;
+ case RightItemAlign:
+ setPosibleResizeDirectionFlags(AllDirections^ResizeRight);
+ break;
+ case ParentWidthItemAlign:
+ setPosibleResizeDirectionFlags(ResizeBottom|ResizeTop);
+ case CenterItemAlign:
+ case DesignedItemAlign:
+ break;
+ }
+}
+
+void BaseDesignIntf::setItemAlign(const ItemAlign &itemAlign)
+{
+ if (m_itemAlign != itemAlign){
+ ItemAlign oldValue = m_itemAlign;
+ m_itemAlign = itemAlign;
+ notify("itemAlign",oldValue,itemAlign);
+ updatePosibleDirectionFlags();
+ updateItemAlign();
+ emit itemAlignChanged(this, oldValue, itemAlign);
+ }
+}
QString BaseDesignIntf::itemTypeName() const
{
@@ -738,6 +808,10 @@ QVariant BaseDesignIntf::itemChange(QGraphicsItem::GraphicsItemChange change, co
updateSelectionMarker();
m_selectionMarker->setVisible(value.toBool());
}
+ if (change == QGraphicsItem::ItemParentHasChanged) {
+ parentChangedEvent(dynamic_cast(value.value()));
+ }
+
return QGraphicsItem::itemChange(change, value);
}
@@ -746,6 +820,11 @@ void BaseDesignIntf::childAddedEvent(BaseDesignIntf *child)
Q_UNUSED(child)
}
+void BaseDesignIntf::parentChangedEvent(BaseDesignIntf *)
+{
+
+}
+
QPainterPath BaseDesignIntf::shape() const
{
QPainterPath path;
@@ -804,8 +883,9 @@ void BaseDesignIntf::setItemMode(ItemMode mode)
void BaseDesignIntf::setItemPos(const QPointF &newPos)
{
QPointF oldPos = pos();
- QGraphicsItem::setPos(newPos);
- emit posChanged(this, newPos, oldPos);
+ QPointF finalPos = modifyPosForAlignedItem(newPos);
+ QGraphicsItem::setPos(finalPos);
+ emit posChanged(this, finalPos, oldPos);
}
void BaseDesignIntf::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@@ -925,10 +1005,12 @@ ReportEnginePrivate *BaseDesignIntf::reportEditor()
else return 0;
}
-void BaseDesignIntf::updateItemSize(RenderPass pass, int maxHeight)
+void BaseDesignIntf::updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight)
{
Q_UNUSED(maxHeight);
+ Q_UNUSED(dataManager);
m_currentPass = pass;
+ updateItemAlign();
}
bool BaseDesignIntf::isNeedUpdateSize(RenderPass /*pass*/) const
@@ -943,8 +1025,10 @@ QObject *BaseDesignIntf::createElement(const QString& /*collectionName*/, const
{
BaseDesignIntf* obj = 0;
try{
- obj = LimeReport::DesignElementsFactory::instance().objectCreator(elementType)(this, this);
- connect(obj,SIGNAL(propertyChanged(QString,QVariant,QVariant)),page(),SLOT(slotItemPropertyChanged(QString,QVariant,QVariant)));
+ if (LimeReport::DesignElementsFactory::instance().objectCreator(elementType)){
+ obj = LimeReport::DesignElementsFactory::instance().objectCreator(elementType)(this, this);
+ connect(obj,SIGNAL(propertyChanged(QString,QVariant,QVariant)),page(),SLOT(slotItemPropertyChanged(QString,QVariant,QVariant)));
+ }
} catch (ReportError error){
qDebug()< childBaseItems();
BaseDesignIntf* childByName(const QString& name);
@@ -212,6 +216,10 @@ public:
void setItemTypeName(const QString &itemTypeName);
void emitObjectNamePropertyChanged(const QString& oldName, const QString& newName);
void showEditorDialog();
+ ItemAlign itemAlign() const;
+ virtual void setItemAlign(const ItemAlign &itemAlign);
+ void updateItemAlign();
+ QPointF modifyPosForAlignedItem(const QPointF &pos);
protected:
//ICollectionContainer
@@ -236,6 +244,7 @@ protected:
virtual void initMode(LimeReport::BaseDesignIntf::ItemMode mode);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
virtual void childAddedEvent(BaseDesignIntf* child);
+ virtual void parentChangedEvent(BaseDesignIntf*);
void drawTopLine(QPainter *painter, QRectF rect) const;
void drawBootomLine(QPainter *painter, QRectF rect) const;
@@ -257,14 +266,14 @@ protected:
RenderPass currentRenderPass(){return m_currentPass;}
virtual bool drawDesignBorders() const {return true;}
+
private:
void updateSelectionMarker();
int resizeDirectionFlags(QPointF position);
void moveSelectedItems(QPointF delta);
Qt::CursorShape getPosibleCursor(int cursorFlags);
void setZValueProperty(qreal value);
-private slots:
-// void slotObjectNameChanged(const QString& newName);
+ void updatePosibleDirectionFlags();
private:
QPointF m_startPos;
QPointF m_startScenePos;
@@ -306,6 +315,8 @@ private:
RenderPass m_currentPass;
int m_margin;
QString m_itemTypeName;
+ ItemAlign m_itemAlign;
+ bool m_changingItemAlign;
signals:
void geometryChanged(QObject* object, QRectF newGeometry, QRectF oldGeometry);
void posChanged(QObject* object, QPointF newPos, QPointF oldPos);
@@ -316,6 +327,7 @@ signals:
void propertyChanged(const QString& propertName, const QVariant& oldValue,const QVariant& newValue);
void propertyObjectNameChanged(const QString& oldValue, const QString& newValue);
void propertyesChanged(QVector propertyNames);
+ void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue);
};
} //namespace LimeReport
diff --git a/src/lrdatadesignintf.cpp b/src/lrdatadesignintf.cpp
index e410fbc..a4f9f52 100644
--- a/src/lrdatadesignintf.cpp
+++ b/src/lrdatadesignintf.cpp
@@ -56,8 +56,9 @@ IDataSource * ModelHolder::dataSource(IDataSource::DatasourceMode mode)
return m_dataSource;
}
-QueryHolder::QueryHolder(QString queryText, QString connectionName)
- : m_query(0), m_queryText(queryText), m_connectionName(connectionName), m_mode(IDataSource::RENDER_MODE)
+QueryHolder::QueryHolder(QString queryText, QString connectionName, DataSourceManager *dataManager)
+ : m_query(0), m_queryText(queryText), m_connectionName(connectionName),
+ m_mode(IDataSource::RENDER_MODE), m_dataManager(dataManager)
{
extractParams();
}
@@ -98,7 +99,7 @@ bool QueryHolder::runQuery(IDataSource::DatasourceMode mode)
return false;
} else setLastError("");
- setDatasource(IDataSource::Ptr(new ModelToDataSource(model,true)));
+ setDatasource(IDataSource::Ptr(new ModelToDataSource(model,true)));
return true;
}
@@ -112,6 +113,18 @@ void QueryHolder::setConnectionName(QString connectionName)
m_connectionName=connectionName;
}
+void QueryHolder::invalidate(IDataSource::DatasourceMode mode){
+ QSqlDatabase db = QSqlDatabase::database(m_connectionName);
+ if (!db.isValid()){
+ setLastError(QObject::tr("Invalid connection! %1").arg(m_connectionName));
+ delete m_query;
+ m_dataSource.clear();
+ } else {
+ runQuery(mode);
+ }
+
+}
+
void QueryHolder::update()
{
runQuery(m_mode);
@@ -124,14 +137,13 @@ void QueryHolder::setDatasource(IDataSource::Ptr value){
void QueryHolder::fillParams(QSqlQuery *query)
{
- DataSourceManager* dm=DataSourceManager::instance();
foreach(QString param,m_aliasesToParam.keys()){
QVariant value;
if (param.contains(".")){
- value = dm->fieldData(m_aliasesToParam.value(param));
+ value = dataManager()->fieldData(m_aliasesToParam.value(param));
param=param.right(param.length()-param.indexOf('.')-1);
} else {
- value = dm->variable(m_aliasesToParam.value(param));
+ value = dataManager()->variable(m_aliasesToParam.value(param));
}
if (value.isValid() || m_mode == IDataSource::DESIGN_MODE)
query->bindValue(':'+param,value);
@@ -344,18 +356,16 @@ QueryDesc::QueryDesc(QString queryName, QString queryText, QString connection)
:m_queryName(queryName), m_query(queryText), m_connectionName(connection)
{}
-SubQueryHolder::SubQueryHolder(QString queryText, QString connectionName, QString masterDatasource)
- : QueryHolder(queryText,connectionName), m_masterDatasource(masterDatasource), m_invalid(false)
+SubQueryHolder::SubQueryHolder(QString queryText, QString connectionName, QString masterDatasource, DataSourceManager* dataManager)
+ : QueryHolder(queryText, connectionName, dataManager), m_masterDatasource(masterDatasource)/*, m_invalid(false)*/
{
extractParams();
}
void SubQueryHolder::setMasterDatasource(const QString &value)
{
- DataSourceManager* dm = DataSourceManager::instance();
- if (dm->dataSource(value)){
+ if (dataManager()->dataSource(value)){
m_masterDatasource = value;
- m_invalid = false;
}
}
@@ -429,8 +439,9 @@ QObject *ProxyDesc::elementAt(const QString &collectionName, int index)
return m_maps.at(index);
}
-ProxyHolder::ProxyHolder(ProxyDesc* desc)
- :m_desc(desc), m_lastError(""), m_mode(IDataSource::RENDER_MODE), m_invalid(false)
+ProxyHolder::ProxyHolder(ProxyDesc* desc, DataSourceManager* dataManager)
+ :m_model(0), m_desc(desc), m_lastError(""), m_mode(IDataSource::RENDER_MODE),
+ m_invalid(false), m_dataManger(dataManager)
{}
QString ProxyHolder::masterDatasource()
@@ -442,12 +453,12 @@ QString ProxyHolder::masterDatasource()
void ProxyHolder::filterModel()
{
if (!m_datasource){
- DataSourceManager* dm=DataSourceManager::instance();
- if (dm){
- IDataSource* master = dm->dataSource(m_desc->master());
- IDataSource* child = dm->dataSource(m_desc->child());
+
+ if (dataManager()){
+ IDataSource* master = dataManager()->dataSource(m_desc->master());
+ IDataSource* child = dataManager()->dataSource(m_desc->child());
if (master&&child){
- m_model = new MasterDetailProxyModel();
+ m_model = new MasterDetailProxyModel(dataManager());
connect(child->model(),SIGNAL(destroyed()), this, SLOT(slotChildModelDestoroyed()));
m_model->setSourceModel(child->model());
m_model->setMaster(m_desc->master());
@@ -459,6 +470,8 @@ void ProxyHolder::filterModel()
} catch (ReportError& exception) {
m_lastError = exception.what();
}
+ m_invalid = false;
+ m_lastError.clear();
} else {
m_lastError.clear();
if(!master) m_lastError+=QObject::tr("Master datasouce \"%1\" not found!").arg(m_desc->master());
@@ -484,6 +497,22 @@ IDataSource *ProxyHolder::dataSource(IDataSource::DatasourceMode mode)
return m_datasource.data();
}
+void ProxyHolder::invalidate(IDataSource::DatasourceMode mode)
+{
+ Q_UNUSED(mode)
+ if (m_model && m_model->isInvalid()){
+ m_invalid = true;
+ m_lastError = tr("Datasource has been invalidated");
+ } else {
+ filterModel();
+ }
+}
+
+void ProxyHolder::slotChildModelDestoroyed(){
+ m_datasource.clear();
+ m_model = 0;
+}
+
void ProxyDesc::addFieldsCorrelation(const FieldsCorrelation& fieldsCorrelation)
{
m_maps.append(new FieldMapDesc(fieldsCorrelation));
@@ -493,6 +522,15 @@ void MasterDetailProxyModel::setMaster(QString name){
m_masterName=name;
}
+bool MasterDetailProxyModel::isInvalid() const
+{
+ if (m_masterName.isEmpty() || m_childName.isEmpty()) return true;
+ IDataSource* masterData = dataManager()->dataSource(m_masterName);
+ IDataSource* childData = dataManager()->dataSource(m_childName);
+ if (!masterData || !childData) return true;
+ return masterData->isInvalid() || childData->isInvalid();
+}
+
bool MasterDetailProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
Q_UNUSED(source_parent)
@@ -529,7 +567,7 @@ QVariant MasterDetailProxyModel::sourceData(QString fieldName, int row) const
QVariant MasterDetailProxyModel::masterData(QString fieldName) const
{
- IDataSource* master = DataSourceManager::instance()->dataSource(m_masterName);
+ IDataSource* master = dataManager()->dataSource(m_masterName);
int columnIndex = master->columnIndexByName(fieldName);
if (columnIndex!=-1){
return master->data(fieldName);
diff --git a/src/lrdatadesignintf.h b/src/lrdatadesignintf.h
index 1aaaab1..cb22141 100644
--- a/src/lrdatadesignintf.h
+++ b/src/lrdatadesignintf.h
@@ -43,6 +43,8 @@
namespace LimeReport{
+class DataSourceManager;
+
class IDataSource {
public:
enum DatasourceMode{DESIGN_MODE,RENDER_MODE};
@@ -72,7 +74,7 @@ public:
virtual bool isOwned() const = 0;
virtual bool isEditable() const = 0;
virtual bool isRemovable() const = 0;
- virtual void invalidate() = 0;
+ virtual void invalidate(IDataSource::DatasourceMode mode) = 0;
virtual void update() = 0;
virtual ~IDataSourceHolder(){}
};
@@ -88,7 +90,7 @@ public:
QString lastError() const { return m_dataSource->lastError(); }
bool isEditable() const { return false; }
bool isRemovable() const { return false; }
- void invalidate(){}
+ void invalidate(IDataSource::DatasourceMode mode){Q_UNUSED(mode)}
void update(){}
signals:
void modelStateChanged();
@@ -165,7 +167,7 @@ private:
class QueryHolder:public IDataSourceHolder{
public:
- QueryHolder(QString queryText, QString connectionName);
+ QueryHolder(QString queryText, QString connectionName, DataSourceManager* dataManager);
~QueryHolder();
virtual bool runQuery(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE);
IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE);
@@ -179,8 +181,9 @@ public:
bool isRemovable() const { return true; }
QString lastError() const { return m_lastError; }
void setLastError(QString value){m_lastError=value; if (m_query) {delete m_query; m_query=0;}}
- void invalidate(){}
+ void invalidate(IDataSource::DatasourceMode mode);
void update();
+ DataSourceManager* dataManager() const {return m_dataManager;}
protected:
void setDatasource(IDataSource::Ptr value);
virtual void fillParams(QSqlQuery* query);
@@ -195,6 +198,7 @@ private:
QString m_lastError;
IDataSource::Ptr m_dataSource;
IDataSource::DatasourceMode m_mode;
+ DataSourceManager* m_dataManager;
};
class SubQueryDesc : public QueryDesc{
@@ -211,18 +215,18 @@ private:
class SubQueryHolder:public QueryHolder{
public:
- SubQueryHolder(QString queryText, QString connectionName, QString masterDatasource);
+ SubQueryHolder(QString queryText, QString connectionName, QString masterDatasource, DataSourceManager *dataManager);
QString masterDatasource(){return m_masterDatasource;}
void setMasterDatasource(const QString& value);
- void invalidate(){m_invalid = true;}
- bool isInvalid() const{ return QueryHolder::isInvalid() || m_invalid;}
+ //void invalidate(){m_invalid = true;}
+ bool isInvalid() const{ return QueryHolder::isInvalid(); /*|| m_invalid;*/}
protected:
void extractParams();
QString extractField(QString source);
QString replaceFields(QString query);
private:
QString m_masterDatasource;
- bool m_invalid;
+ //bool m_invalid;
};
struct FieldsCorrelation{
@@ -273,10 +277,12 @@ private:
class MasterDetailProxyModel : public QSortFilterProxyModel{
public:
- MasterDetailProxyModel():m_maps(0){}
+ MasterDetailProxyModel(DataSourceManager* dataManager):m_maps(0),m_dataManager(dataManager){}
void setMaster(QString name);
void setChildName(QString name){m_childName=name;}
void setFieldsMap(QList *fieldsMap){m_maps=fieldsMap;}
+ bool isInvalid() const;
+ DataSourceManager* dataManager() const {return m_dataManager;}
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
int fieldIndexByName(QString fieldName) const;
@@ -286,13 +292,13 @@ private:
QList* m_maps;
QString m_masterName;
QString m_childName;
-
+ DataSourceManager* m_dataManager;
};
class ProxyHolder: public QObject, public IDataSourceHolder{
Q_OBJECT
public:
- ProxyHolder(ProxyDesc *desc);
+ ProxyHolder(ProxyDesc *desc, DataSourceManager *dataManager);
QString masterDatasource();
void filterModel();
IDataSource* dataSource(IDataSource::DatasourceMode mode = IDataSource::RENDER_MODE);
@@ -301,10 +307,11 @@ public:
bool isEditable() const { return true; }
bool isRemovable() const { return true; }
QString lastError() const { return m_lastError; }
- void invalidate(){m_invalid = true; m_lastError = tr("Datasource has been invalidated");}
- void update(){};
+ void invalidate(IDataSource::DatasourceMode mode);
+ void update(){}
+ DataSourceManager* dataManager() const {return m_dataManger;}
private slots:
- void slotChildModelDestoroyed(){m_datasource.clear();}
+ void slotChildModelDestoroyed();
private:
IDataSource::Ptr m_datasource;
MasterDetailProxyModel *m_model;
@@ -312,6 +319,7 @@ private:
QString m_lastError;
IDataSource::DatasourceMode m_mode;
bool m_invalid;
+ DataSourceManager* m_dataManger;
};
class ModelToDataSource : public QObject, public IDataSource{
@@ -397,7 +405,7 @@ public:
bool isOwned() const {return m_owned;}
bool isEditable() const {return false;}
bool isRemovable() const {return false;}
- void invalidate(){}
+ void invalidate(IDataSource::DatasourceMode mode){Q_UNUSED(mode)}
~CallbackDatasourceHolder(){if (m_datasource) delete m_datasource;}
void update(){}
private:
diff --git a/src/lrdatasourcemanager.cpp b/src/lrdatasourcemanager.cpp
index 6275c07..4ac169b 100644
--- a/src/lrdatasourcemanager.cpp
+++ b/src/lrdatasourcemanager.cpp
@@ -210,21 +210,16 @@ void DataSourceModel::updateModel()
}
}
-DataSourceManager* DataSourceManager::m_instance=0;
-
DataSourceManager::DataSourceManager(QObject *parent) :
QObject(parent), m_lastError(""), m_designTime(true)
{
- m_instance=this;
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("COUNT"),new ConstructorGroupFunctionCreator);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("SUM"),new ConstructorGroupFunctionCreator);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("AVG"),new ConstructorGroupFunctionCreator);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("MIN"),new ConstructorGroupFunctionCreator);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("MAX"),new ConstructorGroupFunctionCreator);
-
setSystemVariable(QLatin1String("#PAGE"),1,FirstPass);
setSystemVariable(QLatin1String("#PAGE_COUNT"),0,SecondPass);
-
m_datasourcesModel.setDataSourceManager(this);
}
bool DataSourceManager::designTime() const
@@ -242,7 +237,6 @@ DataSourceManager::~DataSourceManager()
{
clear(All);
clearGroupFunction();
- m_instance=0;
}
void DataSourceManager::connectAllDatabases()
@@ -387,21 +381,6 @@ QString DataSourceManager::replaceFields(QString query, QMap &a
}
}
return query;
-
-// QRegExp rx(Const::FIELD_RX);
-// if (query.contains(rx)){
-// while ((rx.indexIn(query))!=-1){
-// QString field=rx.cap(0);
-// field.remove("$D{");
-// field.remove("}");
-// if (field.contains("."))
-// aliasesToParam.append(field);
-// else
-// aliasesToParam.append(masterDatasource+"."+field);
-// query.replace(rx.cap(0),":"+extractField(field));
-// }
-// }
-// return query;
}
void DataSourceManager::setReportVariable(const QString &name, const QVariant &value)
@@ -415,7 +394,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));
+ putHolder(name,new QueryHolder(sqlText, connectionName, this));
emit datasourcesChanged();
}
@@ -423,7 +402,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));
+ putHolder(name,new SubQueryHolder(sqlText, connectionName, masterDatasource, this));
emit datasourcesChanged();
}
@@ -437,7 +416,7 @@ void DataSourceManager::addProxy(const QString &name, QString master, QString de
proxyDesc->addFieldsCorrelation(correlation);
}
putProxyDesc(proxyDesc);
- putHolder(name,new ProxyHolder(proxyDesc));
+ putHolder(name,new ProxyHolder(proxyDesc, this));
emit datasourcesChanged();
}
@@ -602,28 +581,28 @@ void DataSourceManager::putHolder(QString name, IDataSourceHolder *dataSource)
name.toLower(),
dataSource
);
- } else throw ReportError(tr("data source with name \"%1\" already exists !!").arg(name));
+ } else throw ReportError(tr("datasource with name \"%1\" already exists !").arg(name));
}
void DataSourceManager::putQueryDesc(QueryDesc* queryDesc)
{
if (!containsDatasource(queryDesc->queryName())){
m_queries.append(queryDesc);
- } else throw ReportError(tr("datasource with name \"%1\"already exists !!").arg(queryDesc->queryName()));
+ } else throw ReportError(tr("datasource with name \"%1\" already exists !").arg(queryDesc->queryName()));
}
void DataSourceManager::putSubQueryDesc(SubQueryDesc *subQueryDesc)
{
if (!containsDatasource(subQueryDesc->queryName())){
m_subqueries.append(subQueryDesc);
- } else throw ReportError(tr("datasource with name \"%1\" already exists !!").arg(subQueryDesc->queryName()));
+ } else throw ReportError(tr("datasource with name \"%1\" already exists !").arg(subQueryDesc->queryName()));
}
void DataSourceManager::putProxyDesc(ProxyDesc *proxyDesc)
{
if (!containsDatasource(proxyDesc->name())){
m_proxies.append(proxyDesc);
- } else throw ReportError(tr("datasource with name \"%1\" already exists !!").arg(proxyDesc->name()));
+ } else throw ReportError(tr("datasource with name \"%1\" already exists !").arg(proxyDesc->name()));
}
bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
@@ -649,13 +628,20 @@ bool DataSourceManager::connectConnection(ConnectionDesc *connectionDesc)
QSqlDatabase::removeDatabase(connectionDesc->name());
setLastError(lastError);
return false;
- //throw ReportError(lastError);
} else {
foreach(QString datasourceName, dataSourceNames()){
if (isQuery(datasourceName) || isSubQuery(datasourceName)){
QueryHolder* qh = dynamic_cast(dataSourceHolder(datasourceName));
if (qh){
- qh->runQuery(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
+ qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
+ }
+ }
+ }
+ foreach(QString datasourceName, dataSourceNames()){
+ if (isProxy(datasourceName)){
+ ProxyHolder* ph = dynamic_cast(dataSourceHolder(datasourceName));
+ if (ph){
+ ph->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
}
}
}
@@ -699,19 +685,21 @@ bool DataSourceManager::connectConnection(const QString& connectionName)
void DataSourceManager::disconnectConnection(const QString& connectionName)
{
+ foreach(QString datasourceName, dataSourceNames()){
+ if (isQuery(datasourceName) || isSubQuery(datasourceName)){
+ QueryHolder* qh = dynamic_cast(dataSourceHolder(datasourceName));
+ if (qh && qh->connectionName().compare(connectionName,Qt::CaseInsensitive)==0){
+ qh->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
+ qh->setLastError(tr("invalid connection"));
+ }
+ }
+ }
{
QSqlDatabase db = QSqlDatabase::database(connectionName);
if (db.isOpen()) db.close();
}
if (QSqlDatabase::contains(connectionName)) QSqlDatabase::removeDatabase(connectionName);
- foreach(QString datasourceName, dataSourceNames()){
- if (isQuery(datasourceName) || isSubQuery(datasourceName)){
- QueryHolder* qh = dynamic_cast(dataSourceHolder(datasourceName));
- if (qh){
- qh->setLastError(tr("invalid connection"));
- }
- }
- }
+
}
IDataSource *DataSourceManager::dataSource(const QString &name)
@@ -881,19 +869,19 @@ void DataSourceManager::collectionLoadFinished(const QString &collectionName)
if (collectionName.compare("queries",Qt::CaseInsensitive)==0){
foreach(QueryDesc* query,m_queries){
- putHolder(query->queryName(),new QueryHolder(query->queryText(),query->connectionName()));
+ putHolder(query->queryName(),new QueryHolder(query->queryText(), query->connectionName(), this));
}
}
if (collectionName.compare("subqueries",Qt::CaseInsensitive)==0){
foreach(SubQueryDesc* query,m_subqueries){
- putHolder(query->queryName(),new SubQueryHolder(query->queryText(),query->connectionName(),query->master()));
+ putHolder(query->queryName(),new SubQueryHolder(query->queryText(), query->connectionName(), query->master(), this));
}
}
if(collectionName.compare("subproxies",Qt::CaseInsensitive)==0){
foreach(ProxyDesc* proxy,m_proxies){
- putHolder(proxy->name(),new ProxyHolder(proxy));
+ putHolder(proxy->name(),new ProxyHolder(proxy, this));
}
}
@@ -949,12 +937,12 @@ void DataSourceManager::invalidateLinkedDatasources(QString datasourceName)
foreach(QString name, dataSourceNames()){
if (isSubQuery(name)){
if (subQueryByName(name)->master() == datasourceName)
- dataSourceHolder(name)->invalidate();
+ dataSourceHolder(name)->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
}
if (isProxy(name)){
ProxyDesc* proxy = proxyByName(name);
if ((proxy->master() == datasourceName) || (proxy->child() == datasourceName))
- dataSourceHolder(name)->invalidate();
+ dataSourceHolder(name)->invalidate(designTime()?IDataSource::DESIGN_MODE:IDataSource::RENDER_MODE);
}
}
diff --git a/src/lrdatasourcemanager.h b/src/lrdatasourcemanager.h
index 4a9179d..cb9134f 100644
--- a/src/lrdatasourcemanager.h
+++ b/src/lrdatasourcemanager.h
@@ -101,8 +101,6 @@ class DataSourceManager : public QObject, public ICollectionContainer, public IV
Q_PROPERTY(ACollectionProperty variables READ fakeCollectionReader)
friend class ReportEnginePrivate;
friend class ReportRender;
-public:
- static DataSourceManager* instance(){return m_instance;}
public:
typedef QHash DataSourcesMap;
enum ClearMethod {All,Owned};
@@ -211,7 +209,6 @@ private:
explicit DataSourceManager(QObject *parent = 0);
Q_DISABLE_COPY(DataSourceManager)
private:
- static DataSourceManager* m_instance;
QList m_connections;
QList m_queries;
QList m_subqueries;
diff --git a/src/lritemdesignintf.cpp b/src/lritemdesignintf.cpp
index 067b998..ef8e869 100644
--- a/src/lritemdesignintf.cpp
+++ b/src/lritemdesignintf.cpp
@@ -113,23 +113,22 @@ void ItemDesignIntf::initFlags()
}
}
-QString ContentItemDesignIntf::expandDataFields(QString context, ExpandType expandType)
-{
- DataSourceManager* dm = DataSourceManager::instance();
+QString ContentItemDesignIntf::expandDataFields(QString context, ExpandType expandType, DataSourceManager* dataManager)
+{
QRegExp rx(Const::FIELD_RX);
if (context.contains(rx)){
while ((rx.indexIn(context))!=-1){
QString field=rx.cap(1);
- if (dm->containsField(field)) {
+ if (dataManager->containsField(field)) {
QString fieldValue;
if (expandType == EscapeSymbols) {
- if (dm->fieldData(field).isNull()) {
+ if (dataManager->fieldData(field).isNull()) {
fieldValue="\"\"";
} else {
- fieldValue = escapeSimbols(dm->fieldData(field).toString());
- switch (dm->fieldData(field).type()) {
+ fieldValue = escapeSimbols(dataManager->fieldData(field).toString());
+ switch (dataManager->fieldData(field).type()) {
case QVariant::Char:
case QVariant::String:
case QVariant::StringList:
@@ -142,18 +141,18 @@ QString ContentItemDesignIntf::expandDataFields(QString context, ExpandType expa
}
}
} else {
- fieldValue = dm->fieldData(field).toString();
+ fieldValue = dataManager->fieldData(field).toString();
}
context.replace(rx.cap(0),fieldValue);
} else {
QString error;
- if (dm->lastError().isEmpty()){
+ if (dataManager->lastError().isEmpty()){
error = QString("Field %1 not found in %2 !!! ").arg(field).arg(this->objectName());
- dm->putError(error);
+ dataManager->putError(error);
} else {
- error = dm->lastError();
+ error = dataManager->lastError();
}
context.replace(rx.cap(0),error);
}
@@ -163,21 +162,20 @@ QString ContentItemDesignIntf::expandDataFields(QString context, ExpandType expa
return context;
}
-QString ContentItemDesignIntf::expandUserVariables(QString context, RenderPass pass, ExpandType expandType)
+QString ContentItemDesignIntf::expandUserVariables(QString context, RenderPass pass, ExpandType expandType, DataSourceManager* dataManager)
{
- DataSourceManager* dm=DataSourceManager::instance();
QRegExp rx(Const::VARIABLE_RX);
if (context.contains(rx)){
int pos = 0;
while ((pos = rx.indexIn(context,pos))!=-1){
QString variable=rx.cap(1);
pos += rx.matchedLength();
- if (dm->containsVariable(variable) ){
- if (pass==dm->variablePass(variable)){
+ if (dataManager->containsVariable(variable) ){
+ if (pass==dataManager->variablePass(variable)){
if (expandType==EscapeSymbols){
- context.replace(rx.cap(0),escapeSimbols(dm->variable(variable).toString()));
+ context.replace(rx.cap(0),escapeSimbols(dataManager->variable(variable).toString()));
} else {
- context.replace(rx.cap(0),dm->variable(variable).toString());
+ context.replace(rx.cap(0),dataManager->variable(variable).toString());
}
pos=0;
}
@@ -189,11 +187,12 @@ QString ContentItemDesignIntf::expandUserVariables(QString context, RenderPass p
return context;
}
-QString ContentItemDesignIntf::expandScripts(QString context)
+QString ContentItemDesignIntf::expandScripts(QString context, DataSourceManager* dataManager)
{
QRegExp rx(Const::SCRIPT_RX);
if (context.contains(rx)){
+ ScriptEngineManager::instance().setDataManager(dataManager);
QScriptEngine* se = ScriptEngineManager::instance().scriptEngine();
QScriptValue svThis = se->globalObject().property("THIS");
@@ -207,8 +206,8 @@ QString ContentItemDesignIntf::expandScripts(QString context)
ScriptExtractor scriptExtractor(context);
if (scriptExtractor.parse()){
for(int i=0; ievaluate(scriptBody);
if (!se->hasUncaughtException()) {
context.replace(scriptExtractor.scriptAt(i),value.toString());
diff --git a/src/lritemdesignintf.h b/src/lritemdesignintf.h
index ca2b926..1d185c5 100644
--- a/src/lritemdesignintf.h
+++ b/src/lritemdesignintf.h
@@ -77,9 +77,9 @@ public:
enum ExpandType {EscapeSymbols, NoEscapeSymbols};
protected:
QString escapeSimbols(const QString& value);
- virtual QString expandUserVariables(QString context, RenderPass pass, ExpandType expandType);
- virtual QString expandDataFields(QString context, ExpandType expandType);
- virtual QString expandScripts(QString context);
+ virtual QString expandUserVariables(QString context, RenderPass pass, ExpandType expandType, DataSourceManager *dataManager);
+ virtual QString expandDataFields(QString context, ExpandType expandType, DataSourceManager *dataManager);
+ virtual QString expandScripts(QString context, DataSourceManager *dataManager);
};
diff --git a/src/lrpagedesignintf.cpp b/src/lrpagedesignintf.cpp
index 7651504..b276098 100644
--- a/src/lrpagedesignintf.cpp
+++ b/src/lrpagedesignintf.cpp
@@ -899,6 +899,13 @@ void PageDesignIntf::emitItemRemoved(BaseDesignIntf *item)
emit itemRemoved(this,item);
}
}
+
+DataSourceManager *PageDesignIntf::datasourceManager()
+{
+ if (m_reportEditor) return m_reportEditor->dataManager();
+ return 0;
+}
+
void PageDesignIntf::registerBand(BandDesignIntf *band)
{
if (pageItem()&&!pageItem()->isBandRegistred(band)) {
@@ -912,14 +919,22 @@ void PageDesignIntf::slotUpdateItemSize()
foreach(QGraphicsItem * item, items()) {
BandDesignIntf *reportBand = dynamic_cast(item);
- if (reportBand) reportBand->updateItemSize();
+ if (reportBand) reportBand->updateItemSize(0);
}
}
void PageDesignIntf::saveChangeProppertyCommand(const QString &objectName, const QString &propertyName, const QVariant &oldPropertyValue, const QVariant &newPropertyValue)
{
if (!m_executingCommand) {
- CommandIf::Ptr command = PropertyChangedCommand::create(this, objectName, propertyName, oldPropertyValue, newPropertyValue);
+ CommandIf::Ptr command;
+ if (propertyName.compare("ItemAlign",Qt::CaseInsensitive)==0){
+ command = PropertyItemAlignChangedCommand::create(this, objectName,
+ BaseDesignIntf::ItemAlign(oldPropertyValue.toInt()),
+ BaseDesignIntf::ItemAlign(newPropertyValue.toInt())
+ );
+ } else {
+ command = PropertyChangedCommand::create(this, objectName, propertyName, oldPropertyValue, newPropertyValue);
+ }
saveCommand(command, false);
}
}
@@ -1821,5 +1836,50 @@ void PropertyObjectNameChangedCommand::undoIt()
}
+CommandIf::Ptr PropertyItemAlignChangedCommand::create(PageDesignIntf *page, const QString &objectName,
+ BaseDesignIntf::ItemAlign oldValue, BaseDesignIntf::ItemAlign newValue)
+{
+ PropertyItemAlignChangedCommand *command = new PropertyItemAlignChangedCommand();
+ command->setPage(page);
+ command->m_objectName = objectName;
+ command->m_propertyName = "itemAlign";
+ command->m_oldValue = oldValue;
+ command->m_newValue = newValue;
+
+ BaseDesignIntf *reportItem = page->reportItemByName(objectName);
+ if (oldValue == BaseDesignIntf::DesignedItemAlign){
+ command->m_savedPos = reportItem->pos();
+ }
+
+ return CommandIf::Ptr(command);
+}
+
+bool PropertyItemAlignChangedCommand::doIt()
+{
+ BaseDesignIntf *reportItem = page()->reportItemByName(m_objectName);
+
+ //if (m_oldValue == BaseDesignIntf::DesignedItemAlign){
+ // m_savedPos = reportItem->pos();
+ //}
+
+ if (reportItem && (reportItem->property(m_propertyName.toLatin1()) != m_newValue)) {
+ reportItem->setProperty(m_propertyName.toLatin1(), m_newValue);
+ }
+
+ return true;
+}
+
+void PropertyItemAlignChangedCommand::undoIt()
+{
+ BaseDesignIntf *reportItem = page()->reportItemByName(m_objectName);
+
+ if (reportItem && (reportItem->property(m_propertyName.toLatin1()) != m_oldValue)) {
+ reportItem->setProperty(m_propertyName.toLatin1(), m_oldValue);
+ }
+ if (m_oldValue == BaseDesignIntf::DesignedItemAlign){
+ reportItem->setPos(m_savedPos);
+ }
+}
+
}
diff --git a/src/lrpagedesignintf.h b/src/lrpagedesignintf.h
index 71ad8ac..2ee9f6e 100644
--- a/src/lrpagedesignintf.h
+++ b/src/lrpagedesignintf.h
@@ -129,7 +129,7 @@ namespace LimeReport {
void emitRegisterdItem(BaseDesignIntf *item);
void emitItemRemoved(BaseDesignIntf* item);
-
+ DataSourceManager* datasourceManager();
protected:
virtual void keyPressEvent(QKeyEvent *event);
@@ -396,6 +396,19 @@ namespace LimeReport {
QString m_newName;
};
+ class PropertyItemAlignChangedCommand : public AbstractPageCommand{
+ public:
+ static CommandIf::Ptr create(PageDesignIntf* page, const QString& objectName, BaseDesignIntf::ItemAlign oldValue, BaseDesignIntf::ItemAlign newValue);
+ bool doIt();
+ void undoIt();
+ private:
+ QString m_objectName;
+ QString m_propertyName;
+ BaseDesignIntf::ItemAlign m_oldValue;
+ BaseDesignIntf::ItemAlign m_newValue;
+ QPointF m_savedPos;
+ };
+
class CommandGroup : public AbstractPageCommand{
public:
static CommandIf::Ptr create();
diff --git a/src/lrpageitemdesignintf.cpp b/src/lrpageitemdesignintf.cpp
index e09d86f..ec7470c 100644
--- a/src/lrpageitemdesignintf.cpp
+++ b/src/lrpageitemdesignintf.cpp
@@ -285,7 +285,7 @@ void PageItemDesignIntf::registerBand(BandDesignIntf *band)
band->setParent(this);
band->setParentItem(this);
- band->setWidth(pageRect().width());
+ 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)));
}
@@ -473,6 +473,11 @@ void PageItemDesignIntf::updateMarginRect()
band->setWidth(pageRect().width());
relocateBands();
}
+ foreach (BaseDesignIntf* item, childBaseItems()) {
+ if (item->itemAlign()!=DesignedItemAlign){
+ item->updateItemAlign();
+ }
+ }
update();
}
diff --git a/src/lrreportdesignwidget.cpp b/src/lrreportdesignwidget.cpp
index 2c612d1..96b47cc 100644
--- a/src/lrreportdesignwidget.cpp
+++ b/src/lrreportdesignwidget.cpp
@@ -84,7 +84,7 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) {
QWheelEvent* wheel_event = static_cast(event);
if (QApplication::keyboardModifiers() == m_modifiers) {
if (wheel_event->orientation() == Qt::Vertical) {
- double angle = wheel_event->angleDelta().y();
+ double angle = wheel_event->delta();
double factor = qPow(m_zoomFactorBase, angle);
gentleZoom(factor);
return true;
diff --git a/src/lrreportdesignwindow.cpp b/src/lrreportdesignwindow.cpp
index b5cca65..46c6fdd 100644
--- a/src/lrreportdesignwindow.cpp
+++ b/src/lrreportdesignwindow.cpp
@@ -190,13 +190,13 @@ void ReportDesignWindow::createActions()
m_hideLeftPanel = new QAction(tr("Hide left panel"),this);
m_hideLeftPanel->setCheckable(true);
- m_hideLeftPanel->setChecked(true);
+// m_hideLeftPanel->setChecked(true);
m_hideLeftPanel->setIcon(QIcon(":/report/images/hideLeftPanel"));
connect(m_hideLeftPanel,SIGNAL(toggled(bool)), this, SLOT(slotHideLeftPanel(bool)));
- m_hideRightPanel = new QAction(tr("Hide left panel"),this);
+ m_hideRightPanel = new QAction(tr("Hide right panel"),this);
m_hideRightPanel->setCheckable(true);
- m_hideRightPanel->setChecked(true);
+// m_hideRightPanel->setChecked(true);
m_hideRightPanel->setIcon(QIcon(":/report/images/hideRightPanel"));
connect(m_hideRightPanel,SIGNAL(toggled(bool)), this, SLOT(slotHideRightPanel(bool)));
}
@@ -279,7 +279,7 @@ void ReportDesignWindow::createItemsActions()
{
foreach(ItemAttribs items,DesignElementsFactory::instance().attribsMap().values()){
if (items.m_tag.compare("Item",Qt::CaseInsensitive)==0){
- QAction* tmpAction = new QAction(items.m_alias,this);
+ QAction* tmpAction = new QAction(QObject::tr(items.m_alias.toLatin1()),this);
tmpAction->setWhatsThis(DesignElementsFactory::instance().attribsMap().key(items));
tmpAction->setIcon(QIcon(":/items/"+tmpAction->whatsThis()));
connect(tmpAction,SIGNAL(triggered()),this,SLOT(slotItemActionCliked()));
@@ -900,16 +900,7 @@ void ReportDesignWindow::slotShowAbout()
about->exec();
}
-void ReportDesignWindow::hideDockWidgets(Qt::DockWidgetArea area, bool value){
- QList dockWidgets = findChildren();
- foreach (QDockWidget* dw, dockWidgets) {
- if (dockWidgetArea(dw) == area)
- value ? dw->show(): dw->hide();
- }
-}
-
-bool ReportDesignWindow::isDockAreaVisible(Qt::DockWidgetArea area)
-{
+bool ReportDesignWindow::isDockAreaVisible(Qt::DockWidgetArea area){
QList dockWidgets = findChildren();
foreach (QDockWidget* dw, dockWidgets){
if ((dockWidgetArea(dw) == area) && !dw->isHidden())
@@ -918,6 +909,14 @@ bool ReportDesignWindow::isDockAreaVisible(Qt::DockWidgetArea area)
return false;
}
+void ReportDesignWindow::hideDockWidgets(Qt::DockWidgetArea area, bool value){
+ QList dockWidgets = findChildren();
+ foreach (QDockWidget* dw, dockWidgets) {
+ if (dockWidgetArea(dw) == area)
+ value ? dw->show(): dw->hide();
+ }
+}
+
void ReportDesignWindow::slotHideLeftPanel(bool value)
{
hideDockWidgets(Qt::LeftDockWidgetArea,value);
diff --git a/src/lrreportengine_p.h b/src/lrreportengine_p.h
index 9273fa8..ade104a 100644
--- a/src/lrreportengine_p.h
+++ b/src/lrreportengine_p.h
@@ -66,7 +66,11 @@ public:
int pageCount() {return m_pages.count();}
DataSourceManager* dataManager(){return m_datasources;}
IDataSourceManager* dataManagerIntf(){return m_datasources;}
- IScriptEngineManager* scriptManagerIntf(){return &ScriptEngineManager::instance();}
+
+ IScriptEngineManager* scriptManagerIntf(){
+ ScriptEngineManager::instance().setDataManager(dataManager());
+ return &ScriptEngineManager::instance();
+ }
void clearReport();
bool printReport(QPrinter *printer=0);
@@ -121,6 +125,7 @@ private:
QScopedPointer m_printer;
bool m_printerSelected;
bool m_showProgressDialog;
+
};
}
diff --git a/src/lrreportrender.cpp b/src/lrreportrender.cpp
index 41121a3..932347e 100644
--- a/src/lrreportrender.cpp
+++ b/src/lrreportrender.cpp
@@ -31,6 +31,7 @@
#include
#include
+#include "lrglobal.h"
#include "lrreportrender.h"
#include "lrpagedesignintf.h"
#include "lrbanddesignintf.h"
@@ -42,9 +43,18 @@
namespace LimeReport{
+void ReportRender::initColumns(){
+ m_maxHeightByColumn.clear();
+ m_currentStartDataPos.clear();
+ m_maxHeightByColumn.append(0);
+ m_currentStartDataPos.append(0);
+}
+
ReportRender::ReportRender(QObject *parent)
- :QObject(parent), m_renderPageItem(0), m_pageCount(0)
-{}
+ :QObject(parent), m_renderPageItem(0), m_pageCount(0), m_currentColumn(0)
+{
+ initColumns();
+}
void ReportRender::setDatasources(DataSourceManager *value)
{
@@ -74,9 +84,10 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
initGroupFunctions();
clearPageMap();
+ resetPageNumber();
startNewPage();
- renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader),StartNewPage);
+ renderBand(m_patternPageItem->bandByType(BandDesignIntf::ReportHeader),StartNewPageAsNeeded);
BandDesignIntf* lastRenderedBand = 0;
for (int i=0;idataBandCount() && !m_renderCanceled;i++){
@@ -87,7 +98,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage)
}
if (reportFooter)
- renderBand(reportFooter,StartNewPage);
+ renderBand(reportFooter,StartNewPageAsNeeded);
if (lastRenderedBand && lastRenderedBand->keepFooterTogether())
closeFooterGroup(lastRenderedBand);
@@ -144,7 +155,7 @@ void ReportRender::extractGroupsFunction(BandDesignIntf *band)
foreach(BaseDesignIntf* item,band->childBaseItems()){
ContentItemDesignIntf* contentItem = dynamic_cast(item);
if (contentItem&&(contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}")))){
- foreach(QString functionName, DataSourceManager::instance()->groupFunctionNames()){
+ foreach(QString functionName, m_datasources->groupFunctionNames()){
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
QRegExp rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName));
if (rx.indexIn(contentItem->content())>=0){
@@ -173,7 +184,7 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band)
ContentItemDesignIntf* contentItem = dynamic_cast(item);
if (contentItem){
QString content = contentItem->content();
- foreach(QString functionName, DataSourceManager::instance()->groupFunctionNames()){
+ foreach(QString functionName, m_datasources->groupFunctionNames()){
QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName));
if (rx.indexIn(content)>=0){
content.replace(rx,QString("%1(%2,%3)").arg(functionName).arg('"'+rx.cap(4)+'"').arg('"'+band->objectName()+'"'));
@@ -188,41 +199,48 @@ void ReportRender::renderBand(BandDesignIntf *patternBand, ReportRender::DataRen
{
QApplication::processEvents();
if (patternBand){
+
+ if (mode == ForcedStartPage){
+ savePage();
+ startNewPage();
+ }
+
BandDesignIntf* bandClone=renderData(patternBand);
patternBand->emitBandRendered(bandClone);
if ( isLast && bandClone->keepFooterTogether() && bandClone->sliceLastRow() ){
- if (m_currentMaxHeight < (bandClone->height()+m_reportFooterHeight))
- m_currentMaxHeight -= ((m_currentMaxHeight-bandClone->height())+(bandClone->height()*calcSlicePercent(bandClone->height())));
+ if (m_maxHeightByColumn[m_currentColumn] < (bandClone->height()+m_reportFooterHeight))
+ m_maxHeightByColumn[m_currentColumn] -= ((m_maxHeightByColumn[m_currentColumn]-bandClone->height())+(bandClone->height()*calcSlicePercent(bandClone->height())));
}
if (!bandClone->isEmpty() || patternBand->printIfEmpty()){
if (!registerBand(bandClone)){
- if (bandClone->canBeSplitted(m_currentMaxHeight)){
+ if (bandClone->canBeSplitted(m_maxHeightByColumn[m_currentColumn])){
bandClone = sliceBand(bandClone,patternBand,isLast);
} else {
-
- qreal percent = (bandClone->height()-m_currentMaxHeight)/(bandClone->height()/100);
+ qreal percent = (bandClone->height()-m_maxHeightByColumn[m_currentColumn])/(bandClone->height()/100);
if (bandClone->maxScalePercent()>=percent){
if (percentmaxScalePercent()){
percent += 2;
bandClone->setScale((100-percent)/100);
- bandClone->setHeight(m_currentMaxHeight);
+ bandClone->setHeight(m_maxHeightByColumn[m_currentColumn]);
registerBand(bandClone);
}
} else {
- if (mode==StartNewPage){
- savePage();
- startNewPage();
+ if (mode==StartNewPageAsNeeded){
+ if (bandClone->columnsCount()>1 && bandClone->columnsFillDirection()==BandDesignIntf::Vertical){
+ startNewColumn();
+ } else {
+ savePage();
+ startNewPage();
+ }
if (!registerBand(bandClone)) {
- bandClone->setHeight(m_currentMaxHeight);
+ bandClone->setHeight(m_maxHeightByColumn[m_currentColumn]);
registerBand(bandClone);
};
- }
-
- else {
- bandClone->setHeight(m_currentMaxHeight);
+ } else {
+ bandClone->setHeight(m_maxHeightByColumn[m_currentColumn]);
registerBand(bandClone);
}
}
@@ -247,7 +265,7 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
renderBand(dataBand->bandHeader());
renderChildHeader(dataBand,PrintNotAlwaysPrintable);
- renderGroupHeader(dataBand,bandDatasource);
+ renderGroupHeader(dataBand, bandDatasource, true);
while(!bandDatasource->eof() && !m_renderCanceled){
if (dataBand->tryToKeepTogether()) openDataGroup(dataBand);
@@ -258,7 +276,7 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
datasources()->updateChildrenData(dataBand->datasourceName());
m_lastDataBand = dataBand;
- renderBand(dataBand,StartNewPage,!bandDatasource->hasNext());
+ renderBand(dataBand,StartNewPageAsNeeded,!bandDatasource->hasNext());
renderChildBands(dataBand);
bandDatasource->next();
@@ -270,15 +288,15 @@ void ReportRender::renderDataBand(BandDesignIntf *dataBand)
datasources()->setReportVariable(groupLineVar,datasources()->variable(groupLineVar).toInt()+1);
}
- renderGroupHeader(dataBand,bandDatasource);
+ renderGroupHeader(dataBand, bandDatasource, false);
if (dataBand->tryToKeepTogether()) closeDataGroup(dataBand);
}
- renderBand(dataBand->bandFooter(),StartNewPage);
+ renderBand(dataBand->bandFooter(),StartNewPageAsNeeded);
renderGroupFooter(dataBand);
//renderChildFooter(dataBand,PrintNotAlwaysPrintable);
datasources()->deleteVariable(varName);
} else if (bandDatasource==0) {
- renderBand(dataBand,StartNewPage);
+ renderBand(dataBand,StartNewPageAsNeeded);
}
}
@@ -294,10 +312,10 @@ void ReportRender::renderPageFooter(PageItemDesignIntf *patternPage)
if (band){
BandDesignIntf* bandClone = dynamic_cast(band->cloneItem(PreviewMode, m_renderPageItem,m_renderPageItem));
replaceGroupsFunction(bandClone);
- bandClone->updateItemSize();
+ bandClone->updateItemSize(m_datasources);
bandClone->setItemPos(m_patternPageItem->pageRect().x(),m_patternPageItem->pageRect().bottom()-bandClone->height());
bandClone->setHeight(m_pageFooterHeight);
- m_currentMaxHeight+=m_pageFooterHeight;
+ m_maxHeightByColumn[0]+=m_pageFooterHeight;
registerBand(bandClone);
datasources()->clearGroupFunctionValues(band->objectName());
}
@@ -311,7 +329,7 @@ void ReportRender::renderPageItems(PageItemDesignIntf* patternPage)
BaseDesignIntf* cloneItem = item->cloneItem(m_renderPageItem->itemMode(),
m_renderPageItem,
m_renderPageItem);
- cloneItem->updateItemSize();
+ cloneItem->updateItemSize(m_datasources);
}
}
}
@@ -332,7 +350,7 @@ void ReportRender::renderChildHeader(BandDesignIntf *parent, BandPrintMode print
if (band->metaObject()->indexOfProperty("printAlways")>0){
printAlways=band->property("printAlways").toBool();
}
- if (printAlways == (printMode==PrintAlwaysPrintable) ) renderBand(band,StartNewPage);
+ if (printAlways == (printMode==PrintAlwaysPrintable) ) renderBand(band,StartNewPageAsNeeded);
}
}
@@ -343,7 +361,7 @@ void ReportRender::renderChildFooter(BandDesignIntf *parent, BandPrintMode print
if (band->metaObject()->indexOfProperty("printAlways")>0){
printAlways=band->property("printAlways").toBool();
}
- if (printAlways == (printMode==PrintAlwaysPrintable)) renderBand(band,StartNewPage);
+ if (printAlways == (printMode==PrintAlwaysPrintable)) renderBand(band,StartNewPageAsNeeded);
}
}
@@ -359,11 +377,11 @@ void ReportRender::renderChildBands(BandDesignIntf *parentBand)
}
}
-void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* dataSource)
+void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* dataSource, bool firstTime)
{
foreach(BandDesignIntf* band,parentBand->childrenByType(BandDesignIntf::GroupHeader)){
IGroupBand* gb = dynamic_cast(band);
- if (gb&&gb->isNeedToClose()){
+ if (gb&&gb->isNeedToClose(m_datasources)){
if (band->childBands().count()>0){
dataSource->prior();
foreach (BandDesignIntf* subBand, parentBand->childrenByType(BandDesignIntf::GroupHeader)) {
@@ -374,15 +392,21 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
closeDataGroup(subBand);
}
}
- renderBand(band->childBands().at(0),StartNewPage);
+
+ renderBand(band->childBands().at(0),StartNewPageAsNeeded);
dataSource->next();
}
closeDataGroup(band);
}
if (!gb->isStarted()){
- gb->startGroup();
+ gb->startGroup(m_datasources);
openDataGroup(band);
- renderBand(band,StartNewPage);
+ if (!firstTime && gb->startNewPage()){
+ if (gb->resetPageNumber()) resetPageNumber();
+ renderBand(band,ForcedStartPage);
+ } else {
+ renderBand(band,StartNewPageAsNeeded);
+ }
}
}
}
@@ -393,7 +417,7 @@ void ReportRender::renderGroupFooter(BandDesignIntf *parentBand)
IGroupBand* gb = dynamic_cast(band);
if (gb->isStarted()){
if (band->childBands().count()>0){
- renderBand(band->childBands().at(0),StartNewPage);
+ renderBand(band->childBands().at(0),StartNewPageAsNeeded);
}
closeDataGroup(band);
}
@@ -481,14 +505,58 @@ void ReportRender::closeFooterGroup(BandDesignIntf *band){
closeGroup(band);
}
+qreal maxVectorValue(QVector vector){
+ qreal curValue = 0;
+ foreach (qreal value, vector) {
+ if (curValue vector){
+ qreal curValue = vector[0];
+ foreach (qreal value, vector) {
+ if (curValue>value) curValue=value;
+ }
+ return curValue;
+}
+
bool ReportRender::registerBand(BandDesignIntf *band, bool registerInChildren)
{
- if (band->height()<=m_currentMaxHeight){
- m_currentMaxHeight-=band->height();
+ if (band->columnsCount()==1 && m_maxHeightByColumn.size()>1){
+ m_currentColumn = 0;
+ qreal minValue = minVectorValue(m_maxHeightByColumn);
+ m_maxHeightByColumn.clear();
+ m_maxHeightByColumn.append(minValue);
+ qreal maxValue = maxVectorValue(m_currentStartDataPos);
+ m_currentStartDataPos.clear();
+ m_currentStartDataPos.append(maxValue);
+ }
+
+ if (band->columnsCount()>1){
+ if (m_maxHeightByColumn.size()!=band->columnsCount()){
+ for(int i=1;icolumnsCount();++i){
+ m_maxHeightByColumn.append(m_maxHeightByColumn[0]);
+ m_currentStartDataPos.append(m_currentStartDataPos[0]);
+ }
+ m_currentColumn = 0;
+ } else {
+ if (band->columnsFillDirection()==BandDesignIntf::Horizontal){
+ if (m_currentColumncolumnsCount()-1)
+ m_currentColumn = m_currentColumn+1;
+ else
+ m_currentColumn = 0;
+ }
+ }
+ }
+
+ if (band->height()<=m_maxHeightByColumn[m_currentColumn]){
+ m_maxHeightByColumn[m_currentColumn]-=band->height();
if (band->bandType()!=BandDesignIntf::PageFooter){
- band->setPos(m_renderPageItem->pageRect().x(),m_currentStartDataPos);
- m_currentStartDataPos+=band->height();
+ 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);
}
m_renderPageItem->registerBand(band);
@@ -514,17 +582,17 @@ qreal ReportRender::calcSlicePercent(qreal height){
BandDesignIntf* ReportRender::sliceBand(BandDesignIntf *band, BandDesignIntf* patternBand, bool isLast)
{
- while (band->height()>m_currentMaxHeight) {
- band = saveUppperPartReturnBottom(band,m_currentMaxHeight,patternBand);
+ while (band->height()>m_maxHeightByColumn[m_currentColumn]) {
+ band = saveUppperPartReturnBottom(band,m_maxHeightByColumn[m_currentColumn],patternBand);
if (!band->isEmpty()) {
band->setHeight(0);
- band->updateItemSize();
+ band->updateItemSize(m_datasources);
DataBandDesignIntf* data = dynamic_cast(band);
if (isLast && data && data->keepFooterTogether() &&
- band->height()sliceLastRow()
+ band->height()sliceLastRow()
){
- if (band->height()>(m_currentMaxHeight-m_reportFooterHeight)){
- m_currentMaxHeight -= ((m_currentMaxHeight-band->height())+(band->height()*calcSlicePercent(band->height())));
+ if (band->height()>(m_maxHeightByColumn[m_currentColumn]-m_reportFooterHeight)){
+ m_maxHeightByColumn[m_currentColumn] -= ((m_maxHeightByColumn[m_currentColumn]-band->height())+(band->height()*calcSlicePercent(band->height())));
}
}
if (registerBand(band)) break;
@@ -543,9 +611,11 @@ BandDesignIntf* ReportRender::sliceBand(BandDesignIntf *band, BandDesignIntf* pa
void ReportRender::secondRenderPass()
{
- foreach(PageItemDesignIntf::Ptr page, m_renderedPages){
+ for(int i=0; isetReportVariable("#PAGE_COUNT",findLastPageNumber(i));
foreach(BandDesignIntf* band, page->childBands()){
- band->updateItemSize(SecondPass);
+ band->updateItemSize(m_datasources, SecondPass);
}
}
}
@@ -561,11 +631,16 @@ BandDesignIntf *ReportRender::saveUppperPartReturnBottom(BandDesignIntf *band, i
closeFooterGroup(patternBand);
}
if (!upperBandPart->isEmpty()){
- upperBandPart->updateItemSize(FirstPass,height);
+ upperBandPart->updateItemSize(m_datasources, FirstPass, height);
registerBand(upperBandPart);
} else delete upperBandPart;
- savePage();
- startNewPage();
+
+ if (band->columnsCount()>1 && band->columnsFillDirection()==BandDesignIntf::Vertical){
+ startNewColumn();
+ } else {
+ savePage();
+ startNewPage();
+ }
// if (!bottomBandPart->isEmpty() && patternBand->keepFooterTogether())
// openFooterGroup(patternBand);
delete band;
@@ -578,33 +653,66 @@ BandDesignIntf *ReportRender::renderData(BandDesignIntf *patternBand)
if (patternBand->isFooter()){
replaceGroupsFunction(bandClone);
}
- bandClone->updateItemSize();
+ bandClone->updateItemSize(m_datasources);
return bandClone;
}
+void ReportRender::startNewColumn(){
+ if (m_currentColumn < m_maxHeightByColumn.size()-1){
+ m_currentColumn++;
+ } else {
+ savePage();
+ startNewPage();
+ }
+}
+
void ReportRender::startNewPage()
{
m_renderPageItem=0;
+ m_currentColumn=0;
+ initColumns();
initRenderPage();
m_renderPageItem->setObjectName(QLatin1String("ReportPage")+QString::number(m_pageCount));
- m_currentMaxHeight=m_renderPageItem->pageRect().height();
+ m_maxHeightByColumn[m_currentColumn]=m_renderPageItem->pageRect().height();
- m_currentStartDataPos=m_patternPageItem->topMargin()*Const::mmFACTOR;
+ m_currentStartDataPos[m_currentColumn]=m_patternPageItem->topMargin()*Const::mmFACTOR;
m_currentIndex=0;
renderPageHeader(m_patternPageItem);
m_pageFooterHeight = calcPageFooterHeight(m_patternPageItem);
- m_currentMaxHeight -= m_pageFooterHeight;
+ m_maxHeightByColumn[m_currentColumn] -= m_pageFooterHeight;
m_currentIndex=10;
- m_dataAreaSize = m_currentMaxHeight;
+ m_dataAreaSize = m_maxHeightByColumn[m_currentColumn];
m_renderedDataBandCount = 0;
pasteGroups();
renderPageItems(m_patternPageItem);
}
+void ReportRender::resetPageNumber()
+{
+ PagesRange range;
+ if (!m_ranges.isEmpty()){
+ m_ranges.last().lastPage = m_pageCount;
+ range.firstPage = m_pageCount+1;
+ } else {
+ range.firstPage = m_pageCount;
+ }
+ range.lastPage = 0;
+ m_ranges.append(range);
+}
+
+int ReportRender::findLastPageNumber(int currentPage)
+{
+ foreach (PagesRange range, m_ranges) {
+ if ( range.firstPage<= (currentPage+1) && range.lastPage>= (currentPage+1) )
+ return range.lastPage-(range.firstPage-1);
+ }
+ return 0;
+}
+
void ReportRender::cutGroups()
{
m_popupedExpression.clear();
@@ -673,9 +781,16 @@ void ReportRender::savePage()
checkFooterGroup(m_lastDataBand);
cutGroups();
renderPageFooter(m_patternPageItem);
+
+ if (m_ranges.last().lastPage==0 && m_ranges.count()>1) {
+ m_datasources->setReportVariable("#PAGE",1);
+ } else {
+ m_datasources->setReportVariable("#PAGE",m_datasources->variable("#PAGE").toInt()+1);
+ }
+
+ m_ranges.last().lastPage = m_pageCount;
m_pageCount++;
- m_datasources->setReportVariable("#PAGE",m_pageCount);
- m_datasources->setReportVariable("#PAGE_COUNT",m_pageCount-1);
+
BandDesignIntf* pageFooter = m_renderPageItem->bandByType(BandDesignIntf::PageFooter);
if (pageFooter) pageFooter->setBandIndex(++m_currentIndex);
m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem));
diff --git a/src/lrreportrender.h b/src/lrreportrender.h
index c4ec1a6..136b8ec 100644
--- a/src/lrreportrender.h
+++ b/src/lrreportrender.h
@@ -57,12 +57,17 @@ private:
typedef QList ReportPages;
+struct PagesRange{
+ int firstPage;
+ int lastPage;
+};
+
class ReportRender: public QObject
{
Q_OBJECT
Q_PROPERTY(QObject* datasourcesManager READ datasources())
public:
- enum DataRenderMode {StartNewPage,NotStartNewPage};
+ enum DataRenderMode {StartNewPageAsNeeded, NotStartNewPage, ForcedStartPage};
enum BandPrintMode {PrintAlwaysPrintable, PrintNotAlwaysPrintable };
typedef QSharedPointer Ptr;
~ReportRender();
@@ -93,7 +98,7 @@ private:
void renderChildHeader(BandDesignIntf* parent, BandPrintMode printMode);
void renderChildFooter(BandDesignIntf* parent, BandPrintMode printMode);
void renderChildBands(BandDesignIntf* parentBand);
- void renderGroupHeader(BandDesignIntf* parentBand, IDataSource* dataSource);
+ void renderGroupHeader(BandDesignIntf* parentBand, IDataSource* dataSource, bool firstTime);
void renderGroupFooter(BandDesignIntf* parentBand);
void initGroupFunctions();
@@ -119,10 +124,15 @@ private:
void secondRenderPass();
BandDesignIntf* saveUppperPartReturnBottom(BandDesignIntf *band, int height, BandDesignIntf *patternBand);
BandDesignIntf* renderData(BandDesignIntf* patternBand);
+ void startNewColumn();
void startNewPage();
+ void resetPageNumber();
+ int findLastPageNumber(int currentPage);
void savePage();
QString toString();
+private:
+ void initColumns();
private:
DataSourceManager* m_datasources;
@@ -132,22 +142,24 @@ private:
QMultiMap< BandDesignIntf*, GroupBandsHolder* > m_childBands;
- int m_currentMaxHeight;
- int m_currentStartDataPos;
+ //int m_maxHeightByColumn[0];
+ //int m_currentStartDataPos;
int m_currentIndex;
int m_pageCount;
QMap m_popupedValues;
QMultiMap m_popupedExpression;
- qreal m_pageFooterHeight;
- qreal m_dataAreaSize;
- qreal m_reportFooterHeight;
- int m_renderedDataBandCount;
+ qreal m_pageFooterHeight;
+ qreal m_dataAreaSize;
+ qreal m_reportFooterHeight;
+ int m_renderedDataBandCount;
BandDesignIntf* m_lastDataBand;
- bool m_renderCanceled;
-
-
+ bool m_renderCanceled;
+ QVector m_maxHeightByColumn;
+ QVector m_currentStartDataPos;
+ int m_currentColumn;
+ QList m_ranges;
};
} // namespace LimeReport
#endif // LRREPORTRENDER_H
diff --git a/src/lrscriptenginemanager.cpp b/src/lrscriptenginemanager.cpp
index 3dfdc5d..e2f3c44 100644
--- a/src/lrscriptenginemanager.cpp
+++ b/src/lrscriptenginemanager.cpp
@@ -190,22 +190,9 @@ void ScriptEngineModel::updateModel()
endResetModel();
}
-//QScriptValue dateToStr(QScriptContext* pcontext, QScriptEngine* pengine){
-// DataSourceManager* dm = DataSourceManager::instance();
-// QString field = pcontext->argument(0).toString();
-// QString format = pcontext->argument(1).toString();
-// QScriptValue res;
-// if (dm->containsField(field)){
-// res=pengine->newVariant(QLocale().toString(dm->fieldData(field).toDate(),format));
-// } else {
-// QString error = (!dm->lastError().isNull())?dm->lastError():QString("Field %1 not found").arg(field);
-// res=pengine->newVariant(error);
-// }
-// return res;
-//}
-
-QScriptValue line(QScriptContext* pcontext, QScriptEngine* pengine){
- DataSourceManager* dm=DataSourceManager::instance();
+QScriptValue line(QScriptContext* pcontext, QScriptEngine* pengine){
+ ScriptEngineManager* sm = qscriptvalue_cast(pcontext->callee().data());
+ DataSourceManager* dm = sm->dataManager();
QString band = pcontext->argument(0).toString();
QScriptValue res;
QString varName = QLatin1String("line_")+band.toLower();
@@ -236,7 +223,9 @@ QScriptValue now(QScriptContext* /*pcontext*/, QScriptEngine* pengine){
QScriptValue callGroupFunction(const QString& functionName, QScriptContext* pcontext, QScriptEngine* pengine){
- DataSourceManager* dm=DataSourceManager::instance();
+ ScriptEngineManager* sm = qscriptvalue_cast(pcontext->callee().data());
+ DataSourceManager* dm = sm->dataManager();
+
QString expression = pcontext->argument(0).toString();
QString band = pcontext->argument(1).toString();
QScriptValue res;
@@ -267,6 +256,26 @@ ScriptEngineManager::~ScriptEngineManager()
delete m_scriptEngine;
}
+bool ScriptEngineManager::isFunctionExists(const QString &functionName) const
+{
+ foreach (ScriptFunctionDesc desc, m_functions) {
+ if (desc.name.compare(functionName,Qt::CaseInsensitive)==0){
+ return true;
+ }
+ }
+ return false;
+}
+
+void ScriptEngineManager::deleteFunction(const QString &functionsName)
+{
+ QMutableListIterator it(m_functions);
+ while(it.hasNext()){
+ if (it.next().name.compare(functionsName, Qt::CaseInsensitive)==0){
+ it.remove();
+ }
+ }
+}
+
QScriptValue ScriptEngineManager::addFunction(const QString& name,
QScriptEngine::FunctionSignature function,
const QString& category,
@@ -278,6 +287,7 @@ QScriptValue ScriptEngineManager::addFunction(const QString& name,
funct.category = category;
funct.scriptValue = scriptEngine()->newFunction(function);
funct.scriptValue.setProperty("functionName",name);
+ funct.scriptValue.setData(m_scriptEngine->toScriptValue(this));
funct.type = ScriptFunctionDesc::Native;
m_functions.append(funct);
if (m_model)
@@ -295,6 +305,7 @@ QScriptValue ScriptEngineManager::addFunction(const QString& name, const QString
funct.category = category;
funct.description = description;
funct.type = ScriptFunctionDesc::Script;
+ funct.scriptValue.setData(m_scriptEngine->toScriptValue(this));
m_functions.append(funct);
m_model->updateModel();
return funct.scriptValue;
@@ -313,8 +324,24 @@ QStringList ScriptEngineManager::functionsNames()
return res;
}
+void ScriptEngineManager::setDataManager(DataSourceManager *dataManager){
+ if (m_dataManager != dataManager){
+ m_dataManager = dataManager;
+ if (m_dataManager){
+ foreach(QString func, m_dataManager->groupFunctionNames()){
+ if (isFunctionExists(func)) deleteFunction(func);
+ addFunction(func, groupFunction,"GROUP FUNCTIONS", func+"(\""+tr("FieldName")+"\",\""+tr("BandName")+"\")");
+ }
+ foreach(ScriptFunctionDesc func, m_functions){
+ if (func.type==ScriptFunctionDesc::Native)
+ m_scriptEngine->globalObject().setProperty(func.name,func.scriptValue);
+ }
+ }
+ }
+}
+
ScriptEngineManager::ScriptEngineManager()
- :m_model(0)
+ :m_model(0), m_dataManager(0)
{
m_scriptEngine = new QScriptEngine;
@@ -332,10 +359,9 @@ ScriptEngineManager::ScriptEngineManager()
QScriptValue fontConstructor = m_scriptEngine->newFunction(QFontPrototype::constructorQFont, fontProto);
m_scriptEngine->globalObject().setProperty("QFont", fontConstructor);
- DataSourceManager* dm=DataSourceManager::instance();
- foreach(QString func, dm->groupFunctionNames()){
- addFunction(func, groupFunction,"GROUP FUNCTIONS", func+"(\""+tr("FieldName")+"\",\""+tr("BandName")+"\")");
- }
+// foreach(QString func, dataManager()->groupFunctionNames()){
+// addFunction(func, groupFunction,"GROUP FUNCTIONS", func+"(\""+tr("FieldName")+"\",\""+tr("BandName")+"\")");
+// }
foreach(ScriptFunctionDesc func, m_functions){
if (func.type==ScriptFunctionDesc::Native)
diff --git a/src/lrscriptenginemanager.h b/src/lrscriptenginemanager.h
index 6c8c9f1..4372462 100644
--- a/src/lrscriptenginemanager.h
+++ b/src/lrscriptenginemanager.h
@@ -44,6 +44,8 @@
namespace LimeReport{
+class DataSourceManager;
+
struct ScriptFunctionDesc{
enum FuncType {Native,Script};
QScriptValue scriptValue;
@@ -110,6 +112,8 @@ public:
QScriptEngine* scriptEngine(){return m_scriptEngine;}
~ScriptEngineManager();
friend class Singleton;
+ bool isFunctionExists(const QString& functionName) const;
+ void deleteFunction(const QString& functionsName);
QScriptValue addFunction(const QString& name, QScriptEngine::FunctionSignature function,
const QString& category="", const QString& description="");
QScriptValue addFunction(const QString &name, const QString& script,
@@ -118,6 +122,8 @@ public:
QStringList functionsNames();
const QList& functionsDescriber(){return m_functions;}
ScriptEngineModel* model(){return m_model;}
+ DataSourceManager* dataManager() const {return m_dataManager;}
+ void setDataManager(DataSourceManager* dataManager);
private:
Q_DISABLE_COPY(ScriptEngineManager)
private:
@@ -126,6 +132,7 @@ private:
QString m_lastError;
QList m_functions;
ScriptEngineModel* m_model;
+ DataSourceManager* m_dataManager;
};
class ScriptExtractor
diff --git a/src/objectinspector/lrobjectitemmodel.cpp b/src/objectinspector/lrobjectitemmodel.cpp
index e2e6a6d..632a7c5 100644
--- a/src/objectinspector/lrobjectitemmodel.cpp
+++ b/src/objectinspector/lrobjectitemmodel.cpp
@@ -35,6 +35,24 @@
namespace LimeReport {
+void QObjectPropertyModel::translatePropertyName()
+{
+ tr("leftMargin");
+ tr("rightMargin");
+ tr("topMargin");
+ tr("bottomMargin");
+ tr("objectName");
+ tr("borders");
+ tr("geometry");
+ tr("itemAlign");
+ tr("pageOrientation");
+ tr("pageSize");
+ tr("TopLine");
+ tr("BottomLine");
+ tr("LeftLine");
+ tr("RightLine");
+}
+
QObjectPropertyModel::QObjectPropertyModel(QObject *parent/*=0*/)
:QAbstractItemModel(parent),m_rootNode(0),m_object(0),m_dataChanging(false), m_subclassesAsLevel(true), m_validator(0)
{}
@@ -291,7 +309,6 @@ void QObjectPropertyModel::setValidator(ValidatorIntf *validator)
m_validator = validator;
}
-
void QObjectPropertyModel::addObjectProperties(const QMetaObject *metaObject, QObject *object, ObjectPropItem::ObjectsList *objects, int level)
{
if (metaObject->propertyCount()>metaObject->propertyOffset()){
diff --git a/src/objectinspector/lrobjectitemmodel.h b/src/objectinspector/lrobjectitemmodel.h
index b354538..98e917f 100644
--- a/src/objectinspector/lrobjectitemmodel.h
+++ b/src/objectinspector/lrobjectitemmodel.h
@@ -70,7 +70,7 @@ public:
bool subclassesAsLevel(){return m_subclassesAsLevel;}
ValidatorIntf* validator() const;
void setValidator(ValidatorIntf* validator);
-
+ void translatePropertyName();
signals:
void objectPropetyChanged(const QString& , const QVariant&, const QVariant&);
private slots:
diff --git a/translations/limereport_ru.qm b/translations/limereport_ru.qm
new file mode 100644
index 0000000..4908bc1
Binary files /dev/null and b/translations/limereport_ru.qm differ
diff --git a/translations/limereport_ru.ts b/translations/limereport_ru.ts
new file mode 100644
index 0000000..65aecce
--- /dev/null
+++ b/translations/limereport_ru.ts
@@ -0,0 +1,1842 @@
+
+
+
+
+ AboutDialog
+
+
+
+ О программе
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Автор
+
+
+
+
+
+
+
+
+
+ Лицензия
+
+
+
+
+
+
+
+
+
+ Закрыть
+
+
+
+
+ Версия
+
+
+
+ ConnectionDialog
+
+
+
+
+ Соединение
+
+
+
+
+ Название
+
+
+
+
+ Драйвер
+
+
+
+
+ Сервер
+
+
+
+
+ Пользователь
+
+
+
+
+ Пароль
+
+
+
+
+ База данных
+
+
+
+
+
+
+
+
+
+ Автоматическое соединение
+
+
+
+
+ Проверить соединение
+
+
+
+
+ Отмена
+
+
+
+
+
+
+
+
+
+
+ Ошибка
+
+
+
+
+ Соединение успешно установлено!
+
+
+
+
+ Наименование соединения не указано
+
+
+
+
+ Соединение
+
+
+
+
+ уже существует
+
+
+
+ DataBrowser
+
+
+
+
+ Источники данных
+
+
+
+
+ Добавить соединение с базой
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Переменные
+
+
+
+ LRVariableDialog
+
+
+
+ Переменная
+
+
+
+
+ Имя переменной
+
+
+
+
+ Значение
+
+
+
+
+ Тип
+
+
+
+
+ Внимание
+
+
+
+ LimeReport::AVariablesHolder
+
+
+
+
+
+
+ переменная
+
+
+
+
+ уже существует !!
+
+
+
+
+
+
+ не существует !!
+
+
+
+ LimeReport::AlignmentPropItem
+
+
+
+ По левому краю
+
+
+
+
+ По правому краю
+
+
+
+
+
+ По центру
+
+
+
+
+ По ширине
+
+
+
+
+ Прижать к верхнему краю
+
+
+
+
+ Прижать к нижнему краю
+
+
+
+
+ горизонтально
+
+
+
+
+ вертикально
+
+
+
+ LimeReport::BandDesignIntf
+
+
+
+ соединён с
+
+
+
+ LimeReport::ContentItemDesignIntf
+
+
+
+ Переменная %1 не найдена
+
+
+
+ LimeReport::DataBand
+
+
+
+ Данные
+
+
+
+ LimeReport::DataBrowser
+
+
+
+ Источники данных
+
+
+
+
+
+
+
+ Внимание
+
+
+
+
+ Do you really want delete "%1" connection ?
+ Вы действительно хотите удалить "%1" соединение ?
+
+
+
+
+ Пользовательские переменные
+
+
+
+
+ Системные переменные
+
+
+
+
+ Do you really want delete "%1" datasource ?
+ Вы действительно хотите удалить источник данных "%1" ?
+
+
+
+
+
+
+
+
+ Вы действительно хотите удалить переменную "%1" ?
+
+
+
+
+ Ошибка
+
+
+
+ LimeReport::DataFooterBand
+
+
+
+ Подвал данных
+
+
+
+ LimeReport::DataHeaderBand
+
+
+
+ Заголовок данных
+
+
+
+ LimeReport::DataSourceManager
+
+
+
+ Соединение "%1" не открыто
+
+
+
+
+
+ Источник данных "%1" не найден !
+
+
+
+
+ соединение "%1" уже существует !
+
+
+
+
+
+
+
+ data source with name "%1" already exists !!
+ источник данных "%1" уже существует !
+
+
+
+
+ нет соединения
+
+
+
+ LimeReport::DataSourceModel
+
+
+
+ Источники данных
+
+
+
+
+ Переменные
+
+
+
+ LimeReport::FontEditorWidget
+
+
+
+ Жирный
+
+
+
+
+ Курсив
+
+
+
+
+ Подчеркнутый
+
+
+
+ LimeReport::FontPropItem
+
+
+
+ жирный
+
+
+
+
+ курсив
+
+
+
+
+ подчеркнутый
+
+
+
+
+ размер
+
+
+
+
+ название
+
+
+
+ LimeReport::GroupBandFooter
+
+
+
+ Подвал группы
+
+
+
+ LimeReport::GroupBandHeader
+
+
+
+ Заголовок группы
+
+
+
+ LimeReport::GroupFunction
+
+
+
+ Поле "%1" не найдено
+
+
+
+
+ Переменная "%1" не найдена
+
+
+
+
+ Элемент "%1" не найден
+
+
+
+ LimeReport::ImageItem
+
+
+
+ Изображение
+
+
+
+ LimeReport::ItemsAlignmentEditorWidget
+
+
+
+ На передний план
+
+
+
+
+ На задний план
+
+
+
+
+ Выровнять по левому краю
+
+
+
+
+ Выровнять по правому краю
+
+
+
+
+ Центрировать вертикально
+
+
+
+
+ Выровнять по верхнему краю
+
+
+
+
+ Выровнять по нижнему краю
+
+
+
+
+ Центрировать горизонтально
+
+
+
+
+ Одинаковая высота
+
+
+
+
+ Одинаковая ширина
+
+
+
+ LimeReport::ItemsBordersEditorWidget
+
+
+
+ Верхняя граница
+
+
+
+
+ Нижняя граница
+
+
+
+
+ Левая граница
+
+
+
+
+ Правая граница
+
+
+
+
+ Удалить границы
+
+
+
+
+ Внешние границы
+
+
+
+ LimeReport::MasterDetailProxyModel
+
+
+
+ Поле: "%1" не найдено в подчиненном источнике данных "%2"
+
+
+
+
+ Поле: "%1" не найдено в главном источнике данных "%2"
+
+
+
+ LimeReport::ModelToDataSource
+
+
+
+ модель уничтожена
+
+
+
+ LimeReport::ObjectBrowser
+
+
+
+ Объекты
+
+
+
+ LimeReport::PageDesignIntf
+
+
+
+ Предупреждение
+
+
+
+
+ Удаление нескольких бандов запрещено
+
+
+
+ LimeReport::PageFooter
+
+
+
+ Нижний колонтитул
+
+
+
+ LimeReport::PageHeader
+
+
+
+ Верхний колонтитул
+
+
+
+ LimeReport::ProxyHolder
+
+
+
+ Источник данных находится в недействительном состоянии
+
+
+
+ LimeReport::QObjectPropertyModel
+
+
+
+ Свойство
+
+
+
+
+ Значение
+
+
+
+
+ Отступ левый
+
+
+
+
+ Отступ правый
+
+
+
+
+ Отступ верхний
+
+
+
+
+ Отступ нижний
+
+
+
+
+ Имя объекта
+
+
+
+
+ Границы
+
+
+
+
+ Геометрия
+
+
+
+
+ Расположение объекта
+
+
+
+
+ Ориентация страницы
+
+
+
+
+ Размер страницы
+
+
+
+
+ Верхняя граница
+
+
+
+
+ Нижняя граница
+
+
+
+
+ Левая граница
+
+
+
+
+ Правая граница
+
+
+
+
+ Предупреждение
+
+
+
+ LimeReport::RectMMPropItem
+
+
+
+
+
+ ширина
+
+
+
+
+
+
+ высота
+
+
+
+ LimeReport::RectPropItem
+
+
+
+ ширина
+
+
+
+
+ высота
+
+
+
+ LimeReport::ReportDesignWidget
+
+
+
+ Файл отчета
+
+
+
+ LimeReport::ReportDesignWindow
+
+
+
+ Новый отчет
+
+
+
+
+ Режим редактирования
+
+
+
+
+ Отменить действие
+
+
+
+
+ Повторить действие
+
+
+
+
+ Копировать
+
+
+
+
+ Вставить
+
+
+
+
+ Вырезать
+
+
+
+
+ Текстовый элемент
+
+
+
+
+ Сохранить отчет
+
+
+
+
+ Сохранить отчет как
+
+
+
+
+ Загрузить отчет
+
+
+
+
+ Удалить элемент
+
+
+
+
+ Увеличить
+
+
+
+
+ Уменьшить
+
+
+
+
+ Сгенерировать отчет
+
+
+
+
+ Режим редактирования группировок
+
+
+
+
+ Горизонтальная группировка
+
+
+
+
+ О программе
+
+
+
+
+ Спрятать левую панель
+
+
+
+
+ Спрятать правую панель
+
+
+
+
+ Элементы отчета
+
+
+
+
+ Шрифт
+
+
+
+
+ Выравнивание текста
+
+
+
+
+ Выравнивание объектов
+
+
+
+
+ Границы
+
+
+
+
+ Заголовок отчета
+
+
+
+
+ Завершение отчета
+
+
+
+
+ Верхний колонтитул
+
+
+
+
+ Нижний колонтитул
+
+
+
+
+ Данные
+
+
+
+
+ Заголовок данных
+
+
+
+
+ Завершение данных
+
+
+
+
+ Подчиненные данные
+
+
+
+
+ Заголовок подчиненных данных
+
+
+
+
+ Завершение подчиненных данных
+
+
+
+
+ Заголовок группы
+
+
+
+
+ Завершение группы
+
+
+
+
+ Файл
+
+
+
+
+ Правка
+
+
+
+
+ Информация
+
+
+
+
+ Инспектор объектов
+
+
+
+
+ Структура отчета
+
+
+
+
+ Инспектор данных
+
+
+
+
+ Отчет был изменен ! Хотите его записать ?
+
+
+
+
+
+ Файл отчета
+
+
+
+
+ Создается отчет
+
+
+
+
+ О генераторе
+
+
+
+
+ создается страница
+
+
+
+ LimeReport::ReportEnginePrivate
+
+
+
+ Ошибка
+
+
+
+ LimeReport::ReportFooter
+
+
+
+ Завершение отчета
+
+
+
+ LimeReport::ReportHeader
+
+
+
+ Заголовок отчета
+
+
+
+ LimeReport::ReportRender
+
+
+
+ Ошибка
+
+
+
+
+ Банд "%1" не найден
+
+
+
+
+ Не правильное использование функции %1
+
+
+
+ LimeReport::ScriptEngineManager
+
+
+
+ Имя поля
+
+
+
+
+
+ Имя банда
+
+
+
+
+
+ Значение
+
+
+
+
+
+ Формат
+
+
+
+
+ Точность
+
+
+
+ LimeReport::SubDetailBand
+
+
+
+ Подчиненные данные
+
+
+
+ LimeReport::SubDetailHeaderBand
+
+
+
+ Заголовок подчиненных данных
+
+
+
+ LimeReport::TextAlignmentEditorWidget
+
+
+
+ По левому краю
+
+
+
+
+
+ По центру
+
+
+
+
+ По правому краю
+
+
+
+
+ По ширине
+
+
+
+
+ Прижать к верхнему краю
+
+
+
+
+ Прижать к нижнему краю
+
+
+
+ PreviewReportWindow
+
+
+
+ Предварительный просмотр
+
+
+
+
+ Просмотр
+
+
+
+
+ Отчет
+
+
+
+
+ Панель инструментов
+
+
+
+
+ Печать
+
+
+
+
+
+
+
+
+
+ Увеличить
+
+
+
+
+ Уменьшить
+
+
+
+
+
+ Предыдущая страница
+
+
+
+
+
+ Следующая страница
+
+
+
+
+
+ Закрыть
+
+
+
+
+ Режим редактирования
+
+
+
+
+
+ Записать в файл
+
+
+
+
+
+ Показать ошибки
+
+
+
+
+ Первая страница
+
+
+
+
+ Первая страница
+
+
+
+
+
+ Последняя страница
+
+
+
+
+ Печать в PDF
+
+
+
+
+ из %1
+
+
+
+
+ Файл отчета
+
+
+
+
+ Имя PDF файла
+
+
+
+ QObject
+
+
+
+
+ Данные
+
+
+
+
+ Заголовок данных
+
+
+
+
+ Завершение данных
+
+
+
+
+ Заголовок группы
+
+
+
+
+ Завершение группы
+
+
+
+
+
+ Нижний колонтитул
+
+
+
+
+
+ Верхний колонтитул
+
+
+
+
+
+ Завершение отчета
+
+
+
+
+
+ Заголовок отчета
+
+
+
+
+
+ Подчиненные данные
+
+
+
+
+ Заголовок подчиненных данных
+
+
+
+
+ Завершение подчиненных данных
+
+
+
+
+ расположение
+
+
+
+
+ Элемент штрих код
+
+
+
+
+ Горизонтальная компоновка
+
+
+
+
+ Элемент изображение
+
+
+
+
+ Элемент фигура
+
+
+
+
+ Расположение объекта
+
+
+
+
+ Текстовый элемент
+
+
+
+
+
+ Неверное соединение %1
+
+
+
+
+ Главный источник данных "%1" не найден!
+
+
+
+
+ Подчиненный
+
+
+
+
+ и подчиненный
+
+
+
+
+ источник данных "%1" не найден !
+
+
+
+
+ Внимание!
+
+
+
+
+ Выделенные элементы имеют различные родительские контейнеры
+
+
+
+
+ Объект с именем %1 уже существует
+
+
+
+
+ Функция %1 не найдена или вызвана с неверными аргументами
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ источник данных
+
+
+
+
+
+ Поле
+
+
+
+
+ Перечисление
+
+
+
+
+ Флаги
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Геометрия
+
+
+
+
+ мм
+
+
+
+
+
+
+
+
+
+ Файл %1 не открыт
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Верхняя граница
+
+
+
+
+ Нижняя граница
+
+
+
+
+ Левая граница
+
+
+
+
+ Правая граница
+
+
+
+ SQLEditDialog
+
+
+
+ Источник данных
+
+
+
+
+ Соединение
+
+
+
+
+ Имя источника
+
+
+
+
+ Подчиненный
+
+
+
+
+ Главный источник
+
+
+
+
+ Режим подзапроса
+
+
+
+
+ Режим фильтрации
+
+
+
+
+ SQL запрос
+
+
+
+
+
+ Предпросмотр
+
+
+
+
+ Скрыть
+
+
+
+
+ Подчиненный источник
+
+
+
+
+ Поля для связи источников
+
+
+
+
+
+
+
+
+
+
+ Данные
+
+
+
+
+ Отмена
+
+
+
+
+
+
+
+
+
+ Ошибка
+
+
+
+
+ Имя источника данных не заполнено !
+
+
+
+
+ SQL запрос пустой !
+
+
+
+
+ Источник данных с именем: "%1" уже существует !
+
+
+
+
+ Источник данных с именем: "%1" уже существует
+
+
+
+
+
+ Внимание
+
+
+
+
+ Соединение не указано
+
+
+
+
+ Обновить
+
+
+
+ TextItemEditor
+
+
+
+ Редактор текстового элемента
+
+
+
+
+ Содержимое
+
+
+
+
+ Источники данных
+
+
+
+
+ Функции
+
+
+
+
+ Настройки
+
+
+
+
+ Шрифт редактора
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Отмена
+
+
+
+
+
+
+
+
+ WaitForm
+
+
+
+ Ожидайте
+
+
+
+
+ Пожалуста подождите ...
+
+
+