diff --git a/src/common/KReportDocument.cpp b/src/common/KReportDocument.cpp
index 968e1a07..98219776 100644
--- a/src/common/KReportDocument.cpp
+++ b/src/common/KReportDocument.cpp
@@ -1,388 +1,384 @@
/* This file is part of the KDE project
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDocument.h"
#include "KReportUnit.h"
#include "KReportDetailSectionData.h"
#include "KReportItemBase.h"
#include "KReportUtils_p.h"
#include "KReportPageSize.h"
#include
#include
#include "kreport_debug.h"
class Q_DECL_HIDDEN KReportDocument::Private
{
public:
bool valid;
QString title;
QString name;
QString query;
#ifdef KREPORT_SCRIPTING
QString script;
QString interpreter;
#endif
bool externalData;
QPageLayout page;
QString pageSize;
QString labelType;
};
void KReportDocument::init()
{
m_pageHeaderFirst = m_pageHeaderOdd = m_pageHeaderEven = m_pageHeaderLast = m_pageHeaderAny = 0;
m_pageFooterFirst = m_pageFooterOdd = m_pageFooterEven = m_pageFooterLast = m_pageFooterAny = 0;
m_reportHeader = m_reportFooter = 0;
}
KReportDocument::KReportDocument(QObject *parent)
: QObject(parent),
m_detailSection(0),
d(new Private())
{
init();
d->valid = true;
}
KReportDocument::KReportDocument(const QDomElement & elemSource, QObject *parent)
: QObject(parent),
m_detailSection(0),
d(new Private())
{
d->valid = false;
init();
//kreportDebug();
if (elemSource.tagName() != QLatin1String("report:content")) {
kreportWarning() << "QDomElement is not tag"
<< elemSource.text();
return;
}
- const qreal dpiX = KReportPrivate::dpiX();
- const qreal dpiY = KReportPrivate::dpiY();
-
-
QDomNodeList sections = elemSource.childNodes();
for (int nodeCounter = 0; nodeCounter < sections.count(); nodeCounter++) {
QDomElement elemThis = sections.item(nodeCounter).toElement();
if (elemThis.tagName() == QLatin1String("report:title")) {
d->title = elemThis.text();
#ifdef KREPORT_SCRIPTING
} else if (elemThis.tagName() == QLatin1String("report:script")) {
d->script = elemThis.text();
d->interpreter = elemThis.attribute(QLatin1String("report:script-interpreter"));
#endif
} else if (elemThis.tagName() == QLatin1String("report:page-style")) {
QString pagetype = elemThis.firstChild().nodeValue();
//Full page mode is required to allow margins to be set to whatever the user has specified
d->page.setMode(QPageLayout::FullPageMode);
if (pagetype == QLatin1String("predefined")) {
setPageSize(elemThis.attribute(QLatin1String("report:page-size"), QLatin1String("A4")));
d->page.setPageSize(QPageSize(KReportPageSize::pageSize(pageSize())));
} else if (pagetype == QLatin1String("custom")) {
QPageSize custom(QSize(elemThis.attribute(QLatin1String("report:custom-page-width"), QString()).toFloat() , elemThis.attribute(QLatin1String("report:custom-page-height"), QString()).toFloat()), QLatin1String("Custom"));
d->page.setPageSize(custom);
} else if (pagetype == QLatin1String("label")) {
setLabelType(elemThis.firstChild().nodeValue());
}
//! @todo add config for default margins or add within templates support
d->page.setUnits(QPageLayout::Point);
d->page.setLeftMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-left"), QLatin1String("1.0cm"))));
d->page.setRightMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-right"), QLatin1String("1.0cm"))));
d->page.setTopMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-top"), QLatin1String("1.0cm"))));
d->page.setBottomMargin(KReportUnit::parseValue(elemThis.attribute(QLatin1String("fo:margin-bottom"), QLatin1String("1.0cm"))));
d->page.setOrientation(elemThis.attribute(QLatin1String("report:print-orientation"), QLatin1String("portrait")) == QLatin1String("portrait") ? QPageLayout::Portrait : QPageLayout::Landscape);
} else if (elemThis.tagName() == QLatin1String("report:body")) {
QDomNodeList sectionlist = elemThis.childNodes();
QDomNode sec;
for (int s = 0; s < sectionlist.count(); ++s) {
sec = sectionlist.item(s);
if (sec.isElement()) {
QString sn = sec.nodeName().toLower();
//kreportDebug() << sn;
if (sn == QLatin1String("report:section")) {
KReportSectionData * sd = new KReportSectionData(sec.toElement(), this);
if (!sd->isValid()) {
kreportDebug() << "Invalid section";
delete sd;
} else {
//kreportDebug() << "Adding section of type " << sd->type();
switch (sd->type()) {
case KReportSectionData::PageHeaderFirst:
m_pageHeaderFirst = sd;
break;
case KReportSectionData::PageHeaderOdd:
m_pageHeaderOdd = sd;
break;
case KReportSectionData::PageHeaderEven:
m_pageHeaderEven = sd;
break;
case KReportSectionData::PageHeaderLast:
m_pageHeaderLast = sd;
break;
case KReportSectionData::PageHeaderAny:
m_pageHeaderAny = sd;
break;
case KReportSectionData::ReportHeader:
m_reportHeader = sd;
break;
case KReportSectionData::ReportFooter:
m_reportFooter = sd;
break;
case KReportSectionData::PageFooterFirst:
m_pageFooterFirst = sd;
break;
case KReportSectionData::PageFooterOdd:
m_pageFooterOdd = sd;
break;
case KReportSectionData::PageFooterEven:
m_pageFooterEven = sd;
break;
case KReportSectionData::PageFooterLast:
m_pageFooterLast = sd;
break;
case KReportSectionData::PageFooterAny:
m_pageFooterAny = sd;
break;
default:
;
}
}
} else if (sn == QLatin1String("report:detail")) {
KReportDetailSectionData * dsd = new KReportDetailSectionData(sec.toElement(), this);
if (dsd->isValid()) {
m_detailSection = dsd;
} else {
kreportDebug() << "Invalid detail section";
delete dsd;
}
}
} else {
kreportWarning() << "Encountered an unknown Element: " << elemThis.tagName();
}
}
}
d->valid = true;
}
}
KReportDocument::~KReportDocument()
{
delete d;
}
QList KReportDocument::objects() const
{
QList obs;
for (int i = 1; i <= KReportSectionData::PageFooterAny; i++) {
KReportSectionData *sec = section((KReportSectionData::Section)i);
if (sec) {
obs << sec->objects();
}
}
if (m_detailSection) {
//kreportDebug() << "Number of groups: " << m_detailSection->m_groupList.count();
foreach(KReportDetailGroupSectionData* g, m_detailSection->m_groupList) {
if (g->m_groupHeader) {
obs << g->m_groupHeader->objects();
}
if (g->m_groupFooter) {
obs << g->m_groupFooter->objects();
}
}
if (m_detailSection->m_detailSection)
obs << m_detailSection->m_detailSection->objects();
}
/*kreportDebug() << "Object List:";
foreach(KReportItemBase* o, obs) {
kreportDebug() << o->entityName();
}*/
return obs;
}
KReportItemBase* KReportDocument::object(const QString& n) const
{
QList obs = objects();
foreach(KReportItemBase* o, obs) {
if (o->entityName() == n) {
return o;
}
}
return 0;
}
QList KReportDocument::sections() const
{
QList secs;
for (int i = 0; i < 12 ; ++i) {
KReportSectionData *sec = section((KReportSectionData::Section)(i + 1));
if (sec) {
secs << sec;
}
}
if (m_detailSection) {
//kreportDebug() << "Number of groups: " << m_detailSection->m_groupList.count();
foreach(KReportDetailGroupSectionData* g, m_detailSection->m_groupList) {
if (g->m_groupHeader) {
secs << g->m_groupHeader;
}
if (g->m_groupFooter) {
secs << g->m_groupFooter;
}
}
if (m_detailSection->m_detailSection)
secs << m_detailSection->m_detailSection;
}
return secs;
}
KReportSectionData* KReportDocument::section(const QString& sn) const
{
QList secs = sections();
foreach(KReportSectionData *sec, secs) {
if (sec->name() == sn) {
return sec;
}
}
return 0;
}
KReportSectionData* KReportDocument::section(KReportSectionData::Section s) const
{
KReportSectionData *sec;
switch (s) {
case KReportSectionData::PageHeaderAny:
sec = m_pageHeaderAny;
break;
case KReportSectionData::PageHeaderEven:
sec = m_pageHeaderEven;
break;
case KReportSectionData::PageHeaderOdd:
sec = m_pageHeaderOdd;
break;
case KReportSectionData::PageHeaderFirst:
sec = m_pageHeaderFirst;
break;
case KReportSectionData::PageHeaderLast:
sec = m_pageHeaderLast;
break;
case KReportSectionData::PageFooterAny:
sec = m_pageFooterAny;
break;
case KReportSectionData::PageFooterEven:
sec = m_pageFooterEven;
break;
case KReportSectionData::PageFooterOdd:
sec = m_pageFooterOdd;
break;
case KReportSectionData::PageFooterFirst:
sec = m_pageFooterFirst;
break;
case KReportSectionData::PageFooterLast:
sec = m_pageFooterLast;
break;
case KReportSectionData::ReportHeader:
sec = m_reportHeader;
break;
case KReportSectionData::ReportFooter:
sec = m_reportFooter;
break;
default:
sec = 0;
}
return sec;
}
QPageLayout KReportDocument::pageLayout() const
{
return d->page;
}
bool KReportDocument::isValid() const
{
return d->valid;
}
QString KReportDocument::title() const
{
return d->title;
}
bool KReportDocument::externalData() const
{
return d->externalData;
}
QString KReportDocument::interpreter() const
{
return d->interpreter;
}
QString KReportDocument::name() const
{
return d->name;
}
void KReportDocument::setName(const QString& n)
{
d->name = n;
}
QString KReportDocument::query() const
{
return d->query;
}
QString KReportDocument::script() const
{
return d->script;
}
QString KReportDocument::pageSize()
{
return d->pageSize;
}
void KReportDocument::setPageSize(const QString& size)
{
d->pageSize = size;
}
QString KReportDocument::labelType() const
{
return d->labelType;
}
void KReportDocument::setLabelType(const QString& label)
{
d->labelType = label;
}
diff --git a/src/common/KReportElement.cpp b/src/common/KReportElement.cpp
index 92774bf4..2fa3e435 100644
--- a/src/common/KReportElement.cpp
+++ b/src/common/KReportElement.cpp
@@ -1,54 +1,54 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
* Copyright (C) 2010-2015 Jarosław Staniek
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportElement.h"
#include
#include
KReportElement::~KReportElement()
{
}
void KReportElement::setBackgroundOpacity(qreal backgroundOpacity)
{
d->backgroundOpacity = qMax(qMin(backgroundOpacity, 1.0), 0.0);
}
KREPORT_EXPORT QDebug operator<<(QDebug dbg, const KReportElement& element)
{
dbg.nospace() << qPrintable(
QString::fromLatin1("KReportElement: name=\"%1\" rect=%2 z=%3 foregroundColor=%4 "
"backgroundColor=%5 backgroundOpacity=%6")
.arg(element.name()).arg(QVariant(element.rect()).toString())
.arg(element.z()).arg(QVariant(element.foregroundColor()).toString())
.arg(QVariant(element.backgroundColor()).toString())
.arg(element.backgroundOpacity()));
return dbg.space();
}
-KREPORT_EXPORT uint qHash(const KReportElement &element, uint seed)
+KREPORT_EXPORT uint qHash(const KReportElement &element, uint seed) Q_DECL_NOTHROW
{
return qHash(element.name(), seed)
^ qHash(element.z(), seed)
^ qHash(element.rect().x(), seed)
^ qHash(element.foregroundColor().name(), seed)
^ qHash(element.backgroundColor().name(), seed)
^ qHash(qRound64(element.backgroundOpacity() * 1000.0), seed);
}
diff --git a/src/common/KReportItemBase.cpp b/src/common/KReportItemBase.cpp
index 8786513a..fe6b2ed7 100644
--- a/src/common/KReportItemBase.cpp
+++ b/src/common/KReportItemBase.cpp
@@ -1,237 +1,239 @@
/* This file is part of the KDE project
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportItemBase.h"
#include "KReportUtils.h"
#include "KReportUtils_p.h"
#include
#include
#include
class Q_DECL_HIDDEN KReportItemBase::Private
{
public:
Private();
~Private();
KPropertySet *set;
KProperty *nameProperty;
KProperty *sizeProperty;
KProperty *positionProperty;
QString oldName;
qreal z = 0;
};
KReportItemBase::Private::Private()
{
set = new KPropertySet();
nameProperty = new KProperty("name", QString(), tr("Name"), tr("Object Name"));
nameProperty->setAutoSync(0);
positionProperty = new KProperty("position", QPointF(), QCoreApplication::translate("ItemPosition", "Position"));
sizeProperty = new KProperty("size", QSizeF(), QCoreApplication::translate("ItemSize", "Size"));
set->addProperty(nameProperty);
set->addProperty(positionProperty);
set->addProperty(sizeProperty);
}
KReportItemBase::Private::~Private()
{
delete set;
}
KReportItemBase::KReportItemBase() : d(new Private())
{
connect(propertySet(), &KPropertySet::propertyChanged,
this, &KReportItemBase::propertyChanged);
}
KReportItemBase::~KReportItemBase()
{
delete d;
}
bool KReportItemBase::parseReportTextStyleData(const QDomElement & elemSource, KRTextStyleData *ts)
{
return KReportUtils::parseReportTextStyleData(elemSource, ts);
}
bool KReportItemBase::parseReportLineStyleData(const QDomElement & elemSource, KReportLineStyle *ls)
{
return KReportUtils::parseReportLineStyleData(elemSource, ls);
}
bool KReportItemBase::parseReportRect(const QDomElement & elemSource)
{
QPointF pos;
QSizeF size;
pos.setX(KReportUnit::parseValue(elemSource.attribute(QLatin1String("svg:x"), QLatin1String("1cm"))));
pos.setY(KReportUnit::parseValue(elemSource.attribute(QLatin1String("svg:y"), QLatin1String("1cm"))));
size.setWidth(KReportUnit::parseValue(elemSource.attribute(QLatin1String("svg:width"), QLatin1String("1cm"))));
size.setHeight(KReportUnit::parseValue(elemSource.attribute(QLatin1String("svg:height"), QLatin1String("1cm"))));
setPosition(pos);
setSize(size);
return true;
}
void KReportItemBase::setUnit(const KReportUnit& u)
{
qDebug() << "Setting page unit to: " << u.symbol();
d->positionProperty->setOption("unit", u.symbol());
d->sizeProperty->setOption("unit", u.symbol());
}
int KReportItemBase::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset,
const QVariant &data, KReportScriptHandler* script)
{
Q_UNUSED(page)
Q_UNUSED(section)
Q_UNUSED(offset)
Q_UNUSED(data)
Q_UNUSED(script)
return 0;
}
int KReportItemBase::renderReportData(OROPage *page, OROSection *section, const QPointF &offset,
KReportData *data, KReportScriptHandler* script)
{
Q_UNUSED(page)
Q_UNUSED(section)
Q_UNUSED(offset)
Q_UNUSED(data)
Q_UNUSED(script)
return 0;
}
QString KReportItemBase::itemDataSource() const
{
return QString();
}
KPropertySet* KReportItemBase::propertySet()
{
return d->set;
}
bool KReportItemBase::supportsSubQuery() const
{
return false;
}
QString KReportItemBase::entityName() const
{
return d->nameProperty->value().toString();
}
void KReportItemBase::setEntityName(const QString& n)
{
d->nameProperty->setValue(n);
}
KProperty* KReportItemBase::nameProperty()
{
return d->nameProperty;
}
QString KReportItemBase::oldName() const
{
return d->oldName;
}
void KReportItemBase::setOldName(const QString& old)
{
d->oldName = old;
}
QPointF KReportItemBase::position() const
{
return d->positionProperty->value().toPointF();
}
QSizeF KReportItemBase::size() const
{
return d->sizeProperty->value().toSizeF();
}
const KPropertySet * KReportItemBase::propertySet() const
{
return d->set;
}
QPointF KReportItemBase::scenePosition(const QPointF &pos)
{
const qreal x = POINT_TO_INCH(pos.x()) * KReportPrivate::dpiX();
const qreal y = POINT_TO_INCH(pos.y()) * KReportPrivate::dpiY();
return QPointF(x, y);
}
QSizeF KReportItemBase::sceneSize(const QSizeF &size)
{
const qreal w = POINT_TO_INCH(size.width()) * KReportPrivate::dpiX();
const qreal h = POINT_TO_INCH(size.height()) * KReportPrivate::dpiY();
return QSizeF(w, h);
}
qreal KReportItemBase::z() const
{
return d->z;
}
void KReportItemBase::setZ(qreal z)
{
d->z = z;
}
void KReportItemBase::setPosition(const QPointF& pos)
{
d->positionProperty->setValue(pos);
}
void KReportItemBase::setSize(const QSizeF& size)
{
d->sizeProperty->setValue(size);
}
QPointF KReportItemBase::positionFromScene(const QPointF& pos)
{
const qreal x = INCH_TO_POINT(pos.x() / KReportPrivate::dpiX());
const qreal y = INCH_TO_POINT(pos.y() / KReportPrivate::dpiY());
return QPointF(x, y);
}
QSizeF KReportItemBase::sizeFromScene(const QSizeF& size)
{
qreal w = INCH_TO_POINT(size.width() / KReportPrivate::dpiX());
qreal h = INCH_TO_POINT(size.height() / KReportPrivate::dpiY());
return QSizeF(w, h);
}
void KReportItemBase::propertyChanged(KPropertySet& s, KProperty& p)
{
+ Q_UNUSED(s)
+ Q_UNUSED(p)
}
diff --git a/src/items/check/KReportDesignerItemCheckBox.cpp b/src/items/check/KReportDesignerItemCheckBox.cpp
index 64bf63ae..7c778be8 100644
--- a/src/items/check/KReportDesignerItemCheckBox.cpp
+++ b/src/items/check/KReportDesignerItemCheckBox.cpp
@@ -1,183 +1,183 @@
/* This file is part of the KDE project
* Copyright (C) 2009-2010 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDesignerItemCheckBox.h"
#include "KReportDesignerItemRectBase.h"
#include "KReportDesigner.h"
#include "KReportLineStyle.h"
#include
#include
#include
#include
//
// class ReportEntityCheck
//
-void KReportDesignerItemCheckBox::init(QGraphicsScene *scene, KReportDesigner *d)
+void KReportDesignerItemCheckBox::init(QGraphicsScene *scene)
{
if (scene)
scene->addItem(this);
connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)),
this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
setZValue(z());
}
// methods (constructors)
KReportDesignerItemCheckBox::KReportDesignerItemCheckBox(KReportDesigner* d, QGraphicsScene * scene, const QPointF &pos)
: KReportDesignerItemRectBase(d, this)
{
Q_UNUSED(pos);
- init(scene, d);
+ init(scene);
setSceneRect(properRect(*d, KREPORT_ITEM_CHECK_DEFAULT_WIDTH, KREPORT_ITEM_CHECK_DEFAULT_HEIGHT));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
}
KReportDesignerItemCheckBox::KReportDesignerItemCheckBox(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s)
: KReportItemCheckBox(element), KReportDesignerItemRectBase(d, this)
{
- init(s, d);
+ init(s);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemCheckBox* KReportDesignerItemCheckBox::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemCheckBox(n, designer(), 0);
}
// methods (deconstructor)
KReportDesignerItemCheckBox::~KReportDesignerItemCheckBox()
{}
void KReportDesignerItemCheckBox::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
// store any values we plan on changing so we can restore them
QFont f = painter->font();
QPen p = painter->pen();
QBrush b = painter->brush();
painter->setBackgroundMode(Qt::OpaqueMode);
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(m_foregroundColor->value().value());
if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) {
painter->setPen(QPen(Qt::lightGray));
} else {
painter->setPen(QPen(m_lineColor->value().value(), m_lineWeight->value().toInt(), (Qt::PenStyle)m_lineStyle->value().toInt()));
}
QSizeF sceneSize = this->sceneSize(size());
qreal ox = sceneSize.width() / 5;
qreal oy = sceneSize.height() / 5;
//Checkbox Style
if (m_checkStyle->value().toString() == QLatin1String("Cross")) {
painter->drawRoundedRect(QGraphicsRectItem::rect(), sceneSize.width() / 10 , sceneSize.height() / 10);
QPen lp;
lp.setColor(m_foregroundColor->value().value());
lp.setWidth(ox > oy ? oy : ox);
painter->setPen(lp);
painter->drawLine(ox, oy, sceneSize.width() - ox, sceneSize.height() - oy);
painter->drawLine(ox, sceneSize.height() - oy, sceneSize.width() - ox, oy);
} else if (m_checkStyle->value().toString() == QLatin1String("Dot")) {
//Radio Style
painter->drawEllipse(QGraphicsRectItem::rect());
QBrush lb(m_foregroundColor->value().value());
painter->setBrush(lb);
painter->setPen(Qt::NoPen);
painter->drawEllipse(rect().center(), sceneSize.width() / 2 - ox, sceneSize.height() / 2 - oy);
} else {
//Tickbox Style
painter->drawRoundedRect(QGraphicsRectItem::rect(), sceneSize.width() / 10 , sceneSize.height() / 10);
QPen lp;
lp.setColor(m_foregroundColor->value().value());
lp.setWidth(ox > oy ? oy : ox);
painter->setPen(lp);
painter->drawLine(ox, sceneSize.height() / 2, sceneSize.width() / 2, sceneSize.height() - oy);
painter->drawLine(sceneSize.width() / 2, sceneSize.height() - oy, sceneSize.width() - ox, oy);
}
painter->setBackgroundMode(Qt::TransparentMode);
painter->setPen(m_foregroundColor->value().value());
// restore an values before we started just in case
painter->setFont(f);
painter->setPen(p);
painter->setBrush(b);
drawHandles(painter);
}
void KReportDesignerItemCheckBox::buildXML(QDomDocument *doc, QDomElement *parent)
{
//kreportpluginDebug();
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
//properties
addPropertyAsAttribute(&entity, nameProperty());
addPropertyAsAttribute(&entity, m_controlSource);
entity.setAttribute(QLatin1String("fo:foreground-color"), m_foregroundColor->value().toString());
addPropertyAsAttribute(&entity, m_checkStyle);
addPropertyAsAttribute(&entity, m_staticValue);
// bounding rect
buildXMLRect(doc, &entity, this);
//Line Style
buildXMLLineStyle(doc, &entity, lineStyle());
parent->appendChild(entity);
}
void KReportDesignerItemCheckBox::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
Q_UNUSED(s)
if (p.name() == "name") {
//For some reason p.oldValue returns an empty string
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
} else {
setOldName(p.value().toString());
}
}
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer()) designer()->setModified(true);
}
void KReportDesignerItemCheckBox::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
KReportDesignerItemRectBase::mousePressEvent(event);
}
diff --git a/src/items/check/KReportDesignerItemCheckBox.h b/src/items/check/KReportDesignerItemCheckBox.h
index 0dcf66d9..8873ba18 100644
--- a/src/items/check/KReportDesignerItemCheckBox.h
+++ b/src/items/check/KReportDesignerItemCheckBox.h
@@ -1,55 +1,55 @@
/* This file is part of the KDE project
* Copyright (C) 2009-2010 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#ifndef KREPORTDESIGNERITEMCHECK_H
#define KREPORTDESIGNERITEMCHECK_H
#include "KReportDesignerItemRectBase.h"
#include "KReportItemCheck.h"
#include
#include
const int KREPORT_ITEM_CHECK_DEFAULT_WIDTH = 15;
const int KREPORT_ITEM_CHECK_DEFAULT_HEIGHT = 15;
class KReportDesignerItemCheckBox : public KReportItemCheckBox, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
KReportDesignerItemCheckBox(KReportDesigner *, QGraphicsScene * scene, const QPointF &pos);
KReportDesignerItemCheckBox(const QDomNode & element, KReportDesigner *, QGraphicsScene * scene);
virtual ~KReportDesignerItemCheckBox();
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual KReportDesignerItemCheckBox* clone();
private:
- void init(QGraphicsScene*, KReportDesigner*);
+ void init(QGraphicsScene *scene);
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
};
#endif // KREPORTDESIGNERITEMCHECK_H
diff --git a/src/items/field/KReportDesignerItemField.cpp b/src/items/field/KReportDesignerItemField.cpp
index 65400bd3..90814c05 100644
--- a/src/items/field/KReportDesignerItemField.cpp
+++ b/src/items/field/KReportDesignerItemField.cpp
@@ -1,186 +1,186 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDesignerItemField.h"
#include "KReportItemField.h"
#include "KReportDesigner.h"
#include "kreportplugin_debug.h"
#include "KReportLineStyle.h"
#include
#include
#include
#include
//
// class ReportEntityField
//
-void KReportDesignerItemField::init(QGraphicsScene * scene, KReportDesigner * d)
+void KReportDesignerItemField::init(QGraphicsScene *scene)
{
if (scene)
scene->addItem(this);
setZValue(z());
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field"));
}
// methods (constructors)
-KReportDesignerItemField::KReportDesignerItemField(KReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos)
+KReportDesignerItemField::KReportDesignerItemField(KReportDesigner *rw, QGraphicsScene *scene, const QPointF &pos)
: KReportDesignerItemRectBase(rw, this)
{
Q_UNUSED(pos);
- init(scene, rw);
+ init(scene);
setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height()));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
}
KReportDesignerItemField::KReportDesignerItemField(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s)
: KReportItemField(element), KReportDesignerItemRectBase(d, this)
{
- init(s, d);
+ init(s);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemField* KReportDesignerItemField::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemField(n, designer(), 0);
}
// methods (deconstructor)
KReportDesignerItemField::~KReportDesignerItemField()
{}
QRect KReportDesignerItemField::getTextRect() const
{
return QFontMetrics(font()).boundingRect(x(), y(), 0, 0, textFlags(), renderText());
}
void KReportDesignerItemField::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
// store any values we plan on changing so we can restore them
QFont f = painter->font();
QPen p = painter->pen();
painter->setFont(font());
painter->setBackgroundMode(Qt::TransparentMode);
QColor bg = m_backgroundColor->value().value();
bg.setAlphaF(m_backgroundOpacity->value().toReal() *0.01);
painter->setPen(m_foregroundColor->value().value());
painter->fillRect(QGraphicsRectItem::rect(), bg);
painter->drawText(rect(), textFlags(), renderText());
if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) {
painter->setPen(QPen(Qt::lightGray));
} else {
painter->setPen(QPen(m_lineColor->value().value(), m_lineWeight->value().toInt(), (Qt::PenStyle)m_lineStyle->value().toInt()));
}
painter->drawRect(rect());
drawHandles(painter);
// restore an values before we started just in case
painter->setFont(f);
painter->setPen(p);
}
void KReportDesignerItemField::buildXML(QDomDocument *doc, QDomElement *parent)
{
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
// properties
addPropertyAsAttribute(&entity, nameProperty());
addPropertyAsAttribute(&entity, m_controlSource);
addPropertyAsAttribute(&entity, m_verticalAlignment);
addPropertyAsAttribute(&entity, m_horizontalAlignment);
addPropertyAsAttribute(&entity, m_wordWrap);
addPropertyAsAttribute(&entity, m_canGrow);
addPropertyAsAttribute(&entity, m_itemValue);
entity.setAttribute(QLatin1String("report:z-index"), zValue());
// bounding rect
buildXMLRect(doc, &entity, this);
//text style info
buildXMLTextStyle(doc, &entity, textStyle());
//Line Style
buildXMLLineStyle(doc, &entity, lineStyle());
#if 0 //Field Totals
if (m_trackTotal) {
QDomElement tracktotal = doc->createElement("tracktotal");
if (m_trackBuiltinFormat)
tracktotal.setAttribute("builtin", "true");
if (_useSubTotal)
tracktotal.setAttribute("subtotal", "true");
tracktotal.appendChild(doc.createTextNode(_trackTotalFormat->value().toString()));
entity.appendChild(tracktotal);
}
#endif
parent->appendChild(entity);
}
void KReportDesignerItemField::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
Q_UNUSED(s);
if (p.name() == "name") {
//For some reason p.oldValue returns an empty string
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
} else {
setOldName(p.value().toString());
}
}
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field"));
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer())designer()->setModified(true);
}
void KReportDesignerItemField::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
//kreportpluginDebug() << m_reportDesigner->fieldKeys() << m_reportDesigner->fieldNames();
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
KReportDesignerItemRectBase::mousePressEvent(event);
}
diff --git a/src/items/field/KReportDesignerItemField.h b/src/items/field/KReportDesignerItemField.h
index cb8b10d5..f51eb1c3 100644
--- a/src/items/field/KReportDesignerItemField.h
+++ b/src/items/field/KReportDesignerItemField.h
@@ -1,55 +1,55 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#ifndef KREPORTDESIGNERITEMFIELD_H
#define KREPORTDESIGNERITEMFIELD_H
#include
#include
#include "KReportItemField.h"
#include "KReportDesignerItemRectBase.h"
class KReportDesignerItemField : public KReportItemField, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
//Used when creating new basic field
KReportDesignerItemField(KReportDesigner *, QGraphicsScene * scene, const QPointF &pos);
//Used when loading from file
KReportDesignerItemField(const QDomNode & element, KReportDesigner *, QGraphicsScene * scene);
virtual ~KReportDesignerItemField();
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget *widget = 0);
virtual KReportDesignerItemField* clone();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
private:
- void init(QGraphicsScene*, KReportDesigner * d);
+ void init(QGraphicsScene *scene);
QRect getTextRect() const;
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
};
#endif
diff --git a/src/items/image/KReportDesignerItemImage.cpp b/src/items/image/KReportDesignerItemImage.cpp
index 3c958d77..48f5c1c1 100644
--- a/src/items/image/KReportDesignerItemImage.cpp
+++ b/src/items/image/KReportDesignerItemImage.cpp
@@ -1,150 +1,150 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDesignerItemImage.h"
#include "KReportDesignerItemBase.h"
#include "KReportDesigner.h"
#include
#include
#include
#include
#include
//
// ReportEntitiesImage
//
// contructors/deconstructors
-void KReportDesignerItemImage::init(QGraphicsScene *scene, KReportDesigner *d)
+void KReportDesignerItemImage::init(QGraphicsScene *scene)
{
//kreportpluginDebug();
if (scene)
scene->addItem(this);
connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)),
this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
setZValue(z());
}
-KReportDesignerItemImage::KReportDesignerItemImage(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos)
+KReportDesignerItemImage::KReportDesignerItemImage(KReportDesigner *rw, QGraphicsScene *scene, const QPointF &pos)
: KReportDesignerItemRectBase(rw, this)
{
Q_UNUSED(pos);
//kreportpluginDebug();
- init(scene, rw);
+ init(scene);
setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
}
KReportDesignerItemImage::KReportDesignerItemImage(const QDomNode & element, KReportDesigner * rw, QGraphicsScene* scene)
: KReportItemImage(element), KReportDesignerItemRectBase(rw, this)
{
- init(scene, rw);
+ init(scene);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemImage* KReportDesignerItemImage::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemImage(n, designer(), 0);
}
KReportDesignerItemImage::~KReportDesignerItemImage()
{
// do we need to clean anything up?
}
void KReportDesignerItemImage::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
// store any values we plan on changing so we can restore them
QPen p = painter->pen();
if (isInline()) {
//QImage t_img = _image;
QImage t_img = m_staticImage->value().value().toImage();
if (mode() == QLatin1String("stretch")) {
t_img = t_img.scaled(rect().width(), rect().height(), Qt::KeepAspectRatio);
}
painter->drawImage(rect().left(), rect().top(), t_img, 0, 0, rect().width(), rect().height());
} else {
painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(), QLatin1String("image")));
}
//Draw a border so user knows the object edge
painter->setPen(QPen(Qt::lightGray));
painter->drawRect(rect());
drawHandles(painter);
// restore an values before we started just in case
painter->setPen(p);
}
void KReportDesignerItemImage::buildXML(QDomDocument *doc, QDomElement *parent)
{
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
// properties
addPropertyAsAttribute(&entity, nameProperty());
addPropertyAsAttribute(&entity, m_resizeMode);
entity.setAttribute(QLatin1String("report:z-index"), z());
buildXMLRect(doc, &entity, this);
if (isInline()) {
QDomElement map = doc->createElement(QLatin1String("report:inline-image-data"));
map.appendChild(doc->createTextNode(QLatin1String(inlineImageData())));
entity.appendChild(map);
} else {
addPropertyAsAttribute(&entity, m_controlSource);
}
parent->appendChild(entity);
}
void KReportDesignerItemImage::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
if (p.name() == "name") {
//For some reason p.oldValue returns an empty string
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
} else {
setOldName(p.value().toString());
}
}
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer()) designer()->setModified(true);
}
void KReportDesignerItemImage::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
KReportDesignerItemRectBase::mousePressEvent(event);
}
diff --git a/src/items/image/KReportDesignerItemImage.h b/src/items/image/KReportDesignerItemImage.h
index fd33011a..4d5094ab 100644
--- a/src/items/image/KReportDesignerItemImage.h
+++ b/src/items/image/KReportDesignerItemImage.h
@@ -1,50 +1,50 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#ifndef KREPORTDESIGNERITEMIMAGE_H
#define KREPORTDESIGNERITEMIMAGE_H
#include "KReportDesignerItemRectBase.h"
#include "KReportItemImage.h"
#include
class KReportDesignerItemImage : public KReportItemImage, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
KReportDesignerItemImage(KReportDesigner *, QGraphicsScene* scene, const QPointF &pos);
KReportDesignerItemImage(const QDomNode & element, KReportDesigner *, QGraphicsScene* scene);
virtual ~KReportDesignerItemImage();
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual KReportDesignerItemImage* clone();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
private:
- void init(QGraphicsScene*, KReportDesigner*);
+ void init(QGraphicsScene *scene);
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
};
#endif
diff --git a/src/items/label/KReportDesignerItemLabel.cpp b/src/items/label/KReportDesignerItemLabel.cpp
index 69db4f59..7a0a4688 100644
--- a/src/items/label/KReportDesignerItemLabel.cpp
+++ b/src/items/label/KReportDesignerItemLabel.cpp
@@ -1,221 +1,221 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDesignerItemLabel.h"
#include "KReportDesignerItemBase.h"
#include "KReportDesigner.h"
#include "KReportDesignerSectionScene.h"
#include "KReportLineStyle.h"
#include
#include
#include
#include
#include
#include
#include
-void KReportDesignerItemLabel::init(QGraphicsScene *scene, KReportDesigner *d)
+void KReportDesignerItemLabel::init(QGraphicsScene *scene)
{
if (scene)
scene->addItem(this);
connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)),
this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
setZValue(z());
setFlag(ItemIsFocusable);
m_inlineEdit = new BoundedTextItem(this);
m_inlineEdit->setVisible(false);
m_inlineEdit->setFlag(ItemIsFocusable);
m_inlineEdit->setFlag(ItemIsSelectable, false);
QTextDocument *doc = new QTextDocument;
doc->setDocumentMargin(0);
doc->setPlainText(text());
m_inlineEdit->setDocument(doc);
connect(m_inlineEdit, SIGNAL(exitEditMode()), this, SLOT(exitInlineEditingMode()));
}
// methods (constructors)
KReportDesignerItemLabel::KReportDesignerItemLabel(KReportDesigner* d, QGraphicsScene * scene, const QPointF &pos)
: KReportDesignerItemRectBase(d, this)
{
Q_UNUSED(pos);
- init(scene, d);
+ init(scene);
setSceneRect(properRect(*d, getTextRect().width(), getTextRect().height()));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
enterInlineEditingMode();
}
KReportDesignerItemLabel::KReportDesignerItemLabel(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s)
: KReportItemLabel(element), KReportDesignerItemRectBase(d, this), m_inlineEdit(0)
{
- init(s, d);
+ init(s);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemLabel* KReportDesignerItemLabel::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemLabel(n, designer(), 0);
}
// methods (deconstructor)
KReportDesignerItemLabel::~KReportDesignerItemLabel()
{}
QRectF KReportDesignerItemLabel::getTextRect() const
{
return QFontMetrics(font()).boundingRect(x(), y(), 0, 0, textFlags(), m_text->value().toString());
}
void KReportDesignerItemLabel::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
if (m_inlineEdit->isVisible()) {
return;
}
// store any values we plan on changing so we can restore them
QFont f = painter->font();
QPen p = painter->pen();
painter->setFont(font());
painter->setBackgroundMode(Qt::TransparentMode);
QColor bg = m_backgroundColor->value().value();
bg.setAlphaF(m_backgroundOpacity->value().toReal() * 0.01);
painter->setPen(m_foregroundColor->value().value());
painter->fillRect(QGraphicsRectItem::rect(), bg);
painter->drawText(rect(), textFlags(), text());
if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) {
painter->setPen(QPen(QColor(224, 224, 224)));
} else {
painter->setPen(QPen(m_lineColor->value().value(), m_lineWeight->value().toInt(), (Qt::PenStyle)m_lineStyle->value().toInt()));
}
painter->drawRect(QGraphicsRectItem::rect());
painter->setPen(m_foregroundColor->value().value());
drawHandles(painter);
// restore an values before we started just in case
painter->setFont(f);
painter->setPen(p);
}
void KReportDesignerItemLabel::buildXML(QDomDocument *doc, QDomElement *parent)
{
//kreportpluginDebug();
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
// properties
addPropertyAsAttribute(&entity, nameProperty());
addPropertyAsAttribute(&entity, m_text);
addPropertyAsAttribute(&entity, m_verticalAlignment);
addPropertyAsAttribute(&entity, m_horizontalAlignment);
entity.setAttribute(QLatin1String("report:z-index"), z());
// bounding rect
buildXMLRect(doc, &entity, this);
//text style info
buildXMLTextStyle(doc, &entity, textStyle());
//Line Style
buildXMLLineStyle(doc, &entity, lineStyle());
parent->appendChild(entity);
}
void KReportDesignerItemLabel::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
Q_UNUSED(s);
if (p.name() == "name") {
//For some reason p.oldValue returns an empty string
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
} else {
setOldName(p.value().toString());
}
} else if (p.name() == "caption") {
m_inlineEdit->setPlainText(p.value().toString());
}
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer()) designer()->setModified(true);
}
void KReportDesignerItemLabel::enterInlineEditingMode()
{
if (!m_inlineEdit->isVisible()) {
m_inlineEdit->setVisible(true);
m_inlineEdit->setPlainText(text());
m_inlineEdit->setFocus();
QTextCursor c = m_inlineEdit->textCursor();
c.select(QTextCursor::Document);
m_inlineEdit->setTextCursor(c);
m_inlineEdit->setFont(m_font->value().value());
m_inlineEdit->setDefaultTextColor(m_foregroundColor->value().value());
m_inlineEdit->setBackgroudColor(m_backgroundColor->value().value());
m_inlineEdit->setBackgroudOpacity(m_backgroundOpacity->value().toDouble() / 100.0);
m_inlineEdit->setForegroundColor(m_foregroundColor->value().value());
m_inlineEdit->setFont(m_font->value().value());
update();
}
}
void KReportDesignerItemLabel::exitInlineEditingMode()
{
if (m_inlineEdit->isVisible()) {
m_inlineEdit->setVisible(false);
setText(m_inlineEdit->toPlainText());
}
}
void KReportDesignerItemLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
Q_UNUSED(event);
enterInlineEditingMode();
}
void KReportDesignerItemLabel::keyReleaseEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_F2) {
enterInlineEditingMode();
} else {
QGraphicsRectItem::keyReleaseEvent(event);
}
}
diff --git a/src/items/label/KReportDesignerItemLabel.h b/src/items/label/KReportDesignerItemLabel.h
index 2372204a..8df953ed 100644
--- a/src/items/label/KReportDesignerItemLabel.h
+++ b/src/items/label/KReportDesignerItemLabel.h
@@ -1,61 +1,61 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#ifndef KREPORTDESIGNERITEMLABEL_H
#define KREPORTDESIGNERITEMLABEL_H
#include "KReportItemLabel.h"
#include "KReportDesignerItemRectBase.h"
#include "KReportBoundedTextItem.h"
#include
#include
#include
#include
class KReportDesignerItemLabel : public KReportItemLabel, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
KReportDesignerItemLabel(KReportDesigner *, QGraphicsScene * scene, const QPointF &pos);
KReportDesignerItemLabel(const QDomNode & element, KReportDesigner *, QGraphicsScene * scene);
virtual ~KReportDesignerItemLabel();
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual KReportDesignerItemLabel* clone();
public Q_SLOTS:
virtual void enterInlineEditingMode();
virtual void exitInlineEditingMode();
protected:
virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event );
virtual void keyReleaseEvent ( QKeyEvent * event );
private:
- void init(QGraphicsScene*, KReportDesigner*);
+ void init(QGraphicsScene *scene);
QRectF getTextRect() const;
BoundedTextItem *m_inlineEdit;
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
};
#endif
diff --git a/src/items/text/KReportDesignerItemText.cpp b/src/items/text/KReportDesignerItemText.cpp
index bad5e5af..914662d8 100644
--- a/src/items/text/KReportDesignerItemText.cpp
+++ b/src/items/text/KReportDesignerItemText.cpp
@@ -1,175 +1,175 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDesignerItemText.h"
#include "KReportDesignerItemBase.h"
#include "KReportDesigner.h"
#include "KReportLineStyle.h"
#include
#include
#include
#include
#include
#include "kreportplugin_debug.h"
//
// class ReportEntityText
//
// methods (constructors)
-void KReportDesignerItemText::init(QGraphicsScene *scene, KReportDesigner *d)
+void KReportDesignerItemText::init(QGraphicsScene *scene)
{
//setFlags(ItemIsSelectable | ItemIsMovable);
if (scene)
scene->addItem(this);
connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)),
this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
setZValue(z());
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(),
QLatin1String("textarea"));
}
KReportDesignerItemText::KReportDesignerItemText(KReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos)
: KReportDesignerItemRectBase(rw, this)
{
Q_UNUSED(pos);
- init(scene, rw);
+ init(scene);
setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height()));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
}
-KReportDesignerItemText::KReportDesignerItemText(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s)
+KReportDesignerItemText::KReportDesignerItemText(const QDomNode & element, KReportDesigner *d, QGraphicsScene *scene)
: KReportItemText(element), KReportDesignerItemRectBase(d, this)
{
- init(s, d);
+ init(scene);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemText* KReportDesignerItemText::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemText(n, designer(), 0);
}
KReportDesignerItemText::~KReportDesignerItemText
()
{}
QRect KReportDesignerItemText::getTextRect() const
{
return QFontMetrics(font()).boundingRect(int (x()), int (y()), 0, 0, textFlags(), renderText());
}
void KReportDesignerItemText::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget)
// store any values we plan on changing so we can restore them
QFont f = painter->font();
QPen p = painter->pen();
painter->setFont(font());
painter->setBackgroundMode(Qt::TransparentMode);
QColor bg = m_backgroundColor->value().value();
bg.setAlphaF(m_backgroundOpacity->value().toReal()*0.01);
painter->setPen(m_foregroundColor->value().value());
painter->fillRect(rect(), bg);
painter->drawText(rect(), textFlags(), renderText());
if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) {
painter->setPen(QPen(Qt::lightGray));
} else {
painter->setPen(QPen(m_lineColor->value().value(), m_lineWeight->value().toInt(), (Qt::PenStyle)m_lineStyle->value().toInt()));
}
painter->drawRect(rect());
painter->setPen(m_foregroundColor->value().value());
drawHandles(painter);
// restore an values before we started just in case
painter->setFont(f);
painter->setPen(p);
}
void KReportDesignerItemText::buildXML(QDomDocument *doc, QDomElement *parent)
{
//kreportpluginDebug();
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
// properties
addPropertyAsAttribute(&entity, nameProperty());
addPropertyAsAttribute(&entity, m_controlSource);
addPropertyAsAttribute(&entity, m_verticalAlignment);
addPropertyAsAttribute(&entity, m_horizontalAlignment);
entity.setAttribute(QLatin1String("report:bottom-padding"), m_bottomPadding);
entity.setAttribute(QLatin1String("report:z-index"), z());
addPropertyAsAttribute(&entity, m_itemValue);
// bounding rect
buildXMLRect(doc, &entity, this);
//text style info
buildXMLTextStyle(doc, &entity, textStyle());
//Line Style
buildXMLLineStyle(doc, &entity, lineStyle());
parent->appendChild(entity);
}
void KReportDesignerItemText::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
KReportDesignerItemRectBase::mousePressEvent(event);
}
void KReportDesignerItemText::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
Q_UNUSED(s);
if (p.name() == "name") {
//For some reason p.oldValue returns an empty string
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
} else {
setOldName(p.value().toString());
}
}
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer()) designer()->setModified(true);
updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(),
QLatin1String("textarea"));
}
diff --git a/src/items/text/KReportDesignerItemText.h b/src/items/text/KReportDesignerItemText.h
index bf995c8f..20b73292 100644
--- a/src/items/text/KReportDesignerItemText.h
+++ b/src/items/text/KReportDesignerItemText.h
@@ -1,54 +1,54 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#ifndef KREPORTDESIGNERITEMTEXT_H
#define KREPORTDESIGNERITEMTEXT_H
#include "KReportDesignerItemRectBase.h"
#include "KReportItemText.h"
#include
//
// ReportEntityText
//
class KReportDesignerItemText : public KReportItemText, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
KReportDesignerItemText(KReportDesigner *, QGraphicsScene * scene, const QPointF &pos);
KReportDesignerItemText(const QDomNode & element, KReportDesigner *, QGraphicsScene * scene);
virtual ~KReportDesignerItemText();
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual KReportDesignerItemText* clone();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
private:
QRect getTextRect() const;
- void init(QGraphicsScene*, KReportDesigner*);
+ void init(QGraphicsScene *scene);
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
};
#endif
diff --git a/src/plugins/barcode/KReportDesignerItemBarcode.cpp b/src/plugins/barcode/KReportDesignerItemBarcode.cpp
index 5eb25631..aa4c25f8 100644
--- a/src/plugins/barcode/KReportDesignerItemBarcode.cpp
+++ b/src/plugins/barcode/KReportDesignerItemBarcode.cpp
@@ -1,173 +1,173 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDesignerItemBarcode.h"
#include "KReportDesignerItemBase.h"
#include "KReportDesigner.h"
#include "barcodepaint.h"
#include
#include
#include
#include
#include
#include
#include "kreportplugin_debug.h"
-void KReportDesignerItemBarcode::init(QGraphicsScene *scene, KReportDesigner *d)
+void KReportDesignerItemBarcode::init(QGraphicsScene *scene)
{
if (scene)
scene->addItem(this);
connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)),
this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
setMaxLength(5);
setZ(z());
updateRenderText(m_itemValue->value().toString().isEmpty() ? m_format->value().toString() : QString(), m_itemValue->value().toString(), QString());
}
// methods (constructors)
KReportDesignerItemBarcode::KReportDesignerItemBarcode(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos)
: KReportDesignerItemRectBase(rw, this)
{
Q_UNUSED(pos);
- init(scene, rw);
+ init(scene);
setSceneRect(properRect(*rw, m_minWidthTotal*m_dpiX, m_minHeight*m_dpiY));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
}
KReportDesignerItemBarcode::KReportDesignerItemBarcode(const QDomNode & element, KReportDesigner * rw, QGraphicsScene* scene)
: KReportItemBarcode(element), KReportDesignerItemRectBase(rw, this)
{
- init(scene, rw);
+ init(scene);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemBarcode* KReportDesignerItemBarcode::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemBarcode(n, designer(), 0);
}
// methods (deconstructor)
KReportDesignerItemBarcode::~KReportDesignerItemBarcode()
{}
QRect KReportDesignerItemBarcode::getTextRect()
{
QFont fnt = QFont();
return QFontMetrics(fnt)
.boundingRect(int (x()), int (y()), 0, 0, 0,
dataSourceAndObjectTypeName(itemDataSource(), QLatin1String("barcode")));
}
void KReportDesignerItemBarcode::paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
// store any values we plan on changing so we can restore them
QPen p = painter->pen();
painter->setBackground(Qt::white);
//Draw a border so user knows the object edge
painter->setPen(QPen(QColor(224, 224, 224)));
painter->drawRect(rect());
drawHandles(painter);
QByteArray fmt = m_format->value().toByteArray();
if (fmt == "i2of5") {
renderI2of5(rect().toRect(), renderText(), alignment(), painter);
} else if (fmt == "3of9") {
render3of9(rect().toRect(), renderText(), alignment(), painter);
} else if (fmt == "3of9+") {
renderExtended3of9(rect().toRect(), renderText(), alignment(), painter);
} else if (fmt == "128") {
renderCode128(rect().toRect(), renderText(), alignment(), painter);
} else if (fmt == "upc-a") {
renderCodeUPCA(rect().toRect(), renderText(), alignment(), painter);
} else if (fmt == "upc-e") {
renderCodeUPCE(rect().toRect(), renderText(), alignment(), painter);
} else if (fmt == "ean13") {
renderCodeEAN13(rect().toRect(), renderText(), alignment(), painter);
} else if (fmt == "ean8") {
renderCodeEAN8(rect().toRect(), renderText(), alignment(), painter);
}
painter->setPen(Qt::black);
painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(),
QLatin1String("barcode")));
// restore an values before we started just in case
painter->setPen(p);
}
void KReportDesignerItemBarcode::buildXML(QDomDocument *doc, QDomElement *parent)
{
//kreportpluginDebug();
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
// properties
addPropertyAsAttribute(&entity, nameProperty());
addPropertyAsAttribute(&entity, m_controlSource);
addPropertyAsAttribute(&entity, m_horizontalAlignment);
addPropertyAsAttribute(&entity, m_format);
addPropertyAsAttribute(&entity, m_maxLength);
entity.setAttribute(QLatin1String("report:z-index"), zValue());
addPropertyAsAttribute(&entity, m_itemValue);
// bounding rect
buildXMLRect(doc, &entity, this);
parent->appendChild(entity);
}
void KReportDesignerItemBarcode::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
if (p.name() == "name") {
//For some reason p.oldValue returns an empty string
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
} else {
setOldName(p.value().toString());
}
}
updateRenderText(m_itemValue->value().toString().isEmpty() ? m_format->value().toString() : QString(), m_itemValue->value().toString(), QString());
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer()) designer()->setModified(true);
}
void KReportDesignerItemBarcode::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
KReportDesignerItemRectBase::mousePressEvent(event);
}
diff --git a/src/plugins/barcode/KReportDesignerItemBarcode.h b/src/plugins/barcode/KReportDesignerItemBarcode.h
index da043cdb..e89642b0 100644
--- a/src/plugins/barcode/KReportDesignerItemBarcode.h
+++ b/src/plugins/barcode/KReportDesignerItemBarcode.h
@@ -1,57 +1,57 @@
/* This file is part of the KDE project
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#ifndef KREPORTDESIGNERITEMBARCODE_H
#define KREPORTDESIGNERITEMBARCODE_H
#include "KReportDesignerItemRectBase.h"
#include "KReportItemBarcode.h"
#include
//
// ReportEntityBarcode
//
class KReportDesignerItemBarcode : public KReportItemBarcode, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
KReportDesignerItemBarcode(KReportDesigner *, QGraphicsScene* scene, const QPointF &pos);
KReportDesignerItemBarcode(const QDomNode & element, KReportDesigner *, QGraphicsScene* scene);
virtual ~KReportDesignerItemBarcode();
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual KReportDesignerItemBarcode* clone();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
private:
- void init(QGraphicsScene*, KReportDesigner*);
+ void init(QGraphicsScene *scene);
QRect getTextRect();
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
};
#endif
diff --git a/src/plugins/maps/KReportDesignerItemMaps.cpp b/src/plugins/maps/KReportDesignerItemMaps.cpp
index f516f844..959d12b7 100644
--- a/src/plugins/maps/KReportDesignerItemMaps.cpp
+++ b/src/plugins/maps/KReportDesignerItemMaps.cpp
@@ -1,133 +1,133 @@
/*
* Copyright (C) 2007-2016 by Adam Pigg (adam@piggz.co.uk)
* Copyright (C) 2011-2015 by Radoslaw Wicik (radoslaw@wicik.pl)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#include "KReportDesignerItemMaps.h"
#include "KReportDesignerItemBase.h"
#include "KReportDesigner.h"
#include
#include
#include
#include
#include
#include
#include "kreportplugin_debug.h"
-void KReportDesignerItemMaps::init(QGraphicsScene *scene, KReportDesigner *d)
+void KReportDesignerItemMaps::init(QGraphicsScene *scene)
{
if (scene)
scene->addItem(this);
connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)),
this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
setZValue(z());
}
-KReportDesignerItemMaps::KReportDesignerItemMaps(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos)
+KReportDesignerItemMaps::KReportDesignerItemMaps(KReportDesigner *rw, QGraphicsScene *scene, const QPointF &pos)
: KReportDesignerItemRectBase(rw, this)
{
Q_UNUSED(pos);
- init(scene, rw);
+ init(scene);
setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
}
-KReportDesignerItemMaps::KReportDesignerItemMaps(const QDomNode &element, KReportDesigner * rw, QGraphicsScene* scene)
+KReportDesignerItemMaps::KReportDesignerItemMaps(const QDomNode &element, KReportDesigner *rw, QGraphicsScene* scene)
: KReportItemMaps(element), KReportDesignerItemRectBase(rw, this)
{
- init(scene, rw);
+ init(scene);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemMaps* KReportDesignerItemMaps::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemMaps(n, designer(), 0);
}
KReportDesignerItemMaps::~KReportDesignerItemMaps()
{
// do we need to clean anything up?
}
void KReportDesignerItemMaps::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
// store any values we plan on changing so we can restore them
QPen p = painter->pen();
painter->fillRect(rect(), QColor(0xc2, 0xfc, 0xc7));//C2FCC7
//Draw a border so user knows the object edge
painter->setPen(QPen(QColor(224, 224, 224)));
painter->drawRect(rect());
painter->setPen(Qt::black);
painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(), QLatin1String("map")));
drawHandles(painter);
// restore an values before we started just in case
painter->setPen(p);
}
void KReportDesignerItemMaps::buildXML(QDomDocument *doc, QDomElement *parent)
{
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
// properties
addPropertyAsAttribute(&entity, nameProperty());
addPropertyAsAttribute(&entity, m_controlSource);
addPropertyAsAttribute(&entity, m_latitudeProperty);
addPropertyAsAttribute(&entity, m_longitudeProperty);
addPropertyAsAttribute(&entity, m_zoomProperty);
addPropertyAsAttribute(&entity, m_themeProperty);
//addPropertyAsAttribute(&entity, m_resizeMode);
entity.setAttribute(QLatin1String("report:z-index"), z());
buildXMLRect(doc, &entity, this);
parent->appendChild(entity);
}
void KReportDesignerItemMaps::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
//kreportpluginDebug() << p.name() << ":" << p.value();
if (p.name().toLower() == "name") {
//For some reason p.oldValue returns an empty string
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
} else {
setOldName(p.value().toString());
}
}
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer()) designer()->setModified(true);
}
void KReportDesignerItemMaps::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
KReportDesignerItemRectBase::mousePressEvent(event);
}
diff --git a/src/plugins/maps/KReportDesignerItemMaps.h b/src/plugins/maps/KReportDesignerItemMaps.h
index 36e52259..792db8ab 100644
--- a/src/plugins/maps/KReportDesignerItemMaps.h
+++ b/src/plugins/maps/KReportDesignerItemMaps.h
@@ -1,52 +1,52 @@
/*
* Copyright (C) 2001-2007 by OpenMFG, LLC (info@openmfg.com)
* Copyright (C) 2007-2008 by Adam Pigg (adam@piggz.co.uk)
* Copyright (C) 2011 by Radoslaw Wicik (radoslaw@wicik.pl)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see .
*/
#ifndef __REPORTENTITYIMAGE_H__
#define __REPORTENTITYIMAGE_H__
#include
#include
#include "KReportItemMaps.h"
class KReportDesignerItemMaps : public KReportItemMaps, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
KReportDesignerItemMaps(KReportDesigner *, QGraphicsScene* scene, const QPointF &pos);
KReportDesignerItemMaps(const QDomNode &element, KReportDesigner *, QGraphicsScene* scene);
virtual ~KReportDesignerItemMaps();
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
virtual KReportDesignerItemMaps* clone();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
private:
- void init(QGraphicsScene*, KReportDesigner*);
+ void init(QGraphicsScene *scene);
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
};
#endif
diff --git a/src/plugins/web/KReportDesignerItemWeb.cpp b/src/plugins/web/KReportDesignerItemWeb.cpp
index 9c668f7e..26868d1c 100644
--- a/src/plugins/web/KReportDesignerItemWeb.cpp
+++ b/src/plugins/web/KReportDesignerItemWeb.cpp
@@ -1,124 +1,124 @@
/* This file is part of the KDE project
Copyright Shreya Pandit
Copyright 2011 Adam Pigg
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KReportDesignerItemWeb.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "kreportplugin_debug.h"
-void KReportDesignerItemWeb::init(QGraphicsScene *scene, KReportDesigner *d)
+void KReportDesignerItemWeb::init(QGraphicsScene *scene)
{
if (scene)
scene->addItem(this);
connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&)));
setZValue(z());
}
KReportDesignerItemWeb::KReportDesignerItemWeb(KReportDesigner *rw, QGraphicsScene *scene,
const QPointF &pos) : KReportDesignerItemRectBase(rw, this)
{
Q_UNUSED(pos);
- init(scene, rw);
+ init(scene);
setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH));
nameProperty()->setValue(designer()->suggestEntityName(typeName()));
}
KReportDesignerItemWeb::KReportDesignerItemWeb(const QDomNode &element, KReportDesigner *rw,
QGraphicsScene *scene)
: KReportItemWeb(element), KReportDesignerItemRectBase(rw, this)
{
- init(scene, rw);
+ init(scene);
setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()));
}
KReportDesignerItemWeb *KReportDesignerItemWeb::clone()
{
QDomDocument d;
QDomElement e = d.createElement(QLatin1String("clone"));
QDomNode n;
buildXML(&d, &e);
n = e.firstChild();
return new KReportDesignerItemWeb(n, designer(), 0);
}
KReportDesignerItemWeb::~KReportDesignerItemWeb() //done,compared
{
// do we need to clean anything up?
}
void KReportDesignerItemWeb::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->drawRect(QGraphicsRectItem::rect());
painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(), QLatin1String("web-view")));
painter->setBackgroundMode(Qt::TransparentMode);
drawHandles(painter);
}
void KReportDesignerItemWeb::buildXML(QDomDocument *doc, QDomElement *parent)
{
Q_UNUSED(doc);
Q_UNUSED(parent);
QDomElement entity = doc->createElement(QLatin1String("report:") + typeName());
// properties
addPropertyAsAttribute(&entity, m_controlSource);
addPropertyAsAttribute(&entity, nameProperty());
entity.setAttribute(QLatin1String("report:z-index"), zValue());
buildXMLRect(doc, &entity, this);
parent->appendChild(entity);
}
void KReportDesignerItemWeb::slotPropertyChanged(KPropertySet &s, KProperty &p)
{
if (p.name() == "name") {
if (!designer()->isEntityNameUnique(p.value().toString(), this)) {
p.setValue(oldName());
}
else {
setOldName(p.value().toString());
}
}
KReportDesignerItemRectBase::propertyChanged(s, p);
if (designer()) {
designer()->setModified(true);
}
}
void KReportDesignerItemWeb::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames());
KReportDesignerItemRectBase::mousePressEvent(event);
}
diff --git a/src/plugins/web/KReportDesignerItemWeb.h b/src/plugins/web/KReportDesignerItemWeb.h
index 7dd1b0cc..5bb0cba0 100644
--- a/src/plugins/web/KReportDesignerItemWeb.h
+++ b/src/plugins/web/KReportDesignerItemWeb.h
@@ -1,55 +1,53 @@
/* This file is part of the KDE project
Copyright Shreya Pandit
Copyright 2011 Adam Pigg
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KREPORTDESIGNERITEMWEB_H
#define KREPORTDESIGNERITEMWEB_H
#include
#include "KReportItemWeb.h"
class QGraphicsScene;
/**
*/
class KReportDesignerItemWeb : public KReportItemWeb, public KReportDesignerItemRectBase
{
Q_OBJECT
public:
KReportDesignerItemWeb(KReportDesigner *rw, QGraphicsScene *scene, const QPointF &pos);
KReportDesignerItemWeb(const QDomNode &element, KReportDesigner *rw, QGraphicsScene *scene);
virtual ~KReportDesignerItemWeb();
- void init(QGraphicsScene *scene);
-
virtual void buildXML(QDomDocument *doc, QDomElement *parent);
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
virtual KReportDesignerItemWeb *clone();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
- void init(QGraphicsScene *, KReportDesigner *r);
+ void init(QGraphicsScene *scene);
private Q_SLOTS:
void slotPropertyChanged(KPropertySet &, KProperty &);
};
#endif