19#include "KReportDesignerSectionDetailGroup.h"
20#include "KReportDesigner.h"
21#include "KReportDesignerSection.h"
22#include "KReportDesignerSectionDetail.h"
23#include "KReportUtils.h"
24#include "kreport_debug.h"
27#include <QDomDocument>
44 KReportDesignerSection *groupHeader;
45 KReportDesignerSection *groupFooter;
46 KReportDesignerSectionDetail * reportSectionDetail;
47 KReportDesignerSectionDetailGroup::PageBreak pageBreak = KReportDesignerSectionDetailGroup::PageBreak::None;
57 d->reportSectionDetail = rsd;
58 if (!d->reportSectionDetail) {
59 kreportWarning() <<
"Error: ReportSectionDetail is null";
65 setGroupHeaderVisible(
false);
66 setGroupFooterVisible(
false);
70KReportDesignerSectionDetailGroup::~KReportDesignerSectionDetailGroup()
77 QDomElement grp = doc->
createElement(QLatin1String(
"report:group"));
79 grp.
setAttribute(QLatin1String(
"report:group-column"), column());
80 if (pageBreak() == KReportDesignerSectionDetailGroup::PageBreak::AfterGroupFooter) {
81 grp.
setAttribute(QLatin1String(
"report:group-page-break"), QLatin1String(
"after-footer"));
82 }
else if (pageBreak() == KReportDesignerSectionDetailGroup::PageBreak::BeforeGroupHeader) {
83 grp.
setAttribute(QLatin1String(
"report:group-page-break"), QLatin1String(
"before-header"));
87 grp.
setAttribute(QLatin1String(
"report:group-sort"), QLatin1String(
"ascending"));
90 grp.
setAttribute(QLatin1String(
"report:group-sort"), QLatin1String(
"descending"));
94 if (groupHeaderVisible()) {
95 QDomElement gheader = doc->
createElement(QLatin1String(
"report:section"));
96 gheader.
setAttribute(QLatin1String(
"report:section-type"), QLatin1String(
"group-header"));
97 groupHeader()->buildXML(doc, &gheader);
101 if (groupFooterVisible()) {
102 QDomElement gfooter = doc->
createElement(QLatin1String(
"report:section"));
103 gfooter.
setAttribute(QLatin1String(
"report:section-type"), QLatin1String(
"group-footer"));
104 groupFooter()->buildXML(doc, &gfooter);
110void KReportDesignerSectionDetailGroup::initFromXML(
const QDomElement &element )
112 if ( element.
hasAttribute(QLatin1String(
"report:group-column") ) ) {
113 setColumn( element.
attribute( QLatin1String(
"report:group-column") ) );
116 if ( element.
hasAttribute( QLatin1String(
"report:group-page-break") ) ) {
117 QString s = element.
attribute( QLatin1String(
"report:group-page-break") );
118 if ( s == QLatin1String(
"after-footer") ) {
119 setPageBreak( KReportDesignerSectionDetailGroup::PageBreak::AfterGroupFooter );
120 }
else if ( s == QLatin1String(
"before-header") ) {
121 setPageBreak( KReportDesignerSectionDetailGroup::PageBreak::BeforeGroupHeader );
125 if (element.
attribute(QLatin1String(
"report:group-sort"), QLatin1String(
"ascending")) == QLatin1String(
"ascending")) {
132 for ( QDomElement e = element.
firstChildElement( QLatin1String(
"report:section") ); ! e.
isNull(); e = e.nextSiblingElement( QLatin1String(
"report:section") ) ) {
133 const QString s = KReportUtils::readSectionTypeNameAttribute(e);
134 if ( s == QLatin1String(
"group-header") ) {
135 setGroupHeaderVisible(
true );
136 d->groupHeader->initFromXML( e );
137 }
else if ( s == QLatin1String(
"group-footer") ) {
138 setGroupFooterVisible(
true );
139 d->groupFooter->initFromXML( e );
144void KReportDesignerSectionDetailGroup::setGroupHeaderVisible(
bool visible)
146 if (groupHeaderVisible() != visible) {
147 if (d->reportSectionDetail && d->reportSectionDetail->reportDesigner()) {
148 d->reportSectionDetail->reportDesigner()->setModified(
true);
151 d->groupHeader->setVisible(visible);
152 if (d->reportSectionDetail) {
153 d->reportSectionDetail->adjustSize();
157void KReportDesignerSectionDetailGroup::setGroupFooterVisible(
bool visible)
159 if (groupFooterVisible() != visible) {
160 if (d->reportSectionDetail && d->reportSectionDetail->reportDesigner()) {
161 d->reportSectionDetail->reportDesigner()->setModified(
true);
164 d->groupFooter->setVisible(visible);
165 if (d->reportSectionDetail) {
166 d->reportSectionDetail->adjustSize();
170void KReportDesignerSectionDetailGroup::setPageBreak(KReportDesignerSectionDetailGroup::PageBreak pb)
175void KReportDesignerSectionDetailGroup::setSort(
Qt::SortOrder s)
186bool KReportDesignerSectionDetailGroup::groupHeaderVisible()
const
189 return ! d->groupHeader->isHidden();
191bool KReportDesignerSectionDetailGroup::groupFooterVisible()
const
194 return ! d->groupFooter->isHidden();
196KReportDesignerSectionDetailGroup::PageBreak KReportDesignerSectionDetailGroup::pageBreak()
const
201QString KReportDesignerSectionDetailGroup::column()
const
205void KReportDesignerSectionDetailGroup::setColumn(
const QString & s)
207 if (d->column != s) {
209 if (d->reportSectionDetail && d->reportSectionDetail->reportDesigner()) d->reportSectionDetail->reportDesigner()->setModified(
true);
212 d->groupHeader->setTitle(d->column + QLatin1String(
" Group Header"));
213 d->groupFooter->setTitle(d->column + QLatin1String(
" Group Footer"));
218 return d->groupHeader;
222 return d->groupFooter;
A section group allows a header and footer to be used for a particular report field.
The central detail section which contains the bulk of the report.
This class is the base to all Report Section's visual representation.
The ReportDesigner is the main widget for designing a report.
KReportDesignerSection * createSection()
Creates new section.
QDomElement createElement(const QString &tagName)
QString attribute(const QString &name, const QString &defValue) const const
bool hasAttribute(const QString &name) const const
void setAttribute(const QString &name, const QString &value)
QDomNode appendChild(const QDomNode &newChild)
QDomElement firstChildElement(const QString &tagName, const QString &namespaceURI) const const
bool isNull() const const