#ifndef YOURONGMODELITEM_H
#define YOURONGMODELITEM_H
#include "uosai_global.h"
#include <QProcess>

#include <DWidget>
#include <DBackgroundGroup>
#include <DLabel>
#include <DSuggestButton>

namespace uos_ai {

static constexpr char YOURONG1_5B[] = "yourong1.5B-Instruct-GGUF";
static constexpr char YOURONG7B[] = "yourong7B-Instruct-GGUF";
class Downloader;
class YouRongModelItem: public DTK_WIDGET_NAMESPACE::DWidget
{
    Q_OBJECT

public:
    explicit YouRongModelItem(DTK_WIDGET_NAMESPACE::DWidget *parent = nullptr);
    ~YouRongModelItem();

    void stopDownload();

private:
    void initUI();
    void initConnect();
    void changeInstallStatus();
    void adjustSummaryLabelWidth();

public:
    void setText(const QString &theme, const QString &summary);
    void setAppName(const QString &appName);
    void checkInstallStatus();
    bool getInstallStatus();

private slots:
    void onInstall();
    void onUninstall();
    void onDownloadFinished();
    void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);

protected:
    void resizeEvent(QResizeEvent *event) override;

private:
    DTK_WIDGET_NAMESPACE::DLabel *m_pLabelTheme = nullptr;
    DTK_WIDGET_NAMESPACE::DLabel *m_pLabelSummary = nullptr;
    DTK_WIDGET_NAMESPACE::DSuggestButton *m_pBtnInstall = nullptr;
    DTK_WIDGET_NAMESPACE::DPushButton *m_pBtnUninstall = nullptr;
    DTK_WIDGET_NAMESPACE::DPushButton *m_pBtnStop = nullptr;

    QString m_appName;
    bool m_isInstall = false;

    double m_lastProgress = 0.0;
    QString m_installPath;
    QString m_baseUrl;
    QStringList m_modelFileList;
    QSharedPointer<Downloader> m_downloader;
};
}

#endif // YOURONGMODELITEM_H
