[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [marble] /: legend: support checkbox for section items
From:       Thibaut Gridel <tgridel () free ! fr>
Date:       2014-01-04 21:43:03
Message-ID: E1VzYzn-0003y0-Hk () scm ! kde ! org
[Download RAW message or body]

Git commit 5e12abd29ff929a9829dfe968638c930bcc369bd by Thibaut Gridel.
Committed on 04/01/2014 at 21:20.
Pushed by tgridel into branch 'master'.

legend: support checkbox for section items

M  +5    -6    data/legend.css
M  +17   -3    src/lib/marble/MarbleLegendBrowser.cpp

http://commits.kde.org/marble/5e12abd29ff929a9829dfe968638c930bcc369bd

diff --git a/data/legend.css b/data/legend.css
index a526d04..253beb1 100644
--- a/data/legend.css
+++ b/data/legend.css
@@ -18,11 +18,6 @@ body
   padding: 10px;
 }
 
-label span {
-   line-height: 30px;
-   font-weight: 600;
-}
-
 label input {
    margin-right: 5px!important;
 }
@@ -38,12 +33,16 @@ label input {
    color: #b3925d!important;
 }
 
+.section-head span {
+   line-height: 30px;
+   font-weight: 600;
+}
+
 .legend-entry {
    margin-bottom: -10px!important;
 }
 
 .legend-entry .image-pic {
-   float: left;
    margin-right: 20px;
    margin-top: 3px;
 }
diff --git a/src/lib/marble/MarbleLegendBrowser.cpp b/src/lib/marble/MarbleLegendBrowser.cpp
index 0f4f684..30e491f 100644
--- a/src/lib/marble/MarbleLegendBrowser.cpp
+++ b/src/lib/marble/MarbleLegendBrowser.cpp
@@ -321,6 +321,19 @@ QString MarbleLegendBrowser::generateSectionsHtml()
         }
 
         foreach (const GeoSceneItem *item, section->items()) {
+
+            // checkbox for item
+            QString checkBoxString;
+            if (item->checkable()) {
+                QString const checked = d->m_checkBoxMap[item->connectTo()] ? "checked" : "";
+                checkBoxString = ""
+                        "<input type=\"checkbox\" "
+                        "onchange=\"Marble.setCheckedProperty(this.name, this.checked);\" "
+                        + checked + " name=\"" + item->connectTo() + "\" />";
+
+            }
+
+            // pixmap and text
             QString path = "";
             int pixmapWidth = 24;
             int pixmapHeight = 12;
@@ -345,9 +358,10 @@ QString MarbleLegendBrowser::generateSectionsHtml()
             QString src = QUrl::fromLocalFile( path ).toString();
             QString html = ""
                     "<div class=\"legend-entry\">"
-                    "       <img class=\"image-pic\""
-                    "       src=\"" + src + "\" style=\"" + styleDiv + "\" />"
-                    "   <p class=\"notation\">" + item->text() + "</p>"
+                    "  <label>" + checkBoxString +
+                    "    <img class=\"image-pic\" src=\"" + src + "\" style=\"" + styleDiv + "\"/>"
+                    "    <span class=\"notation\">" + item->text() + "</span>"
+                    "  </label>"
                     "</div>";
             customLegendString += html;
         }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic