4 * John Levon, moz@compsoc.man.ac.uk
7 /***************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 ***************************************************************************/
16 #include "emptytable.h"
19 * A simple widget for a quick "preview" in TabularCreateDialog
22 const unsigned int cellsize = 20;
24 EmptyTable::EmptyTable(QWidget * parent, const char * name)
25 : QTableView(parent,name)
29 setCellWidth(cellsize);
30 setCellHeight(cellsize);
31 setTableFlags(Tbl_autoScrollBars);
34 void EmptyTable::paintCell(QPainter *p, int row, int col)
36 int x2 = cellWidth(col) - 1;
37 int y2 = cellHeight(row) - 1;
39 p->fillRect(0, 0, x2, y2, QColor("white"));
40 p->drawLine(x2, 0, x2, y2);
41 p->drawLine(0, y2, x2, y2);
44 void EmptyTable::setNumberColumns(int nr_cols)
48 if (nr_cols == numCols())
54 emit colsChanged(nr_cols);
57 void EmptyTable::setNumberRows(int nr_rows)
61 if (nr_rows == numRows())
67 emit rowsChanged(nr_rows);
70 void EmptyTable::mouseMoveEvent(QMouseEvent *ev)
72 int x = ev->pos().x();
73 int y = ev->pos().y();
76 setNumberColumns(x / cellsize + leftCell());
79 setNumberRows(y / cellsize + topCell());