#ifndef CTAI_HISTORY_WIDGET_H
#define CTAI_HISTORY_WIDGET_H

#include <QTableWidget>
#include <QScrollBar>
#include <QHeaderView>

#include <map>
#include "ctai_history_textedit.h"
class ctai_history_widget : public QTableWidget
{
    Q_OBJECT
public:
    ctai_history_widget(QWidget *parent = nullptr);
    ~ctai_history_widget();

    void add_message(const model_data &message);
    ctai_history_textedit *current_message() const;
private:
    std::map<QString, std::pair<model_data*, int>> message_map_; // int存储行号
    QString last_send_id_;
    
    void setup_table();
    void update_stored_data(model_data* stored_data, const model_data& message);
private slots:
    void on_msg_remove(QString send_id);
    void on_rows_height_changed(); // 新增槽函数处理高度变化
    void on_current_rows_height_changed();
};
#endif