[Marble-commits] KDE/kdeedu/marble/src

Andrew Manson g.real.ate at gmail.com
Wed Jul 22 17:44:17 CEST 2009


SVN commit 1001078 by mansona:

Implementing GeoGraphicsItem flags and setting the OsmNodeGraphicsItems
as invisable by default.



 M  +19 -0     lib/GeoGraphicsItem.cpp  
 M  +22 -7     lib/GeoGraphicsItem.h  
 M  +1 -0      lib/GeoGraphicsItem_p.h  
 M  +3 -1      plugins/render/osmannotate/OsmAnnotatePlugin.cpp  
 M  +2 -0      plugins/render/osmannotate/osm/OsmWayTagHandler.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/GeoGraphicsItem.cpp #1001077:1001078
@@ -61,6 +61,25 @@
     p()->m_target = target;
 }
 
+GeoGraphicsItem::GeoGraphicsItemFlags GeoGraphicsItem::flags()
+{
+    return p()->m_flags;
+}
+
+void GeoGraphicsItem::setFlag( GeoGraphicsItemFlag flag, bool enabled )
+ {
+    if( enabled ) {
+        p()->m_flags = p()->m_flags | flag;
+    } else {
+        p()->m_flags = p()->m_flags & ~flag;
+    }
+}
+
+void GeoGraphicsItem::setFlags( GeoGraphicsItemFlags flags )
+{
+    p()->m_flags = flags;
+}
+
 QList<QPointF> GeoGraphicsItem::positions() {
     return p()->positions();
 }
--- trunk/KDE/kdeedu/marble/src/lib/GeoGraphicsItem.h #1001077:1001078
@@ -41,10 +41,11 @@
     enum GeoGraphicsItemFlag{
         NoOptions = 0x0,
         ItemIsMovable = 0x1,
-        ItemIsSelectable = 0x2
+        ItemIsSelectable = 0x2,
+        ItemIsVisable = 0x4
     };
 
-    Q_DECLARE_FLAGS( GeoGraphicsItemFlags, GeoGraphicsItemFlag )
+    Q_DECLARE_FLAGS(GeoGraphicsItemFlags, GeoGraphicsItemFlag)
     
     /**
      * Return the coordinate of the item as a GeoDataCoordinates
@@ -77,6 +78,24 @@
      * Set the target of the item with @p target.
      */
     void setTarget( const QString& target );
+
+    /**
+     * Get the GeoGraphicItemFlags value that describes which flags are set on
+     * this item. @see QFlags
+     */
+    GeoGraphicsItemFlags flags();
+
+    /**
+     * Set or unset a single flag
+     * @param enabled sets if the flag is to be set or unset
+     */
+     void setFlag( GeoGraphicsItemFlag flag, bool enabled = true );
+
+     /**
+      * Replace all of the current flags.
+      * @param flags is the new value for this item's flags.
+      */
+     void setFlags( GeoGraphicsItemFlags flags );
     
     /**
      * Returns all coordinates of the item in view coordinates according to the given projection.
@@ -93,11 +112,7 @@
     GeoGraphicsItemPrivate *p() const;
 };
 
-//Declares the operator|() for flags but breaks other enum comparisons related to 
-//GeoGraphicsItem
-//FIXME ... is this necessary?
-//Q_DECLARE_OPERATORS_FOR_FLAGS(GeoGraphicsItem::GeoGraphicsItemFlags)
-
 } // Namespace Marble
+Q_DECLARE_OPERATORS_FOR_FLAGS(Marble::GeoGraphicsItem::GeoGraphicsItemFlags)
 
 #endif // GEOGRAPHICSITEM_H
--- trunk/KDE/kdeedu/marble/src/lib/GeoGraphicsItem_p.h #1001077:1001078
@@ -59,6 +59,7 @@
     GeoDataCoordinates m_coordinate;
     QString m_target;
     QList<QPointF> m_positions;
+    GeoGraphicsItem::GeoGraphicsItemFlags m_flags;
 };
 
 }
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/OsmAnnotatePlugin.cpp #1001077:1001078
@@ -152,7 +152,9 @@
 
         while( it.hasNext() ) {
             GeoGraphicsItem* i = it.next();
-            i->paint( painter, viewport, renderPos, layer );
+            if( i->flags() & GeoGraphicsItem::ItemIsVisable ) {
+                i->paint( painter, viewport, renderPos, layer );
+            }
         }
     }
 
--- trunk/KDE/kdeedu/marble/src/plugins/render/osmannotate/osm/OsmWayTagHandler.cpp #1001077:1001078
@@ -29,6 +29,8 @@
     GeoNode* result;
     OsmWayGraphicsItem* way = new OsmWayGraphicsItem();
 
+    way->setFlag( GeoGraphicsItem::ItemIsVisable );
+
     parser.activeModel()->append(way);
 
     result = reinterpret_cast<GeoNode*>(way);


More information about the Marble-commits mailing list