diff --git a/src/common/KReportItemBase.cpp b/src/common/KReportItemBase.cpp --- a/src/common/KReportItemBase.cpp +++ b/src/common/KReportItemBase.cpp @@ -30,12 +30,12 @@ Private(); ~Private(); - KPropertySet *set; - KProperty *nameProperty; - KProperty *sizeProperty; - KProperty *positionProperty; + KPropertySet *set = nullptr; + KProperty *nameProperty = nullptr; + KProperty *sizeProperty = nullptr; + KProperty *positionProperty = nullptr; QString oldName; - qreal z; + qreal z = 0; }; KReportItemBase::Private::Private() diff --git a/src/common/KReportItemLine.cpp b/src/common/KReportItemLine.cpp --- a/src/common/KReportItemLine.cpp +++ b/src/common/KReportItemLine.cpp @@ -131,10 +131,12 @@ if (page) page->insertPrimitive(ln); OROLine *l2 = dynamic_cast(ln->clone()); - l2->setStartPoint(m_start->value().toPointF()); - l2->setEndPoint(m_end->value().toPointF()); - if (section) section->addPrimitive(l2); - + if (l2) { + l2->setStartPoint(m_start->value().toPointF()); + l2->setEndPoint(m_end->value().toPointF()); + + if (section) section->addPrimitive(l2); + } return 0; } diff --git a/src/common/KReportRenderObjects.cpp b/src/common/KReportRenderObjects.cpp --- a/src/common/KReportRenderObjects.cpp +++ b/src/common/KReportRenderObjects.cpp @@ -179,7 +179,7 @@ public: Private(); ~Private(); - ORODocument *document; + ORODocument *document = nullptr; QList primitives; }; @@ -288,18 +288,17 @@ public: Private(); ~Private(); - ORODocument * document; + ORODocument * document = nullptr; QList primitives; - qint64 row; - int height; - KReportSectionData::Section type; - QColor backgroundColor; + qint64 row = 0; + int height = 0; + KReportSectionData::Section type = KReportSectionData::None; + QColor backgroundColor = Qt::white; }; OROSection::Private::Private() { - height = 0; - backgroundColor = Qt::white; + } OROSection::Private::~Private() @@ -405,15 +404,14 @@ class Q_DECL_HIDDEN OROPrimitive::Private { public: - OROPage * page; + OROPage * page = nullptr; QPointF position; QSizeF size; }; OROPrimitive::OROPrimitive() : d(new Private()) { - d->page = 0; } OROPrimitive::~OROPrimitive() 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 @@ -170,8 +170,10 @@ if (section) { OROCheckBox *chk2 = dynamic_cast(chk->clone()); - chk2->setPosition(scenePosition(position())); - section->addPrimitive(chk2); + if (chk2) { + chk2->setPosition(scenePosition(position())); + section->addPrimitive(chk2); + } } if (!page) { 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 @@ -174,8 +174,10 @@ if (section) { OROImage *i2 = dynamic_cast(id->clone()); - i2->setPosition(scenePosition(position())); - section->addPrimitive(i2); + if (i2) { + i2->setPosition(scenePosition(position())); + section->addPrimitive(i2); + } } if (!page) { 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 @@ -270,8 +270,10 @@ if (section) { OROTextBox *tb2 = dynamic_cast(tb->clone()); - tb2->setPosition(scenePosition(position())); - section->addPrimitive(tb2); + if (tb2) { + tb2->setPosition(scenePosition(position())); + section->addPrimitive(tb2); + } } if (!page) { diff --git a/src/renderer/KReportHTMLCSSRenderer_p.cpp b/src/renderer/KReportHTMLCSSRenderer_p.cpp --- a/src/renderer/KReportHTMLCSSRenderer_p.cpp +++ b/src/renderer/KReportHTMLCSSRenderer_p.cpp @@ -121,9 +121,7 @@ for (int i = 0; i < section->primitiveCount(); i++) { OROPrimitive * prim = section->primitive(i); //kreportDebug() << "Got object type" << prim->type(); - if (dynamic_cast(prim)) { - OROTextBox * tb = dynamic_cast(prim); - + if (OROTextBox *tb = dynamic_cast(prim)) { QColor bg = tb->textStyle().backgroundColor; style = QLatin1String("position: absolute; ") + QLatin1String("background-color: ") + QString::fromLatin1("rgba(%1,%2,%3,%4)") @@ -151,9 +149,7 @@ body += QLatin1String("
") + tb->text() + QLatin1String("
\n"); - } else if (dynamic_cast(prim)) { - //kreportDebug() << "Saving an image"; - OROImage * im = dynamic_cast(prim); + } else if (OROImage *im = dynamic_cast(prim)) { style = QLatin1String("position: absolute; ") + QLatin1String("top: ") + QString::number(im->position().y()) + QLatin1String("pt; ") + QLatin1String("left: ") + QString::number(im->position().x()) + QLatin1String("pt; "); @@ -168,9 +164,7 @@ im->image().save(m_tempDirName + QLatin1String("/object") + QString::number(s) + QString::number(i) + QLatin1String(".png")); - } else if (dynamic_cast(prim)) { - //kreportDebug() << "Saving a picture"; - OROPicture * im = dynamic_cast(prim); + } else if (OROPicture *im = dynamic_cast(prim)) { style = QLatin1String("position: absolute; ") + QLatin1String("top: ") + QString::number(im->position().y()) + QLatin1String("pt; ") + QLatin1String("left: ") + QString::number(im->position().x()) + QLatin1String("pt; "); diff --git a/src/renderer/KReportHTMLTableRenderer_p.cpp b/src/renderer/KReportHTMLTableRenderer_p.cpp --- a/src/renderer/KReportHTMLTableRenderer_p.cpp +++ b/src/renderer/KReportHTMLTableRenderer_p.cpp @@ -115,23 +115,16 @@ for (int i = 0; i < section->primitiveCount(); i++) { OROPrimitive * prim = section->primitive(i); - if (dynamic_cast(prim)) { - OROTextBox * tb = dynamic_cast(prim); - + if (OROTextBox *tb = dynamic_cast(prim)) { tr += QLatin1String("") + tb->text() + QLatin1String("\n"); - } else if (dynamic_cast(prim)) { - //kreportDebug() << "Saving an image"; - OROImage * im = dynamic_cast(prim); + } else if (OROImage *im = dynamic_cast(prim)) { tr += QLatin1String("" "" "\n"); im->image().save(m_tempDirName + QLatin1String("/object") + QString::number(s) + QString::number(i) + QLatin1String(".png")); - } else if (dynamic_cast(prim)) { - //kreportDebug() << "Saving a picture"; - OROPicture * im = dynamic_cast(prim); - + } else if (OROPicture *im = dynamic_cast(prim)) { tr += QLatin1String("" "" "\n"); diff --git a/src/renderer/KReportPage.cpp b/src/renderer/KReportPage.cpp --- a/src/renderer/KReportPage.cpp +++ b/src/renderer/KReportPage.cpp @@ -34,20 +34,18 @@ public: explicit Private(ORODocument *document) : reportDocument(document) - , page(0) {} ~Private() { delete renderer; } - ORODocument *reportDocument; - int page; + ORODocument *reportDocument = nullptr; + int page = 0; QPixmap pixmap; KReportRendererFactory factory; - KReportRendererBase *renderer; - + KReportRendererBase *renderer = nullptr; QTimer renderTimer; }; diff --git a/src/renderer/KReportPreRenderer.cpp b/src/renderer/KReportPreRenderer.cpp --- a/src/renderer/KReportPreRenderer.cpp +++ b/src/renderer/KReportPreRenderer.cpp @@ -368,8 +368,7 @@ } for (int i = 0; i < m_page->primitiveCount(); ++i) { OROPrimitive *prim = m_page->primitive(i); - if (dynamic_cast(prim)) { - OROTextBox *text = dynamic_cast(prim); + if (OROTextBox *text = dynamic_cast(prim)) { if (text->requiresPostProcessing()) { m_postProcText.append(text); } diff --git a/src/renderer/KReportPrintRenderer_p.cpp b/src/renderer/KReportPrintRenderer_p.cpp --- a/src/renderer/KReportPrintRenderer_p.cpp +++ b/src/renderer/KReportPrintRenderer_p.cpp @@ -101,10 +101,7 @@ prim->setPosition(QPointF(prim->position().x() * scaleX, prim->position().y() * scaleY)); prim->setSize(QSizeF(prim->size().width() * scaleX, prim->size().height() * scaleY)); //kreportDebug() << "Rendering object" << i << "type" << prim->type(); - if (dynamic_cast(prim)) { - //kreportDebug() << "Text Box"; - OROTextBox * tb = dynamic_cast(prim); - + if (OROTextBox *tb = dynamic_cast(prim)) { QPointF ps = tb->position(); QSizeF sz = tb->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -131,9 +128,7 @@ //Reset back to defaults for next element context.painter()->restore(); - } else if (dynamic_cast(prim)) { - //kreportDebug() << "Line"; - OROLine * ln = dynamic_cast(prim); + } else if (OROLine *ln = dynamic_cast(prim)) { QPointF s = ln->startPoint(); QPointF e(ln->endPoint().x() * scaleX, ln->endPoint().y() * scaleY); //QPen pen ( _painter()->pen() ); @@ -145,9 +140,7 @@ context.painter()->drawLine(QLineF(s.x(), s.y(), e.x(), e.y())); context.painter()->setRenderHint(QPainter::Antialiasing, false); context.painter()->restore(); - } else if (dynamic_cast(prim)) { - //kreportDebug() << "Image"; - OROImage * im = dynamic_cast(prim); + } else if (OROImage *im = dynamic_cast(prim)) { QPointF ps = im->position(); QSizeF sz = im->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -158,10 +151,7 @@ QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size())); context.painter()->drawImage(rc.topLeft(), img, sr); - } else if (dynamic_cast(prim)) { - //kreportDebug() << "Rect"; - ORORect * re = dynamic_cast(prim); - + } else if (ORORect *re = dynamic_cast(prim)) { QPointF ps = re->position(); QSizeF sz = re->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -171,9 +161,7 @@ context.painter()->setBrush(re->brush()); context.painter()->drawRect(rc); context.painter()->restore(); - } else if (dynamic_cast(prim)) { - OROEllipse * re = dynamic_cast(prim); - + } else if (OROEllipse *re = dynamic_cast(prim)) { QPointF ps = re->position(); QSizeF sz = re->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -183,14 +171,12 @@ context.painter()->setBrush(re->brush()); context.painter()->drawEllipse(rc); context.painter()->restore(); - } else if (dynamic_cast(prim)) { - OROPicture * im = dynamic_cast(prim); + } else if (OROPicture *im = dynamic_cast(prim)) { QPointF ps = im->position(); QSizeF sz = im->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); context.painter()->drawPicture(rc.topLeft(), *(im->picture())); - } else if (dynamic_cast(prim)) { - OROCheckBox * chk = dynamic_cast(prim); + } else if (OROCheckBox *chk = dynamic_cast(prim)) { QPointF ps = chk->position(); QSizeF sz = chk->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); diff --git a/src/renderer/KReportScreenRenderer_p.cpp b/src/renderer/KReportScreenRenderer_p.cpp --- a/src/renderer/KReportScreenRenderer_p.cpp +++ b/src/renderer/KReportScreenRenderer_p.cpp @@ -50,9 +50,7 @@ for (int i = 0; i < p->primitiveCount(); i++) { OROPrimitive *prim = p->primitive(i); - if (dynamic_cast(prim)) { - OROTextBox *tb = dynamic_cast(prim); - + if (OROTextBox *tb = dynamic_cast(prim)) { QPointF ps = tb->position(); QSizeF sz = tb->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -79,8 +77,7 @@ //Reset back to defaults for next element context.painter()->restore(); } - else if (dynamic_cast(prim)) { - OROLine * ln = dynamic_cast(prim); + else if (OROLine *ln = dynamic_cast(prim)) { QPointF s = ln->startPoint(); QPointF e = ln->endPoint(); //QPen pen ( _painter->pen() ); @@ -93,9 +90,7 @@ context.painter()->setRenderHint(QPainter::Antialiasing, false); context.painter()->restore(); } - else if (dynamic_cast(prim)) { - ORORect * re = dynamic_cast(prim); - + else if (ORORect *re = dynamic_cast(prim)) { QPointF ps = re->position(); QSizeF sz = re->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -106,9 +101,7 @@ context.painter()->drawRect(rc); context.painter()->restore(); } - else if (dynamic_cast(prim)) { - OROEllipse * re = dynamic_cast(prim); - + else if (OROEllipse *re = dynamic_cast(prim)) { QPointF ps = re->position(); QSizeF sz = re->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -119,8 +112,7 @@ context.painter()->drawEllipse(rc); context.painter()->restore(); } - else if (dynamic_cast(prim)) { - OROImage * im = dynamic_cast(prim); + else if ( OROImage *im = dynamic_cast(prim)) { QPointF ps = im->position(); QSizeF sz = im->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); @@ -133,17 +125,15 @@ QRectF sr = QRectF(QPointF(0.0, 0.0), rc.size().boundedTo(img.size())); context.painter()->drawImage(rc.topLeft(), img, sr); } - else if (dynamic_cast(prim)) { - OROPicture * im = dynamic_cast(prim); + else if (OROPicture *im = dynamic_cast(prim)) { QPointF ps = im->position(); QSizeF sz = im->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); context.painter()->save(); context.painter()->drawPicture(rc.topLeft(), *(im->picture())); context.painter()->restore(); } - else if (dynamic_cast(prim)) { - OROCheckBox * chk = dynamic_cast(prim); + else if (OROCheckBox *chk = dynamic_cast(prim)) { QPointF ps = chk->position(); QSizeF sz = chk->size(); QRectF rc = QRectF(ps.x(), ps.y(), sz.width(), sz.height()); diff --git a/src/renderer/scripting/KReportScriptHandler.cpp b/src/renderer/scripting/KReportScriptHandler.cpp --- a/src/renderer/scripting/KReportScriptHandler.cpp +++ b/src/renderer/scripting/KReportScriptHandler.cpp @@ -39,20 +39,15 @@ public: Private(); ~Private(); - KReportScriptConstants *constants; - KReportScriptDebug *debug; - KReportScriptDraw *draw; - - Scripting::Report *report; - - const KReportData *reportData; - + KReportScriptConstants *constants = nullptr; + KReportScriptDebug *debug = nullptr; + KReportScriptDraw *draw = nullptr; + Scripting::Report *report = nullptr; + const KReportData *reportData = nullptr; QString source; - KReportDocument *reportDocument; - + KReportDocument *reportDocument = nullptr; QJSEngine engine; QJSValue scriptValue; - QMap groups; QMap sectionMap; }; diff --git a/src/wrtembed/KReportDesigner.cpp b/src/wrtembed/KReportDesigner.cpp --- a/src/wrtembed/KReportDesigner.cpp +++ b/src/wrtembed/KReportDesigner.cpp @@ -106,28 +106,7 @@ class Q_DECL_HIDDEN KReportDesigner::Private { public: - Private() - : activeScene(0) - , reportHeader(0) - , pageHeaderFirst(0) - , pageHeaderOdd(0) - , pageHeaderEven(0) - , pageHeaderLast(0) - , pageHeaderAny(0) - , pageFooterFirst(0) - , pageFooterOdd(0) - , pageFooterEven(0) - , pageFooterLast(0) - , pageFooterAny(0) - , reportFooter(0) - , detail(0) - , pressX(-1) - , pressY(-1) - , releaseX(-1) - , releaseY(-1) - , modified(false) - , kordata(0) - {} + Private(){} ~Private() { @@ -137,73 +116,73 @@ delete kordata; } - QGridLayout *grid; - KReportRuler *hruler; - KReportZoomHandler *zoom; - QVBoxLayout *vboxlayout; - KReportPropertiesButton *pageButton; + QGridLayout *grid = nullptr; + KReportRuler *hruler = nullptr; + KReportZoomHandler *zoom = nullptr; + QVBoxLayout *vboxlayout = nullptr; + KReportPropertiesButton *pageButton = nullptr; - QGraphicsScene *activeScene; + QGraphicsScene *activeScene = nullptr; - ReportWriterSectionData *sectionData; + ReportWriterSectionData *sectionData = nullptr; - KReportDesignerSection *reportHeader; - KReportDesignerSection *pageHeaderFirst; - KReportDesignerSection *pageHeaderOdd; - KReportDesignerSection *pageHeaderEven; - KReportDesignerSection *pageHeaderLast; - KReportDesignerSection *pageHeaderAny; + KReportDesignerSection *reportHeader = nullptr; + KReportDesignerSection *pageHeaderFirst = nullptr; + KReportDesignerSection *pageHeaderOdd = nullptr; + KReportDesignerSection *pageHeaderEven = nullptr; + KReportDesignerSection *pageHeaderLast = nullptr; + KReportDesignerSection *pageHeaderAny = nullptr; - KReportDesignerSection *pageFooterFirst; - KReportDesignerSection *pageFooterOdd; - KReportDesignerSection *pageFooterEven; - KReportDesignerSection *pageFooterLast; - KReportDesignerSection *pageFooterAny; - KReportDesignerSection *reportFooter; - KReportDesignerSectionDetail *detail; + KReportDesignerSection *pageFooterFirst = nullptr; + KReportDesignerSection *pageFooterOdd = nullptr; + KReportDesignerSection *pageFooterEven = nullptr; + KReportDesignerSection *pageFooterLast = nullptr; + KReportDesignerSection *pageFooterAny = nullptr; + KReportDesignerSection *reportFooter = nullptr; + KReportDesignerSectionDetail *detail = nullptr; //Properties - KPropertySet *set; - KPropertySet *itmset; - KProperty *title; - KProperty *pageSize; - KProperty *orientation; - KProperty *unit; - KProperty *customHeight; - KProperty *customWidth; - KProperty *leftMargin; - KProperty *rightMargin; - KProperty *topMargin; - KProperty *bottomMargin; - KProperty *showGrid; - KProperty *gridDivisions; - KProperty *gridSnap; - KProperty *labelType; + KPropertySet *set = nullptr; + KPropertySet *itmset = nullptr; + KProperty *title = nullptr; + KProperty *pageSize = nullptr; + KProperty *orientation = nullptr; + KProperty *unit = nullptr; + KProperty *customHeight = nullptr; + KProperty *customWidth = nullptr; + KProperty *leftMargin = nullptr; + KProperty *rightMargin = nullptr; + KProperty *topMargin = nullptr; + KProperty *bottomMargin = nullptr; + KProperty *showGrid = nullptr; + KProperty *gridDivisions = nullptr; + KProperty *gridSnap = nullptr; + KProperty *labelType = nullptr; #ifdef KREPORT_SCRIPTING - KProperty *script; + KProperty *script = nullptr; #endif //Actions - QAction *editCutAction; - QAction *editCopyAction; - QAction *editPasteAction; - QAction *editDeleteAction; - QAction *sectionEdit; - QAction *parameterEdit; - QAction *itemRaiseAction; - QAction *itemLowerAction; - - qreal pressX; - qreal pressY; - qreal releaseX; - qreal releaseY; - - bool modified; // true if this document has been modified, false otherwise + QAction *editCutAction = nullptr; + QAction *editCopyAction = nullptr; + QAction *editPasteAction = nullptr; + QAction *editDeleteAction = nullptr; + QAction *sectionEdit = nullptr; + QAction *parameterEdit = nullptr; + QAction *itemRaiseAction = nullptr; + QAction *itemLowerAction = nullptr; + + qreal pressX = -1; + qreal pressY = -1; + qreal releaseX = -1; + qreal releaseY = -1; + + bool modified = false; // true if this document has been modified, false otherwise QString originalInterpreter; //Value of the script interpreter at load time QString originalScript; //Value of the script at load time - KReportData *kordata; + KReportData *kordata = nullptr; }; KReportDesigner::KReportDesigner(QWidget * parent) @@ -1172,13 +1151,15 @@ //kreportDebug() << type; KReportDesignerItemBase *ent = item->clone(); KReportItemBase *new_obj = dynamic_cast(ent); - new_obj->setEntityName(suggestEntityName(type)); - if (activeItem) { - new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); - } else { - new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); + if (new_obj) { + new_obj->setEntityName(suggestEntityName(type)); + if (activeItem) { + new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(activeItem->x() + 10, activeItem->y() + 10))); + } else { + new_obj->setPosition(KReportItemBase::positionFromScene(QPointF(0, 0))); + } + changeSet(new_obj->propertySet()); } - changeSet(new_obj->propertySet()); QGraphicsItem *pasted_ent = dynamic_cast(ent); if (pasted_ent) { pasted_ent->setSelected(true); diff --git a/src/wrtembed/KReportDesignerItemBase.cpp b/src/wrtembed/KReportDesignerItemBase.cpp --- a/src/wrtembed/KReportDesignerItemBase.cpp +++ b/src/wrtembed/KReportDesignerItemBase.cpp @@ -30,8 +30,8 @@ Private(); ~Private(); - KReportDesigner *reportDesigner; - KReportItemBase *item; + KReportDesigner *reportDesigner = nullptr; + KReportItemBase *item = nullptr; QString renderText; }; diff --git a/src/wrtembed/KReportDesignerItemLine.cpp b/src/wrtembed/KReportDesignerItemLine.cpp --- a/src/wrtembed/KReportDesignerItemLine.cpp +++ b/src/wrtembed/KReportDesignerItemLine.cpp @@ -170,7 +170,12 @@ int x; int y; - QPointF p = dynamic_cast(scene())->gridPoint(event->scenePos()); + KReportDesignerSectionScene *_section = dynamic_cast(scene()); + if (!_section) { + return; + } + + QPointF p = _section->gridPoint(event->scenePos()); //kreportDebug() << p; x = p.x(); y = p.y(); @@ -188,7 +193,7 @@ m_end->setValue(positionFromScene(QPointF(x,y))); break; default: - QPointF d = mapToItem(this, dynamic_cast(scene())->gridPoint(event->scenePos())) - mapToItem(this, dynamic_cast(scene())->gridPoint(event->lastScenePos())); + QPointF d = mapToItem(this, _section->gridPoint(event->scenePos())) - mapToItem(this, _section->gridPoint(event->lastScenePos())); if (((line().p1() + d).x() >= 0) && ((line().p2() + d).x() >= 0) && diff --git a/src/wrtembed/KReportDesignerItemRectBase.h b/src/wrtembed/KReportDesignerItemRectBase.h --- a/src/wrtembed/KReportDesignerItemRectBase.h +++ b/src/wrtembed/KReportDesignerItemRectBase.h @@ -49,12 +49,12 @@ virtual void exitInlineEditingMode(); protected: - int m_dpiX; - int m_dpiY; - qreal m_userHeight; - qreal m_userWidth; - qreal m_pressX; - qreal m_pressY; + int m_dpiX = 96; + int m_dpiY = 96; + qreal m_userHeight = 0; + qreal m_userWidth = 0; + qreal m_pressX = 0; + qreal m_pressY = 0; enum UpdatePropertyFlag { UpdateProperty, diff --git a/src/wrtembed/KReportDesignerItemRectBase.cpp b/src/wrtembed/KReportDesignerItemRectBase.cpp --- a/src/wrtembed/KReportDesignerItemRectBase.cpp +++ b/src/wrtembed/KReportDesignerItemRectBase.cpp @@ -32,7 +32,7 @@ Private(); ~Private(); - int grabAction; + int grabAction = 0; }; KReportDesignerItemRectBase::Private::Private() @@ -112,7 +112,12 @@ qreal w, h; - QPointF p = dynamic_cast(scene())->gridPoint(event->scenePos()); + KReportDesignerSectionScene *_section = dynamic_cast(scene()); + if (!_section) { + return; + } + + QPointF p = _section->gridPoint(event->scenePos()); w = p.x() - scenePos().x(); h = p.y() - scenePos().y(); @@ -266,42 +271,45 @@ QVariant KReportDesignerItemRectBase::itemChange(GraphicsItemChange change, const QVariant &value) { - if (change == ItemPositionChange && scene()) { - QPointF newPos = value.toPointF(); - - newPos = dynamic_cast(scene())->gridPoint(newPos); - if (newPos.x() < 0) - newPos.setX(0); - else if (newPos.x() > (scene()->width() - rect().width())) - newPos.setX(scene()->width() - rect().width()); - - if (newPos.y() < 0) - newPos.setY(0); - else if (newPos.y() > (scene()->height() - rect().height())) - newPos.setY(scene()->height() - rect().height()); - - return newPos; - } else if (change == ItemPositionHasChanged && scene()) { - 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); - if (newPos.x() < 0) - newPos.setX(0); - else if (newPos.x() > (scene()->width() - rect().width())) - newPos.setX(scene()->width() - rect().width()); - - if (newPos.y() < 0) - newPos.setY(0); - else if (newPos.y() > (scene()->height() - rect().height())) - newPos.setY(scene()->height() - rect().height()); - - setSceneRect(newPos, KReportItemBase::sceneSize(item()->size()), KReportDesignerItemRectBase::DontUpdateProperty); + KReportDesignerSectionScene *_section = dynamic_cast(scene()); + if (_section) { + + if (change == ItemPositionChange) { + QPointF newPos = value.toPointF(); + + newPos = _section->gridPoint(newPos); + if (newPos.x() < 0) + newPos.setX(0); + else if (newPos.x() > (scene()->width() - rect().width())) + newPos.setX(scene()->width() - rect().width()); + + if (newPos.y() < 0) + newPos.setY(0); + else if (newPos.y() > (scene()->height() - rect().height())) + newPos.setY(scene()->height() - rect().height()); + + return newPos; + } else if (change == ItemPositionHasChanged) { + item()->setPosition(KReportItemBase::positionFromScene(value.toPointF())); + //TODO dont update property + //m_ppos->setScenePos(value.toPointF(), KReportPosition::DontUpdateProperty); + } else if (change == ItemSceneHasChanged && item()) { + QPointF newPos = pos(); + + newPos = _section->gridPoint(newPos); + if (newPos.x() < 0) + newPos.setX(0); + else if (newPos.x() > (scene()->width() - rect().width())) + newPos.setX(scene()->width() - rect().width()); + + if (newPos.y() < 0) + newPos.setY(0); + else if (newPos.y() > (scene()->height() - rect().height())) + newPos.setY(scene()->height() - rect().height()); + + setSceneRect(newPos, KReportItemBase::sceneSize(item()->size()), KReportDesignerItemRectBase::DontUpdateProperty); + } } - return QGraphicsItem::itemChange(change, value); } diff --git a/src/wrtembed/KReportDesignerSection.cpp b/src/wrtembed/KReportDesignerSection.cpp --- a/src/wrtembed/KReportDesignerSection.cpp +++ b/src/wrtembed/KReportDesignerSection.cpp @@ -85,15 +85,15 @@ ~Private() {} - KReportDesignerSectionTitle *title; - KReportDesignerSectionScene *scene; - ReportResizeBar *resizeBar; - KReportDesignerSectionView *sceneView; - KReportDesigner*reportDesigner; - KReportRuler *sectionRuler; - - KReportSectionData *sectionData; - int dpiY; + KReportDesignerSectionTitle *title = nullptr; + KReportDesignerSectionScene *scene = nullptr; + ReportResizeBar *resizeBar = nullptr; + KReportDesignerSectionView *sceneView = nullptr; + KReportDesigner*reportDesigner = nullptr; + KReportRuler *sectionRuler = nullptr; + + KReportSectionData *sectionData = nullptr; + int dpiY = 96; }; @@ -390,29 +390,30 @@ { QPainter painter(this); KReportDesignerSection* _section = dynamic_cast(parent()); - - const bool current = _section->d->scene == _section->d->reportDesigner->activeScene(); - QPalette::ColorGroup cg = QPalette::Inactive; - QWidget *activeWindow = QApplication::activeWindow(); - if (activeWindow) { - QWidget *par = activeWindow->focusWidget(); - if (qobject_cast(par)) { - par = par->parentWidget(); // we're close, pick common parent + if (_section) { + const bool current = _section->d->scene == _section->d->reportDesigner->activeScene(); + QPalette::ColorGroup cg = QPalette::Inactive; + QWidget *activeWindow = QApplication::activeWindow(); + if (activeWindow) { + QWidget *par = activeWindow->focusWidget(); + if (qobject_cast(par)) { + par = par->parentWidget(); // we're close, pick common parent + } + if (hasParent(par, this)) { + cg = QPalette::Active; + } } - if (hasParent(par, this)) { - cg = QPalette::Active; + if (current) { + painter.fillRect(rect(), palette().brush(cg, QPalette::Highlight)); } - } - if (current) { - painter.fillRect(rect(), palette().brush(cg, QPalette::Highlight)); - } - painter.setPen(palette().color(cg, current ? QPalette::HighlightedText : QPalette::WindowText)); - QPixmap pixmap(QIcon::fromTheme(QLatin1String("arrow-down")).pixmap(16,16)); - replaceColors(&pixmap, painter.pen().color()); - const int left = 25; - painter.drawPixmap(QPoint(left, (height() - pixmap.height()) / 2), pixmap); + painter.setPen(palette().color(cg, current ? QPalette::HighlightedText : QPalette::WindowText)); + QPixmap pixmap(QIcon::fromTheme(QLatin1String("arrow-down")).pixmap(16,16)); + replaceColors(&pixmap, painter.pen().color()); + const int left = 25; + painter.drawPixmap(QPoint(left, (height() - pixmap.height()) / 2), pixmap); - painter.drawText(rect().adjusted(left + pixmap.width() + 4, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, text()); + painter.drawText(rect().adjusted(left + pixmap.width() + 4, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, text()); + } QFrame::paintEvent(event); } diff --git a/src/wrtembed/KReportDesignerSectionDetail.cpp b/src/wrtembed/KReportDesignerSectionDetail.cpp --- a/src/wrtembed/KReportDesignerSectionDetail.cpp +++ b/src/wrtembed/KReportDesignerSectionDetail.cpp @@ -29,23 +29,18 @@ class Q_DECL_HIDDEN KReportDesignerSectionDetail::Private { public: - explicit Private() - : pageBreak(KReportDesignerSectionDetail::BreakNone) - {} + explicit Private(){} ~Private() { } QString name; - KReportDesignerSection *detail; - KReportDesigner *reportDesigner; - + KReportDesignerSection *detail = nullptr; + KReportDesigner *reportDesigner = nullptr; QList groupList; - - QVBoxLayout *vboxlayout; - - int pageBreak; + QVBoxLayout *vboxlayout = nullptr; + int pageBreak = KReportDesignerSectionDetail::BreakNone; }; KReportDesignerSectionDetail::KReportDesignerSectionDetail(KReportDesigner * rptdes) diff --git a/src/wrtembed/KReportDesignerSectionDetailGroup.cpp b/src/wrtembed/KReportDesignerSectionDetailGroup.cpp --- a/src/wrtembed/KReportDesignerSectionDetailGroup.cpp +++ b/src/wrtembed/KReportDesignerSectionDetailGroup.cpp @@ -29,30 +29,22 @@ class Q_DECL_HIDDEN KReportDesignerSectionDetailGroup::Private { public: - explicit Private() - : groupHeader(0) - , groupFooter(0) - , pageBreak(KReportDesignerSectionDetailGroup::BreakNone) - , sort(Qt::AscendingOrder) - {} + explicit Private(){} ~Private() { - // I delete these here so that there are no widgets + //Delete these here so that there are no widgets //left floating around delete groupHeader; delete groupFooter; } QString column; - - KReportDesignerSection *groupHeader; - KReportDesignerSection *groupFooter; - - KReportDesignerSectionDetail * reportSectionDetail; - - PageBreak pageBreak; - Qt::SortOrder sort; + KReportDesignerSection *groupHeader = nullptr; + KReportDesignerSection *groupFooter = nullptr; + KReportDesignerSectionDetail * reportSectionDetail = nullptr; + PageBreak pageBreak = KReportDesignerSectionDetailGroup::BreakNone; + Qt::SortOrder sort = Qt::AscendingOrder; }; KReportDesignerSectionDetailGroup::KReportDesignerSectionDetailGroup(const QString & column, KReportDesignerSectionDetail * rsd, diff --git a/src/wrtembed/KReportDesignerSectionScene.h b/src/wrtembed/KReportDesignerSectionScene.h --- a/src/wrtembed/KReportDesignerSectionScene.h +++ b/src/wrtembed/KReportDesignerSectionScene.h @@ -67,16 +67,16 @@ qreal highestZValue(); void exitInlineEditingModeInItems(KReportDesignerItemRectBase *rectUnderCursor); - KReportDesigner * m_rd; + KReportDesigner * m_rd = nullptr; KReportUnit m_unit; - int m_minorSteps; - qreal m_majorX; - qreal m_majorY; - qreal m_pixelIncrementX; - qreal m_pixelIncrementY; - int m_dpiX; - int m_dpiY; + int m_minorSteps = 0; + qreal m_majorX = 0; + qreal m_majorY = 0; + qreal m_pixelIncrementX = 0; + qreal m_pixelIncrementY = 0; + int m_dpiX = 96; + int m_dpiY = 96; }; #endif diff --git a/src/wrtembed/KReportDesignerSectionView.h b/src/wrtembed/KReportDesignerSectionView.h --- a/src/wrtembed/KReportDesignerSectionView.h +++ b/src/wrtembed/KReportDesignerSectionView.h @@ -40,7 +40,7 @@ void mouseReleaseEvent(QMouseEvent * e); private: - KReportDesigner* m_reportDesigner; + KReportDesigner* m_reportDesigner = nullptr; }; #endif