Fixed a small bug in flicker effect.
[jspeed] / src / graphicselement.cpp
index fba0e95..0442b3a 100644 (file)
@@ -37,7 +37,8 @@
 #include "poialerts.h"
 #include "speedalarm.h"
 
-GraphicsElement::GraphicsElement(Reader* reader): QObject(0), reader_(reader), error_(""), effect_(0), visibleWhen_(ALWAYS)
+GraphicsElement::GraphicsElement(Reader* reader): QObject(0),
+reader_(reader), error_(""), effect_(0), visibleWhen_(ALWAYS), canBeVisible_(true)
 {
 }
 
@@ -205,7 +206,7 @@ bool GraphicsElement::setEffectAttribute(QString const& name, QString const& val
 
 void GraphicsElement::applyEffect()
 {
-    effect_->apply(getElement());
+    effect_->apply(this);
 }
 
 void GraphicsElement::setVisibleWhen(VisibleWhen when)
@@ -217,14 +218,17 @@ void GraphicsElement::setVisibleWhen(VisibleWhen when)
         switch(when)
         {
         case POI_VISIBLE:
+            updateVisibility(false);
             connect(&(PoiAlerts::instance()), SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibility(bool)));
             break;
         case SPEED_EXCEEDED:
+            updateVisibility(false);
             connect(&(SpeedAlarm::instance()), SIGNAL(speedExceedChanged(bool)), this, SLOT(updateVisibility(bool)));
             break;
         case ALWAYS:
             disconnect(&(PoiAlerts::instance()), SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibility(bool)));
             disconnect(&(SpeedAlarm::instance()), SIGNAL(speedExceedChanged(bool)), this, SLOT(updateVisibility(bool)));
+            updateVisibility(true);
             break;
         }
     }
@@ -251,5 +255,19 @@ void GraphicsElement::updateVisibility(bool visible)
     if(item)
     {
         item->setVisible(visible);
+
+        if(!visible)
+        {
+            canBeVisible_ = false;
+        }
+        else
+        {
+            canBeVisible_ = true;
+        }
     }
 }
+
+bool GraphicsElement::canBeVisible() const
+{
+    return canBeVisible_;
+}