@@ -220,27 +220,26 @@ void CharacterWidget::paintEvent( QPaintEvent *event )
220
220
QPainter painter ( this );
221
221
painter.setFont ( mDisplayFont );
222
222
223
+ QFontMetrics fontMetrics ( mDisplayFont );
224
+
223
225
QRect redrawRect = event->rect ();
224
226
int beginRow = redrawRect.top () / mSquareSize ;
225
227
int endRow = redrawRect.bottom () / mSquareSize ;
226
228
int beginColumn = redrawRect.left () / mSquareSize ;
227
229
int endColumn = std::min ( mColumns - 1 , redrawRect.right () / mSquareSize );
228
230
229
231
QPalette palette = qApp->palette ();
230
- QRectF backgroundRect = event->rect ();
231
- backgroundRect.setWidth ( std::min ( backgroundRect.width (), ( endColumn + 1 ) * mSquareSize - backgroundRect.left () ) );
232
- painter.fillRect ( backgroundRect, QBrush ( palette.color ( QPalette::Base ) ) );
233
-
234
232
painter.setPen ( QPen ( palette.color ( QPalette::Mid ) ) );
235
233
for ( int row = beginRow; row <= endRow; ++row )
236
234
{
237
235
for ( int column = beginColumn; column <= endColumn; ++column )
238
236
{
237
+ int key = row * mColumns + column;
238
+ painter.setBrush ( fontMetrics.inFont ( QChar ( key ) ) ? QBrush ( palette.color ( QPalette::Base ) ) : Qt::NoBrush );
239
239
painter.drawRect ( column * mSquareSize , row * mSquareSize , mSquareSize , mSquareSize );
240
240
}
241
241
}
242
242
243
- QFontMetrics fontMetrics ( mDisplayFont );
244
243
for ( int row = beginRow; row <= endRow; ++row )
245
244
{
246
245
for ( int column = beginColumn; column <= endColumn; ++column )
0 commit comments