OSM notes: improved rendering
ClosedPublic

Authored by spencerb on Jan 4 2017, 6:01 PM.

Diff Detail

Repository
R34 Marble
Lint
Lint Skipped
Unit
Unit Tests Skipped
spencerb updated this revision to Diff 9718.Jan 4 2017, 6:01 PM
spencerb retitled this revision from to OSM notes: improved rendering.
spencerb updated this object.
spencerb edited the test plan for this revision. (Show Details)
spencerb set the repository for this revision to R34 Marble.
spencerb added reviewers: Marble, rahn, nienhueser.
spencerb added subscribers: Marble, nienhueser, rahn.
spencerb removed subscribers: rahn, nienhueser, Marble.
nienhueser edited edge metadata.Jan 4 2017, 7:09 PM

Shouldn't there be something like a QVector<Comment> property also, where Comment is another class that has member variables for date, user, uid, text at least?

For displaying the values I'd keep things simple for now and just display the information as described in the GCI task:

  • Use the text of the last comment to draw a label text next to the icon. Since the text can be long, shorten it with the help of https://doc.qt.io/qt-5/qfontmetrics.html#elidedText
  • Use the extracted information to change the icon such that resolved notes have a different icon than unresolved ones

More complicated stuff can come in follow-up tasks.

src/plugins/render/notes/NotesItem.h
47

This should be a QDateTime, not a QString. Same for m_dateClosed. You can use QDateTime::fromString() to parse them.

50

Should be an int.

spencerb updated this revision to Diff 9799.Jan 6 2017, 4:02 PM
spencerb edited edge metadata.

Added a few things, like a Comment class and changed a few member variables.
JSON parsing is completely done.
Still testing - getting some odd qpainter errors that I'm trying to figure out.
Also still need to make the qlabel member render in the paint function.

Is it possible to draw a widget like qlabel inside like this (without setting a parent and allowing the painting to occur automatically), or do I just need to implement my own thing instead of using qlabel?

That's possible, but would be overkill here (and not really suitable for mobile). But a simple drawText() should be enough -- no need to support line breaks, html or similar.

That's possible, but would be overkill here (and not really suitable for mobile). But a simple drawText() should be enough -- no need to support line breaks, html or similar.

To elaborate a bit on that: I don't think painting all comments directly in the map is useful. A short "preview" of the note in the form of a short text excerpt should be nice to distinguish notes quickly though.

In a future step we can show the full comment history when the user selects a note later, and use proper widgets/QML elements then which handle all the text drawing on their own.

spencerb updated this revision to Diff 9806.Jan 6 2017, 6:53 PM
spencerb edited the test plan for this revision. (Show Details)

Just realized: I still need to change the icon for open vs closed notes.

nienhueser requested changes to this revision.Jan 6 2017, 7:58 PM
nienhueser edited edge metadata.

Works fine here, but needs a bit of fine-tweaking:

  • I think eliding the text to the right is nicer. One reason is that many apps that generate notes append some automatic text (e..g "generated with $app $version")
  • the size calculation seems wrong, and the icon and the label overlap. Here's some code for inspiration: https://paste.kde.org/psnras3zg That still only solves part of the problem, e.g. the glow effect is not yet included in the size calculation and the painting is not centered on the position (note how it "moves" when zooming in/out)

The addLatestComment could be improved a bit: Sort the vector by date. This can be done with std::sort and a lambda function easily. Afterwards you can just take the first (or last?) value of the QVector, and call the method addComment.

This revision now requires changes to proceed.Jan 6 2017, 7:58 PM
spencerb updated this revision to Diff 9826.EditedJan 7 2017, 9:36 PM
spencerb edited edge metadata.

Icon is much too big. Tried to use QPixmap::Scaled but is seems to have no effect.

On a sidenote, how is mDebug() supposed to work? It doesn't seem to display anything for me.

Edit:
Nevermind, I glanced at the api and I just have to do MarbleDebug::SetEnabled()

Edit 2:
QPixmap::Scaled() is a const function... whoops. Now it scales perfectly.

spencerb updated this revision to Diff 9827.Jan 7 2017, 10:04 PM
spencerb edited edge metadata.

Now the pixmap scales correctly.
I thought I fixed the problem with the non-centering painting, but it doesn't look like it. I'll keep reading up on QPainter and the coordinate system.

spencerb updated this revision to Diff 9985.Jan 10 2017, 3:16 PM
spencerb updated this revision to Diff 10006.Jan 10 2017, 8:01 PM
spencerb added a project: Marble.

Seems to be fully working, except for adding the new icons.

spencerb updated this revision to Diff 10008.Jan 10 2017, 8:57 PM
spencerb updated this object.
spencerb edited the test plan for this revision. (Show Details)
nienhueser accepted this revision.Jan 14 2017, 8:40 AM
nienhueser edited edge metadata.
This revision is now accepted and ready to land.Jan 14 2017, 8:40 AM
nienhueser closed this revision.Jan 14 2017, 8:40 AM