5 #include "scoretable.h"
6 #include "matchdaymodel.h"
8 ScoreTable::ScoreTable(QWidget *parent, MatchDayModel* model) :
11 this->setAttribute(Qt::WA_TranslucentBackground);
12 this->setAttribute(Qt::WA_TransparentForMouseEvents);
14 this->setModel(model);
15 this->setSelectionMode(QAbstractItemView::NoSelection);
17 this->verticalHeader()->hide();
18 this->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
19 this->verticalHeader()->setMinimumSectionSize(1);
21 this->horizontalHeader()->hide();
22 this->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
23 this->horizontalHeader()->setMinimumSectionSize(1);
25 qDebug() << "Min VertHeaderSize: " << this->verticalHeader()->minimumSectionSize();
27 this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
28 this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
30 this->viewport()->setAutoFillBackground(true);
31 this->setShowGrid(false);
34 QSize ScoreTable::sizeHint() const
38 for (int i = 0; i < horizontalHeader()->count(); i++) {
39 s.setWidth(s.width() + horizontalHeader()->sectionSize(i));
41 // add missing few pixels (from borders mabye?)
42 // TODO: find better solution!
43 s.setWidth(s.width());
44 for (int i = 0; i < verticalHeader()->count(); i++) {
45 s.setHeight(s.height() + verticalHeader()->sectionSize(i));
47 // add missing few pixels (from borders mabye?)
48 // TODO: find better solution!
49 s.setHeight(s.height() + 3);
54 void ScoreTable::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
58 // this will recalculate section sizes
59 QTableView::dataChanged(topLeft, bottomRight);
61 for (int i = 0; i < horizontalHeader()->count(); i++) {
62 s.setWidth(s.width() + horizontalHeader()->sectionSize(i));
64 // add missing few pixels (from borders mabye?)
65 // TODO: find better solution!
66 s.setWidth(s.width());
67 for (int i = 0; i < verticalHeader()->count(); i++) {
68 s.setHeight(s.height() + verticalHeader()->sectionSize(i));
70 // add missing few pixels (from borders mabye?)
71 // TODO: find better solution!
72 s.setHeight(s.height() + 3);
75 this->parentWidget()->resize(s);
82 //void ScoreTable::mousePressEvent(QMouseEvent* event)