#ifndef AISUBSYSTEM_H
#define AISUBSYSTEM_H

#include <QObject>
#include <QVBoxLayout>
#include <QFrame>
#include <QListWidget>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QTranslator>

#include <aisubsystemplugininterface.h>

#include "modelwidget.h"
#include "modelcallpriority.h"
#include "cloudmodelconfigwidget.h"
#include "localmodelconfigwidget.h"
#include "privatemodelconfigwidget.h"
#include "appversionerrorwarningwidget.h"

class TestAiSubSystem : public QObject, KylinAiSubSystemPluginInterface
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.kylinaisubsystem.PluginInterface")
    Q_INTERFACES(KylinAiSubSystemPluginInterface)

public:
    explicit TestAiSubSystem(QObject *parent = nullptr);
    //通过这个接口返回模型配置UI
    QWidget* createModelConfigWidget();
    QWidget* createComputePowerSharingWidget();
    static CloudModelConfigWidget* getCloudModelConfigPage();
    static LocalModelConfigWidget* getLocalModelConfigPage();
    static PrivateModelConfigWidget* getPrivateModelConfigPage();

private:
    void initConnect();
    void updateModelLayout();
    void updateModelPriority(const QMap<DeployType, int> &priorityMap);
    QMap<DeployType, int> getCurrentProrityMap();
    DeployType getDeployTypeByFrame(QFrame *frame);
    void showErrorMessage(const QString &message, QWidget *parent); // 报错弹窗
    bool hasLocalModel(); // 判断是否需要隐藏本地模型

private:
    QTranslator *m_translator = nullptr;

    QLabel *m_modelConfigLabel = nullptr;

    QWidget *m_msgWidget;
    AppVersionErrorWarningWidget *m_appTipsWidget = nullptr;

    ModelWidget *m_publicCloudModel = nullptr;
    ModelWidget *m_ondeviceModel = nullptr;
    ModelWidget *m_privateModel = nullptr;

    QFrame *m_tipsFrame = nullptr;
    QFrame *m_publicCloudFrame = nullptr;
    QFrame *m_ondeviceFrame = nullptr;
    QFrame *m_privateFrame = nullptr;


    QWidget *m_modelWidget = nullptr;
    QVBoxLayout *m_modelVLayout = nullptr;

    QWidget *m_mainWidget = nullptr;
    QVBoxLayout *m_mainVLayout = nullptr;

    QMap<DeployType, int> m_priorityMap;

};

#endif // AISUBSYSTEM_H
