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.
13 #include "emptytable.h"
17 * A simple widget for a quick "preview" in TabularCreateDialog
20 unsigned int const cellsize = 20;
23 EmptyTable::EmptyTable(QWidget * parent, const char * name)
24 : QtTableView(parent, name, WRepaintNoErase)
28 setCellWidth(cellsize);
29 setCellHeight(cellsize);
30 setTableFlags(Tbl_autoScrollBars);
34 QSize EmptyTable::sizeHint() const
36 return QSize(cellsize * numCols(), cellsize * numRows());
40 void EmptyTable::paintCell(QPainter * p, int row, int col)
42 int const x2 = cellWidth(col) - 1;
43 int const y2 = cellHeight(row) - 1;
45 p->fillRect(0, 0, x2, y2, QColor("white"));
46 p->drawLine(x2, 0, x2, y2);
47 p->drawLine(0, y2, x2, y2);
49 if (row + 1 != numRows() || col + 1 != numCols())
53 int const step = cellsize / 5;
55 int x = cellsize - step;
56 int const y = cellsize - space;
57 int const ex = cellsize - space;
58 int ey = cellsize - step;
60 p->drawLine(x, y, ex, ey);
67 void EmptyTable::setNumberColumns(int nr_cols)
71 if (nr_cols == numCols())
78 emit colsChanged(nr_cols);
82 void EmptyTable::setNumberRows(int nr_rows)
86 if (nr_rows == numRows())
93 emit rowsChanged(nr_rows);
97 void EmptyTable::mouseMoveEvent(QMouseEvent *ev)
99 int const x = ev->pos().x();
100 int const y = ev->pos().y();
103 setNumberColumns(x / cellsize + leftCell());
106 setNumberRows(y / cellsize + topCell());