5 #include "scoretable.h"
6 #include "matchdaymodel.h"
8 ScoreTable::ScoreTable(QWidget *parent) :
11 this->setAttribute(Qt::WA_TranslucentBackground);
12 this->setModel(new MatchDayModel(this));
13 this->setSelectionMode(QAbstractItemView::NoSelection);
15 this->verticalHeader()->hide();
16 this->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
17 this->verticalHeader()->setMinimumSectionSize(1);
19 this->horizontalHeader()->hide();
20 this->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
21 this->horizontalHeader()->setMinimumSectionSize(1);
23 qDebug() << "Min VertHeaderSize: " << this->verticalHeader()->minimumSectionSize();
26 this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
27 this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
29 this->viewport()->setAutoFillBackground(true);
30 this->setShowGrid(false);
33 QSize ScoreTable::sizeHint() const
37 for (int i = 0; i < horizontalHeader()->count(); i++) {
38 s.setWidth(s.width() + horizontalHeader()->sectionSize(i));
40 // add missing few pixels (from borders mabye?)
41 // TODO: find better solution!
42 s.setWidth(s.width());
43 for (int i = 0; i < verticalHeader()->count(); i++) {
44 s.setHeight(s.height() + verticalHeader()->sectionSize(i));
46 // add missing few pixels (from borders mabye?)
47 // TODO: find better solution!
48 s.setHeight(s.height() + 3);
53 void ScoreTable::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
57 // this will recalculate section sizes
58 QTableView::dataChanged(topLeft, bottomRight);
60 for (int i = 0; i < horizontalHeader()->count(); i++) {
61 s.setWidth(s.width() + horizontalHeader()->sectionSize(i));
63 // add missing few pixels (from borders mabye?)
64 // TODO: find better solution!
65 s.setWidth(s.width());
66 for (int i = 0; i < verticalHeader()->count(); i++) {
67 s.setHeight(s.height() + verticalHeader()->sectionSize(i));
69 // add missing few pixels (from borders mabye?)
70 // TODO: find better solution!
71 s.setHeight(s.height() + 3);
74 this->parentWidget()->resize(s);