T1513
AbandonedPublic

Authored by asemke on Mar 14 2018, 10:11 PM.

Details

Summary

This is an attempt to solve TASK T1513
https://phabricator.kde.org/T1513
I added several options to choose the shape of the label from.

Video about the functionality:
https://www.youtube.com/watch?v=15pwzEUDoHo&feature=youtu.be

Test Plan

The testing was done manually as you can see in the pictures.

Diff Detail

Repository
R262 LabPlot
Lint
Lint Skipped
Unit
Unit Tests Skipped
There are a very large number of changes, so older changes are hidden. Show Older Changes
Restricted Application added a project: KDE Edu. · View Herald TranscriptMar 14 2018, 10:11 PM
Restricted Application added a subscriber: KDE Edu. · View Herald Transcript
ferenczkovacs requested review of this revision.Mar 14 2018, 10:11 PM
fkristof added inline comments.Mar 15 2018, 7:26 AM
src/backend/worksheet/TextLabel.cpp
80

Remove unnecessary comment.

81

Initialize members in the initializer list of the class instead.

508

I don't think that the name "labelShape" would be too long to be necessary to shorten it.

516

Remove unnecessary comment.

518

In this case a switch-case would be more handy in my opinion.

523

If you don't intend to modify these then you can make them const.

527

Check the coding style for these lines (spacing in the expressions).

556

Remove empty line.

560

Remove empty line.

991

You should move m_labelShape (instead of m_labelshape) to TextLabelPrivate. That way you won't need any getter, you can just set it in TextLabelPrivate. You should also rename this function to recalcShapeAndBoundingRect(TextLabel::LabelShape) too.

993

Remove empty line.

998

There's no need of a second cast, the static_cast does what you wanted. Anyway, this will be reduced to

return m_labelShape;

if you'll change its type to TextLabel.

1000

Remove this function.

src/backend/worksheet/TextLabel.h
56

Remove unnecessary comment.

58

Respect our coding style, it should be "Rect = 0"

68

Why do you use an int instead of the previously declared enum? Using the enum you've created becomes more clear what your parameter is about. (LabelShape)

69

Getters should be const functions.

70

This is unnecessary, a single getter is enough for a member variable.

71

Remove this declaration, can't see any use of it.

139

Remove unnecessary comment.

140

Why is this member an int? Its type should be TextLabel.

src/backend/worksheet/TextLabelPrivate.h
63

Not providing a name when using a default argument is a bad practice, the other developers can't deduce what the default parameter means since it has no name. Also the recheck the coding style (space before/after =)

src/kdefrontend/ui/labelwidget.ui
558

Don't leave the name of the QLabel default. It sould be "lLabel".

src/kdefrontend/widgets/LabelWidget.cpp
107

Remove unnecessary comment.

169

Remove unnecessary comment.

793

Remove unnecessary comment.

794

This isn't the way you load the configuration. Check the other parameters how they are saved and then loaded here from the config file.

850

Remove unnecessary comment.

856

Possible improvement: use const pointer (auto* const label : m_labelsList).

src/kdefrontend/widgets/LabelWidget.h
103

Remove unnecessary comment.

104

Respect out coding style, the name of this method should be "labelShapeIndexChanged". I think "labelShapeChanged" would do the job too.

I made some new features regarding the label's border style, border color, and its fill color and pattern. There is also a preview feature available when one wants to choose the label's shape.

ferenczkovacs marked 27 inline comments as done.

solved the comments mostly

fkristof added inline comments.Mar 21 2018, 9:11 PM
src/backend/worksheet/TextLabel.cpp
564

Remove empty line.

src/backend/worksheet/TextLabel.h
25

Remove empty lines.

32

This should be a const member function.

33

There's no need of another getter, you have already one:

TextLabel::LabelShape getLabelShape();
40

This should return

Qt::BrushStyle

because of

Qt::BrushStyle patternStyle;
77

Make this function const, it's a getter.

78

Remove this getter, you've got already

TextLabel::LabelShape getLabelShape();
79

Make this function const, it's a getter.

81

I think this should be

QColor backgroundColor;

or

QColor fillColor;
83

This should be:

void chooseLabelBackgroundColor(const QColor&);

or

void chooseLabelFillColor(const QColor&);

(pass const reference to avoid copy constrution)

85

Here too, pass const reference

const QColor&
86

This should be

void choosePatternStyle(const Qt::BrushStyle);

because

Qt::BrushStyle patternStyle;
87

This should return

Qt::BrushStyle

because

Qt::BrushStyle patternStyle;
156

Move these members to TextLabelPrivate.

src/kdefrontend/ui/dockwidgets/cartesianplotdock.ui
20

Revert this change.

1184

Revert this change too, it shouldn't be removed.

src/kdefrontend/ui/labelwidget.ui
308

The name of this widget should be

bBackgroundColor

or

bFillColor
633

The name of this widget should be

cbBackgroundPattern

or

cbFillPattern
src/kdefrontend/widgets/LabelWidget.cpp
129

These combobox items/styles/patterns should all start with an upper-case letter.

200

Remove extra space after

SLOT(
923

The parameter name should start with a lower-case letter.

928

Use const pointer:

for (auto* const label
940

Const pointer here too.

947

No need to cast to QObject*, ui.cbLabelsShape inherits QObject too.

951

Const pointer.

963

This object can be const if you don't intend to change it in the future.

973

No use of this else.

979

Const pointer.

984

backcolor can be const.

988

There's no need of a cast, backcolor it's a QColor already.

990

Const pointer.

994

Neither here has any use to have this else here.

1000

Const pointer.

src/kdefrontend/widgets/LabelWidget.h
11

It should be

void labelShapeChanged(int);
12

It should be

void labelShapePreview(int);
64

What does this represent? The name isn't very self-describing.

103

It should be

void labelShapeIndexChanged(int);

The same applies for the other functions you've introduced, they start with upper-case "L".

ferenczkovacs marked 30 inline comments as done.
ferenczkovacs edited the summary of this revision. (Show Details)

I tried to solve the problems mentioned in the comments. Furthermore i uploaded a video about the features which i implemented:
https://www.youtube.com/watch?v=15pwzEUDoHo&feature=youtu.be

ferenczkovacs added inline comments.Mar 21 2018, 11:30 PM
src/backend/worksheet/TextLabel.cpp
991

I don't think so, because then i'll need a plus set of set-get functions

src/backend/worksheet/TextLabel.h
78

I'll rather use const int getLabelShapeint();
and delete
TextLabel::LabelShape getLabelShape();

156

I'll pass if possible, i'll need unnecessarily an additional set/get function pair

src/kdefrontend/widgets/LabelWidget.cpp
794

can't manage to solve it

src/kdefrontend/widgets/LabelWidget.h
64

a copy of the temporary shape, i think it's quite clear

fkristof added inline comments.Mar 21 2018, 11:40 PM
src/backend/worksheet/TextLabel.cpp
991

That's not a problem. The main idea I have here is that you use labelShape in TextLabelPrivate, and not in TextLabel, this implies that labelShape should be a member of TextLabelPrivate, not TextLabel. So I suggest you to make this change. The same applies to the other parameters you've added, like backgroundColor, borderStyle, etc, they all belong to TextLabelPrivate. TextLabel can access them through the d pointer, if needed you can write getters and setters for them.

src/backend/worksheet/TextLabel.h
78

Since labelShape has the type of TextLabel::LabelShape your getter should look like

TextLabel::LabelShape getLabelShape() const;
src/kdefrontend/widgets/LabelWidget.h
64

I think m_previewTempLabelShape would be more self-describing in this case.

asemke commandeered this revision.Dec 2 2018, 6:46 PM
asemke added a reviewer: ferenczkovacs.
Restricted Application edited subscribers, added: kde-edu; removed: KDE Edu. · View Herald TranscriptDec 2 2018, 6:46 PM
asemke abandoned this revision.Dec 2 2018, 6:48 PM

Adjusted and completed version of this patch was uploaded in https://phabricator.kde.org/R262:2728e198e5b724bd7b43d6d441e938918968bd7f