19#include "KReportDesignerSectionDetail.h"
20#include "KReportDesignerSectionDetailGroup.h"
21#include "KReportDesignerSection.h"
22#include "KReportDesigner.h"
23#include "KReportUtils.h"
24#include "kreport_debug.h"
27#include <QDomDocument>
40 KReportDesignerSection *detail;
41 KReportDesigner *reportDesigner;
42 QList<KReportDesignerSectionDetailGroup*> groupList;
43 QVBoxLayout *vboxlayout;
44 KReportDesignerSectionDetail::PageBreak pageBreak = KReportDesignerSectionDetail::PageBreak::None;
47KReportDesignerSectionDetail::KReportDesignerSectionDetail(
KReportDesigner * rptdes)
54 d->vboxlayout->setSpacing(0);
55 d->vboxlayout->setMargin(0);
56 d->reportDesigner = rptdes;
58 d->vboxlayout->addWidget(d->detail);
60 this->setLayout(d->vboxlayout);
63KReportDesignerSectionDetail::~KReportDesignerSectionDetail()
68KReportDesignerSectionDetail::PageBreak KReportDesignerSectionDetail::pageBreak()
const
72void KReportDesignerSectionDetail::setPageBreak(PageBreak pb)
84 if (pageBreak() != KReportDesignerSectionDetail::PageBreak::None) {
85 QDomElement spagebreak = doc->
createElement(QLatin1String(
"pagebreak"));
86 if (pageBreak() == KReportDesignerSectionDetail::PageBreak::AtEnd)
87 spagebreak.
setAttribute(QLatin1String(
"when"), QLatin1String(
"at end"));
91 foreach(KReportDesignerSectionDetailGroup* rsdg, d->groupList) {
92 rsdg->buildXML(doc, section);
96 QDomElement gdetail = doc->
createElement(QLatin1String(
"report:section"));
97 gdetail.
setAttribute(QLatin1String(
"report:section-type"), QLatin1String(
"detail"));
98 d->detail->buildXML(doc, &gdetail);
108 for (
int i = 0; i < nl.
count(); i++) {
115 setPageBreak(PageBreak::AtEnd);
119 insertGroupSection(groupSectionCount(), rsdg);
124 d->detail->initFromXML(node);
127 kreportWarning() <<
"while parsing section encountered and unknown element: " << n;
135 return d->reportDesigner;
138int KReportDesignerSectionDetail::groupSectionCount()
const
140 return d->groupList.count();
145 return d->groupList.at(i);
150 d->groupList.insert(idx, rsd);
157 for (gi = 0; gi < (int) d->groupList.count(); gi++) {
158 rsd = d->groupList.at(gi);
159 d->vboxlayout->removeWidget(rsd->groupHeader());
160 d->vboxlayout->insertWidget(idx, rsd->groupHeader());
163 d->vboxlayout->removeWidget(d->detail);
164 d->vboxlayout->insertWidget(idx, d->detail);
166 for (gi = ((
int) d->groupList.count() - 1); gi >= 0; --gi) {
167 rsd = d->groupList.at(gi);
168 d->vboxlayout->removeWidget(rsd->groupFooter());
169 d->vboxlayout->insertWidget(idx, rsd->groupFooter());
173 if (d->reportDesigner) d->reportDesigner->setModified(
true);
177int KReportDesignerSectionDetail::indexOfGroupSection(
const QString & column)
const
180 for (uint i = 0; i < (uint)d->groupList.count(); i++) {
181 KReportDesignerSectionDetailGroup * rsd = d->groupList.at(i);
182 if (column == rsd->column())
return i;
187void KReportDesignerSectionDetail::removeGroupSection(
int idx,
bool del)
189 KReportDesignerSectionDetailGroup * rsd = d->groupList.at(idx);
191 d->vboxlayout->removeWidget(rsd->groupHeader());
192 d->vboxlayout->removeWidget(rsd->groupFooter());
194 d->groupList.removeAt(idx);
196 if (d->reportDesigner) d->reportDesigner->setModified(
true);
201QSize KReportDesignerSectionDetail::sizeHint()
const
204 foreach(KReportDesignerSectionDetailGroup* rsdg, d->groupList) {
205 if (rsdg->groupHeaderVisible()) s += rsdg->groupHeader()->
size();
206 if (rsdg->groupFooterVisible()) s += rsdg->groupFooter()->
size();
208 return s += d->detail->size();
211void KReportDesignerSectionDetail::setSectionCursor(
const QCursor& c)
214 d->detail->setSectionCursor(c);
215 foreach(KReportDesignerSectionDetailGroup* rsdg, d->groupList) {
216 if (rsdg->groupHeader())
217 rsdg->groupHeader()->setSectionCursor(c);
218 if (rsdg->groupFooter())
219 rsdg->groupFooter()->setSectionCursor(c);
223void KReportDesignerSectionDetail::unsetSectionCursor()
226 d->detail->unsetSectionCursor();
228 foreach(KReportDesignerSectionDetailGroup* rsdg, d->groupList) {
229 if (rsdg->groupHeader())
230 rsdg->groupHeader()->unsetSectionCursor();
231 if (rsdg->groupFooter())
232 rsdg->groupFooter()->unsetSectionCursor();
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.
void initFromXML(QDomNode *node)
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.
QString name(StandardAction id)
QDomElement createElement(const QString &tagName)
QString attribute(const QString &name, const QString &defValue) const const
void setAttribute(const QString &name, const QString &value)
QDomNode appendChild(const QDomNode &newChild)
QDomNodeList childNodes() const const
QString nodeName() const const
QDomElement toElement() const const
QDomNode item(int index) const const