26class QWellArray :
public QWidget
29 Q_PROPERTY(
int selectedColumn READ selectedColumn)
30 Q_PROPERTY(
int selectedRow READ selectedRow)
33 QWellArray(
int rows,
int cols, QWidget *parent =
nullptr);
36 int currentColumn()
const {
return curCol; }
37 int currentRow()
const {
return curRow; }
39 int selectedColumn()
const {
return selCol; }
40 int selectedRow()
const {
return selRow; }
42 virtual void setCurrent(
int row,
int col);
43 virtual void setSelected(
int row,
int col);
45 QSize sizeHint()
const override;
47 inline int cellWidth()
const {
return cellw; }
49 inline int cellHeight()
const {
return cellh; }
51 inline int rowAt(
int y)
const {
return y / cellh; }
53 inline int columnAt(
int x)
const
56 return ncols - (x / cellw) - 1;
60 inline int rowY(
int row)
const {
return cellh * row; }
62 inline int columnX(
int column)
const
65 return cellw * (ncols - column - 1);
66 return cellw * column;
69 inline int numRows()
const {
return nrows; }
71 inline int numCols()
const {
return ncols; }
73 inline int index(
int row,
int col) {
return col * nrows + row; }
75 inline QRect cellRect()
const {
return QRect(0, 0, cellw, cellh); }
77 inline QSize gridSize()
const {
return QSize(ncols * cellw, nrows * cellh); }
79 QRect cellGeometry(
int row,
int column)
82 if (row >= 0 && row < nrows && column >= 0 && column < ncols)
83 r.setRect(columnX(column), rowY(row), cellw, cellh);
87 inline void updateCell(
int row,
int column) { update(cellGeometry(row, column)); }
90 void selected(
int row,
int col);
91 void currentChanged(
int row,
int col);
92 void colorChanged(
int index, QRgb color);
95 virtual void paintCell(QPainter *,
int row,
int col,
const QRect &);
96 virtual void paintCellContents(QPainter *,
int row,
int col,
const QRect &);
98 void mousePressEvent(QMouseEvent *) override;
99 void mouseReleaseEvent(QMouseEvent *) override;
100 void keyPressEvent(QKeyEvent *) override;
101 void focusInEvent(QFocusEvent *) override;
102 void focusOutEvent(QFocusEvent *) override;
103 void paintEvent(QPaintEvent *) override;
105 void sendAccessibleChildFocusEvent();
108 Q_DISABLE_COPY(QWellArray)