#include "scoretable.h"
#include "matchdaymodel.h"
-ScoreTable::ScoreTable(QWidget *parent, MatchDayModel* model) :
+ScoreTable::ScoreTable(MatchDayModel* model, QWidget *parent) :
QTableView(parent)
{
- this->setAttribute(Qt::WA_TranslucentBackground);
this->setAttribute(Qt::WA_TransparentForMouseEvents);
+ this->setAttribute(Qt::WA_TranslucentBackground);
this->setModel(model);
this->setSelectionMode(QAbstractItemView::NoSelection);
+ this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
this->verticalHeader()->hide();
this->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
this->verticalHeader()->setMinimumSectionSize(1);
}
// add missing few pixels (from borders mabye?)
// TODO: find better solution!
- s.setHeight(s.height() + 3);
+ s.setHeight(s.height() + 2);
return s;
}
void ScoreTable::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
- QSize s;
-
// this will recalculate section sizes
QTableView::dataChanged(topLeft, bottomRight);
- for (int i = 0; i < horizontalHeader()->count(); i++) {
- s.setWidth(s.width() + horizontalHeader()->sectionSize(i));
- }
- // add missing few pixels (from borders mabye?)
- // TODO: find better solution!
- s.setWidth(s.width());
- for (int i = 0; i < verticalHeader()->count(); i++) {
- s.setHeight(s.height() + verticalHeader()->sectionSize(i));
- }
- // add missing few pixels (from borders mabye?)
- // TODO: find better solution!
- s.setHeight(s.height() + 3);
-
- this->resize(s);
- this->parentWidget()->resize(s);
-
- qDebug() << s;
+ this->updateGeometry();
+}
- updateGeometry();
+void ScoreTable::mousePressEvent(QMouseEvent* event)
+{
+ MatchDayModel* m = (MatchDayModel*)this->model();
+ m->update();
}
-//void ScoreTable::mousePressEvent(QMouseEvent* event)
-//{
-// event->ignore();
-//}