diff --git a/src/common/KReportItemBase.h b/src/common/KReportItemBase.h --- a/src/common/KReportItemBase.h +++ b/src/common/KReportItemBase.h @@ -22,6 +22,7 @@ #include "kreport_export.h" #include "KReportPosition.h" #include "KReportSize.h" +#include "KReportDpi.h" #include #include @@ -104,35 +105,52 @@ @return True if uses a sub query */ virtual bool supportsSubQuery() const; - - KPropertySet* propertySet() const; - + + KPropertySet* propertySet(); + const KPropertySet* propertySet() const; + void setEntityName(const QString& n); QString entityName() const; virtual void setUnit(const KReportUnit& u); - KReportPosition position() const; - KReportSize size() const; + /** + * @brief Return the size in points + */ + QSizeF size() const; + + /** + * @brief Return the position in points + */ + QPointF position() const; + + void setPosition(const QPointF &pos); + void setSize(const QSizeF &siz); + + qreal z() const; + void setZ(qreal z); + + //Helper function to map between size/position units + static QPointF scenePosition(const QPointF &pos); + static QSizeF sceneSize(const QSizeF &size); + static QPointF positionFromScene(const QPointF &pos); + static QSizeF sizeFromScene(const QSizeF &size); - qreal Z; protected: - KPropertySet *m_set; - KProperty *m_name; - KReportPosition m_pos; - KReportSize m_size; - - QString m_oldName; - - void addDefaultProperties(); - virtual void createProperties() = 0; - - static bool parseReportRect(const QDomElement &, KReportPosition *pos, KReportSize *size); + bool parseReportRect(const QDomElement &elem); static bool parseReportTextStyleData(const QDomElement &, KRTextStyleData*); static bool parseReportLineStyleData(const QDomElement &, KReportLineStyle*); - - + + KProperty *nameProperty(); + QString oldName() const; + void setOldName(const QString &old); + + Q_SLOT virtual void propertyChanged(KPropertySet &s, KProperty &p); + +private: + class Private; + Private * const d; }; #endif diff --git a/src/common/KReportItemBase.cpp b/src/common/KReportItemBase.cpp --- a/src/common/KReportItemBase.cpp +++ b/src/common/KReportItemBase.cpp @@ -17,25 +17,56 @@ #include "KReportItemBase.h" -#include "KReportPosition.h" -#include "KReportSize.h" #include "KReportUtils.h" #include +#include +#include -KReportItemBase::KReportItemBase() +class Q_DECL_HIDDEN KReportItemBase::Private { - Z = 0; - m_name = new KProperty("name", QString(), tr("Name"), tr("Object Name")); - m_name->setAutoSync(0); +public: + Private(); + ~Private(); + + KPropertySet *set; + KProperty *nameProperty; + KProperty *sizeProperty; + KProperty *positionProperty; + QString oldName; + qreal z; +}; + +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() { } -void KReportItemBase::addDefaultProperties() +KReportItemBase::KReportItemBase() : d(new Private()) { - m_set->addProperty(m_name); - m_set->addProperty(m_pos.property()); - m_set->addProperty(m_size.property()); + d->z = 0; + + connect(propertySet(), &KPropertySet::propertyChanged, + this, &KReportItemBase::propertyChanged); +} + +KReportItemBase::~KReportItemBase() +{ + delete d; } bool KReportItemBase::parseReportTextStyleData(const QDomElement & elemSource, KRTextStyleData *ts) @@ -49,15 +80,28 @@ } -bool KReportItemBase::parseReportRect(const QDomElement & elemSource, KReportPosition *pos, KReportSize *size) +bool KReportItemBase::parseReportRect(const QDomElement & elemSource) { - return KReportUtils::parseReportRect(elemSource, pos, size); + 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) { - m_pos.setUnit(u); - m_size.setUnit(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, @@ -87,9 +131,9 @@ return QString(); } -KPropertySet* KReportItemBase::propertySet() const +KPropertySet* KReportItemBase::propertySet() { - return m_set; + return d->set; } bool KReportItemBase::supportsSubQuery() const @@ -99,21 +143,95 @@ QString KReportItemBase::entityName() const { - return m_name->value().toString(); + return d->nameProperty->value().toString(); } void KReportItemBase::setEntityName(const QString& n) { - m_name->setValue(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 propertySet(); } -KReportPosition KReportItemBase::position() const +QPointF KReportItemBase::scenePosition(const QPointF &pos) { - return m_pos; + const qreal x = POINT_TO_INCH(pos.x()) * KReportDpi::dpiX(); + const qreal y = POINT_TO_INCH(pos.y()) * KReportDpi::dpiY(); + return QPointF(x, y); } -KReportSize KReportItemBase::size() const +QSizeF KReportItemBase::sceneSize(const QSizeF &size) { - return m_size; + const qreal w = POINT_TO_INCH(size.width()) * KReportDpi::dpiX(); + const qreal h = POINT_TO_INCH(size.height()) * KReportDpi::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() / KReportDpi::dpiX()); + const qreal y = INCH_TO_POINT(pos.y() / KReportDpi::dpiY()); + return QPointF(x, y); +} + +QSizeF KReportItemBase::sizeFromScene(const QSizeF& size) +{ + qreal w = INCH_TO_POINT(size.width() / KReportDpi::dpiX()); + qreal h = INCH_TO_POINT(size.height() / KReportDpi::dpiY()); + return QSizeF(w, h); +} + +void KReportItemBase::propertyChanged(KPropertySet& s, KProperty& p) +{ +} + + + diff --git a/src/common/KReportItemLine.h b/src/common/KReportItemLine.h --- a/src/common/KReportItemLine.h +++ b/src/common/KReportItemLine.h @@ -31,7 +31,7 @@ /** */ -class KREPORT_EXPORT KReportItemLine : public KReportItemBase +class KReportItemLine : public KReportItemBase { Q_OBJECT public: diff --git a/src/common/KReportItemLine.cpp b/src/common/KReportItemLine.cpp --- a/src/common/KReportItemLine.cpp +++ b/src/common/KReportItemLine.cpp @@ -36,8 +36,8 @@ QDomNode node; QPointF _s, _e; - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); _s.setX(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:x1"), QLatin1String("1cm")))); _s.setY(KReportUnit::parseValue(element.toElement().attribute(QLatin1String("svg:y1"), QLatin1String("1cm")))); @@ -65,25 +65,21 @@ KReportItemLine::~KReportItemLine() { - delete m_set; } void KReportItemLine::createProperties() { - m_set = new KPropertySet; - m_lineWeight = new KProperty("line-weight", 1, tr("Line Weight")); m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); m_lineStyle = new KProperty("line-style", (int)Qt::SolidLine, tr("Line Style"), tr("Line Style"), KProperty::LineStyle); m_start.setName(QLatin1String("Start")); m_end.setName(QLatin1String("End")); - m_set->addProperty(m_name); - m_set->addProperty(m_start.property()); - m_set->addProperty(m_end.property()); - m_set->addProperty(m_lineWeight); - m_set->addProperty(m_lineColor); - m_set->addProperty(m_lineStyle); + propertySet()->addProperty(m_start.property()); + propertySet()->addProperty(m_end.property()); + propertySet()->addProperty(m_lineWeight); + propertySet()->addProperty(m_lineColor); + propertySet()->addProperty(m_lineStyle); } KReportLineStyle KReportItemLine::lineStyle() const diff --git a/src/common/KReportSectionData.cpp b/src/common/KReportSectionData.cpp --- a/src/common/KReportSectionData.cpp +++ b/src/common/KReportSectionData.cpp @@ -88,7 +88,7 @@ bool KReportSectionData::zLessThan(KReportItemBase* s1, KReportItemBase* s2) { - return s1->Z < s2->Z; + return s1->z() < s2->z(); } bool KReportSectionData::xLessThan(KReportItemBase* s1, KReportItemBase* s2) diff --git a/src/common/KReportUtils.h b/src/common/KReportUtils.h --- a/src/common/KReportUtils.h +++ b/src/common/KReportUtils.h @@ -90,7 +90,7 @@ KREPORT_EXPORT void writeFontAttributes(QDomElement *el, const QFont &font); //! Writes attributes for the rect position @p pos, @p siz - KREPORT_EXPORT void buildXMLRect(QDomElement *entity, KReportPosition *pos, KReportSize *size); + KREPORT_EXPORT void buildXMLRect(QDomElement *entity, const QPointF &pos, const QSizeF &size); //! Writes attributes for text style @p ts KREPORT_EXPORT void buildXMLTextStyle(QDomDocument *doc, QDomElement *entity, const KRTextStyleData &ts); diff --git a/src/common/KReportUtils.cpp b/src/common/KReportUtils.cpp --- a/src/common/KReportUtils.cpp +++ b/src/common/KReportUtils.cpp @@ -356,13 +356,12 @@ } -void KReportUtils::buildXMLRect(QDomElement *entity, KReportPosition *pos, KReportSize *size) +void KReportUtils::buildXMLRect(QDomElement *entity, const QPointF &pos, const QSizeF &size) { Q_ASSERT(entity); - Q_ASSERT(pos); - Q_ASSERT(size); - KReportUtils::setAttribute(entity, pos->toPoint() ); - KReportUtils::setAttribute(entity, size->toPoint() ); + + KReportUtils::setAttribute(entity, pos); + KReportUtils::setAttribute(entity, size ); } void KReportUtils::buildXMLTextStyle(QDomDocument *doc, QDomElement *entity, const KRTextStyleData &ts) diff --git a/src/items/check/KReportDesignerItemCheckBox.cpp b/src/items/check/KReportDesignerItemCheckBox.cpp --- a/src/items/check/KReportDesignerItemCheckBox.cpp +++ b/src/items/check/KReportDesignerItemCheckBox.cpp @@ -34,29 +34,27 @@ if (scene) scene->addItem(this); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); - connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - setZValue(Z); + setZValue(z()); } // methods (constructors) KReportDesignerItemCheckBox::KReportDesignerItemCheckBox(KReportDesigner* d, QGraphicsScene * scene, const QPointF &pos) - : KReportDesignerItemRectBase(d) + : KReportDesignerItemRectBase(d, this) { Q_UNUSED(pos); init(scene, d); setSceneRect(properRect(*d, KREPORT_ITEM_CHECK_DEFAULT_WIDTH, KREPORT_ITEM_CHECK_DEFAULT_HEIGHT)); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); } KReportDesignerItemCheckBox::KReportDesignerItemCheckBox(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) - : KReportItemCheckBox(element), KReportDesignerItemRectBase(d) + : KReportItemCheckBox(element), KReportDesignerItemRectBase(d, this) { init(s, d); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } KReportDesignerItemCheckBox* KReportDesignerItemCheckBox::clone() @@ -94,37 +92,38 @@ painter->setPen(QPen(m_lineColor->value().value(), m_lineWeight->value().toInt(), (Qt::PenStyle)m_lineStyle->value().toInt())); } - qreal ox = m_size.toScene().width() / 5; - qreal oy = m_size.toScene().height() / 5; + 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(), m_size.toScene().width() / 10 , m_size.toScene().height() / 10); + 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, m_size.toScene().width() - ox, m_size.toScene().height() - oy); - painter->drawLine(ox, m_size.toScene().height() - oy, m_size.toScene().width() - ox, oy); + 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(), m_size.toScene().width() / 2 - ox, m_size.toScene().height() / 2 - oy); + painter->drawEllipse(rect().center(), sceneSize.width() / 2 - ox, sceneSize.height() / 2 - oy); } else { //Tickbox Style - painter->drawRoundedRect(QGraphicsRectItem::rect(), m_size.toScene().width() / 10 , m_size.toScene().height() / 10); + 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, m_size.toScene().height() / 2, m_size.toScene().width() / 2, m_size.toScene().height() - oy); - painter->drawLine(m_size.toScene().width() / 2, m_size.toScene().height() - oy, m_size.toScene().width() - ox, oy); + painter->drawLine(ox, sceneSize.height() / 2, sceneSize.width() / 2, sceneSize.height() - oy); + painter->drawLine(sceneSize.width() / 2, sceneSize.height() - oy, sceneSize.width() - ox, oy); } @@ -145,14 +144,14 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); //properties - addPropertyAsAttribute(&entity, m_name); + 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, &m_pos, &m_size); + buildXMLRect(doc, &entity, this); //Line Style buildXMLLineStyle(doc, &entity, lineStyle()); @@ -166,19 +165,19 @@ if (p.name() == "name") { //For some reason p.oldValue returns an empty string - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } KReportDesignerItemRectBase::propertyChanged(s, p); - if (m_reportDesigner) m_reportDesigner->setModified(true); + if (designer()) designer()->setModified(true); } void KReportDesignerItemCheckBox::mousePressEvent(QGraphicsSceneMouseEvent * event) { - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/items/check/KReportItemCheck.cpp b/src/items/check/KReportItemCheck.cpp --- a/src/items/check/KReportItemCheck.cpp +++ b/src/items/check/KReportItemCheck.cpp @@ -39,14 +39,14 @@ QString n; QDomNode node; - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); m_foregroundColor->setValue(QColor(element.toElement().attribute(QLatin1String("fo:foreground-color")))); m_checkStyle->setValue(element.toElement().attribute(QLatin1String("report:check-style"))); m_staticValue->setValue(QVariant(element.toElement().attribute(QLatin1String("report:value"))).toBool()); - parseReportRect(element.toElement(), &m_pos, &m_size); + parseReportRect(element.toElement()); for (int i = 0; i < nl.count(); i++) { node = nl.item(i); @@ -68,13 +68,10 @@ KReportItemCheckBox::~KReportItemCheckBox() { - delete m_set; } void KReportItemCheckBox::createProperties() { - m_set = new KPropertySet; - QStringList keys, strings; keys << QLatin1String("Cross") << QLatin1String("Tick") << QLatin1String("Dot"); @@ -91,14 +88,13 @@ m_lineStyle = new KProperty("line-style", QPen(Qt::SolidLine), tr("Line Style"), tr("Line Style"), KProperty::LineStyle); m_staticValue = new KProperty("value", QVariant(false), tr("Value"), tr("Value used if not bound to a field")); - addDefaultProperties(); - m_set->addProperty(m_controlSource); - m_set->addProperty(m_staticValue); - m_set->addProperty(m_checkStyle); - m_set->addProperty(m_foregroundColor); - m_set->addProperty(m_lineWeight); - m_set->addProperty(m_lineColor); - m_set->addProperty(m_lineStyle); + propertySet()->addProperty(m_controlSource); + propertySet()->addProperty(m_staticValue); + propertySet()->addProperty(m_checkStyle); + propertySet()->addProperty(m_foregroundColor); + propertySet()->addProperty(m_lineWeight); + propertySet()->addProperty(m_lineColor); + propertySet()->addProperty(m_lineStyle); } KReportLineStyle KReportItemCheckBox::lineStyle() @@ -126,8 +122,8 @@ { OROCheck *chk = new OROCheck(); - chk->setPosition(m_pos.toScene() + offset); - chk->setSize(m_size.toScene()); + chk->setPosition(scenePosition(position()) + offset); + chk->setSize(sceneSize(size())); chk->setLineStyle(lineStyle()); chk->setForegroundColor(m_foregroundColor->value().value()); @@ -168,7 +164,7 @@ if (section) { OROCheck *chk2 = dynamic_cast(chk->clone()); - chk2->setPosition(m_pos.toPoint()); + chk2->setPosition(scenePosition(position())); section->addPrimitive(chk2); } diff --git a/src/items/check/KReportScriptCheck.cpp b/src/items/check/KReportScriptCheck.cpp --- a/src/items/check/KReportScriptCheck.cpp +++ b/src/items/check/KReportScriptCheck.cpp @@ -92,20 +92,20 @@ QPointF CheckBox::position() const { - return m_check->m_pos.toPoint(); + return m_check->position(); } void CheckBox::setPosition(const QPointF &p) { - m_check->m_pos.setPointPos(p); + m_check->setPosition(p); } QSizeF CheckBox::size() const { - return m_check->m_size.toPoint(); + return m_check->size(); } void CheckBox::setSize(const QSizeF &s) { - m_check->m_size.setPointSize(s); + m_check->setSize(s); } } diff --git a/src/items/field/KReportDesignerItemField.cpp b/src/items/field/KReportDesignerItemField.cpp --- a/src/items/field/KReportDesignerItemField.cpp +++ b/src/items/field/KReportDesignerItemField.cpp @@ -36,31 +36,26 @@ if (scene) scene->addItem(this); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); - - connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), - this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - - setZValue(Z); + setZValue(z()); updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field")); } // methods (constructors) KReportDesignerItemField::KReportDesignerItemField(KReportDesigner * rw, QGraphicsScene * scene, const QPointF &pos) - : KReportDesignerItemRectBase(rw) + : KReportDesignerItemRectBase(rw, this) { Q_UNUSED(pos); init(scene, rw); setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height())); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); } KReportDesignerItemField::KReportDesignerItemField(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) - : KReportItemField(element), KReportDesignerItemRectBase(d) + : KReportItemField(element), KReportDesignerItemRectBase(d, this) { init(s, d); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } KReportDesignerItemField* KReportDesignerItemField::clone() @@ -79,7 +74,7 @@ QRect KReportDesignerItemField::getTextRect() const { - return QFontMetrics(font()).boundingRect(x(), y(), 0, 0, textFlags(), m_renderText); + return QFontMetrics(font()).boundingRect(x(), y(), 0, 0, textFlags(), renderText()); } @@ -103,7 +98,7 @@ painter->setPen(m_foregroundColor->value().value()); painter->fillRect(QGraphicsRectItem::rect(), bg); - painter->drawText(rect(), textFlags(), m_renderText); + painter->drawText(rect(), textFlags(), renderText()); if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) { @@ -127,7 +122,7 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties - addPropertyAsAttribute(&entity, m_name); + addPropertyAsAttribute(&entity, nameProperty()); addPropertyAsAttribute(&entity, m_controlSource); addPropertyAsAttribute(&entity, m_verticalAlignment); addPropertyAsAttribute(&entity, m_horizontalAlignment); @@ -138,7 +133,7 @@ entity.setAttribute(QLatin1String("report:z-index"), zValue()); // bounding rect - buildXMLRect(doc, &entity, &m_pos, &m_size); + buildXMLRect(doc, &entity, this); //text style info buildXMLTextStyle(doc, &entity, textStyle()); @@ -168,23 +163,23 @@ if (p.name() == "name") { //For some reason p.oldValue returns an empty string - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } updateRenderText(m_controlSource->value().toString(), m_itemValue->value().toString(), QLatin1String("field")); KReportDesignerItemRectBase::propertyChanged(s, p); - if (m_reportDesigner)m_reportDesigner->setModified(true); + if (designer())designer()->setModified(true); } void KReportDesignerItemField::mousePressEvent(QGraphicsSceneMouseEvent * event) { //kreportpluginDebug() << m_reportDesigner->fieldKeys() << m_reportDesigner->fieldNames(); - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/items/field/KReportItemField.cpp b/src/items/field/KReportItemField.cpp --- a/src/items/field/KReportItemField.cpp +++ b/src/items/field/KReportItemField.cpp @@ -41,17 +41,17 @@ QString n; QDomNode node; - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); m_canGrow->setValue(element.toElement().attribute(QLatin1String("report:can-grow"))); m_wordWrap->setValue(element.toElement().attribute(QLatin1String("report:word-wrap"))); - parseReportRect(element.toElement(), &m_pos, &m_size); + parseReportRect(element.toElement()); for (int i = 0; i < nl.count(); i++) { node = nl.item(i); @@ -81,13 +81,10 @@ KReportItemField::~KReportItemField() { - delete m_set; } void KReportItemField::createProperties() { - m_set = new KPropertySet; - QStringList keys, strings; m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); @@ -130,20 +127,19 @@ _trackTotalFormat = new KProperty("trackTotalFormat", QString(), futureI18n("Track Total Format")); #endif - addDefaultProperties(); - m_set->addProperty(m_controlSource); - m_set->addProperty(m_itemValue); - m_set->addProperty(m_horizontalAlignment); - m_set->addProperty(m_verticalAlignment); - m_set->addProperty(m_font); - m_set->addProperty(m_backgroundColor); - m_set->addProperty(m_foregroundColor); - m_set->addProperty(m_backgroundOpacity); - m_set->addProperty(m_lineWeight); - m_set->addProperty(m_lineColor); - m_set->addProperty(m_lineStyle); - m_set->addProperty(m_wordWrap); - m_set->addProperty(m_canGrow); + propertySet()->addProperty(m_controlSource); + propertySet()->addProperty(m_itemValue); + propertySet()->addProperty(m_horizontalAlignment); + propertySet()->addProperty(m_verticalAlignment); + propertySet()->addProperty(m_font); + propertySet()->addProperty(m_backgroundColor); + propertySet()->addProperty(m_foregroundColor); + propertySet()->addProperty(m_backgroundOpacity); + propertySet()->addProperty(m_lineWeight); + propertySet()->addProperty(m_lineColor); + propertySet()->addProperty(m_lineStyle); + propertySet()->addProperty(m_wordWrap); + propertySet()->addProperty(m_canGrow); //_set->addProperty ( _trackTotal ); //_set->addProperty ( _trackBuiltinFormat ); @@ -219,8 +215,8 @@ const QVariant &data, KReportScriptHandler *script) { OROTextBox * tb = new OROTextBox(); - tb->setPosition(m_pos.toScene() + offset); - tb->setSize(m_size.toScene()); + tb->setPosition(scenePosition(position()) + offset); + tb->setSize(sceneSize(size())); tb->setFont(font()); tb->setFlags(textFlags()); tb->setTextStyle(textStyle()); @@ -279,10 +275,10 @@ if (section) { OROPrimitive *clone = tb->clone(); - clone->setPosition(m_pos.toScene()); + clone->setPosition(scenePosition(position())); section->addPrimitive(clone); } - int height = m_pos.toScene().y() + tb->size().height(); + int height = scenePosition(position()).y() + tb->size().height(); //If there is no page to add the item to, delete it now because it wont be deleted later if (!page) { delete tb; diff --git a/src/items/field/KReportScriptField.cpp b/src/items/field/KReportScriptField.cpp --- a/src/items/field/KReportScriptField.cpp +++ b/src/items/field/KReportScriptField.cpp @@ -164,20 +164,20 @@ QPointF Field::position() const { - return m_field->m_pos.toPoint(); + return m_field->position(); } void Field::setPosition(const QPointF &p) { - m_field->m_pos.setPointPos(p); + m_field->setPosition(p); } QSizeF Field::size() const { - return m_field->m_size.toPoint(); + return m_field->size(); } void Field::setSize(const QSizeF &s) { - m_field->m_size.setPointSize(s); + m_field->setSize(s); } } diff --git a/src/items/image/KReportDesignerItemImage.cpp b/src/items/image/KReportDesignerItemImage.cpp --- a/src/items/image/KReportDesignerItemImage.cpp +++ b/src/items/image/KReportDesignerItemImage.cpp @@ -37,30 +37,28 @@ if (scene) scene->addItem(this); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); - - connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), + connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); - setZValue(Z); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); + setZValue(z()); } KReportDesignerItemImage::KReportDesignerItemImage(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) - : KReportDesignerItemRectBase(rw) + : KReportDesignerItemRectBase(rw, this) { Q_UNUSED(pos); //kreportpluginDebug(); init(scene, rw); setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); } KReportDesignerItemImage::KReportDesignerItemImage(const QDomNode & element, KReportDesigner * rw, QGraphicsScene* scene) - : KReportItemImage(element), KReportDesignerItemRectBase(rw) + : KReportItemImage(element), KReportDesignerItemRectBase(rw, this) { init(scene, rw); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } KReportDesignerItemImage* KReportDesignerItemImage::clone() @@ -113,10 +111,10 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties - addPropertyAsAttribute(&entity, m_name); + addPropertyAsAttribute(&entity, nameProperty()); addPropertyAsAttribute(&entity, m_resizeMode); - entity.setAttribute(QLatin1String("report:z-index"), zValue()); - buildXMLRect(doc, &entity, &m_pos, &m_size); + entity.setAttribute(QLatin1String("report:z-index"), z()); + buildXMLRect(doc, &entity, this); if (isInline()) { @@ -134,19 +132,19 @@ { if (p.name() == "name") { //For some reason p.oldValue returns an empty string - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } KReportDesignerItemRectBase::propertyChanged(s, p); - if (m_reportDesigner) m_reportDesigner->setModified(true); + if (designer()) designer()->setModified(true); } void KReportDesignerItemImage::mousePressEvent(QGraphicsSceneMouseEvent * event) { - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/items/image/KReportItemImage.cpp b/src/items/image/KReportItemImage.cpp --- a/src/items/image/KReportItemImage.cpp +++ b/src/items/image/KReportItemImage.cpp @@ -37,12 +37,12 @@ QString n; QDomNode node; - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); m_resizeMode->setValue(element.toElement().attribute(QLatin1String("report:resize-mode"), QLatin1String("stretch"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); - parseReportRect(element.toElement(), &m_pos, &m_size); + parseReportRect(element.toElement()); for (int i = 0; i < nl.count(); i++) { node = nl.item(i); @@ -60,7 +60,6 @@ KReportItemImage::~KReportItemImage() { - delete m_set; } bool KReportItemImage::isInline() const @@ -113,8 +112,6 @@ void KReportItemImage::createProperties() { - m_set = new KPropertySet; - m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); QStringList keys, strings; @@ -124,10 +121,9 @@ m_staticImage = new KProperty("static-image", QPixmap(), tr("Value"), tr("Value used if not bound to a field")); - addDefaultProperties(); - m_set->addProperty(m_controlSource); - m_set->addProperty(m_resizeMode); - m_set->addProperty(m_staticImage); + propertySet()->addProperty(m_controlSource); + propertySet()->addProperty(m_resizeMode); + propertySet()->addProperty(m_staticImage); } @@ -170,15 +166,15 @@ id->setTransformationMode(Qt::SmoothTransformation); } - id->setPosition(m_pos.toScene() + offset); - id->setSize(m_size.toScene()); + id->setPosition(scenePosition(position()) + offset); + id->setSize(sceneSize(size())); if (page) { page->addPrimitive(id); } if (section) { OROImage *i2 = dynamic_cast(id->clone()); - i2->setPosition(m_pos.toPoint()); + i2->setPosition(scenePosition(position())); section->addPrimitive(i2); } diff --git a/src/items/image/KReportScriptImage.cpp b/src/items/image/KReportScriptImage.cpp --- a/src/items/image/KReportScriptImage.cpp +++ b/src/items/image/KReportScriptImage.cpp @@ -35,20 +35,20 @@ QPointF Image::position() const { - return m_image->m_pos.toPoint(); + return m_image->position(); } void Image::setPosition(const QPointF& p) { - m_image->m_pos.setPointPos(p); + m_image->setPosition(p); } QSizeF Image::size() const { - return m_image->m_size.toPoint(); + return m_image->size(); } void Image::setSize(const QSizeF& s) { - m_image->m_size.setPointSize(s); + m_image->setSize(s); } QString Image::resizeMode() const diff --git a/src/items/label/KReportDesignerItemLabel.cpp b/src/items/label/KReportDesignerItemLabel.cpp --- a/src/items/label/KReportDesignerItemLabel.cpp +++ b/src/items/label/KReportDesignerItemLabel.cpp @@ -35,12 +35,10 @@ if (scene) scene->addItem(this); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); - connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - setZValue(Z); + setZValue(z()); setFlag(ItemIsFocusable); m_inlineEdit = new BoundedTextItem(this); @@ -57,21 +55,21 @@ // methods (constructors) KReportDesignerItemLabel::KReportDesignerItemLabel(KReportDesigner* d, QGraphicsScene * scene, const QPointF &pos) - : KReportDesignerItemRectBase(d) + : KReportDesignerItemRectBase(d, this) { Q_UNUSED(pos); init(scene, d); setSceneRect(properRect(*d, getTextRect().width(), getTextRect().height())); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); enterInlineEditingMode(); } KReportDesignerItemLabel::KReportDesignerItemLabel(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) - : KReportItemLabel(element), KReportDesignerItemRectBase(d), m_inlineEdit(0) + : KReportItemLabel(element), KReportDesignerItemRectBase(d, this), m_inlineEdit(0) { init(s, d); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } KReportDesignerItemLabel* KReportDesignerItemLabel::clone() @@ -139,14 +137,14 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties - addPropertyAsAttribute(&entity, m_name); + addPropertyAsAttribute(&entity, nameProperty()); addPropertyAsAttribute(&entity, m_text); addPropertyAsAttribute(&entity, m_verticalAlignment); addPropertyAsAttribute(&entity, m_horizontalAlignment); - entity.setAttribute(QLatin1String("report:z-index"), zValue()); + entity.setAttribute(QLatin1String("report:z-index"), z()); // bounding rect - buildXMLRect(doc, &entity, &m_pos, &m_size); + buildXMLRect(doc, &entity, this); //text style info buildXMLTextStyle(doc, &entity, textStyle()); @@ -163,17 +161,17 @@ if (p.name() == "name") { //For some reason p.oldValue returns an empty string - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } else if (p.name() == "caption") { m_inlineEdit->setPlainText(p.value().toString()); } KReportDesignerItemRectBase::propertyChanged(s, p); - if (m_reportDesigner) m_reportDesigner->setModified(true); + if (designer()) designer()->setModified(true); } diff --git a/src/items/label/KReportItemLabel.cpp b/src/items/label/KReportItemLabel.cpp --- a/src/items/label/KReportItemLabel.cpp +++ b/src/items/label/KReportItemLabel.cpp @@ -37,13 +37,13 @@ QString n; QDomNode node; - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); m_text->setValue(element.toElement().attribute(QLatin1String("report:caption"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); - parseReportRect(element.toElement(), &m_pos, &m_size); + parseReportRect(element.toElement()); for (int i = 0; i < nl.count(); i++) { node = nl.item(i); @@ -73,7 +73,6 @@ KReportItemLabel::~KReportItemLabel() { - delete m_set; } QString KReportItemLabel::text() const @@ -88,8 +87,6 @@ void KReportItemLabel::createProperties() { - m_set = new KPropertySet; - m_text = new KProperty("caption", QLatin1String("Label"), tr("Caption")); QStringList keys, strings; @@ -117,17 +114,16 @@ m_lineColor = new KProperty("line-color", QColor(Qt::black), tr("Line Color")); m_lineStyle = new KProperty("line-style", QPen(Qt::NoPen), tr("Line Style"), tr("Line Style"), KProperty::LineStyle); - addDefaultProperties(); - m_set->addProperty(m_text); - m_set->addProperty(m_horizontalAlignment); - m_set->addProperty(m_verticalAlignment); - m_set->addProperty(m_font); - m_set->addProperty(m_backgroundColor); - m_set->addProperty(m_foregroundColor); - m_set->addProperty(m_backgroundOpacity); - m_set->addProperty(m_lineWeight); - m_set->addProperty(m_lineColor); - m_set->addProperty(m_lineStyle); + propertySet()->addProperty(m_text); + propertySet()->addProperty(m_horizontalAlignment); + propertySet()->addProperty(m_verticalAlignment); + propertySet()->addProperty(m_font); + propertySet()->addProperty(m_backgroundColor); + propertySet()->addProperty(m_foregroundColor); + propertySet()->addProperty(m_backgroundOpacity); + propertySet()->addProperty(m_lineWeight); + propertySet()->addProperty(m_lineColor); + propertySet()->addProperty(m_lineStyle); } Qt::Alignment KReportItemLabel::textFlags() const @@ -185,8 +181,8 @@ Q_UNUSED(script) OROTextBox * tb = new OROTextBox(); - tb->setPosition(m_pos.toScene() + offset); - tb->setSize(m_size.toScene()); + tb->setPosition(scenePosition(position()) + offset); + tb->setSize(sceneSize(size())); tb->setFont(font()); tb->setText(text()); tb->setFlags(textFlags()); @@ -199,7 +195,7 @@ if (section) { OROPrimitive *clone = tb->clone(); - clone->setPosition(m_pos.toScene()); + clone->setPosition(scenePosition(position())); section->addPrimitive(clone); } diff --git a/src/items/label/KReportScriptLabel.cpp b/src/items/label/KReportScriptLabel.cpp --- a/src/items/label/KReportScriptLabel.cpp +++ b/src/items/label/KReportScriptLabel.cpp @@ -164,20 +164,20 @@ QPointF Label::position() const { - return m_label->m_pos.toPoint(); + return m_label->position(); } void Label::setPosition(const QPointF &p) { - m_label->m_pos.setPointPos(p); + m_label->setPosition(p); } QSizeF Label::size() const { - return m_label->m_size.toPoint(); + return m_label->size(); } void Label::setSize(const QSizeF &s) { - m_label->m_size.setPointSize(s); + m_label->setSize(s); } } diff --git a/src/items/text/KReportDesignerItemText.cpp b/src/items/text/KReportDesignerItemText.cpp --- a/src/items/text/KReportDesignerItemText.cpp +++ b/src/items/text/KReportDesignerItemText.cpp @@ -42,29 +42,27 @@ connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); - - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); - setZValue(Z); + 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) + : KReportDesignerItemRectBase(rw, this) { Q_UNUSED(pos); init(scene, rw); setSceneRect(properRect(*rw, getTextRect().width(), getTextRect().height())); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); } KReportDesignerItemText::KReportDesignerItemText(const QDomNode & element, KReportDesigner * d, QGraphicsScene * s) - : KReportItemText(element), KReportDesignerItemRectBase(d) + : KReportItemText(element), KReportDesignerItemRectBase(d, this) { init(s, d); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } KReportDesignerItemText* KReportDesignerItemText::clone() @@ -84,7 +82,7 @@ QRect KReportDesignerItemText::getTextRect() const { - return QFontMetrics(font()).boundingRect(int (x()), int (y()), 0, 0, textFlags(), m_renderText); + return QFontMetrics(font()).boundingRect(int (x()), int (y()), 0, 0, textFlags(), renderText()); } void KReportDesignerItemText::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) @@ -105,7 +103,7 @@ painter->setPen(m_foregroundColor->value().value()); painter->fillRect(rect(), bg); - painter->drawText(rect(), textFlags(), m_renderText); + painter->drawText(rect(), textFlags(), renderText()); if ((Qt::PenStyle)m_lineStyle->value().toInt() == Qt::NoPen || m_lineWeight->value().toInt() <= 0) { painter->setPen(QPen(Qt::lightGray)); @@ -129,16 +127,16 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties - addPropertyAsAttribute(&entity, m_name); + 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"), zValue()); + entity.setAttribute(QLatin1String("report:z-index"), z()); addPropertyAsAttribute(&entity, m_itemValue); // bounding rect - buildXMLRect(doc, &entity, &m_pos, &m_size); + buildXMLRect(doc, &entity, this); //text style info buildXMLTextStyle(doc, &entity, textStyle()); @@ -151,33 +149,26 @@ void KReportDesignerItemText::mousePressEvent(QGraphicsSceneMouseEvent * event) { - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); KReportDesignerItemRectBase::mousePressEvent(event); } void KReportDesignerItemText::slotPropertyChanged(KPropertySet &s, KProperty &p) { Q_UNUSED(s); - if (p.name() == "position") { - m_pos.setUnitPos(p.value().toPointF(), KReportPosition::DontUpdateProperty); - } else if (p.name() == "size") { - m_size.setUnitSize(p.value().toSizeF(), KReportSize::DontUpdateProperty); - } else if (p.name() == "name") { + if (p.name() == "name") { //For some reason p.oldValue returns an empty string - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } - setSceneRect(m_pos.toScene(), m_size.toScene(), DontUpdateProperty); - if (m_reportDesigner) - m_reportDesigner->setModified(true); - if (scene()) - scene()->update(); + 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/KReportItemText.cpp b/src/items/text/KReportItemText.cpp --- a/src/items/text/KReportItemText.cpp +++ b/src/items/text/KReportItemText.cpp @@ -39,15 +39,15 @@ QDomNode node; createProperties(); - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); m_verticalAlignment->setValue(element.toElement().attribute(QLatin1String("report:vertical-align"))); m_bottomPadding = element.toElement().attribute(QLatin1String("report:bottom-padding")).toDouble(); - parseReportRect(element.toElement(), &m_pos, &m_size); + parseReportRect(element.toElement()); for (int i = 0; i < nl.count(); i++) { node = nl.item(i); @@ -78,7 +78,6 @@ KReportItemText::~KReportItemText() { - delete m_set; } Qt::Alignment KReportItemText::textFlags() const @@ -106,8 +105,6 @@ void KReportItemText::createProperties() { - m_set = new KPropertySet; - //connect ( set, SIGNAL ( propertyChanged ( KPropertySet &, KProperty & ) ), this, SLOT ( propertyChanged ( KPropertySet &, KProperty & ) ) ); QStringList keys, strings; @@ -140,18 +137,17 @@ m_backgroundOpacity->setOption("min", 0); m_backgroundOpacity->setOption("unit", QLatin1String("%")); - addDefaultProperties(); - m_set->addProperty(m_controlSource); - m_set->addProperty(m_itemValue); - m_set->addProperty(m_horizontalAlignment); - m_set->addProperty(m_verticalAlignment); - m_set->addProperty(m_font); - m_set->addProperty(m_backgroundColor); - m_set->addProperty(m_foregroundColor); - m_set->addProperty(m_backgroundOpacity); - m_set->addProperty(m_lineWeight); - m_set->addProperty(m_lineColor); - m_set->addProperty(m_lineStyle); + propertySet()->addProperty(m_controlSource); + propertySet()->addProperty(m_itemValue); + propertySet()->addProperty(m_horizontalAlignment); + propertySet()->addProperty(m_verticalAlignment); + propertySet()->addProperty(m_font); + propertySet()->addProperty(m_backgroundColor); + propertySet()->addProperty(m_foregroundColor); + propertySet()->addProperty(m_backgroundOpacity); + propertySet()->addProperty(m_lineWeight); + propertySet()->addProperty(m_lineColor); + propertySet()->addProperty(m_lineStyle); } @@ -216,12 +212,12 @@ } else { qstrValue = m_itemValue->value().toString(); } - - QPointF pos = m_pos.toScene(); - QSizeF size = m_size.toScene(); + + QPointF pos = scenePosition(position()); + QSizeF siz = sceneSize(size()); pos += offset; - QRectF trf(pos, size); + QRectF trf(pos, siz); qreal intStretch = trf.top() - offset.y(); if (qstrValue.length()) { @@ -234,7 +230,7 @@ QFontMetrics fm(font(), &prnt); // int intRectWidth = (int)(trf.width() * prnt.resolution()) - 10; - int intRectWidth = (int)((m_size.toPoint().width() / 72) * prnt.resolution()); + int intRectWidth = (int)((size().width() / 72) * prnt.resolution()); int intLineCounter = 0; qreal intBaseTop = trf.top(); qreal intRectHeight = trf.height(); @@ -274,7 +270,7 @@ if (section) { OROTextBox *tb2 = dynamic_cast(tb->clone()); - tb2->setPosition(m_pos.toPoint()); + tb2->setPosition(scenePosition(position())); section->addPrimitive(tb2); } diff --git a/src/items/text/KReportScriptText.cpp b/src/items/text/KReportScriptText.cpp --- a/src/items/text/KReportScriptText.cpp +++ b/src/items/text/KReportScriptText.cpp @@ -168,20 +168,20 @@ QPointF Text::position() const { - return m_text->m_pos.toPoint(); + return m_text->position(); } void Text::setPosition(const QPointF& p) { - m_text->m_pos.setPointPos(p); + m_text->setPosition(p); } QSizeF Text::size() const { - return m_text->m_size.toPoint(); + return m_text->size(); } void Text::setSize(const QSizeF& s) { - m_text->m_size.setPointSize(s); + m_text->setSize(s); } void Text::loadFromFile(const QString &fn) diff --git a/src/plugins/barcode/KReportDesignerItemBarcode.cpp b/src/plugins/barcode/KReportDesignerItemBarcode.cpp --- a/src/plugins/barcode/KReportDesignerItemBarcode.cpp +++ b/src/plugins/barcode/KReportDesignerItemBarcode.cpp @@ -36,31 +36,30 @@ if (scene) scene->addItem(this); - connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), + connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); setMaxLength(5); - setZValue(Z); + 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) + : KReportDesignerItemRectBase(rw, this) { Q_UNUSED(pos); init(scene, rw); setSceneRect(properRect(*rw, m_minWidthTotal*m_dpiX, m_minHeight*m_dpiY)); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); } KReportDesignerItemBarcode::KReportDesignerItemBarcode(const QDomNode & element, KReportDesigner * rw, QGraphicsScene* scene) - : KReportItemBarcode(element), KReportDesignerItemRectBase(rw) + : KReportItemBarcode(element), KReportDesignerItemRectBase(rw, this) { init(scene, rw); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } KReportDesignerItemBarcode* KReportDesignerItemBarcode::clone() @@ -105,21 +104,21 @@ QByteArray fmt = m_format->value().toByteArray(); if (fmt == "i2of5") { - renderI2of5(rect().toRect(), m_renderText, alignment(), painter); + renderI2of5(rect().toRect(), renderText(), alignment(), painter); } else if (fmt == "3of9") { - render3of9(rect().toRect(), m_renderText, alignment(), painter); + render3of9(rect().toRect(), renderText(), alignment(), painter); } else if (fmt == "3of9+") { - renderExtended3of9(rect().toRect(), m_renderText, alignment(), painter); + renderExtended3of9(rect().toRect(), renderText(), alignment(), painter); } else if (fmt == "128") { - renderCode128(rect().toRect(), m_renderText, alignment(), painter); + renderCode128(rect().toRect(), renderText(), alignment(), painter); } else if (fmt == "upc-a") { - renderCodeUPCA(rect().toRect(), m_renderText, alignment(), painter); + renderCodeUPCA(rect().toRect(), renderText(), alignment(), painter); } else if (fmt == "upc-e") { - renderCodeUPCE(rect().toRect(), m_renderText, alignment(), painter); + renderCodeUPCE(rect().toRect(), renderText(), alignment(), painter); } else if (fmt == "ean13") { - renderCodeEAN13(rect().toRect(), m_renderText, alignment(), painter); + renderCodeEAN13(rect().toRect(), renderText(), alignment(), painter); } else if (fmt == "ean8") { - renderCodeEAN8(rect().toRect(), m_renderText, alignment(), painter); + renderCodeEAN8(rect().toRect(), renderText(), alignment(), painter); } painter->setPen(Qt::black); @@ -136,39 +135,39 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties - addPropertyAsAttribute(&entity, m_name); + 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, &m_pos, &m_size); + 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 (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + 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 (m_reportDesigner) m_reportDesigner->setModified(true); + if (designer()) designer()->setModified(true); } void KReportDesignerItemBarcode::mousePressEvent(QGraphicsSceneMouseEvent * event) { - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/plugins/barcode/KReportItemBarcode.cpp b/src/plugins/barcode/KReportItemBarcode.cpp --- a/src/plugins/barcode/KReportItemBarcode.cpp +++ b/src/plugins/barcode/KReportItemBarcode.cpp @@ -39,14 +39,14 @@ QString n; QDomNode node; - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); m_itemValue->setValue(element.toElement().attribute(QLatin1String("report:value"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); m_horizontalAlignment->setValue(element.toElement().attribute(QLatin1String("report:horizontal-align"))); m_maxLength->setValue(element.toElement().attribute(QLatin1String("report:barcode-max-length"))); m_format->setValue(element.toElement().attribute(QLatin1String("report:barcode-format"))); - parseReportRect(element.toElement(), &m_pos, &m_size); + parseReportRect(element.toElement()); } @@ -118,8 +118,6 @@ void KReportItemBarcode::createProperties() { - m_set = new KPropertySet; - QStringList keys, strings; m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), @@ -152,17 +150,15 @@ m_maxLength = new KProperty("barcode-max-length", 5, tr("Max Length"), tr("Maximum Barcode Length")); - addDefaultProperties(); - m_set->addProperty(m_controlSource); - m_set->addProperty(m_itemValue); - m_set->addProperty(m_format); - m_set->addProperty(m_horizontalAlignment); - m_set->addProperty(m_maxLength); + propertySet()->addProperty(m_controlSource); + propertySet()->addProperty(m_itemValue); + propertySet()->addProperty(m_format); + propertySet()->addProperty(m_horizontalAlignment); + propertySet()->addProperty(m_maxLength); } KReportItemBarcode::~KReportItemBarcode() { - delete m_set; } int KReportItemBarcode::alignment() @@ -216,11 +212,11 @@ Q_UNUSED(section); Q_UNUSED(script); - QPointF pos = m_pos.toScene(); - QSizeF size = m_size.toScene(); + QPointF pos = scenePosition(position()); + QSizeF siz = sceneSize(size()); pos += offset; - QRectF rect = QRectF(pos, size); + QRectF rect = QRectF(pos, siz); QString val; diff --git a/src/plugins/barcode/KReportScriptBarcode.cpp b/src/plugins/barcode/KReportScriptBarcode.cpp --- a/src/plugins/barcode/KReportScriptBarcode.cpp +++ b/src/plugins/barcode/KReportScriptBarcode.cpp @@ -34,20 +34,20 @@ QPointF Barcode::position() { - return m_barcode->m_pos.toPoint(); + return m_barcode->position(); } void Barcode::setPosition(const QPointF& p) { - m_barcode->m_pos.setPointPos(p); + m_barcode->setPosition(p); } QSizeF Barcode::size() { - return m_barcode->m_size.toPoint(); + return m_barcode->size(); } void Barcode::setSize(const QSizeF& s) { - m_barcode->m_size.setPointSize(s); + m_barcode->setSize(s); } int Barcode::horizontalAlignment() diff --git a/src/plugins/maps/KReportDesignerItemMaps.cpp b/src/plugins/maps/KReportDesignerItemMaps.cpp --- a/src/plugins/maps/KReportDesignerItemMaps.cpp +++ b/src/plugins/maps/KReportDesignerItemMaps.cpp @@ -34,29 +34,27 @@ if (scene) scene->addItem(this); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); - - connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), + connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); - setZValue(Z); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); + setZValue(z()); } KReportDesignerItemMaps::KReportDesignerItemMaps(KReportDesigner * rw, QGraphicsScene* scene, const QPointF &pos) - : KReportDesignerItemRectBase(rw) + : KReportDesignerItemRectBase(rw, this) { Q_UNUSED(pos); init(scene, rw); setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); } KReportDesignerItemMaps::KReportDesignerItemMaps(const QDomNode &element, KReportDesigner * rw, QGraphicsScene* scene) - : KReportItemMaps(element), KReportDesignerItemRectBase(rw) + : KReportItemMaps(element), KReportDesignerItemRectBase(rw, this) { init(scene, rw); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } KReportDesignerItemMaps* KReportDesignerItemMaps::clone() @@ -99,15 +97,15 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties - addPropertyAsAttribute(&entity, m_name); + 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"), zValue()); - buildXMLRect(doc, &entity, &m_pos, &m_size); + entity.setAttribute(QLatin1String("report:z-index"), z()); + buildXMLRect(doc, &entity, this); parent->appendChild(entity); } @@ -117,19 +115,19 @@ //kreportpluginDebug() << p.name() << ":" << p.value(); if (p.name().toLower() == "name") { //For some reason p.oldValue returns an empty string - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } KReportDesignerItemRectBase::propertyChanged(s, p); - if (m_reportDesigner) m_reportDesigner->setModified(true); + if (designer()) designer()->setModified(true); } void KReportDesignerItemMaps::mousePressEvent(QGraphicsSceneMouseEvent * event) { - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/plugins/maps/KReportItemMaps.h b/src/plugins/maps/KReportItemMaps.h --- a/src/plugins/maps/KReportItemMaps.h +++ b/src/plugins/maps/KReportItemMaps.h @@ -63,7 +63,6 @@ int zoom() const; QString themeId() const; - QSize size() const; OROPicture* oroImage(); protected: diff --git a/src/plugins/maps/KReportItemMaps.cpp b/src/plugins/maps/KReportItemMaps.cpp --- a/src/plugins/maps/KReportItemMaps.cpp +++ b/src/plugins/maps/KReportItemMaps.cpp @@ -46,28 +46,25 @@ { createProperties(); - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); m_latitudeProperty->setValue(element.toElement().attribute(QLatin1String("report:latitude")).toDouble()); m_longitudeProperty->setValue(element.toElement().attribute(QLatin1String("report:longitude")).toDouble()); m_zoomProperty->setValue(element.toElement().attribute(QLatin1String("report:zoom")).toInt()); QString themeId(element.toElement().attribute(QLatin1String("report:theme"))); themeId = themeId.isEmpty() ? m_themeManager.mapThemeIds()[0] : themeId; m_themeProperty->setValue(themeId); - parseReportRect(element.toElement(), &m_pos, &m_size); + parseReportRect(element.toElement()); } KReportItemMaps::~KReportItemMaps() { - delete m_set; } void KReportItemMaps::createProperties() { - m_set = new KPropertySet; - m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); m_latitudeProperty = new KProperty("latitude", 0.0, tr("Latitude"), tr("Latitude"), KProperty::Double); @@ -98,12 +95,11 @@ m_themeProperty->setValue(QLatin1String("earth/srtm/srtm.dgml"), false); } - addDefaultProperties(); - m_set->addProperty(m_controlSource); - m_set->addProperty(m_latitudeProperty); - m_set->addProperty(m_longitudeProperty); - m_set->addProperty(m_zoomProperty); - m_set->addProperty(m_themeProperty); + propertySet()->addProperty(m_controlSource); + propertySet()->addProperty(m_latitudeProperty); + propertySet()->addProperty(m_longitudeProperty); + propertySet()->addProperty(m_zoomProperty); + propertySet()->addProperty(m_themeProperty); } @@ -134,17 +130,17 @@ m_oroPicture = new OROPicture(); - m_oroPicture->setPosition(m_pos.toScene() + m_offset); - m_oroPicture->setSize(m_size.toScene()); + m_oroPicture->setPosition(scenePosition(position()) + m_offset); + m_oroPicture->setSize(sceneSize(size())); if (m_pageId) { m_pageId->addPrimitive(m_oroPicture); } if (m_sectionId) { OROPicture *i2 = dynamic_cast(m_oroPicture->clone()); if (i2) { - i2->setPosition(m_pos.toPoint()); + i2->setPosition(scenePosition(position())); } } @@ -193,11 +189,6 @@ return m_zoom; } -QSize KReportItemMaps::size() const -{ - return m_size.toScene().toSize(); -} - QString KReportItemMaps::themeId() const { return m_themeProperty->value().toString(); diff --git a/src/plugins/maps/KReportMapRenderer.cpp b/src/plugins/maps/KReportMapRenderer.cpp --- a/src/plugins/maps/KReportMapRenderer.cpp +++ b/src/plugins/maps/KReportMapRenderer.cpp @@ -63,7 +63,7 @@ m_marble.setMapThemeId(m_currentJob->themeId()); //some themes enable overview map, and this must be disabled after theme switch. m_marble.setShowOverviewMap(false); - m_marble.setSize(m_currentJob->size()); + m_marble.setSize(KReportItemBase::sceneSize(m_currentJob->size()).toSize()); m_marble.centerOn(m_currentJob->longtitude(), m_currentJob->latitude()); m_marble.setRadius(pow(M_E, (zoom / 200.0))); diff --git a/src/plugins/maps/KReportScriptMaps.cpp b/src/plugins/maps/KReportScriptMaps.cpp --- a/src/plugins/maps/KReportScriptMaps.cpp +++ b/src/plugins/maps/KReportScriptMaps.cpp @@ -35,22 +35,22 @@ QPointF Maps::position() const { - return m_map->m_pos.toPoint(); + return m_map->position(); } void Maps::setPosition(const QPointF& p) { - m_map->m_pos.setPointPos(p); + m_map->setPosition(p); } QSizeF Maps::size() const { - return m_map->m_size.toPoint(); + return m_map->size(); } void Maps::setSize(const QSizeF& s) { - m_map->m_size.setPointSize(s); + m_map->setSize(s); } void Maps::setLatitude(qreal latitude) diff --git a/src/plugins/web/KReportDesignerItemWeb.cpp b/src/plugins/web/KReportDesignerItemWeb.cpp --- a/src/plugins/web/KReportDesignerItemWeb.cpp +++ b/src/plugins/web/KReportDesignerItemWeb.cpp @@ -31,35 +31,34 @@ #include #include "kreportplugin_debug.h" -void KReportDesignerItemWeb::init(QGraphicsScene *scene, KReportDesigner *d) //done,compared,add function if necessary +void KReportDesignerItemWeb::init(QGraphicsScene *scene, KReportDesigner *d) { if (scene) scene->addItem(this); - connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); - setZValue(Z); + connect(propertySet(), SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); + + setZValue(z()); } KReportDesignerItemWeb::KReportDesignerItemWeb(KReportDesigner *rw, QGraphicsScene *scene, - const QPointF &pos) //done,compared - : KReportDesignerItemRectBase(rw) + const QPointF &pos) : KReportDesignerItemRectBase(rw, this) { Q_UNUSED(pos); init(scene, rw); setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + nameProperty()->setValue(designer()->suggestEntityName(typeName())); } KReportDesignerItemWeb::KReportDesignerItemWeb(const QDomNode &element, KReportDesigner *rw, - QGraphicsScene *scene) //done,compared - : KReportItemWeb(element), KReportDesignerItemRectBase(rw) + QGraphicsScene *scene) + : KReportItemWeb(element), KReportDesignerItemRectBase(rw, this) { init(scene, rw); - setSceneRect(m_pos.toScene(), m_size.toScene()); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } -KReportDesignerItemWeb *KReportDesignerItemWeb::clone() //done,compared +KReportDesignerItemWeb *KReportDesignerItemWeb::clone() { QDomDocument d; QDomElement e = d.createElement(QLatin1String("clone")); @@ -95,31 +94,31 @@ // properties addPropertyAsAttribute(&entity, m_controlSource); - addPropertyAsAttribute(&entity, m_name); + addPropertyAsAttribute(&entity, nameProperty()); entity.setAttribute(QLatin1String("report:z-index"), zValue()); - buildXMLRect(doc, &entity, &m_pos, &m_size); + buildXMLRect(doc, &entity, this); parent->appendChild(entity); } void KReportDesignerItemWeb::slotPropertyChanged(KPropertySet &s, KProperty &p) { if (p.name() == "name") { - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } KReportDesignerItemRectBase::propertyChanged(s, p); - if (m_reportDesigner) { - m_reportDesigner->setModified(true); + if (designer()) { + designer()->setModified(true); } } void KReportDesignerItemWeb::mousePressEvent(QGraphicsSceneMouseEvent *event) { - m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); + m_controlSource->setListData(designer()->fieldKeys(), designer()->fieldNames()); KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/plugins/web/KReportItemWeb.cpp b/src/plugins/web/KReportItemWeb.cpp --- a/src/plugins/web/KReportItemWeb.cpp +++ b/src/plugins/web/KReportItemWeb.cpp @@ -48,9 +48,9 @@ QDomElement e = element.toElement(); m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); - m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); - Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); - parseReportRect(element.toElement(), &m_pos, &m_size); + nameProperty()->setValue(element.toElement().attribute(QLatin1String("report:name"))); + setZ(element.toElement().attribute(QLatin1String("report:z-index")).toDouble()); + parseReportRect(element.toElement()); for (int i = 0; i < nl.count(); i++) { node = nl.item(i); n = node.nodeName(); @@ -66,18 +66,15 @@ void KReportItemWeb::createProperties() { - m_set = new KPropertySet; - m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); - m_set->addProperty(m_controlSource); - addDefaultProperties(); + propertySet()->addProperty(m_controlSource); } KReportItemWeb::~KReportItemWeb() { - delete m_set; } + QString KReportItemWeb::typeName() const { return QLatin1String("web"); @@ -88,30 +85,31 @@ //kreportpluginDebug() << m_rendering; if (m_rendering) { OROPicture * pic = new OROPicture(); - m_webPage->setViewportSize(m_size.toScene().toSize()); + m_webPage->setViewportSize(sceneSize(size()).toSize()); m_webPage->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); m_webPage->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); QPainter p(pic->picture()); m_webPage->mainFrame()->render(&p); - QPointF pos = m_pos.toScene(); - QSizeF size = m_size.toScene(); + QPointF pos = scenePosition(position()); + QSizeF siz = sceneSize(size()); pos += m_targetOffset; pic->setPosition(pos); - pic->setSize(size); + pic->setSize(siz); if (m_targetPage) m_targetPage->addPrimitive(pic, false, true); OROPicture *p2 = dynamic_cast(pic->clone()); if (p2) { - p2->setPosition(m_pos.toPoint()); + p2->setPosition(scenePosition(position())); if (m_targetSection) { m_targetSection->addPrimitive(p2); } } + m_rendering = false; emit(finishedRendering()); } diff --git a/src/wrtembed/KReportDesigner.cpp b/src/wrtembed/KReportDesigner.cpp --- a/src/wrtembed/KReportDesigner.cpp +++ b/src/wrtembed/KReportDesigner.cpp @@ -1021,6 +1021,7 @@ item->setSelected(true); KReportItemBase* baseReportItem = dynamic_cast(item); if (baseReportItem) { + baseReportItem->setUnit(pageUnit()); KPropertySet *set = baseReportItem->propertySet(); KReportDesigner::addMetaProperties(set, classString, iconName); changeSet(set); @@ -1173,9 +1174,9 @@ KReportItemBase *new_obj = dynamic_cast(ent); new_obj->setEntityName(suggestEntityName(type)); if (activeItem) { - new_obj->position().setScenePos(QPointF(activeItem->x() + 10, activeItem->y() + 10)); + new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); } else { - new_obj->position().setScenePos(QPointF(0, 0)); + new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); } changeSet(new_obj->propertySet()); QGraphicsItem *pasted_ent = dynamic_cast(ent); diff --git a/src/wrtembed/KReportDesignerItemBase.h b/src/wrtembed/KReportDesignerItemBase.h --- a/src/wrtembed/KReportDesignerItemBase.h +++ b/src/wrtembed/KReportDesignerItemBase.h @@ -46,28 +46,20 @@ static void buildXML(QGraphicsItem * item, QDomDocument *doc, QDomElement *parent); virtual void buildXML(QDomDocument *doc, QDomElement *parent) = 0; - static void buildXMLRect(QDomDocument *doc, QDomElement *entity, KReportPosition *pos, KReportSize *size); + static void buildXMLRect(QDomDocument *doc, QDomElement *entity, KReportItemBase *i); static void buildXMLTextStyle(QDomDocument *doc, QDomElement *entity, const KRTextStyleData &ts); static void buildXMLLineStyle(QDomDocument *doc, QDomElement *entity, const KReportLineStyle &ls); - static QFont getDefaultEntityFont(); - static void setDefaultEntityFont(const QFont &); - virtual KReportDesignerItemBase* clone() = 0; virtual void move(const QPointF&) = 0; - KReportDesigner* designer() const { - return m_reportDesigner; - } - void setDesigner(KReportDesigner* rd) { - m_reportDesigner = rd; - } + KReportDesigner* designer() const; + void setDesigner(KReportDesigner* rd); static void addPropertyAsAttribute(QDomElement* e, KProperty* p); protected: - explicit KReportDesignerItemBase(KReportDesigner*); - KReportDesigner* m_reportDesigner; + explicit KReportDesignerItemBase(KReportDesigner*, KReportItemBase*); QString dataSourceAndObjectTypeName(const QString& dataSource, const QString& objectTypeName) const; /** @@ -80,12 +72,15 @@ * @param itemType type of item * @return void */ - void updateRenderText(const QString &itemDataSource, const QString &itemStaticValue, const QString &itemType); - QString m_renderText; + void updateRenderText(const QString &itemDataSource, const QString &itemStaticValue, const QString &itemType); + KReportItemBase *item() const; + + void setRenderText(const QString &text); + QString renderText() const; private: - static bool m_readDefaultFont; - static QFont m_defaultFont; + class Private; + Private * const d; }; #endif diff --git a/src/wrtembed/KReportDesignerItemBase.cpp b/src/wrtembed/KReportDesignerItemBase.cpp --- a/src/wrtembed/KReportDesignerItemBase.cpp +++ b/src/wrtembed/KReportDesignerItemBase.cpp @@ -24,16 +24,34 @@ #include #include -// -// ReportEntity -// +class Q_DECL_HIDDEN KReportDesignerItemBase::Private +{ +public: + Private(); + ~Private(); + + KReportDesigner *reportDesigner; + KReportItemBase *item; + QString renderText; +}; + +KReportDesignerItemBase::Private::Private() +{ +} + +KReportDesignerItemBase::Private::~Private() +{ +} + KReportDesignerItemBase::~KReportDesignerItemBase() { + delete d; } -KReportDesignerItemBase::KReportDesignerItemBase(KReportDesigner* r) +KReportDesignerItemBase::KReportDesignerItemBase(KReportDesigner *r, KReportItemBase *b) : d(new Private()) { - m_reportDesigner = r; + d->reportDesigner = r; + d->item = b; } void KReportDesignerItemBase::buildXML(QGraphicsItem * item, QDomDocument *doc, QDomElement *parent) @@ -47,10 +65,10 @@ } -void KReportDesignerItemBase::buildXMLRect(QDomDocument *doc, QDomElement *entity, KReportPosition *pos, KReportSize *size) +void KReportDesignerItemBase::buildXMLRect(QDomDocument *doc, QDomElement *entity, KReportItemBase *i) { Q_UNUSED(doc); - KReportUtils::buildXMLRect(entity, pos, size); + KReportUtils::buildXMLRect(entity, i->position(), i->size()); } void KReportDesignerItemBase::buildXMLTextStyle(QDomDocument *doc, QDomElement *entity, const KRTextStyleData &ts) @@ -73,3 +91,28 @@ { KReportUtils::addPropertyAsAttribute(e, p); } + +KReportDesigner * KReportDesignerItemBase::designer() const +{ + return d->reportDesigner; +} + +void KReportDesignerItemBase::setDesigner(KReportDesigner* rd) +{ + d->reportDesigner = rd; +} + +KReportItemBase *KReportDesignerItemBase::item() const +{ + return d->item; +} + +QString KReportDesignerItemBase::renderText() const +{ + return d->renderText; +} + +void KReportDesignerItemBase::setRenderText(const QString& text) +{ + d->renderText = text; +} diff --git a/src/wrtembed/KReportDesignerItemLine.h b/src/wrtembed/KReportDesignerItemLine.h --- a/src/wrtembed/KReportDesignerItemLine.h +++ b/src/wrtembed/KReportDesignerItemLine.h @@ -56,9 +56,7 @@ virtual void mousePressEvent(QGraphicsSceneMouseEvent * event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * event); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - -private Q_SLOTS: - void slotPropertyChanged(KPropertySet &, KProperty &); + virtual void propertyChanged(KPropertySet &s, KProperty &p); }; #endif diff --git a/src/wrtembed/KReportDesignerItemLine.cpp b/src/wrtembed/KReportDesignerItemLine.cpp --- a/src/wrtembed/KReportDesignerItemLine.cpp +++ b/src/wrtembed/KReportDesignerItemLine.cpp @@ -33,43 +33,39 @@ // void KReportDesignerItemLine::init(QGraphicsScene* s, KReportDesigner *r) { - m_reportDesigner = r; setPos(0, 0); setUnit(r->pageUnit()); + nameProperty()->setValue(r->suggestEntityName(typeName())); + setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); setPen(QPen(Qt::black, 5)); setAcceptHoverEvents(true); if (s) s->addItem(this); - connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), - this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - - setZValue(Z); + setZValue(z()); } KReportDesignerItemLine::KReportDesignerItemLine(KReportDesigner * d, QGraphicsScene * scene, const QPointF &pos) - : KReportDesignerItemBase(d) + : KReportDesignerItemBase(d, this) { init(scene, d); setLineScene(QLineF(pos, QPointF(20,20)+pos)); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); + } KReportDesignerItemLine::KReportDesignerItemLine(KReportDesigner * d, QGraphicsScene * scene, const QPointF &startPos, const QPointF &endPos) - : KReportDesignerItemBase(d) + : KReportDesignerItemBase(d, this) { init(scene, d); setLineScene(QLineF(startPos, endPos)); - m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); - } KReportDesignerItemLine::KReportDesignerItemLine(const QDomNode & entity, KReportDesigner * d, QGraphicsScene * scene) - : KReportItemLine(entity), KReportDesignerItemBase(d) + : KReportItemLine(entity), KReportDesignerItemBase(d, this) { init(scene, d); setLine ( m_start.toScene().x(), m_start.toScene().y(), m_end.toScene().x(), m_end.toScene().y() ); @@ -113,7 +109,7 @@ QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties - addPropertyAsAttribute(&entity, m_name); + addPropertyAsAttribute(&entity, nameProperty()); entity.setAttribute(QLatin1String("report:z-index"), zValue()); KReportUtils::setAttribute(&entity, QLatin1String("svg:x1"), m_start.toPoint().x()); KReportUtils::setAttribute(&entity, QLatin1String("svg:y1"), m_start.toPoint().y()); @@ -125,7 +121,7 @@ parent->appendChild(entity); } -void KReportDesignerItemLine::slotPropertyChanged(KPropertySet &s, KProperty &p) +void KReportDesignerItemLine::propertyChanged(KPropertySet &s, KProperty &p) { Q_UNUSED(s); @@ -139,21 +135,21 @@ } else if (p.name() == "name") { //For some reason p.oldValue returns an empty string - if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { - p.setValue(m_oldName); + if (!designer()->isEntityNameUnique(p.value().toString(), this)) { + p.setValue(oldName()); } else { - m_oldName = p.value().toString(); + setOldName(p.value().toString()); } } - if (m_reportDesigner) - m_reportDesigner->setModified(true); + if (designer()) + designer()->setModified(true); update(); } void KReportDesignerItemLine::mousePressEvent(QGraphicsSceneMouseEvent * event) { - m_reportDesigner->changeSet(m_set); + designer()->changeSet(propertySet()); setSelected(true); QGraphicsLineItem::mousePressEvent(event); } @@ -245,7 +241,8 @@ void KReportDesignerItemLine::move(const QPointF& m) { - QPointF original = m_pos.toScene(); + QPointF original = scenePosition(position()); original += m; - m_pos.setScenePos(original); + + setPosition(positionFromScene(original)); } diff --git a/src/wrtembed/KReportDesignerItemRectBase.h b/src/wrtembed/KReportDesignerItemRectBase.h --- a/src/wrtembed/KReportDesignerItemRectBase.h +++ b/src/wrtembed/KReportDesignerItemRectBase.h @@ -39,7 +39,7 @@ class KREPORT_EXPORT KReportDesignerItemRectBase : public QGraphicsRectItem, public KReportDesignerItemBase { public: - explicit KReportDesignerItemRectBase(KReportDesigner*); + explicit KReportDesignerItemRectBase(KReportDesigner *r, KReportItemBase *b); virtual ~KReportDesignerItemRectBase(); @@ -49,8 +49,6 @@ virtual void exitInlineEditingMode(); protected: - void init(KReportPosition*, KReportSize*, KPropertySet*, KReportDesigner *r); - int m_dpiX; int m_dpiY; qreal m_userHeight; @@ -81,12 +79,9 @@ private: int grabHandle(QPointF); QPointF properPressPoint(const KReportDesigner &d) const; - int m_grabAction; - - KReportPosition* m_ppos; - KReportSize* m_psize; - KPropertySet* m_pset; + class Private; + Private * const d; }; #endif diff --git a/src/wrtembed/KReportDesignerItemRectBase.cpp b/src/wrtembed/KReportDesignerItemRectBase.cpp --- a/src/wrtembed/KReportDesignerItemRectBase.cpp +++ b/src/wrtembed/KReportDesignerItemRectBase.cpp @@ -28,47 +28,48 @@ #include #include -KReportDesignerItemRectBase::KReportDesignerItemRectBase(KReportDesigner *r) - : QGraphicsRectItem(), KReportDesignerItemBase(r) +class Q_DECL_HIDDEN KReportDesignerItemRectBase::Private +{ +public: + Private(); + ~Private(); + + int grabAction; +}; + +KReportDesignerItemRectBase::Private::Private() +{ +} + +KReportDesignerItemRectBase::Private::~Private() +{ +} + +KReportDesignerItemRectBase::KReportDesignerItemRectBase(KReportDesigner *r, KReportItemBase *b) + : QGraphicsRectItem(), KReportDesignerItemBase(r, b), d(new KReportDesignerItemRectBase::Private) { m_dpiX = KReportDpi::dpiX(); m_dpiY = KReportDpi::dpiY(); - m_ppos = 0; - m_psize = 0; - m_grabAction = 0; + d->grabAction = 0; setAcceptHoverEvents(true); -#if QT_VERSION >= 0x040600 setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges); -#else - setFlags(ItemIsSelectable | ItemIsMovable); -#endif -} - -void KReportDesignerItemRectBase::init(KReportPosition* p, KReportSize* s, KPropertySet* se, KReportDesigner *d) -{ - Q_UNUSED(d); - m_ppos = p; - m_psize = s; - m_pset = se; } KReportDesignerItemRectBase::~KReportDesignerItemRectBase() { + delete d; } QRectF KReportDesignerItemRectBase::sceneRect() { - return QRectF(m_ppos->toScene(), m_psize->toScene()); + return QRectF(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size())); } QRectF KReportDesignerItemRectBase::pointRect() const { - if (m_ppos && m_psize) - return QRectF(m_ppos->toPoint(), m_psize->toPoint()); - else - return QRectF(0, 0, 0, 0); + return QRectF(item()->position(), item()->size()); } void KReportDesignerItemRectBase::setSceneRect(const QPointF& topLeft, const QSizeF& size, UpdatePropertyFlag update) @@ -81,17 +82,17 @@ QGraphicsRectItem::setPos(rect.x(), rect.y()); setRect(0, 0, rect.width(), rect.height()); if (update == UpdateProperty) { - m_ppos->setScenePos(QPointF(rect.x(), rect.y())); - m_psize->setSceneSize(QSizeF(rect.width(), rect.height())); + item()->setPosition(KReportItemBase::positionFromScene(QPointF(rect.x(), rect.y()))); + item()->setSize(KReportItemBase::sizeFromScene(QSizeF(rect.width(), rect.height()))); } this->update(); } void KReportDesignerItemRectBase::mousePressEvent(QGraphicsSceneMouseEvent * event) { //Update and show properties - m_ppos->setScenePos(QPointF(sceneRect().x(), sceneRect().y())); - m_reportDesigner->changeSet(m_pset); + item()->setPosition(KReportItemBase::positionFromScene(QPointF(sceneRect().x(), sceneRect().y()))); + designer()->changeSet(item()->propertySet()); setSelected(true); scene()->update(); @@ -101,8 +102,8 @@ void KReportDesignerItemRectBase::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { //Keep the size and position in sync - m_ppos->setScenePos(pos()); - m_psize->setSceneSize(QSizeF(rect().width(), rect().height())); + item()->setPosition(KReportItemBase::positionFromScene(pos())); + item()->setSize(KReportItemBase::sizeFromScene(QSizeF(rect().width(), rect().height()))); QGraphicsItem::mouseReleaseEvent(event); } @@ -119,7 +120,7 @@ //! @todo use an enum for the directions - switch (m_grabAction) { + switch (d->grabAction) { case 1: if (sceneRect().y() - p.y() + rect().height() > 0 && sceneRect().x() - p.x() + rect().width() >= 0) setSceneRect(QPointF(p.x(), p.y()), QSizeF(sceneRect().x() - p.x() + rect().width(), sceneRect().y() - p.y() + rect().height())); @@ -162,8 +163,8 @@ //m_grabAction = 0; if (isSelected()) { - m_grabAction = grabHandle(event->pos()); - switch (m_grabAction) { + d->grabAction = grabHandle(event->pos()); + switch (d->grabAction) { case 1: setCursor(Qt::SizeFDiagCursor); break; @@ -283,8 +284,10 @@ return newPos; } else if (change == ItemPositionHasChanged && scene()) { - m_ppos->setScenePos(value.toPointF(), KReportPosition::DontUpdateProperty); - } else if (change == ItemSceneHasChanged && scene() && m_psize) { + item()->setPosition(KReportItemBase::positionFromScene(value.toPointF())); + //TODO dont update property + //m_ppos->setScenePos(value.toPointF(), KReportPosition::DontUpdateProperty); + } else if (change == ItemSceneHasChanged && scene() && item()) { QPointF newPos = pos(); newPos = dynamic_cast(scene())->gridPoint(newPos); @@ -298,7 +301,7 @@ else if (newPos.y() > (scene()->height() - rect().height())) newPos.setY(scene()->height() - rect().height()); - setSceneRect(newPos, m_psize->toScene(), KReportDesignerItemRectBase::DontUpdateProperty); + setSceneRect(newPos, KReportItemBase::sceneSize(item()->size()), KReportDesignerItemRectBase::DontUpdateProperty); } return QGraphicsItem::itemChange(change, value); @@ -309,12 +312,12 @@ Q_UNUSED(s) if (p.name() == "position") { - m_ppos->setUnitPos(p.value().toPointF(), KReportPosition::DontUpdateProperty); + item()->setPosition(p.value().toPointF()); //TODO dont update property } else if (p.name() == "size") { - m_psize->setUnitSize(p.value().toSizeF(), KReportSize::DontUpdateProperty); + item()->setSize(p.value().toSizeF()); //TODO dont update property } - setSceneRect(m_ppos->toScene(), m_psize->toScene(), DontUpdateProperty); + setSceneRect(KReportItemBase::scenePosition(item()->position()), KReportItemBase::sceneSize(item()->size()), DontUpdateProperty); } void KReportDesignerItemRectBase::move(const QPointF& /*m*/) @@ -372,15 +375,15 @@ { if (itemDataSource.isEmpty()) { if (itemType.isEmpty()) { - m_renderText = itemStaticValue; + setRenderText(itemStaticValue); } else { - m_renderText = dataSourceAndObjectTypeName(itemStaticValue, itemType); + setRenderText(dataSourceAndObjectTypeName(itemStaticValue, itemType)); } } else { if (itemType.isEmpty()) { - m_renderText = itemDataSource; + setRenderText(itemDataSource); } else { - m_renderText = dataSourceAndObjectTypeName(itemDataSource, itemType); + setRenderText(dataSourceAndObjectTypeName(itemDataSource, itemType)); } } } diff --git a/src/wrtembed/KReportDesignerSection.cpp b/src/wrtembed/KReportDesignerSection.cpp --- a/src/wrtembed/KReportDesignerSection.cpp +++ b/src/wrtembed/KReportDesignerSection.cpp @@ -233,6 +233,7 @@ } KReportItemBase *item = dynamic_cast(obj); if (item) { + item->setUnit(d->reportDesigner->pageUnit()); KReportDesigner::addMetaProperties(item->propertySet(), plugin->metaData()->name(), plugin->metaData()->iconName());