3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
9 #include "emptytable.h"
12 * A simple widget for a quick "preview" in TabularCreateDialog
15 const unsigned int cellsize = 20;
17 EmptyTable::EmptyTable(QWidget * parent, const char * name)
18 : QTableView(parent,name)
22 setCellWidth(cellsize);
23 setCellHeight(cellsize);
24 setTableFlags(Tbl_autoScrollBars);
27 QSize EmptyTable::sizeHint() const
29 return QSize(cellsize * numCols(), cellsize * numRows());
33 void EmptyTable::paintCell(QPainter *p, int row, int col)
35 int const x2 = cellWidth(col) - 1;
36 int const y2 = cellHeight(row) - 1;
38 p->fillRect(0, 0, x2, y2, QColor("white"));
39 p->drawLine(x2, 0, x2, y2);
40 p->drawLine(0, y2, x2, y2);
43 void EmptyTable::setNumberColumns(int nr_cols)
47 if (nr_cols == numCols())
54 emit colsChanged(nr_cols);
57 void EmptyTable::setNumberRows(int nr_rows)
61 if (nr_rows == numRows())
68 emit rowsChanged(nr_rows);
71 void EmptyTable::mouseMoveEvent(QMouseEvent *ev)
73 int const x = ev->pos().x();
74 int const y = ev->pos().y();
77 setNumberColumns(x / cellsize + leftCell());
80 setNumberRows(y / cellsize + topCell());