/*
 * scbus utils to switch card settings.
 *
 * Copyright (C) 2011 Otvos Attila oattila@onebithq.com
 *
 * This 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.
 *
 * This is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */


#ifndef __CONFIGDIALOG_H__
#define __CONFIGDIALOG_H__

#include <QWidget>
#include <QComboBox>
#include <QLabel>
#include <QGridLayout>
#include <QPushButton>
#include <QList>

#include "rs485class.h"
#include "ledstatus.h"

class ConfigTab : public QWidget {
    Q_OBJECT

    public:

    ConfigTab(const int deviceid, const int output, RS485Config config, QList<int>* devices, QWidget *parent = NULL);

    public:
        int getDevice(void);
        RS485Config getEditedConfig(void);
        void setEditedConfig(RS485Config config);

    public slots:
        void pressReset(void);
        void pressAccept(void);
        void setConfig(RS485Config config);
        void setDevice(int deviceid, RS485Config config);
        void updateDevices(void);

    signals:
        void setModify(int id, bool m);
        void accept(int deviceid, int output, RS485Config config);

    private slots:
        void deviceChanged(int index);
        void inputChanged(int index);
        void typeChanged(int index);
        void parChanged(int index);
        void mdf(bool m);

    private:
        void setBox(QComboBox* box, int value);
        void updatePar(int type, bool force);

        int deviceid;
        int output;
        int alterinput;
        int timmer;
        RS485Config currConfig;
        RS485Config newConfig;
        QComboBox *iDevice;
        QComboBox *iInput;
        QComboBox *iType;
        QComboBox *iPar;
        QLabel *deviceValueLabel;
        LedStatus * ls;
        QPushButton *acceptButton;
        QPushButton *resetButton;

        QList<int>* devices;
};

#endif
