Stats: fix a bug when the table is flipped.

The hidden rows/columns where not correctly updated.
This commit is contained in:
Olivier Teulière 2013-01-07 18:37:01 +01:00
parent fcb9fa572a
commit 2fc948189f
2 changed files with 13 additions and 3 deletions

View file

@ -52,7 +52,7 @@ const QColor StatsWidget::InvalidBrush(255, 0, 0);
/** /**
* Flipped version of a model (using the decorator pattern) * Flipped version of a model (using the decorator pattern)
* This implementation does not super tree-models. * This implementation does not support tree-models.
*/ */
class FlippedModel : public QAbstractItemModel class FlippedModel : public QAbstractItemModel
{ {
@ -307,7 +307,10 @@ QModelIndex StatsWidget::getIndex(int row, int col) const
void StatsWidget::setSectionHidden(int index, bool iHide) void StatsWidget::setSectionHidden(int index, bool iHide)
{ {
m_table->setRowHidden(index, iHide); if (isFlipped())
m_table->setColumnHidden(index, iHide);
else
m_table->setRowHidden(index, iHide);
} }
@ -455,9 +458,15 @@ void StatsWidget::lockSizesChanged(bool checked)
} }
bool StatsWidget::isFlipped() const
{
return m_table->model() != m_model;
}
void StatsWidget::flipTable() void StatsWidget::flipTable()
{ {
bool flipped = m_table->model() != m_model; bool flipped = isFlipped();
m_table->setSortingEnabled(!flipped); m_table->setSortingEnabled(!flipped);
if (flipped) if (flipped)
m_table->setModel(m_model); m_table->setModel(m_model);

View file

@ -77,6 +77,7 @@ private:
QModelIndex getIndex(int row, int col) const; QModelIndex getIndex(int row, int col) const;
QString getTooltip(const TurnData &iTurn, const TurnData &iGameTurn) const; QString getTooltip(const TurnData &iTurn, const TurnData &iGameTurn) const;
bool isFlipped() const;
void setSectionHidden(int index, bool iHide); void setSectionHidden(int index, bool iHide);
void setModelSize(int rowCount, int colCount); void setModelSize(int rowCount, int colCount);
void setModelHeader(int index, const QString &iText, bool iPlayerNames); void setModelHeader(int index, const QString &iText, bool iPlayerNames);