#ifndef LIBRARY_H
#define LIBRARY_H

#include <QDialog>
#include "camp.h"
#include "cspeaker.h"
#include "cdac.h"
#include <QListWidget>

namespace Ui {
class library;
}

class library : public QDialog
{
    Q_OBJECT

public:
    explicit library(QWidget *parent = nullptr);

    void setAmpPointer(cAmp* pAmp,unsigned int ampCount);
    unsigned int getAmpCount();
    cAmp* getAmps();

    void setSpeakerPointer(cSpeaker* pSpeaker, unsigned int speakerCount);
    unsigned int getSpeakerCount();
    cSpeaker* getSpeaker();

    void setDacPoint(cdac* dac, unsigned int dacCount);
    unsigned int getDacCount();
    cdac* getDacs();

    void open();
    ~library();


private slots:

    void on_pushButton_addAmp_clicked();

    void on_listWidget_ampView_currentRowChanged(int currentRow);


    void on_pushButton_applyChanges_clicked();

    void on_comboBox_sensUnit_currentIndexChanged(int index);

    void on_pushButton_deleteAmp_clicked();

    void on_pushButton_addMode_clicked();


    void on_listWidget_modeSelector_currentRowChanged(int currentRow);


    void on_pushButton_deleteMode_clicked();

    void on_pushButton_applyMode_clicked();

    void on_lineEdit_ampName_textEdited(const QString &arg1);


    void on_pushButton_addSpeaker_clicked();

    void on_listWidget_speakerView_currentRowChanged(int currentRow);

    void on_pushButton_deleteSpeaker_clicked();

    void on_pushButton_applySpeaker_clicked();

    void on_lineEdit_speakerName_textEdited(const QString &arg1);

    void on_pushButton_dacAdd_clicked();

    void on_pushButton_deleteDac_clicked();

    void on_pushButton_Apply_clicked();

    void on_listWidget_dacView_currentRowChanged(int currentRow);

    void on_lineEdit_dacName_textEdited(const QString &arg1);

    void on_spinBox_dacOutputLevel_editingFinished();

    void on_spinBox_speakerImp_editingFinished();

    void on_spinBox_speakerRMSPower_editingFinished();

    void on_spinBox_speakerPeakPower_editingFinished();

    void on_spinBox_speakerHPF_editingFinished();

    void on_doubleSpinBox_inputSensitivity_editingFinished();

private:
    Ui::library *ui;
    cAmp* m_pCamp;
    unsigned int m_cAmpCount;

    cSpeaker* m_pSpeaker;
    unsigned int m_SpeakerCount;

    cdac* m_pDac;
    unsigned int m_dacCount;

    void refreshAmpView();
    void refreshModeOverview();

    void refreshSpeakerView();

    void refreshDacView();

    int getCurrentAmpIndex();
    int getCurrentAmpModeIndex();
    int getCurrentSpeakerIndex();
    int getCurrentDacIndex();

    void ampEdited();
    void speakerEdited();
    void dacEdited();

    void confirmAmpChanges();
    void confirmSpeakerChanges();
    void confirmDacChanges();

    void printAllAmps();
    bool unsaved;
    bool speakerUnsaved;
    bool dacUnsaved;

};

#endif // LIBRARY_H
