#ifndef BUTTONDELEGATE_H
#define BUTTONDELEGATE_H

#include <QAbstractItemModel>
#include <QApplication>
#include <QDebug>
#include <QHBoxLayout>
#include <QModelIndex>
#include <QMouseEvent>
#include <QPainter>
#include <QPushButton>
#include <QStyleOptionButton>
#include <QStyleOptionViewItem>
#include <QStyledItemDelegate>
#include <QTableView>
#include <QWidget>

class ButtonDelegate : public QStyledItemDelegate {
    Q_OBJECT

   public:
    explicit ButtonDelegate(int buttonColumn, QObject *parent = nullptr);

    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

    bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option,
                     const QModelIndex &index) override;

    void handleButtonClick(int row, int button);

   private:
    int buttonColumn;  // 成员变量
   signals:
    void buttonClicked(int row, int button);
};

#endif  // BUTTONDELEGATE_H
