Changeset View
Changeset View
Standalone View
Standalone View
src/lib/marble/MarbleLegendBrowser.cpp
Show First 20 Lines • Show All 286 Lines • ▼ Show 20 Line(s) | 273 | { | |||
---|---|---|---|---|---|
287 | * do it, anyway. It's complicated a lot, the most important | 287 | * do it, anyway. It's complicated a lot, the most important | ||
288 | * thing is to understand everything. | 288 | * thing is to understand everything. | ||
289 | */ | 289 | */ | ||
290 | foreach ( const GeoSceneSection *section, currentMapTheme->legend()->sections() ) { | 290 | foreach ( const GeoSceneSection *section, currentMapTheme->legend()->sections() ) { | ||
291 | // Each section is divided into the "well" | 291 | // Each section is divided into the "well" | ||
292 | // Well is like a block of data with rounded corners | 292 | // Well is like a block of data with rounded corners | ||
293 | customLegendString += "<div class=\"well well-small well-legend\">"; | 293 | customLegendString += "<div class=\"well well-small well-legend\">"; | ||
294 | 294 | | |||
295 | 295 | const QString heading = QCoreApplication::translate("DGML", section->heading().toUtf8().constData()); | |||
296 | QString checkBoxString; | 296 | QString checkBoxString; | ||
297 | if (section->checkable()) { | 297 | if (section->checkable()) { | ||
298 | // If it's needed to make a checkbox here, we will | 298 | // If it's needed to make a checkbox here, we will | ||
299 | QString const checked = d->m_checkBoxMap[section->connectTo()] ? "checked" : ""; | 299 | QString const checked = d->m_checkBoxMap[section->connectTo()] ? "checked" : ""; | ||
300 | /* Important comment: | 300 | /* Important comment: | ||
301 | * We inject Marble object into JavaScript of each legend html file | 301 | * We inject Marble object into JavaScript of each legend html file | ||
302 | * This is only one way to handle checkbox changes we see, so | 302 | * This is only one way to handle checkbox changes we see, so | ||
303 | * Marble.setCheckedProperty is a function that does it | 303 | * Marble.setCheckedProperty is a function that does it | ||
304 | */ | 304 | */ | ||
305 | if(!section->radio().isEmpty()) { | 305 | if(!section->radio().isEmpty()) { | ||
306 | checkBoxString = "" | 306 | checkBoxString = "" | ||
307 | "<label class=\"section-head\">" | 307 | "<label class=\"section-head\">" | ||
308 | "<input type=\"radio\" " | 308 | "<input type=\"radio\" " | ||
309 | "onchange=\"Marble.setRadioCheckedProperty(this.value, this.name ,this.checked);\" " + | 309 | "onchange=\"Marble.setRadioCheckedProperty(this.value, this.name ,this.checked);\" " + | ||
310 | checked + " value=\"" + section->connectTo() + "\" name=\"" + section->radio() + "\" /><span>" | 310 | checked + " value=\"" + section->connectTo() + "\" name=\"" + section->radio() + "\" /><span>" | ||
311 | + section->heading() + | 311 | + heading + | ||
312 | "</span></label>"; | 312 | "</span></label>"; | ||
313 | 313 | | |||
314 | } else { | 314 | } else { | ||
315 | checkBoxString = "" | 315 | checkBoxString = "" | ||
316 | "<label class=\"section-head\">" | 316 | "<label class=\"section-head\">" | ||
317 | "<input type=\"checkbox\" " | 317 | "<input type=\"checkbox\" " | ||
318 | "onchange=\"Marble.setCheckedProperty(this.name, this.checked);\" "+checked+" name=\"" + section->connectTo() + "\" /><span>" | 318 | "onchange=\"Marble.setCheckedProperty(this.name, this.checked);\" "+checked+" name=\"" + section->connectTo() + "\" /><span>" | ||
319 | + section->heading() + | 319 | + heading + | ||
320 | "</span></label>"; | 320 | "</span></label>"; | ||
321 | 321 | | |||
322 | } | 322 | } | ||
323 | customLegendString += checkBoxString; | 323 | customLegendString += checkBoxString; | ||
324 | 324 | | |||
325 | } else { | 325 | } else { | ||
326 | customLegendString += "<h4 class=\"section-head\">"+section->heading()+"</h4>"; | 326 | customLegendString += "<h4 class=\"section-head\">" + heading + "</h4>"; | ||
327 | } | 327 | } | ||
328 | 328 | | |||
329 | foreach (const GeoSceneItem *item, section->items()) { | 329 | foreach (const GeoSceneItem *item, section->items()) { | ||
330 | 330 | | |||
331 | // checkbox for item | 331 | // checkbox for item | ||
332 | QString checkBoxString; | 332 | QString checkBoxString; | ||
333 | if (item->checkable()) { | 333 | if (item->checkable()) { | ||
334 | QString const checked = d->m_checkBoxMap[item->connectTo()] ? "checked" : ""; | 334 | QString const checked = d->m_checkBoxMap[item->connectTo()] ? "checked" : ""; | ||
Show All 22 Lines | |||||
357 | 357 | | |||
358 | // NOTICE. There are some pixmaps without image, so we should | 358 | // NOTICE. There are some pixmaps without image, so we should | ||
359 | // create just a plain rectangle with set color | 359 | // create just a plain rectangle with set color | ||
360 | QColor color = item->icon()->color(); | 360 | QColor color = item->icon()->color(); | ||
361 | if ( color.isValid() ) { | 361 | if ( color.isValid() ) { | ||
362 | styleDiv = "width: " + QString::number(pixmapWidth) + "px; height: " + | 362 | styleDiv = "width: " + QString::number(pixmapWidth) + "px; height: " + | ||
363 | QString::number(pixmapHeight) + "px; background-color: " + color.name() + ';'; | 363 | QString::number(pixmapHeight) + "px; background-color: " + color.name() + ';'; | ||
364 | } | 364 | } | ||
365 | const QString text = QCoreApplication::translate("DGML", item->text().toUtf8().constData()); | ||||
365 | QString html = "" | 366 | QString html = "" | ||
366 | "<div class=\"legend-entry\">" | 367 | "<div class=\"legend-entry\">" | ||
367 | " <label>" + checkBoxString + | 368 | " <label>" + checkBoxString + | ||
368 | " <img class=\"image-pic\" src=\"" + src + "\" style=\"" + styleDiv + "\"/>" | 369 | " <img class=\"image-pic\" src=\"" + src + "\" style=\"" + styleDiv + "\"/>" | ||
369 | " <span class=\"notation\">" + item->text() + "</span>" | 370 | " <span class=\"notation\">" + text + "</span>" | ||
370 | " </label>" | 371 | " </label>" | ||
371 | "</div>"; | 372 | "</div>"; | ||
372 | customLegendString += html; | 373 | customLegendString += html; | ||
373 | } | 374 | } | ||
374 | customLegendString += "</div>"; // <div class="well"> | 375 | customLegendString += "</div>"; // <div class="well"> | ||
375 | } | 376 | } | ||
376 | 377 | | |||
377 | return customLegendString; | 378 | return customLegendString; | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |