5 #include "scoretable.h"
6 #include "matchdaymodel.h"
8 ScoreTable::ScoreTable(MatchDayModel* model, QWidget *parent) :
15 this->setModel(model);
18 this->setAttribute(Qt::WA_TransparentForMouseEvents);
19 this->setSelectionMode(QAbstractItemView::NoSelection);
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
45 for (int i = 0; i < horizontalHeader()->count(); i++) {
46 s.setWidth(s.width() + horizontalHeader()->sectionSize(i));
48 // add missing few pixels (from borders mabye?)
49 // TODO: find better solution!
50 s.setWidth(s.width());
51 for (int i = 0; i < verticalHeader()->count(); 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);
61 void ScoreTable::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
63 // this will recalculate section sizes
64 QTableView::dataChanged(topLeft, bottomRight);
66 this->updateGeometry();