25class QWellArray :
public QWidget
28 Q_PROPERTY(
int selectedColumn READ selectedColumn)
29 Q_PROPERTY(
int selectedRow READ selectedRow)
32 QWellArray(
int rows,
int cols, QWidget *parent =
nullptr);
35 int selectedColumn()
const {
return selCol; }
36 int selectedRow()
const {
return selRow; }
38 virtual void setCurrent(
int row,
int col);
39 virtual void setSelected(
int row,
int col);
41 QSize sizeHint()
const override;
43 inline int cellWidth()
const {
return cellw; }
45 inline int cellHeight()
const {
return cellh; }
47 inline int rowAt(
int y)
const {
return y / cellh; }
49 inline int columnAt(
int x)
const
52 return ncols - (x / cellw) - 1;
56 inline int rowY(
int row)
const {
return cellh * row; }
58 inline int columnX(
int column)
const
61 return cellw * (ncols - column - 1);
62 return cellw * column;
65 inline int numRows()
const {
return nrows; }
67 inline int numCols()
const {
return ncols; }
69 inline QRect cellRect()
const {
return QRect(0, 0, cellw, cellh); }
71 inline QSize gridSize()
const {
return QSize(ncols * cellw, nrows * cellh); }
73 QRect cellGeometry(
int row,
int column)
76 if (row >= 0 && row < nrows && column >= 0 && column < ncols)
77 r.setRect(columnX(column), rowY(row), cellw, cellh);
81 inline void updateCell(
int row,
int column) { update(cellGeometry(row, column)); }
84 void selected(
int row,
int col);
85 void currentChanged(
int row,
int col);
86 void colorChanged(
int index, QRgb color);
89 virtual void paintCell(QPainter *,
int row,
int col,
const QRect &);
90 virtual void paintCellContents(QPainter *,
int row,
int col,
const QRect &);
92 void mousePressEvent(QMouseEvent *) override;
93 void mouseReleaseEvent(QMouseEvent *) override;
94 void keyPressEvent(QKeyEvent *) override;
95 void focusInEvent(QFocusEvent *) override;
96 void focusOutEvent(QFocusEvent *) override;
97 void paintEvent(QPaintEvent *) override;
100 Q_DISABLE_COPY(QWellArray)