From 2fc948189f3fbfa44893b5d7716191a6c81263ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Mon, 7 Jan 2013 18:37:01 +0100 Subject: [PATCH] Stats: fix a bug when the table is flipped. The hidden rows/columns where not correctly updated. --- qt/stats_widget.cpp | 15 ++++++++++++--- qt/stats_widget.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qt/stats_widget.cpp b/qt/stats_widget.cpp index e3ba2be..c645e08 100644 --- a/qt/stats_widget.cpp +++ b/qt/stats_widget.cpp @@ -52,7 +52,7 @@ const QColor StatsWidget::InvalidBrush(255, 0, 0); /** * 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 { @@ -307,7 +307,10 @@ QModelIndex StatsWidget::getIndex(int row, int col) const 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() { - bool flipped = m_table->model() != m_model; + bool flipped = isFlipped(); m_table->setSortingEnabled(!flipped); if (flipped) m_table->setModel(m_model); diff --git a/qt/stats_widget.h b/qt/stats_widget.h index a8cc6ea..57a1a56 100644 --- a/qt/stats_widget.h +++ b/qt/stats_widget.h @@ -77,6 +77,7 @@ private: QModelIndex getIndex(int row, int col) const; QString getTooltip(const TurnData &iTurn, const TurnData &iGameTurn) const; + bool isFlipped() const; void setSectionHidden(int index, bool iHide); void setModelSize(int rowCount, int colCount); void setModelHeader(int index, const QString &iText, bool iPlayerNames);