QSize scoresWidget::calcSize() { int mw, mh, lt; QRect r; QPixmap dummyPixmap(2000, 2000); QPainter p(&dummyPixmap); QFont f; if (blinkenSettings::customFont()) f = QFont("Steve"); p.setFont(f); f.setPointSize(KFontUtils::adaptFontSize(p, "A", 1000, namesFontSize, 28, 1, KFontUtils::DoNotAllowWordWrap)); p.setFont(f); for (int i = 0; i < 3; i++) { lt = 0; QList< QPair<int, QString> >::const_iterator it; for (it = m_scores.begin(); it != m_scores.end(); ++it) { r = p.boundingRect(QRect(), Qt::AlignLeft, (*it).second); lt = qMax(lt, r.width()); } } mw = margin + counter::width(false) + 2 * smallMargin + lt + margin; mh = margin * 2 + counter::height() * 5 + smallMargin * 4; QSize size(mw, mh); setMinimumSize(size); resize(size); return size; }
Tagaro::SpriteObjectItem::Private::Private(QGraphicsItem* parent) : QGraphicsPixmapItem(dummyPixmap(), parent) , m_size(1, 1) , m_pixmapSize(1, 1) , m_board(0) { setCacheMode(QGraphicsItem::DeviceCoordinateCache); }
void Tagaro::SpriteObjectItem::receivePixmap(const QPixmap& pixmap) { QPixmap pixmapUse = pixmap.size().isEmpty() ? dummyPixmap() : pixmap; const QSizeF pixmapSize = pixmapUse.size(); if (d->m_pixmapSize != pixmapSize) { prepareGeometryChange(); d->m_pixmapSize = pixmapUse.size(); d->updateTransform(); } d->setPixmap(pixmapUse); update(); }
QIcon NewstuffModelPrivate::preview( int index ) { if ( m_items.at( index ).m_preview.isNull() ) { QPixmap dummyPixmap( 136, 136 ); dummyPixmap.fill( Qt::transparent ); setPreview( index, QIcon( dummyPixmap ) ); QNetworkReply *reply = m_networkAccessManager.get( QNetworkRequest( m_items.at( index ).m_previewUrl ) ); m_networkJobs.insert( reply, new FetchPreviewJob( this, index ) ); } Q_ASSERT( !m_items.at( index ).m_preview.isNull() ); return m_items.at( index ).m_preview; }