/***************************************************************************
 *                                                                         *
 *   copyright : (C) 2007 The University of Toronto                        *
 *                   netterfield@astro.utoronto.ca                         *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef SCALARSELECTOR_H
#define SCALARSELECTOR_H

#include <QWidget>

#include "scalarlistselector.h"

#include <scalar.h>

#include "kstwidgets_export.h"

namespace Ui {
  class ScalarSelector;
}

namespace Kst {

class ObjectStore;

class KSTWIDGETS_EXPORT ScalarSelector : public QWidget
{
  Q_OBJECT
  public:
    explicit ScalarSelector(QWidget *parent = 0, ObjectStore *store = 0);
    virtual ~ScalarSelector();

    void setObjectStore(ObjectStore *store);

    ScalarPtr selectedScalar();
    void setSelectedScalar(ScalarPtr selectedScalar);
    void setSelectedScalar(QString name);
    QString SR();

    void fillScalars();

    QString selectedScalarString(bool *editable = NULL);

    void setDefaultValue(double value);

    virtual QSize	minimumSizeHint () const;

    int iconWidth() const;
    void setIsFOverSR(bool is_f_over_sr);

  Q_SIGNALS:
    void selectionChanged(const QString&);
    void SRChanged(const QString&);

  private Q_SLOTS:
    void newScalar();
    void editScalar();
    void selectScalar();
    void emitSelectionChanged();
    void updateDescriptionTip();
    void updateScalarList();

    void ratioChanged();
    void cutoffChanged();
    void srChanged();

  public Q_SLOTS:
    void setSR(const QString &sr);

  private:
    ScalarListSelector* _scalarListSelector;
    ObjectStore *_store;
    bool _defaultsSet;
    Ui::ScalarSelector *ui;

    enum ControlField {Ratio, Cutoff, SampleRate, None};

    void updateFields(ControlField cf);

};

}

#endif

// vim: ts=2 sw=2 et
