File indexing completed on 2024-04-21 04:02:34
0001 /* 0002 This file is part of the KDE project "KLines" 0003 0004 SPDX-FileCopyrightText: 2007 Dmitry Suzdalev <dimsuz@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #include "previewitem.h" 0010 #include "renderer.h" 0011 0012 #include <QPainter> 0013 0014 PreviewItem::PreviewItem( QGraphicsScene* scene ) 0015 : QGraphicsItem( nullptr ) 0016 { 0017 Q_UNUSED( scene ); 0018 } 0019 0020 void PreviewItem::paint( QPainter* p, const QStyleOptionGraphicsItem*, QWidget* ) 0021 { 0022 int ballHeight = KLinesRenderer::cellSize(); 0023 p->drawPixmap( 0, 0, KLinesRenderer::previewPixmap() ); 0024 for(int i=0; i < 3; i++) 0025 p->drawPixmap( 2, i*ballHeight, 0026 KLinesRenderer::ballPixmap( m_colors.at(i) ) ); 0027 } 0028 0029 QRectF PreviewItem::boundingRect() const 0030 { 0031 return KLinesRenderer::previewPixmap().rect(); 0032 } 0033 0034 void PreviewItem::setPreviewColors( const QList<BallColor>& colors ) 0035 { 0036 m_colors = colors; 0037 update(); 0038 }