From 649b31e1222f551021739f71a5cc468f7df80e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Meril=C3=A4?= Date: Tue, 5 May 2009 15:12:58 +0300 Subject: S60Style: intersect QTable background graphics with viewPort rect. --- src/gui/styles/qs60style.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index fb76b09..87353f9 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1225,18 +1225,16 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast(option); const QTableView *table = qobject_cast(widget); if (table && tableOption) { - const QModelIndex indexCurrent = tableOption->index; - // Draw cell background only once - for the first cell - //todo: calc area based on viewport only so that 1000x1000 table doesn't get ridiculously big background - //todo: try to do this only once. For some reason, if I try to - //if ( indexCurrent.column() == 2 && indexCurrent.row() == 2 ) { - QStyleOptionViewItemV4 voptAdj2 = voptAdj2; - const QModelIndex index = table->model()->index(0,0); - const QModelIndex indexLast = table->model()->index( - table->model()->rowCount()-1,table->model()->columnCount()-1); - voptAdj2.rect = QRect( table->visualRect(index).topLeft(), table->visualRect(indexLast).bottomRight()); - drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget); - //} + const QModelIndex index = tableOption->index; + //todo: Draw cell background only once - for the first cell. + QStyleOptionViewItemV4 voptAdj2 = voptAdj2; + const QModelIndex indexFirst = table->model()->index(0,0); + const QModelIndex indexLast = table->model()->index( + table->model()->rowCount()-1,table->model()->columnCount()-1); + if (table->viewport()) + voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(), + table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect()); + drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget); } // draw the focus rect -- cgit v0.12