mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-09-23 08:39:07 +03:00
Calculated condition has been added to group band header
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
|
||||
|
||||
const QString xmlTagHeader = QLatin1String("GroupHeader");
|
||||
const QString xmlTagFooter = QLatin1String("GroupFooter");
|
||||
|
||||
@@ -98,6 +97,8 @@ void GroupBandHeader::startGroup(DataSourceManager* dataManager)
|
||||
if (ds && ds->columnIndexByName(m_groupFiledName)!=-1)
|
||||
m_groupFieldValue=ds->data(m_groupFiledName);
|
||||
}
|
||||
|
||||
if (!m_condition.isEmpty()) m_conditionValue = calcCondition(dataManager);
|
||||
}
|
||||
|
||||
QColor GroupBandHeader::bandColor() const
|
||||
@@ -114,20 +115,47 @@ QString GroupBandHeader::findDataSourceName(BandDesignIntf* parentBand){
|
||||
|
||||
}
|
||||
|
||||
QString GroupBandHeader::condition() const
|
||||
{
|
||||
return m_condition;
|
||||
}
|
||||
|
||||
void GroupBandHeader::setCondition(const QString &condition)
|
||||
{
|
||||
m_condition = condition;
|
||||
}
|
||||
|
||||
QString GroupBandHeader::calcCondition(DataSourceManager* dataManager){
|
||||
QString result = m_condition;
|
||||
if (!m_condition.isEmpty()){
|
||||
result=expandUserVariables(result, FirstPass, NoEscapeSymbols, dataManager);
|
||||
result=expandScripts(result, dataManager);
|
||||
result=expandDataFields(result, NoEscapeSymbols, dataManager);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
|
||||
{
|
||||
if (!m_groupStarted) return false;
|
||||
if (m_groupFiledName.isNull() || m_groupFiledName.isEmpty())
|
||||
if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()){
|
||||
dataManager->putError(tr("Group field not found"));
|
||||
QString datasourceName = findDataSourceName(parentBand());
|
||||
if (dataManager->containsDatasource(datasourceName)){
|
||||
IDataSource* ds = dataManager->dataSource(datasourceName);
|
||||
if (ds){
|
||||
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull()) return false;
|
||||
return ds->data(m_groupFiledName)!=m_groupFieldValue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_condition.isEmpty()){
|
||||
return m_conditionValue != calcCondition(dataManager);
|
||||
} else {
|
||||
dataManager->putError(tr("Datasource \"%1\" not found !!!").arg(datasourceName));
|
||||
QString datasourceName = findDataSourceName(parentBand());
|
||||
if (dataManager->containsDatasource(datasourceName)){
|
||||
IDataSource* ds = dataManager->dataSource(datasourceName);
|
||||
if (ds){
|
||||
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull()) return false;
|
||||
return ds->data(m_groupFiledName)!=m_groupFieldValue;
|
||||
}
|
||||
} else {
|
||||
dataManager->putError(tr("Datasource \"%1\" not found !!!").arg(datasourceName));
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -141,6 +169,7 @@ bool GroupBandHeader::isStarted()
|
||||
void GroupBandHeader::closeGroup()
|
||||
{
|
||||
m_groupFieldValue=QVariant();
|
||||
m_conditionValue="";
|
||||
m_groupStarted=false;
|
||||
}
|
||||
|
||||
|
@@ -43,6 +43,7 @@ class GroupBandHeader : public BandDesignIntf, public IGroupBand{
|
||||
Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage)
|
||||
Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber)
|
||||
Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage)
|
||||
Q_PROPERTY(QString condition READ condition WRITE setCondition)
|
||||
public:
|
||||
GroupBandHeader(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
virtual bool isUnique() const;
|
||||
@@ -57,6 +58,8 @@ public:
|
||||
void setResetPageNumber(bool resetPageNumber);
|
||||
bool isHeader() const{return true;}
|
||||
bool isGroupHeader() const {return true;}
|
||||
QString condition() const;
|
||||
void setCondition(const QString &condition);
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
void startGroup(DataSourceManager* dataManager);
|
||||
@@ -65,12 +68,15 @@ private:
|
||||
void closeGroup();
|
||||
int index();
|
||||
QString findDataSourceName(BandDesignIntf *parentBand);
|
||||
QString calcCondition(DataSourceManager *dataManager);
|
||||
private:
|
||||
QVariant m_groupFieldValue;
|
||||
QString m_groupFiledName;
|
||||
bool m_groupStarted;
|
||||
//bool m_startNewPage;
|
||||
bool m_resetPageNumber;
|
||||
QString m_condition;
|
||||
QString m_conditionValue;
|
||||
};
|
||||
|
||||
class GroupBandFooter : public BandDesignIntf{
|
||||
|
Reference in New Issue
Block a user