#ifndef TDE_WIDGETS_LED_H
#define TDE_WIDGETS_LED_H

#include <QWidget>
#include <QSvgWidget>

#include <QMap>

#include "common.h"
#include "opaque.h"

// -- TDE NAMESPACE ----------------------------------------------------

namespace TDE {

// -- Widgets NAMESPACE ------------------------------------------------

namespace Widgets {

/*!
 * \class LED
 * \brief Widget for displaying multi-valued DataStore variables as LED images.
 *
 * \see DataStore
 * \see WidgetInfo
 */
class LED : public QSvgWidget
{
    Q_OBJECT
	Q_PROPERTY(QString variableName READ variableName WRITE setVariableName NOTIFY variableChanged)
    Q_PROPERTY(bool trace READ trace WRITE setTrace NOTIFY traceChanged)
    Q_PROPERTY(int refresh READ refresh WRITE setRefresh NOTIFY refreshChanged)
    Q_PROPERTY(bool raw READ raw WRITE setRaw NOTIFY rawChanged)
    Q_PROPERTY(QStringList choices READ choices WRITE setChoices NOTIFY choicesChanged)

public:
    LED(QWidget *parent = 0);
    virtual ~LED();

    SHARED_PTR<TDE::DataStore> dataStore();
    LED& setDataStore(SHARED_PTR<TDE::DataStore> ds_p);
    LED& setVariableName(const std::string& name);

    int   variableIndex() const;
    const TDE::VariableDescr& variableDescr() const;

    // properties getters/setters

    QString variableName() const;
    void    setVariableName(const QString&);

    bool trace() const;
    bool setTrace(bool value = true);

    int refresh() const;
    int setRefresh(int value = 0);

    bool raw() const;
    bool setRaw(bool value = true);

    QStringList choices() const;
    void setChoices(const QStringList& choices);

signals:
    void variableChanged(QString);

    void traceChanged(bool);                // trace option changed
    void refreshChanged(int);               // refresh value changed
    void rawChanged(bool);                  // raw option changed

    void choicesChanged(const QStringList&);

public slots:
    void ui2ds();    // set DataStore variable with value from UI
    void ds2ui();    // set UI with value from DataStore
    void showTooltip();   //show Tooltip delayed

private:
	SHARED_PTR<WidgetInfo> m_winfo;
    QStringList m_choices_list;
    QMap<int, QString> m_choices;
    QString dbStr;
    QString originalTip;

protected:
	virtual void showEvent(QShowEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent* e);
};

} /* end of namespace Widgets */

} /* end of namespace TDE */

#endif /* TDE_WIDGETS_LED_H */
