#include "imageelement.h"
#include "rectangle.h"
#include "pointer.h"
+#include "compass.h"
#include "settings.h"
#include "effect.h"
+#include "poialerts.h"
+#include "speedalarm.h"
-GraphicsElement::GraphicsElement(Reader* reader): reader_(reader), error_(""), effect_(0)
+GraphicsElement::GraphicsElement(Reader* reader): QObject(0), reader_(reader), error_(""), effect_(0), visibleWhen_(ALWAYS)
{
}
return new Pointer(reader, animate);
}
+ if(name == "compass")
+ {
+ bool animate = Settings::instance().value("animate_pointer", true).toBool();
+ return new Compass(reader, animate);
+ }
+
qDebug() << "Element not found: " << name;
return 0;
}
bool GraphicsElement::setEffect(QString const& name)
{
- /* QGraphicsDropShadowEffect* eff = new QGraphicsDropShadowEffect;
- eff->setOffset(1);
- eff->setBlurRadius(3);
-
- getElement()->setGraphicsEffect(eff);
-
- return true;*/
-
effect_ = Effect::getEffect(name);
if(!effect_)
bool GraphicsElement::setEffectAttribute(QString const& name, QString const& value)
{
- //return true;
if(!effect_)
{
qDebug() << "Effect not set";
void GraphicsElement::applyEffect()
{
- //return;
effect_->apply(getElement());
}
+
+void GraphicsElement::setVisibleWhen(VisibleWhen when)
+{
+ if(when != visibleWhen_)
+ {
+ visibleWhen_ = when;
+
+ switch(when)
+ {
+ case POI_VISIBLE:
+ connect(&(PoiAlerts::instance()), SIGNAL(visibilityChanged(bool)), this, SLOT(updateVisibility(bool)));
+ break;
+ case SPEED_EXCEEDED:
+ 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)));
+ break;
+ }
+ }
+}
+
+GraphicsElement::VisibleWhen GraphicsElement::strToVisibleWhen(QString const& str) const
+{
+ if(str == "poivisible")
+ {
+ return POI_VISIBLE;
+ }
+ else if(str == "speedexceeded")
+ {
+ return SPEED_EXCEEDED;
+ }
+
+ return ALWAYS;
+}
+
+void GraphicsElement::updateVisibility(bool visible)
+{
+ QGraphicsItem* item = getElement();
+
+ if(item)
+ {
+ item->setVisible(visible);
+ }
+}