5 #include "scoretable.h"
6 #include "matchdaymodel.h"
8 ScoreTable::ScoreTable(MatchDayModel* model, QWidget *parent) :
15 this->setModel(model);
18 this->setSelectionMode(QAbstractItemView::NoSelection);
19 this->setAttribute(Qt::WA_TransparentForMouseEvents);
22 palette.setColor(QPalette::Background, QColor(0, 0, 0, 200));
24 this->verticalHeader()->hide();
25 this->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
26 this->verticalHeader()->setMinimumSectionSize(1);
27 this->horizontalHeader()->hide();
28 this->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
29 this->horizontalHeader()->setMinimumSectionSize(1);
31 this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
32 this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
34 this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
35 this->setAttribute(Qt::WA_TranslucentBackground);
36 this->viewport()->setAttribute(Qt::WA_TranslucentBackground);
38 this->setShowGrid(false);
41 QSize ScoreTable::sizeHint() const
46 if (verticalHeader()->count() > 0) {
47 for (int i = 0; i < horizontalHeader()->count(); i++) {
48 s.setWidth(s.width() + horizontalHeader()->sectionSize(i));
51 for (int i = 0; i < verticalHeader()->count() && i < maxrows; i++) {
52 s.setHeight(s.height() + verticalHeader()->sectionSize(i));
54 // add missing few pixels (from borders mabye?)
55 // TODO: find better solution!
56 s.setHeight(s.height() + 2);
65 void ScoreTable::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
67 // this will recalculate section sizes
68 QTableView::dataChanged(topLeft, bottomRight);