58 lines
1.2 KiB
C++
58 lines
1.2 KiB
C++
#ifndef CCHECKBOXMODEL_H
|
|
#define CCHECKBOXMODEL_H
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QStyledItemDelegate>
|
|
#include <QEvent>
|
|
#include <QHeaderView>
|
|
#include <QPainter>
|
|
|
|
|
|
class TableHeaderView :public QHeaderView
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
TableHeaderView(Qt::Orientation orientation, QWidget *parent);
|
|
~TableHeaderView();
|
|
|
|
protected:
|
|
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
|
|
bool event(QEvent *e) Q_DECL_OVERRIDE;
|
|
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
|
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
public slots:
|
|
void onStateChanged(int state);
|
|
|
|
signals:
|
|
void stateChanged(int state);
|
|
|
|
private:
|
|
bool m_bPressed;
|
|
bool m_bChecked;
|
|
bool m_bTristate;
|
|
bool m_bNoChange;
|
|
bool m_bMoving;
|
|
};
|
|
|
|
|
|
class CheckBoxDelegate :public QStyledItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CheckBoxDelegate(QObject *parent);
|
|
~CheckBoxDelegate();
|
|
// painting
|
|
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
|
|
|
protected:
|
|
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
|
const QStyleOptionViewItem &option, const QModelIndex &index);
|
|
};
|
|
|
|
|
|
|
|
#endif // TABLE_MODEL_H
|
|
|
|
|