#ifndef MODELINFOEDITDIALOG_H
#define MODELINFOEDITDIALOG_H

#include <QDialog>
#include "global.h"

class MainWindow;
class QListWidgetItem;

QT_BEGIN_NAMESPACE
namespace Ui {
class ModelInfoEditDialog;
}
QT_END_NAMESPACE

class ModelInfoEditDialog : public QDialog
{
    Q_OBJECT

public:
    ModelInfoEditDialog(QWidget *parent = nullptr);
    ~ModelInfoEditDialog();

    void setState(DialogState state) {m_state = state;}
    void setMainWindow(MainWindow*);
    void setModel(int id) {m_curModelID = id;}

protected:
    virtual void showEvent(QShowEvent*);

private:
    void initialize();
    void setErrorInfo(const QString&);
    void resetUI();
    void refreshGroupList();

    Ui::ModelInfoEditDialog* ui;
    DialogState m_state;
    MainWindow* m_pMainWindow;
    int m_curModelID;

signals:
    void addModel(Model&);

public slots:
    void onBtnClicked_save();
    void onBtnClicked_cancle();
    void onBtnClicked_addGroup();
    void onBtnClicked_removeSelected();
    void onItemDblCliked_sourceList(QListWidgetItem*);
};

#endif //MODELINFOEDITDIALOG_H
