#ifndef CTAI_SESSION_WIDGET_H
#define CTAI_SESSION_WIDGET_H

#include <QWidget>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QGroupBox>
#include <QPushButton>
#include <QMessageBox>
#include <QTableWidget>
#include <QObject>
#include <QLabel>
#include <QMap>
#include <QHeaderView>
#include <QString>
#include <QUuid>

#include "ctai_session_info.h"
#include "ctai_session_setting.h"
typedef struct c_session
{
   QString session_id;
   QString session_name;
   QString session_type;
   ctai_session_info* session_info;
}session;

class ctai_session_widget : public QWidget
{
    Q_OBJECT
public:
    ctai_session_widget();
    ~ctai_session_widget();
    void init_layout();
private:
    void on_session_selected(int currentRow, int currentColumn);
private:
    //主布局,左右
    QHBoxLayout *m_session_layout;
    QSplitter   *splitter;
    QWidget     *m_table_widget;
    QWidget     *m_info_widget;
    //会话按钮和列表布局
    QVBoxLayout *m_session_table_btn_layout;
    //会话按钮布局
    QHBoxLayout *m_session_btn_layout;   
    QPushButton *m_btn_new_chat;
    QPushButton *m_btn_set_chat;
    QPushButton *m_btn_del_chat;
    //会话列表布局
    QHBoxLayout *m_session_table_layout;
    QTableWidget* m_session_table;  
    //会话信息布局
    QHBoxLayout       *m_session_info_layout;
    //会话设置
    ctai_session_setting *m_session_setting;
    bool is_setting_visible; 
    // 会话管理map，key为会话ID，value为对应的会话信息对象
    std::vector<session*> m_session_map;
    QSpacerItem *sparcer_item = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
public slots:
    void on_new_chat_clicked();    // 新建会话
    void on_set_chat_clicked();    // 设置会话
    void on_del_chat_clicked();    // 删除会话
    void connect_signals();
private slots:
    void on_session_name_changed(QTableWidgetItem* item);  // 处理会话名称修改
};

#endif