Bug 360918 - There are no line breaks in the placemark description
Summary: There are no line breaks in the placemark description
Status: RESOLVED INTENTIONAL
Alias: None
Product: marble
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: marble-bugs
URL: https://forum.kde.org/viewtopic.php?f...
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-23 20:36 UTC by strag
Modified: 2016-04-16 09:00 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description strag 2016-03-23 20:36:29 UTC
I add new GeoDataPlacemark to the map and do "setDescription(text)", where text contains line breaks, but placemark description displays without line breaks.

Reproducible: Always

Steps to Reproduce:
1. Create Qt application and add marble-widget to the form:
    MarbleWidget w = new MarbleWidget;
2. Add new GeoDataDocument:
    doc = new GeoDataDocument;
    w->model()->treeModel()->addDocument(doc);
3. Add new GeoDataPlacemark:
   GeoDataPlacemark *place = new GeoDataPlacemark;
   place->setCoordinate(l, b, 0, GeoDataCoordinates::Radian); // l, b - coordinates of the place
4. Create text - description of the place:
    QString text = "string 1, \n";
    text += "string 2, \n";
    text += "string 3";
5. Set description of the place and add place to the document:
    place->setDescription(text);
    w->document()->append(place);
6. Launch application and click on the place.

Actual Results:  
"Short Description" contains: 
"string 1, string 2, string 3"

Expected Results:  
"Short Description" contains: 
"string 1, 
 string 2, 
 string 3"
Comment 1 strag 2016-03-29 21:10:18 UTC
I seem to have solved the problem. The placemark description is displayed using HTML. To preserve the original text formatting should be added the tags <pre> and </pre>:

QString text = "<pre>";     //added tag <pre>
text += "string 1, \n";
text += "string 2, \n";
text += "string 3 \n";
text += "</pre>";              //added tag </pre>

As I understand it, it is necessary to add a "framing" of text by tags to function setDescription(QString). I never participated in opensource projects, so maybe someone can fix it before I'll understand how it's done.
Comment 2 Dennis Nienhüser 2016-04-16 09:00:48 UTC
See https://forum.kde.org/viewtopic.php?f=217&t=131357#p354450

The description is interpreted as html, so newlines need to be indicated using <br/> or similar html tags.

We could introduce some heuristic detection of plain text versus rich text and transform plain text with '\n' into rich text with '<br/>' tags, but I don't see the need for this really. Please reopen if you have a use-case.