3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
14 #include "emptytable.h"
18 * A simple widget for a quick "preview" in TabularCreateDialog
21 unsigned int const cellsize = 20;
24 EmptyTable::EmptyTable(QWidget * parent, const char * name)
25 : QtTableView(parent, name, WRepaintNoErase)
29 setCellWidth(cellsize);
30 setCellHeight(cellsize);
31 setTableFlags(Tbl_autoScrollBars);
35 QSize EmptyTable::sizeHint() const
37 return QSize(cellsize * numCols(), cellsize * numRows());
41 void EmptyTable::paintCell(QPainter * p, int row, int col)
43 int const x2 = cellWidth(col) - 1;
44 int const y2 = cellHeight(row) - 1;
46 p->fillRect(0, 0, x2, y2, QColor("white"));
47 p->drawLine(x2, 0, x2, y2);
48 p->drawLine(0, y2, x2, y2);
50 if (row + 1 != numRows() || col + 1 != numCols())
54 int const step = cellsize / 5;
56 int x = cellsize - step;
57 int const y = cellsize - space;
58 int const ex = cellsize - space;
59 int ey = cellsize - step;
61 p->drawLine(x, y, ex, ey);
68 void EmptyTable::setNumberColumns(int nr_cols)
72 if (nr_cols == numCols())
79 emit colsChanged(nr_cols);
83 void EmptyTable::setNumberRows(int nr_rows)
87 if (nr_rows == numRows())
94 emit rowsChanged(nr_rows);
98 void EmptyTable::mouseMoveEvent(QMouseEvent *ev)
100 int const x = ev->pos().x();
101 int const y = ev->pos().y();
104 setNumberColumns(x / cellsize + leftCell());
107 setNumberRows(y / cellsize + topCell());