mirror of
https://github.com/fralx/LimeReport.git
synced 2025-11-25 00:18:06 +03:00
Define code style and format all source file using clang-format-14
except those placed in 3rdparty directories.
This commit is contained in:
@@ -28,131 +28,130 @@
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrgroupbands.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTagHeader = QLatin1String("GroupHeader");
|
||||
const QString xmlTagFooter = QLatin1String("GroupFooter");
|
||||
|
||||
namespace{
|
||||
namespace {
|
||||
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::GroupBandHeader(owner,parent);
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::GroupBandHeader(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG),
|
||||
createHeader
|
||||
);
|
||||
bool VARIABLE_IS_NOT_USED registredHeader
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"), LimeReport::Const::bandTAG),
|
||||
createHeader);
|
||||
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::GroupBandFooter(owner,parent);
|
||||
LimeReport::BaseDesignIntf* createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent)
|
||||
{
|
||||
return new LimeReport::GroupBandFooter(owner, parent);
|
||||
}
|
||||
|
||||
bool VARIABLE_IS_NOT_USED registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
bool VARIABLE_IS_NOT_USED registredFooter
|
||||
= LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"), LimeReport::Const::bandTAG),
|
||||
createFooter);
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
namespace LimeReport {
|
||||
|
||||
GroupBandHeader::GroupBandHeader(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner,parent),
|
||||
m_groupFiledName(""), m_groupStarted(false), m_resetPageNumber(false)
|
||||
GroupBandHeader::GroupBandHeader(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner, parent),
|
||||
m_groupFiledName(""),
|
||||
m_groupStarted(false),
|
||||
m_resetPageNumber(false)
|
||||
{
|
||||
setBandTypeText(tr("GroupHeader"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool GroupBandHeader::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool GroupBandHeader::isUnique() const { return false; }
|
||||
|
||||
//bool GroupBandHeader::tryToKeepTogether()
|
||||
// bool GroupBandHeader::tryToKeepTogether()
|
||||
//{
|
||||
// return m_tryToKeepTogether;
|
||||
//}
|
||||
|
||||
BaseDesignIntf *GroupBandHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
BaseDesignIntf* GroupBandHeader::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return new GroupBandHeader(owner, parent);
|
||||
}
|
||||
|
||||
void GroupBandHeader::startGroup(DataSourceManager* dataManager)
|
||||
{
|
||||
m_groupStarted=true;
|
||||
m_groupStarted = true;
|
||||
|
||||
QString lineVar = QLatin1String("line_")+objectName().toLower();
|
||||
dataManager->setReportVariable(lineVar,1);
|
||||
QString lineVar = QLatin1String("line_") + objectName().toLower();
|
||||
dataManager->setReportVariable(lineVar, 1);
|
||||
|
||||
QString datasourceName = findDataSourceName(parentBand());
|
||||
if (dataManager->containsDatasource(datasourceName)){
|
||||
if (dataManager->containsDatasource(datasourceName)) {
|
||||
IDataSource* ds = dataManager->dataSource(datasourceName);
|
||||
if (ds && ds->columnIndexByName(m_groupFiledName)!=-1)
|
||||
m_groupFieldValue=ds->data(m_groupFiledName);
|
||||
if (ds && ds->columnIndexByName(m_groupFiledName) != -1)
|
||||
m_groupFieldValue = ds->data(m_groupFiledName);
|
||||
}
|
||||
|
||||
if (!m_condition.isEmpty()) m_conditionValue = calcCondition(dataManager);
|
||||
if (!m_condition.isEmpty())
|
||||
m_conditionValue = calcCondition(dataManager);
|
||||
}
|
||||
|
||||
QColor GroupBandHeader::bandColor() const
|
||||
QColor GroupBandHeader::bandColor() const { return QColor(Qt::darkBlue); }
|
||||
|
||||
QString GroupBandHeader::findDataSourceName(BandDesignIntf* parentBand)
|
||||
{
|
||||
return QColor(Qt::darkBlue);
|
||||
}
|
||||
|
||||
QString GroupBandHeader::findDataSourceName(BandDesignIntf* parentBand){
|
||||
if (!parentBand) return "";
|
||||
if (!parentBand)
|
||||
return "";
|
||||
if (!parentBand->datasourceName().isEmpty())
|
||||
return parentBand->datasourceName();
|
||||
else
|
||||
return findDataSourceName(parentBand->parentBand());
|
||||
|
||||
}
|
||||
|
||||
QString GroupBandHeader::condition() const
|
||||
QString GroupBandHeader::condition() const { return m_condition; }
|
||||
|
||||
void GroupBandHeader::setCondition(const QString& condition) { m_condition = condition; }
|
||||
|
||||
QString GroupBandHeader::calcCondition(DataSourceManager* dataManager)
|
||||
{
|
||||
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);
|
||||
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()) && condition().isEmpty()){
|
||||
if (!m_groupStarted)
|
||||
return false;
|
||||
if ((m_groupFiledName.isNull() || m_groupFiledName.isEmpty()) && condition().isEmpty()) {
|
||||
dataManager->putError(tr("Group field not found"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_condition.isEmpty()){
|
||||
if (!m_condition.isEmpty()) {
|
||||
return m_conditionValue != calcCondition(dataManager);
|
||||
} else {
|
||||
QString datasourceName = findDataSourceName(parentBand());
|
||||
if (dataManager->containsDatasource(datasourceName)){
|
||||
if (dataManager->containsDatasource(datasourceName)) {
|
||||
IDataSource* ds = dataManager->dataSource(datasourceName);
|
||||
if (ds){
|
||||
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull()) return false;
|
||||
if (!ds->data(m_groupFiledName).isValid()) return false;
|
||||
return ds->data(m_groupFiledName)!=m_groupFieldValue;
|
||||
if (ds) {
|
||||
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull())
|
||||
return false;
|
||||
if (!ds->data(m_groupFiledName).isValid())
|
||||
return false;
|
||||
return ds->data(m_groupFiledName) != m_groupFieldValue;
|
||||
}
|
||||
} else {
|
||||
dataManager->putError(tr("Datasource \"%1\" not found!").arg(datasourceName));
|
||||
@@ -164,62 +163,47 @@ bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
|
||||
|
||||
bool GroupBandHeader::isStarted()
|
||||
{
|
||||
return m_groupStarted;//!m_groupFieldValue.isNull();
|
||||
return m_groupStarted; //! m_groupFieldValue.isNull();
|
||||
}
|
||||
|
||||
void GroupBandHeader::closeGroup()
|
||||
{
|
||||
m_groupFieldValue=QVariant();
|
||||
m_conditionValue="";
|
||||
m_groupStarted=false;
|
||||
m_groupFieldValue = QVariant();
|
||||
m_conditionValue = "";
|
||||
m_groupStarted = false;
|
||||
}
|
||||
|
||||
int GroupBandHeader::index()
|
||||
{
|
||||
return bandIndex();
|
||||
}
|
||||
int GroupBandHeader::index() { return bandIndex(); }
|
||||
|
||||
bool GroupBandHeader::startNewPage() const
|
||||
{
|
||||
return BandDesignIntf::startNewPage();
|
||||
}
|
||||
bool GroupBandHeader::startNewPage() const { return BandDesignIntf::startNewPage(); }
|
||||
|
||||
void GroupBandHeader::setStartNewPage(bool startNewPage)
|
||||
{
|
||||
BandDesignIntf::setStartNewPage(startNewPage);
|
||||
}
|
||||
|
||||
bool GroupBandHeader::resetPageNumber() const
|
||||
{
|
||||
return m_resetPageNumber;
|
||||
}
|
||||
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)
|
||||
GroupBandFooter::GroupBandFooter(QObject* owner, QGraphicsItem* parent):
|
||||
BandDesignIntf(BandDesignIntf::GroupFooter, xmlTagFooter, owner, parent)
|
||||
{
|
||||
setBandTypeText(tr("GroupFooter"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool GroupBandFooter::isUnique() const
|
||||
bool GroupBandFooter::isUnique() const { return false; }
|
||||
|
||||
QColor GroupBandFooter::bandColor() const { return QColor(Qt::darkBlue); }
|
||||
|
||||
BaseDesignIntf* GroupBandFooter::createSameTypeItem(QObject* owner, QGraphicsItem* parent)
|
||||
{
|
||||
return false;
|
||||
return new GroupBandFooter(owner, parent);
|
||||
}
|
||||
|
||||
QColor GroupBandFooter::bandColor() const
|
||||
{
|
||||
return QColor(Qt::darkBlue);
|
||||
}
|
||||
|
||||
BaseDesignIntf *GroupBandFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new GroupBandFooter(owner,parent);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
||||
} // namespace LimeReport
|
||||
|
||||
Reference in New Issue
Block a user