Add a dptr and required accessors to KReportItemBase
and port KReportItemLine
Details
Diff Detail
- Repository
- R14 KReport
- Branch
- dptr_kreportitembase
- Lint
No Linters Available - Unit
No Unit Test Coverage
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); |
Thx for the comments, they actually address the issues I wasn't happy with in the design 😁
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) |
src/common/KReportItemBase.cpp | ||
---|---|---|
56 | i dont know :D | |
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() |
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:
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.
Ok, i will progress remaining items
src/common/KReportItemBase.h | ||
---|---|---|
138–139 | now d->zIndex with getter/setter |
src/common/KReportItemBase.cpp | ||
---|---|---|
196 | Not sure but maybe zValue like in QGraphicsItem::zValue? Or z like in QQuickItem::z? |
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? |
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. |
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.
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.