#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <fstream>

class QPushButton;
class QTextBrowser;
class QComboBox;
class QLineEdit;
class QGroupBox;
class QTableView;
class ModuleCommunication;
class PalmFeatureTableModel;
class Database;

class Widget : public QWidget {
    Q_OBJECT
public:
    explicit Widget(QWidget *parent = nullptr);
    void onNewLog(const QString &log);

protected:
    QGroupBox *initializeCommandGroupBox();
    void onClearLogButtonClicked();
    void onSerialConnectButtonClicked();
    void onSerialRefreshButtonClicked();

    void onUvcRefreshButtonClicked();

    void onEnrollButtonClicked();
    void onEnrollExButtonClicked();
    void onVerifyButtonClicked();
    void onDeleteAllButtonClicked();
    void onDeleteButtonClicked();
    void onRequestPalmFeatureButtonClicked();
    void onRegisterPalmFeatureButtonClicked();
    void onResetButtonClicked();

    QGroupBox *initializeEnrollGroupBox();
    QGroupBox *initializeVerifyGroupBox();
    QGroupBox *initializeDeleteGroupBox();
    QGroupBox *initializePalmFeatureGroupBox();

    QGroupBox *initializeUvcGroupBox();

private:
    QComboBox *m_serialComboBox = nullptr;
    QPushButton *m_serialConnectButton = nullptr;
    QTextBrowser *m_logBrowser = nullptr;
    QGroupBox *m_commandGroupBox = nullptr;

    QLineEdit *m_enrollNameEdit = nullptr;
    QLineEdit *m_enrollTimeoutEdit = nullptr;
    QPushButton *m_enrollButton = nullptr;

    QLineEdit *m_verifyTimeoutEdit = nullptr;
    QPushButton *m_verifyButton = nullptr;

    QLineEdit *m_deleteIdEdit = nullptr;
    QPushButton *m_deleteButton = nullptr;
    QPushButton *m_deleteAllButton = nullptr;

    QLineEdit *m_palmFeatureEdit = nullptr;

    PalmFeatureTableModel *m_featureModel = nullptr;
    QTableView *m_featureTableView = nullptr;
};

#endif // WIDGET_H
