size_t Heap::sizeAfterCollect() { // The result here may not agree with the normal Heap::size(). // This is due to the fact that we only count live copied bytes // rather than all used (including dead) copied bytes, thus it's // always the case that m_totalBytesCopied <= m_storageSpace.size(). ASSERT(m_totalBytesCopied <= m_storageSpace.size()); return m_totalBytesVisited + m_totalBytesCopied + extraSize(); }
//---------------------------------------------------------------------------- QSize ctkDoubleSpinBox::sizeHint() const { Q_D(const ctkDoubleSpinBox); if (d->SizeHintPolicy == ctkDoubleSpinBox::SizeHintByMinMax) { return this->Superclass::sizeHint(); } if (!d->CachedSizeHint.isEmpty()) { return d->CachedSizeHint; } QSize newSizeHint; newSizeHint.setHeight(this->lineEdit()->sizeHint().height()); QString extraString = " "; // give some room QString s = this->text() + extraString; s.truncate(18); int extraWidth = 2; // cursor width this->ensurePolished(); // ensure we are using the right font const QFontMetrics fm(this->fontMetrics()); newSizeHint.setWidth(fm.width(s + extraString) + extraWidth); QStyleOptionSpinBox opt; d->SpinBox->initStyleOptionSpinBox(&opt); QSize extraSize(35, 6); opt.rect.setSize(newSizeHint + extraSize); extraSize += newSizeHint - this->style()->subControlRect( QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size(); // Converging size hint... opt.rect.setSize(newSizeHint + extraSize); extraSize += newSizeHint - this->style()->subControlRect( QStyle::CC_SpinBox, &opt, QStyle::SC_SpinBoxEditField, this).size(); newSizeHint += extraSize; opt.rect = this->rect(); d->CachedSizeHint = this->style()->sizeFromContents( QStyle::CT_SpinBox, &opt, newSizeHint, this) .expandedTo(QApplication::globalStrut()); return d->CachedSizeHint; }
MemoryUnit::MemoryUnit(QGraphicsItem *parent /*= 0*/) : QGraphicsItem(parent) { // setFlag(QGraphicsItem::ItemHasNoContents); rand = qrand()%2; m_scene = dynamic_cast<MemoryScene*>(scene()); if(!m_scene) qDebug() << "Not MemoryScene*"; setUnitSelected(false); setAcceptsHoverEvents(true); setZValue(1); m_borderPen=QPen(QBrush(QColor(rand?Qt::red:Qt::blue)/*.lighter()*/), extraSize()*2 ,Qt::SolidLine,Qt::SquareCap,Qt::MiterJoin); }
QRectF MemoryUnit::boundingRect() const { return m_shapeBorder.boundingRect().adjusted(-extraSize(),-extraSize(),extraSize(),extraSize()); }
size_t Heap::capacity() { return m_objectSpace.capacity() + m_storageSpace.capacity() + extraSize(); }
size_t Heap::size() { return m_objectSpace.size() + m_storageSpace.size() + extraSize(); }