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)
27 setBackgroundMode(NoBackground);
30 setCellWidth(cellsize);
31 setCellHeight(cellsize);
32 setTableFlags(Tbl_autoScrollBars);
35 void EmptyTable::paintCell(QPainter *p, int row, int col)
37 int x2 = cellWidth(col) - 1;
38 int y2 = cellHeight(row) - 1;
40 p->fillRect(0, 0, x2, y2, QColor("white"));
41 p->drawLine(x2, 0, x2, y2);
42 p->drawLine(0, y2, x2, y2);
45 void EmptyTable::setNumberColumns(int nr_cols)
49 if (nr_cols == numCols())
55 emit colsChanged(nr_cols);
58 void EmptyTable::setNumberRows(int nr_rows)
62 if (nr_rows == numRows())
68 emit rowsChanged(nr_rows);
71 void EmptyTable::mouseMoveEvent(QMouseEvent *ev)
73 int x = ev->pos().x();
74 int y = ev->pos().y();
77 setNumberColumns(x / cellsize + leftCell());
80 setNumberRows(y / cellsize + topCell());