0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 00:33:02 +03:00
This commit is contained in:
Sergey Popovichev 2016-02-17 10:28:27 +03:00
parent 0a16bed249
commit 20fe567ab2
45 changed files with 3169 additions and 1784 deletions

View File

@ -0,0 +1,245 @@
<Report>
<object ClassName="LimeReport::ReportEnginePrivate" Type="Object">
<objectName Type="QString"></objectName>
<pages Type="Collection">
<item ClassName="LimeReport::PageDesignIntf" Type="Object">
<objectName Type="QString">page1</objectName>
<sceneRect x="-50" Type="QRect" y="-50" height="3070" width="2200"/>
<bspTreeDepth Type="int" Value="5"/>
<font bold="0" family="MS Shell Dlg 2" undeline="0" italic="0" Type="QFont" pointSize="8"/>
<sortCacheEnabled Type="bool" Value="0"/>
<stickyFocus Type="bool" Value="0"/>
<minimumRenderSize Type="qreal" Value="0"/>
<pageItem ClassName="PageItem" Type="Object">
<objectName Type="QString">ReportPage1</objectName>
<geometry x="0" Type="QRect" y="0" height="2970" width="2100"/>
<children Type="Collection">
<item ClassName="Data" Type="Object">
<objectName Type="QString">DataBand1</objectName>
<geometry x="50" Type="QRect" y="154" height="206" width="1000"/>
<children Type="Collection">
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem1</objectName>
<geometry x="22" Type="QRect" y="26" height="50" width="250"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">DataBand1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">$D{orders.OrderID}</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font bold="0" family="Arial" undeline="0" italic="0" Type="QFont" pointSize="10"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem2</objectName>
<geometry x="284" Type="QRect" y="24" height="50" width="360"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">DataBand1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">$D{orders.OrderDate}</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font bold="0" family="Arial" undeline="0" italic="0" Type="QFont" pointSize="10"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
<item ClassName="BarcodeItem" Type="Object">
<objectName Type="QString">BarcodeItem1</objectName>
<geometry x="716" Type="QRect" y="16" height="166" width="254"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">DataBand1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">$D{orders.OrderID}</content>
<barcodeType Type="enumAndFlags" Value="20"/>
<testValue Type="QString">1</testValue>
<foregroundColor Type="QColor" Value="#000000"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<whitespace Type="int" Value="10"/>
<angle Type="enumAndFlags" Value="0"/>
<barcodeWidth Type="int" Value="0"/>
<securityLevel Type="int" Value="0"/>
<pdf417CodeWords Type="int" Value="928"/>
</item>
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem4</objectName>
<geometry x="20" Type="QRect" y="86" height="50" width="624"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">DataBand1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">$D{orders.ShipName}</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font bold="0" family="Arial" undeline="0" italic="0" Type="QFont" pointSize="10"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem5</objectName>
<geometry x="18" Type="QRect" y="142" height="50" width="626"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">DataBand1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">$D{orders.ShipPostalCode}</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font bold="0" family="Arial" undeline="0" italic="0" Type="QFont" pointSize="10"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
</children>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="15"/>
<parentName Type="QString">ReportPage1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<autoHeight Type="bool" Value="1"/>
<bandIndex Type="int" Value="4"/>
<keepBottomSpace Type="bool" Value="0"/>
<parentBand Type="QString"></parentBand>
<backgroundColor Type="QColor" Value="#ffffff"/>
<printIfEmpty Type="bool" Value="0"/>
<datasource Type="QString">orders</datasource>
<keepSubdetailTogether Type="bool" Value="0"/>
<splittable Type="bool" Value="0"/>
<keepFooterTogether Type="bool" Value="0"/>
<sliceLastRow Type="bool" Value="0"/>
<columnsCount Type="int" Value="2"/>
<columnsFillDirection Type="enumAndFlags" Value="0"/>
</item>
<item ClassName="ReportHeader" Type="Object">
<objectName Type="QString">ReportHeader1</objectName>
<geometry x="50" Type="QRect" y="50" height="100" width="2000"/>
<children Type="Collection">
<item ClassName="TextItem" Type="Object">
<objectName Type="QString">TextItem3</objectName>
<geometry x="18" Type="QRect" y="28" height="50" width="1002"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">ReportHeader1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">Orders selected by condition used variable OrdersDate</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font bold="0" family="Arial" undeline="0" italic="0" Type="QFont" pointSize="10"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
</children>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">ReportPage1</parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<autoHeight Type="bool" Value="1"/>
<bandIndex Type="int" Value="1"/>
<keepBottomSpace Type="bool" Value="0"/>
<parentBand Type="QString"></parentBand>
<backgroundColor Type="QColor" Value="#ffffff"/>
<printIfEmpty Type="bool" Value="0"/>
<splittable Type="bool" Value="0"/>
</item>
</children>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString"></parentName>
<itemAlign Type="enumAndFlags" Value="4"/>
<topMargin Type="int" Value="5"/>
<bottomMargin Type="int" Value="5"/>
<rightMargin Type="int" Value="5"/>
<leftMargin Type="int" Value="5"/>
<pageOrientation Type="enumAndFlags" Value="0"/>
<pageSize Type="enumAndFlags" Value="0"/>
</pageItem>
</item>
</pages>
<datasourcesManager ClassName="LimeReport::DataSourceManager" Type="Object">
<objectName Type="QString">datasources</objectName>
<connections Type="Collection">
<item ClassName="LimeReport::ConnectionDesc" Type="Object">
<objectName Type="QString"></objectName>
<name Type="QString">northwind.db</name>
<driver Type="QString">QSQLITE</driver>
<databaseName Type="QString">./demo_reports/northwind.db</databaseName>
<userName Type="QString"></userName>
<password Type="QString" Value=""/>
<host Type="QString"></host>
<autoconnect Type="bool" Value="1"/>
</item>
</connections>
<queries Type="Collection">
<item ClassName="LimeReport::QueryDesc" Type="Object">
<objectName Type="QString"></objectName>
<queryName Type="QString">orders</queryName>
<queryText Type="QString">Select * from orders where OrderDate = $V{OrdersDate}</queryText>
<connectionName Type="QString">northwind.db</connectionName>
</item>
</queries>
<subqueries Type="Collection"/>
<subproxies Type="Collection"/>
<variables Type="Collection">
<item ClassName="LimeReport::VarDesc" Type="Object">
<objectName Type="QString"></objectName>
<name Type="QString">OrdersDate</name>
<value Type="QString">2005-03-22</value>
</item>
</variables>
</datasourcesManager>
</object>
</Report>

View File

@ -0,0 +1,168 @@
<Report>
<object Type="Object" ClassName="LimeReport::ReportEnginePrivate">
<objectName Type="QString"></objectName>
<pages Type="Collection">
<item Type="Object" ClassName="LimeReport::PageDesignIntf">
<objectName Type="QString">page1</objectName>
<sceneRect height="3070" width="2200" Type="QRect" x="-50" y="-50"/>
<bspTreeDepth Type="int" Value="5"/>
<font Type="QFont" italic="0" pointSize="8" bold="0" undeline="0" family="MS Shell Dlg 2"/>
<sortCacheEnabled Type="bool" Value="0"/>
<stickyFocus Type="bool" Value="0"/>
<minimumRenderSize Type="qreal" Value="0"/>
<pageItem Type="Object" ClassName="PageItem">
<objectName Type="QString">ReportPage1</objectName>
<geometry height="2970" width="2100" Type="QRect" x="0" y="0"/>
<children Type="Collection">
<item Type="Object" ClassName="Data">
<objectName Type="QString">DataBand1</objectName>
<geometry height="100" width="2000" Type="QRect" x="50" y="154"/>
<children Type="Collection">
<item Type="Object" ClassName="TextItem">
<objectName Type="QString">TextItem1</objectName>
<geometry height="50" width="250" Type="QRect" x="22" y="26"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">DataBand1</parentName>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">$D{orders.OrderID}</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font Type="QFont" italic="0" pointSize="10" bold="0" undeline="0" family="Arial"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
<item Type="Object" ClassName="TextItem">
<objectName Type="QString">TextItem2</objectName>
<geometry height="50" width="250" Type="QRect" x="284" y="24"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">DataBand1</parentName>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">$D{orders.OrderDate}</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font Type="QFont" italic="0" pointSize="10" bold="0" undeline="0" family="Arial"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
</children>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">ReportPage1</parentName>
<autoHeight Type="bool" Value="1"/>
<bandIndex Type="int" Value="4"/>
<keepBottomSpace Type="bool" Value="0"/>
<parentBand Type="QString"></parentBand>
<backgroundColor Type="QColor" Value="#ffffff"/>
<printIfEmpty Type="bool" Value="0"/>
<datasource Type="QString">orders</datasource>
<keepSubdetailTogether Type="bool" Value="0"/>
<splittable Type="bool" Value="0"/>
<keepFooterTogether Type="bool" Value="0"/>
<sliceLastRow Type="bool" Value="0"/>
</item>
<item Type="Object" ClassName="ReportHeader">
<objectName Type="QString">ReportHeader1</objectName>
<geometry height="100" width="2000" Type="QRect" x="50" y="50"/>
<children Type="Collection">
<item Type="Object" ClassName="TextItem">
<objectName Type="QString">TextItem3</objectName>
<geometry height="50" width="1002" Type="QRect" x="18" y="28"/>
<children Type="Collection"/>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">ReportHeader1</parentName>
<itemLocation Type="enumAndFlags" Value="0"/>
<stretchToMaxHeight Type="bool" Value="0"/>
<content Type="QString">Orders selected by condition used variable OrdersDate</content>
<margin Type="int" Value="4"/>
<alignment Type="enumAndFlags" Value="33"/>
<autoWidth Type="enumAndFlags" Value="0"/>
<autoHeight Type="bool" Value="0"/>
<font Type="QFont" italic="0" pointSize="10" bold="0" undeline="0" family="Arial"/>
<backgroundOpacity Type="int" Value="100"/>
<backgroundMode Type="enumAndFlags" Value="1"/>
<backgroundColor Type="QColor" Value="#ffffff"/>
<fontColor Type="QColor" Value="#000000"/>
<angle Type="enumAndFlags" Value="0"/>
<foregroundOpacity Type="int" Value="100"/>
<trimValue Type="bool" Value="1"/>
</item>
</children>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString">ReportPage1</parentName>
<autoHeight Type="bool" Value="1"/>
<bandIndex Type="int" Value="1"/>
<keepBottomSpace Type="bool" Value="0"/>
<parentBand Type="QString"></parentBand>
<backgroundColor Type="QColor" Value="#ffffff"/>
<printIfEmpty Type="bool" Value="0"/>
<splittable Type="bool" Value="0"/>
</item>
</children>
<zOrder Type="qreal" Value="0"/>
<borders Type="enumAndFlags" Value="0"/>
<parentName Type="QString"></parentName>
<topMargin Type="int" Value="5"/>
<bottomMargin Type="int" Value="5"/>
<rightMargin Type="int" Value="5"/>
<leftMargin Type="int" Value="5"/>
<pageOrientation Type="enumAndFlags" Value="0"/>
<pageSize Type="enumAndFlags" Value="0"/>
</pageItem>
</item>
</pages>
<datasourcesManager Type="Object" ClassName="LimeReport::DataSourceManager">
<objectName Type="QString">datasources</objectName>
<connections Type="Collection">
<item Type="Object" ClassName="LimeReport::ConnectionDesc">
<objectName Type="QString"></objectName>
<name Type="QString">northwind.db</name>
<driver Type="QString">QSQLITE</driver>
<databaseName Type="QString">./demo_reports/northwind.db</databaseName>
<userName Type="QString"></userName>
<password Type="QString" Value=""/>
<host Type="QString"></host>
<autoconnect Type="bool" Value="1"/>
</item>
</connections>
<queries Type="Collection">
<item Type="Object" ClassName="LimeReport::QueryDesc">
<objectName Type="QString"></objectName>
<queryName Type="QString">orders</queryName>
<queryText Type="QString">Select * from orders where OrderDate = $V{OrdersDate}</queryText>
<connectionName Type="QString">northwind.db</connectionName>
</item>
</queries>
<subqueries Type="Collection"/>
<subproxies Type="Collection"/>
<variables Type="Collection">
<item Type="Object" ClassName="LimeReport::VarDesc">
<objectName Type="QString"></objectName>
<name Type="QString">OrdersDate</name>
<value Type="QString">2005-03-22</value>
</item>
</variables>
</datasourcesManager>
</object>
</Report>

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<BaseDesignIntf*>(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()<childItems().size()-1){
m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) {
m_children.append(item);
}
}
qSort(m_children.begin(),m_children.end(),lessThen);
for (int i=0; i<m_children.count();++i){
if (m_children[i]==item && m_children.size()>i+1){ return m_children[i+1];}
}
return 0;
}
BaseDesignIntf* HorizontalLayout::findPrior(BaseDesignIntf* item){
if (m_children.count()<childItems().size()-1){
m_children.clear();
foreach (BaseDesignIntf* item, childBaseItems()) {
m_children.append(item);
}
}
qSort(m_children.begin(),m_children.end(),lessThen);
for (int i=0; i<m_children.count();++i){
if (m_children[i]==item && i!=0){ return m_children[i-1];}
}
return 0;
}
void HorizontalLayout::divideSpace(){
m_isRelocating = true;
qreal itemsSumSize = 0;
foreach(BaseDesignIntf* item, m_children){
itemsSumSize += item->width();
}
qreal delta = (width() - itemsSumSize)/m_children.size();
for (int i=0; i<m_children.size(); ++i){
m_children[i]->setWidth(m_children[i]->width()+(delta));
if ((i+1)<m_children.size())
m_children[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<BaseDesignIntf*>(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);

View File

@ -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<BaseDesignIntf *> m_children;
bool m_isRelocating;
LayoutMarker* m_layoutMarker;
friend class LayoutMarker;
LayoutType m_layoutType;
};
} //namespace LimeReport

View File

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

View File

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

View File

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

View File

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

View File

@ -34,6 +34,7 @@
#include "lrscriptenginemanager.h"
#include "lrdatadesignintf.h"
#include "lrdatasourcemanager.h"
#include <QMenu>
#include <QScrollBar>
@ -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<<functionDesc.name;
}
@ -139,29 +141,29 @@ void TextItemEditor::initUI()
QStringListModel *TextItemEditor::getDataSources()
{
LimeReport::DataSourceManager* dm= LimeReport::DataSourceManager::instance();
LimeReport::DataSourceManager* dm = m_page->datasourceManager();
QStringList dataSources;
foreach(QString dsName,dm->dataSourceNames()){
dataSources<<dsName;
}
return new QStringListModel(dataSources,m_completer);
return new QStringListModel(dataSources, m_completer);
}
QStringListModel *TextItemEditor::getPrefixes()
{
QStringList prefixes;
prefixes<<"D{"<<"S{";
return new QStringListModel(prefixes,m_completer);
return new QStringListModel(prefixes, m_completer);
}
QStringListModel *TextItemEditor::getColumns(QString datasource)
{
QStringList fields;
LimeReport::DataSourceManager* dm= LimeReport::DataSourceManager::instance();
LimeReport::DataSourceManager* dm = m_page->datasourceManager();
foreach(QString field, dm->fieldNames(datasource)){
fields<<field;
}
return new QStringListModel(fields,m_completer);
return new QStringListModel(fields, m_completer);
}
void TextItemEditor::on_pbCancel_clicked()

View File

@ -137,7 +137,10 @@ BandDesignIntf::BandDesignIntf(BandsType bandType, const QString &xmlTypeName, Q
m_keepFooterTogether(false),
m_maxScalePercent(0),
m_sliceLastRow(false),
m_printIfEmpty(false)
m_printIfEmpty(false),
m_columnsCount(1),
m_columnIndex(0),
m_columnsFillDirection(Horizontal)
{
setPosibleResizeDirectionFlags(ResizeBottom);
setPosibleMoveFlags(TopBotom);
@ -375,6 +378,30 @@ void BandDesignIntf::checkEmptyTable(){
}
}
void BandDesignIntf::setColumnsCount(int value)
{
if (m_columnsCount!=value && value>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<BandDesignIntf*>(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()<findMaxBottom()) setHeight(findMaxBottom()+spaceBorder);
if ((maxHeight>0)&&(height()>maxHeight)){
trimToMaxHeight(maxHeight);
setHeight(maxHeight);
}
BaseDesignIntf::updateItemSize(pass,maxHeight);
BaseDesignIntf::updateItemSize(dataManager, pass, maxHeight);
}
QColor BandDesignIntf::selectionColor() const

View File

@ -30,6 +30,7 @@
#ifndef LRBANDDESIGNINTF_H
#define LRBANDDESIGNINTF_H
#include "lrbasedesignintf.h"
#include "lrdatasourcemanager.h"
#include <QObject>
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{

View File

@ -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<BaseDesignIntf *>(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<BaseDesignIntf*> 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<BaseDesignIntf*>(parentItem());
PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(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<BaseDesignIntf*>(parentItem());
PageItemDesignIntf* parentPage = dynamic_cast<PageItemDesignIntf*>(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<BaseDesignIntf*>(value.value<QGraphicsItem*>()));
}
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()<<error.what();
}

View File

@ -61,6 +61,8 @@ private:
};
class DataSourceManager;
class BaseDesignIntf :
public QObject, public QGraphicsItem, public ICollectionContainer, public ObjectLoadingStateIntf {
Q_OBJECT
@ -68,12 +70,14 @@ class BaseDesignIntf :
Q_ENUMS(BGMode)
Q_ENUMS(Qt::BrushStyle)
Q_ENUMS(BrushMode)
Q_ENUMS(ItemAlign)
Q_FLAGS(BorderLines)
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometryProperty NOTIFY geometryChanged)
Q_PROPERTY(ACollectionProperty children READ fakeCollectionReader DESIGNABLE false)
Q_PROPERTY(qreal zOrder READ zValue WRITE setZValueProperty DESIGNABLE false)
Q_PROPERTY(BorderLines borders READ borderLines WRITE setBorderLinesFlags)
Q_PROPERTY(QString parentName READ parentReportItem WRITE setParentReportItem DESIGNABLE false)
Q_PROPERTY(ItemAlign itemAlign READ itemAlign WRITE setItemAlign)
public:
enum BGMode { TransparentMode,OpaqueMode};
enum BrushMode{Solid,None};
@ -94,6 +98,7 @@ public:
RightLine = 8
};
enum ObjectState {ObjectLoading, ObjectLoaded, ObjectCreated};
enum ItemAlign {LeftItemAlign,RightItemAlign,CenterItemAlign,ParentWidthItemAlign,DesignedItemAlign};
Q_DECLARE_FLAGS(BorderLines, BorderSide)
Q_DECLARE_FLAGS(ItemMode,ItemModes)
public:
@ -170,7 +175,7 @@ public:
QString storageTypeName() const {return m_storageTypeName;}
ReportEnginePrivate *reportEditor();
virtual void updateItemSize(RenderPass pass=FirstPass,int maxHeight=0);
virtual void updateItemSize(DataSourceManager* dataManager, RenderPass pass=FirstPass, int maxHeight=0);
virtual bool isNeedUpdateSize(RenderPass) const;
virtual BaseDesignIntf* cloneItem(LimeReport::BaseDesignIntf::ItemMode mode, QObject* owner=0, QGraphicsItem* parent=0);
virtual BaseDesignIntf* cloneItemWOChild(LimeReport::BaseDesignIntf::ItemMode mode, QObject* owner=0, QGraphicsItem* parent=0);
@ -192,7 +197,6 @@ public:
virtual void parentObjectLoadFinished();
virtual void beforeDelete();
QList<BaseDesignIntf*> 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<QString> propertyNames);
void itemAlignChanged(BaseDesignIntf* item, const ItemAlign& oldValue, const ItemAlign& newValue);
};
} //namespace LimeReport

View File

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

View File

@ -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<FieldMapDesc*> *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<FieldMapDesc*>* 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:

View File

@ -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<CountGroupFunction>);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("SUM"),new ConstructorGroupFunctionCreator<SumGroupFunction>);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("AVG"),new ConstructorGroupFunctionCreator<AvgGroupFunction>);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("MIN"),new ConstructorGroupFunctionCreator<MinGroupFunction>);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("MAX"),new ConstructorGroupFunctionCreator<MaxGroupFunction>);
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<QString,QString> &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<QueryHolder*>(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<ProxyHolder*>(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<QueryHolder*>(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<QueryHolder*>(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);
}
}

View File

@ -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<QString,IDataSourceHolder*> 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<ConnectionDesc*> m_connections;
QList<QueryDesc*> m_queries;
QList<SubQueryDesc*> m_subqueries;

View File

@ -113,23 +113,22 @@ void ItemDesignIntf::initFlags()
}
}
QString ContentItemDesignIntf::expandDataFields(QString context, ExpandType expandType)
QString ContentItemDesignIntf::expandDataFields(QString context, ExpandType expandType, DataSourceManager* dataManager)
{
DataSourceManager* dm = DataSourceManager::instance();
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; i<scriptExtractor.count();++i){
QString scriptBody = expandDataFields(scriptExtractor.bodyAt(i),EscapeSymbols);
scriptBody = expandUserVariables(scriptBody,FirstPass, EscapeSymbols);
QString scriptBody = expandDataFields(scriptExtractor.bodyAt(i),EscapeSymbols, dataManager);
scriptBody = expandUserVariables(scriptBody, FirstPass, EscapeSymbols, dataManager);
QScriptValue value = se->evaluate(scriptBody);
if (!se->hasUncaughtException()) {
context.replace(scriptExtractor.scriptAt(i),value.toString());

View File

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

View File

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

View File

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

View File

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

View File

@ -84,7 +84,7 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) {
QWheelEvent* wheel_event = static_cast<QWheelEvent*>(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;

View File

@ -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<QDockWidget *> dockWidgets = findChildren<QDockWidget *>();
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<QDockWidget *> dockWidgets = findChildren<QDockWidget *>();
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<QDockWidget *> dockWidgets = findChildren<QDockWidget *>();
foreach (QDockWidget* dw, dockWidgets) {
if (dockWidgetArea(dw) == area)
value ? dw->show(): dw->hide();
}
}
void ReportDesignWindow::slotHideLeftPanel(bool value)
{
hideDockWidgets(Qt::LeftDockWidgetArea,value);

View File

@ -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<QPrinter> m_printer;
bool m_printerSelected;
bool m_showProgressDialog;
};
}

View File

@ -31,6 +31,7 @@
#include <QMessageBox>
#include <QApplication>
#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;i<m_patternPageItem->dataBandCount() && !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<ContentItemDesignIntf*>(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<ContentItemDesignIntf*>(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 (percent<bandClone->maxScalePercent()){
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<BandDesignIntf*>(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<IGroupBand*>(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<IGroupBand*>(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<qreal> vector){
qreal curValue = 0;
foreach (qreal value, vector) {
if (curValue<value) curValue=value;
}
return curValue;
}
qreal minVectorValue(QVector<qreal> 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;i<band->columnsCount();++i){
m_maxHeightByColumn.append(m_maxHeightByColumn[0]);
m_currentStartDataPos.append(m_currentStartDataPos[0]);
}
m_currentColumn = 0;
} else {
if (band->columnsFillDirection()==BandDesignIntf::Horizontal){
if (m_currentColumn<band->columnsCount()-1)
m_currentColumn = m_currentColumn+1;
else
m_currentColumn = 0;
}
}
}
if (band->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<DataBandDesignIntf*>(band);
if (isLast && data && data->keepFooterTogether() &&
band->height()<m_currentMaxHeight && band->sliceLastRow()
band->height()<m_maxHeightByColumn[m_currentColumn] && band->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; i<m_renderedPages.count(); ++i){
PageItemDesignIntf::Ptr page = m_renderedPages.at(i);
m_datasources->setReportVariable("#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));

View File

@ -57,12 +57,17 @@ private:
typedef QList<PageItemDesignIntf::Ptr> 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<ReportRender> 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<QString,QVariant> m_popupedValues;
QMultiMap<BandDesignIntf*,QString> 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<qreal> m_maxHeightByColumn;
QVector<qreal> m_currentStartDataPos;
int m_currentColumn;
QList<PagesRange> m_ranges;
};
} // namespace LimeReport
#endif // LRREPORTRENDER_H

View File

@ -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();
ScriptEngineManager* sm = qscriptvalue_cast<ScriptEngineManager*>(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<ScriptEngineManager*>(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<ScriptFunctionDesc> 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)

View File

@ -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<ScriptEngineManager>;
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<ScriptFunctionDesc>& 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<ScriptFunctionDesc> m_functions;
ScriptEngineModel* m_model;
DataSourceManager* m_dataManager;
};
class ScriptExtractor

View File

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

View File

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

Binary file not shown.

File diff suppressed because it is too large Load Diff