#ifndef RENDER_LISTITEMWIDGET_H
#define RENDER_LISTITEMWIDGET_H
#include <QWidget>

class SelectedItemWidgetGroup;
//-blue
class ListItemWidget : public QWidget { //可选中的
    Q_OBJECT

public:
    explicit ListItemWidget(QWidget *inner, QWidget *parent = nullptr, SelectedItemWidgetGroup *group = nullptr);
    ~ListItemWidget() override;
    void SetMime(const char *mimeType, const char *mimeData);
    std::string GetMimeData();
    void SetSelected(bool selected);
    [[nodiscard]] bool IsSelected() const;
    std::byte m_data[8]{};

signals:
    void Clicked(ListItemWidget *item);

protected:
    QString m_MimeType{};
    std::string m_mimeData{}; //这个buffer就放path的utf8
    void mousePressEvent(QMouseEvent *e) override;
    void mouseMoveEvent(QMouseEvent *e) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    virtual void TryStartDrag();

private:
    friend class SelectedItemWidgetGroup;
    void SetSelectedFromGroup_(bool selected);
    SelectedItemWidgetGroup *const m_group{};
    QWidget *m_inner{};
    bool m_selected{};
    bool m_prepareClick{};
    QPoint m_pressPos;

};


//-blue
class DragItemWidget : public ListItemWidget { //可拖拽的
    Q_OBJECT

public:
    explicit DragItemWidget(QWidget *inner, QWidget *parent = nullptr,
                            SelectedItemWidgetGroup *group = nullptr);

signals:
    void StartDrag(DragItemWidget *item);

protected:
    void TryStartDrag() override;

private:
    bool m_dragging{};
};















#endif //RENDER_LISTITEMWIDGET_H
