#ifndef TDE_WIDGETS_COMBOBOX_H
#define TDE_WIDGETS_COMBOBOX_H

#include <QWidget>
#include <QComboBox>

#include <stdint.h>
#include <sys/types.h>

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

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

namespace TDE {

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

namespace Widgets {

/*!
 * \class ComboBox
 * \brief Widget for editing multiple-valued DataStore variables through a combo-box.
 *
 * \see DataStore
 * \see WidgetInfo
 */
class ComboBox : public QComboBox
{
    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(QString description READ description WRITE setDescription)

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

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

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

    // properties getters/setters

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

    QString description() const;
    void    setDescription(const QString&);

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

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

signals:
    void variableChanged(QString);
    void integerVariableValueChanged(int);
    void floatVariableValueChanged(float);
    void traceChanged(bool);                // trace option changed

    void refreshChanged(int);               // refresh value changed
    void ui2LoggerMsg(QString);

public slots:
    void selectedItemChanged(int index);

    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;
    bool initialized;
    QString dbStr;
    QString originalTip;
    QString oldText;

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

} /* end of namespace Widgets */

} /* end of namespace TDE */

#endif /* TDE_WIDGETS_COMBOBOX_H */
