Add d-ptr to kReportItemBase and port KReportItemLine
ClosedPublic

Authored by piggz on Oct 18 2016, 8:01 PM.

Details

Reviewers
staniek
Summary

Add a dptr and required accessors to KReportItemBase
and port KReportItemLine

Diff Detail

Repository
R14 KReport
Branch
dptr_kreportitembase
Lint
No Linters Available
Unit
No Unit Test Coverage
piggz updated this revision to Diff 7517.Oct 18 2016, 8:01 PM
piggz retitled this revision from to Add d-ptr to kReportItemBase and port KReportItemLine.
piggz updated this object.
piggz edited the test plan for this revision. (Show Details)
piggz added a reviewer: staniek.
Restricted Application added a project: KReport. · View Herald TranscriptOct 18 2016, 8:01 PM
staniek requested changes to this revision.Oct 19 2016, 11:05 PM
staniek edited edge metadata.

Good progress!

src/common/KReportItemBase.cpp
28

I propose to move these two lines to KReportItemBase::Private ctor's initializer. Such approach will also remove COVERITY warnings about uninitialized members if I remember correctly (COVERITY has no idea about d-pointer tricks).

29

Let's use nameProperty for more clear meaning.

30

This line can be also moved to the KReportItemBase::Private ctor.

52–55

Memory leak, missing delete d

57–58

Hmm! Since we no longer constructing property set instance in subclasses, we can move this code directly to the KReportItemBase::Private ctor, remove this method, and have so much code removed in all files (all new KPropertySet calls and all addDefaultProperties() calls).

Finally, we can own the property set at the level of KReportItemBase so how about having it declared as KPropertySet set in the KReportItemBase::Private class so we don't need to play with memory? All 'delete m_set` calls can be removed as well then.

src/common/KReportItemBase.h
107–108

I propose to change to

KPropertySet* propertySet();

and add

const KPropertySet* propertySet() const;

145

Not needed, we already have KPropertySet* propertySet()

147

QString &oldName() -> QString oldName() const

149

Hmm, for obtaining the values we already have

KReportPosition position() const;
KReportSize size() const;

For setting let's add protected setters.

src/common/KReportItemLine.cpp
26–31

+Q_DECL_HIDDEN

84–88

We already do that in superclass.

src/wrtembed/KReportDesignerItemLine.cpp
48–49

By the way I propose further simplification by adding an empty protected Q_SLOT:

virtual void KReportItemBase::propertyChanged(KPropertySet &s, KProperty &p)

And moving the connect() to KReportItemBase.

Note the virtual here. Subclasses can reimplement the method without adding any connect() -- 14 occurences can be removed. And because KReportItemBase::propertyChanged() is empty, it does not need to be called from the reimplementation.

57

Maybe it's name is in init(scene, d)?

64–65

Like above.

244

based on the changes I propose the line could be:

QPointF original = position().toScene();
246–247

based on the changes I propose the line could be:

setPosition(original);
This revision now requires changes to proceed.Oct 19 2016, 11:05 PM
piggz added a comment.Oct 20 2016, 7:18 AM

Thx for the comments, they actually address the issues I wasn't happy with in the design 😁

piggz updated this revision to Diff 7608.Oct 22 2016, 9:33 PM
piggz edited edge metadata.
piggz marked 16 inline comments as done.
  • Implement review comments

Also removed need for KReportSize and KReportPosition

staniek requested changes to this revision.Oct 22 2016, 11:04 PM
staniek edited edge metadata.

Much better!

src/common/KReportItemBase.cpp
19–20

let's remove them

30

let's remove them

36

Let's keep all methods on top before any members

56

Doesn't KPropertySet own and destroy properties?

62

Let's use new connection API

99

is this method needed?

206

Let's use full name size

src/common/KReportItemBase.h
141

I think this line is a bit too redundant

143

Not QSizeF size() const?

146

& not needed

148

I think this line is a bit too redundant

149

Why not Q_SLOT?

150

Like above re const

src/wrtembed/KReportDesigner.cpp
1177

can we remove now?

1179

can we remove now?

src/wrtembed/KReportDesignerItemLine.h
59

(KPropertySet &s, KProperty &p)

This revision now requires changes to proceed.Oct 22 2016, 11:04 PM
piggz marked 15 inline comments as done.Oct 23 2016, 7:16 PM
piggz added inline comments.
src/common/KReportItemBase.cpp
56

i dont know :D
I'll take your word on it ;)

99

yes....although i think the original implementation pre-dates kproperty supporting units, so did it itself ... lets make use of kproperty unit support now

src/common/KReportItemBase.h
149

added public setter as its used in kReportDesigner()

piggz updated this revision to Diff 7626.Oct 23 2016, 7:17 PM
piggz edited edge metadata.
piggz marked 2 inline comments as done.
  • Implement more comments
staniek added a comment.EditedOct 24 2016, 6:35 PM

Good, I tried:

arc patch D3103

And got this build error:

src/kreport/src/items/label/KReportItemLabel.cpp:40: error: ‘m_name’ was not declared in this scope
     m_name->setValue(element.toElement().attribute(QLatin1String("report:name")));
     ^

Also I propose to use .git/hooks/pre-commit in your repos to get rid of extra whitespace in commits:

piggz added a comment.Oct 24 2016, 7:08 PM

Expected .... its a 'design' review .... only line is ported, not the other items yet .... if you're generally happy with the approach i will proceed.

Got it now, OK. Per habit I tried to build as a last step :)

staniek requested changes to this revision.Oct 30 2016, 10:25 PM
staniek edited edge metadata.

Almost ready!

src/common/KReportItemBase.cpp
152

->nameProperty

src/common/KReportItemBase.h
138–139

would it go to Private?

This revision now requires changes to proceed.Oct 30 2016, 10:25 PM
piggz marked 2 inline comments as done.Nov 2 2016, 9:05 PM

Ok, i will progress remaining items

src/common/KReportItemBase.h
138–139

now d->zIndex with getter/setter

piggz updated this revision to Diff 7843.Nov 2 2016, 10:30 PM
piggz edited edge metadata.
piggz marked an inline comment as done.
  • Further porting of items
staniek requested changes to this revision.Nov 2 2016, 10:44 PM
staniek edited edge metadata.
staniek added inline comments.
src/common/KReportItemBase.cpp
196

Not sure but maybe zValue like in QGraphicsItem::zValue?

Or z like in QQuickItem::z?

This revision now requires changes to proceed.Nov 2 2016, 10:44 PM
piggz added inline comments.Nov 3 2016, 7:10 AM
src/common/KReportItemBase.cpp
196

Yeah, I considered similar....I chose zIndex because that's what CSS uses, and we store the value as svg:z-index

Higher up the stack I was concerned about subclasses which also subclass qgraphcsitem clashing with zValue.

Thoughts?

staniek added inline comments.Nov 3 2016, 2:31 PM
src/common/KReportItemBase.cpp
196

KReportElement which I added as a high-level API that would be used with scripting too, has z() and setZ(). Why I picked it over anything else? Because it's consistent with what javescript would use: 'z' property.

So I am all for using 'z' everywhere, like we're using QPoint::x, etc.

piggz marked 3 inline comments as done.Nov 3 2016, 7:44 PM
piggz updated this revision to Diff 7876.Nov 3 2016, 9:05 PM
piggz edited edge metadata.
  • Further porting, Label designer item ported.
piggz added a comment.Nov 3 2016, 9:05 PM
Some more structural changes, mainly around KReportDeisignerItemBase
gaining a d-ptr, and a pointer to the KReportItemBase so there is no
need to pass in individual pointers to the propertyset, size and
position.
piggz added a comment.Nov 3 2016, 9:06 PM

a little bit of extra work is also required so that when the kReportItemBase size and position are updated, they update their respective properties, with a flag to disable updates.

staniek accepted this revision.Nov 3 2016, 9:22 PM
staniek edited edge metadata.

Minor note and go!

Thx

src/common/KReportItemBase.h
131

_z -> z

This revision is now accepted and ready to land.Nov 3 2016, 9:22 PM
piggz closed this revision.Nov 4 2016, 7:24 PM
piggz marked an inline comment as done.