예제 #1
0
QRectF CartesianChartLayout::calculateAxisMinimum(const QRectF &minimum, const QList<ChartAxisElement *> &axes) const
{
    QSizeF left;
    QSizeF right;
    QSizeF bottom;
    QSizeF top;

    foreach (ChartAxisElement *axis, axes) {
        QSizeF size = axis->effectiveSizeHint(Qt::MinimumSize);

        if (!axis->isVisible())
            continue;

        switch (axis->axis()->alignment()) {
        case Qt::AlignLeft:
            left.setWidth(left.width() + size.width());
            left.setHeight(qMax(left.height(), size.height()));
            break;
        case Qt::AlignRight:
            right.setWidth(right.width() + size.width());
            right.setHeight(qMax(right.height(), size.height()));
            break;
        case Qt::AlignTop:
            top.setWidth(qMax(top.width(), size.width()));
            top.setHeight(top.height() + size.height());
            break;
        case Qt::AlignBottom:
            bottom.setWidth(qMax(bottom.width(), size.width()));
            bottom.setHeight(bottom.height() + size.height());
            break;
        }
    }
예제 #2
0
QSizeF CanvasSize::size(SizeUnits unit) const
{
    QSizeF result;
    result.setWidth( toPixels(m_size.width(), m_resolution.width(), m_size_unit, m_resolution_unit) );
    result.setHeight( toPixels(m_size.height(), m_resolution.height(), m_size_unit, m_resolution_unit) );
    if (unit != Pixels)
    {
        result.setWidth( fromPixels(result.width(), m_resolution.width(), unit, m_resolution_unit) );
        result.setHeight( fromPixels(result.height(), m_resolution.height(), unit, m_resolution_unit) );
    }
    return result;
}
예제 #3
0
QSizeF EglUtils::physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize)
{
#ifndef Q_OS_LINUX
    Q_UNUSED(framebufferDevice)
#endif
    const int defaultPhysicalDpi = 100;
    static QSizeF size;

    if (size.isEmpty()) {
        // Note: in millimeters
        int width = qEnvironmentVariableIntValue("GREENISLAND_QPA_PHYSICAL_WIDTH");
        int height = qEnvironmentVariableIntValue("GREENISLAND_QPA_PHYSICAL_HEIGHT");

        if (width && height) {
            size.setWidth(width);
            size.setHeight(height);
            return size;
        }

        int w = -1;
        int h = -1;
        QSize screenResolution;
#ifdef Q_OS_LINUX
        struct fb_var_screeninfo vinfo;

        if (framebufferDevice != -1) {
            if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) {
                qCWarning(lcEglConvenience, "Could not query screen info");
            } else {
                w = vinfo.width;
                h = vinfo.height;
                screenResolution = QSize(vinfo.xres, vinfo.yres);
            }
        } else
#endif
        {
            // Use the provided screen size, when available, since some platforms may have their own
            // specific way to query it. Otherwise try querying it from the framebuffer.
            screenResolution = screenSize.isEmpty() ? screenSizeFromFb(framebufferDevice) : screenSize;
        }

        size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
        size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));

        if (w <= 0 || h <= 0)
            qCWarning(lcEglConvenience,
                      "Unable to query physical screen size, defaulting to %d dpi.\n"
                      "To override, set GREENISLAND_QPA_PHYSICAL_WIDTH "
                      "and GREENISLAND_QPA_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi);
    }

    return size;
}
예제 #4
0
    QSizeF targetSize() const {
        QSizeF size = imageData->imageSize();
        if (targetImageSizePercent.width() > 0.0)
            size.setWidth(0.01 * targetImageSizePercent.width() * size.width());
        else if (targetImageSize.width() > 0.0)
            size.setWidth(targetImageSize.width());
        if (targetImageSizePercent.height() > 0.0)
            size.setHeight(0.01 * targetImageSizePercent.height() * size.height());
        else if (targetImageSize.height() > 0.0)
            size.setHeight(targetImageSize.height());

        return size;
    }
예제 #5
0
void KWRootAreaProviderBase::doPostLayout(KoTextLayoutRootArea *rootArea, bool /*isNewRootArea*/)
{
    KoShape *shape = rootArea->associatedShape();
    if (!shape) {
        return;
    }

    KoTextShapeData *data = qobject_cast<KoTextShapeData*>(shape->userData());
    Q_ASSERT(data);

    QRectF updateRect = shape->outlineRect();

    QSizeF newSize = shape->size()
                    - QSizeF(data->leftPadding() + data->rightPadding(),
                             data->topPadding() + data->bottomPadding());

    KoBorder *border = shape->border();

    if (border) {
        newSize -= QSizeF(border->borderWidth(KoBorder::LeftBorder) + border->borderWidth(KoBorder::RightBorder), border->borderWidth(KoBorder::TopBorder) + border->borderWidth(KoBorder::BottomBorder));
    }

    if (data->resizeMethod() == KoTextShapeData::AutoGrowWidthAndHeight
        ||data->resizeMethod() == KoTextShapeData::AutoGrowHeight) {

        newSize.setHeight(rootArea->bottom() - rootArea->top());

        // adjust size to have at least the defined minimum height
        Q_ASSERT(frameSet()->shapeCount() > 0);
        KoShape *firstShape = frameSet()->shapes().first();
        if (firstShape->minimumHeight() > newSize.height())
            newSize.setHeight(firstShape->minimumHeight());
    }
    if (data->resizeMethod() == KoTextShapeData::AutoGrowWidthAndHeight
        ||data->resizeMethod() == KoTextShapeData::AutoGrowWidth) {
        newSize.setWidth(rootArea->right() - rootArea->left());
    }

    newSize += QSizeF(data->leftPadding() + data->rightPadding(),
                      data->topPadding() + data->bottomPadding());
    if (border) {
        newSize += QSizeF(border->borderWidth(KoBorder::LeftBorder) + border->borderWidth(KoBorder::RightBorder), border->borderWidth(KoBorder::TopBorder) + border->borderWidth(KoBorder::BottomBorder));
    }

    if (newSize != rootArea->associatedShape()->size()) {
        rootArea->associatedShape()->setSize(newSize);

        // transfer the new size to the copy-shapes
        foreach(KWCopyShape *cs, frameSet()->copyShapes()) {
            cs->setSize(newSize);
        }
예제 #6
0
QSizeF QEglFSHooks::physicalScreenSize() const
{
    static QSizeF size;
    if (size.isEmpty()) {

        // Note: in millimeters
        int width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt();
        int height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt();

        if (width && height) {
            // no need to read fb0
            size.setWidth(width);
            size.setHeight(height);
            return size;
        }

        struct fb_var_screeninfo vinfo;
        int w = -1;
        int h = -1;

        if (framebuffer != -1) {
            if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1) {
                qWarning("EGLFS: Could not query variable screen info.");
            } else {
                w = vinfo.width;
                h = vinfo.height;
            }
        }

        const int defaultPhysicalDpi = 100;
        size.setWidth(w <= 0 ? vinfo.xres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
        size.setHeight(h <= 0 ? vinfo.yres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));

        if (w <= 0 || h <= 0) {
            qWarning("EGLFS: Unable to query physical screen size, defaulting to %d dpi.\n"
                     "EGLFS: To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH "
                     "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).",
                     defaultPhysicalDpi);
        }

        // override fb0 from environment var setting
        if (width)
            size.setWidth(width);
        if (height)
            size.setWidth(height);
    }
    return size;
}
예제 #7
0
파일: KPathShape.cpp 프로젝트: KDE/koffice
void KPathShapePrivate::applyViewboxTransformation(const KXmlElement &element)
{
    Q_Q(KPathShape);
    // apply viewbox transformation
    QRectF viewBox = q->loadOdfViewbox(element);
    if (! viewBox.isEmpty()) {
        // load the desired size
        QSizeF size;
        size.setWidth(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "width", QString())));
        size.setHeight(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "height", QString())));

        // load the desired position
        QPointF pos;
        pos.setX(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "x", QString())));
        pos.setY(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "y", QString())));

        // create matrix to transform original path data into desired size and position
        QTransform viewMatrix;
        viewMatrix.translate(-viewBox.left(), -viewBox.top());
        viewMatrix.scale(size.width() / viewBox.width(), size.height() / viewBox.height());
        viewMatrix.translate(pos.x(), pos.y());

        // transform the path data
        map(viewMatrix);
    }
}
예제 #8
0
/**
 * @brief cwRegionLoadTask::loadSizeF
 * @param protoSize
 * @return
 */
QSizeF cwRegionLoadTask::loadSizeF(const QtProto::QSizeF &protoSize)
{
    QSizeF size;
    size.setWidth(protoSize.width());
    size.setHeight(protoSize.height());
    return size;
}
QSizeF UIGraphicsScrollArea::minimumSizeHint() const
{
    /* Minimum size-hint of scroll-bar by default: */
    QSizeF msh = m_pScrollBar->minimumSizeHint();
    if (m_pViewport)
    {
        switch (m_enmOrientation)
        {
            case Qt::Horizontal:
            {
                /* Expand it with viewport height: */
                const int iWidgetHeight = m_pViewport->size().height();
                if (msh.height() < iWidgetHeight)
                    msh.setHeight(iWidgetHeight);
                break;
            }
            case Qt::Vertical:
            {
                /* Expand it with viewport width: */
                const int iWidgetWidth = m_pViewport->size().width();
                if (msh.width() < iWidgetWidth)
                    msh.setWidth(iWidgetWidth);
                break;
            }
        }
    }
    return msh;
}
예제 #10
0
static void expandSize(QSizeF &result, const QSizeF &size)
{
    if (size.width() >= 0 && size.width() > result.width())
        result.setWidth(size.width());
    if (size.height() >= 0 && size.height() > result.height())
        result.setHeight(size.height());
}
예제 #11
0
bool AbstractScrollArea::event(QEvent *e)
{
    if (e->type() == QEvent::ApplicationLayoutDirectionChange
       || e->type() == QEvent::LayoutDirectionChange) {
    } else if (e->type() == QEvent::GraphicsSceneResize) {        
        QGraphicsSceneResizeEvent *event = 
            static_cast<QGraphicsSceneResizeEvent*>(e);

        QSizeF newSize = event->newSize();
        QRectF hrect = m_horizontalScrollBar->boundingRect();
        QRectF vrect = m_verticalScrollBar->boundingRect();

        QSizeF vpSize = newSize;

        if (m_horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff)
            vpSize.setHeight(newSize.height() - hrect.height());
        if (m_verticalScrollBarPolicy != Qt::ScrollBarAlwaysOff)
            vpSize.setWidth(newSize.width() - vrect.width());

        m_viewport->resize(vpSize);

        adjustScrollBars();
    }

    return QGraphicsWidget::event(e);
}
예제 #12
0
void BSplineVisDialog::on_printButton_clicked() {
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save PDF File"), "/tmpfs", tr("PDF File (*.pdf)"));
    
    if (fileName.isNull()) {
        return;
    }

    QGraphicsScene printerScene;
    renderScene(printerScene, true);
    
    QPrinter printer(QPrinter::HighResolution);
    QSizeF paperSize;
    paperSize.setWidth(printerScene.sceneRect().width());
    paperSize.setHeight(printerScene.sceneRect().height());
    printer.setPaperSize(paperSize, QPrinter::Millimeter);
    printer.setPageMargins(5, 5, 5, 5, QPrinter::Millimeter);
    printer.setOrientation(QPrinter::Portrait);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName(fileName);


    QPainter painter(&printer);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::NonCosmeticDefaultPen);
    printerScene.render(&painter);
    painter.end();
}
예제 #13
0
// --------------------------------------------------------------------------------------------------------------------------------------
QVariant CSizeGrip::itemChange(GraphicsItemChange change, const QVariant &value)
{
    switch(change)
    {
    case QGraphicsItem::ItemPositionChange:
        {
            QPointF nextPos =  value.toPointF();
            QPointF targetPos = pos() - nextPos;
            QSizeF resultSize = gWindow()->size() - QSizeF(targetPos.x(), targetPos.y());

            if(resultSize.width() < gWindow()->minSize().width())
            {
                resultSize.setWidth(gWindow()->minSize().width());
                nextPos.setX(pos().x());
            }
            if(resultSize.height() < gWindow()->minSize().height())
            {
                resultSize.setHeight(gWindow()->minSize().height());
                nextPos.setY(pos().y());
            }
            gWindow()->setSize(resultSize);
            return nextPos;
        }
        break;
    default: return QGraphicsItem::itemChange(change, value);
    }
    return QGraphicsItem::itemChange(change, value);
}
예제 #14
0
파일: xml.cpp 프로젝트: gthomas/MuseScore
QSizeF readSize(QDomElement e)
      {
      QSizeF p;
      p.setWidth(e.attribute("w", "0.0").toDouble());
      p.setHeight(e.attribute("h", "0.0").toDouble());
      return p;
      }
static void combineSize(QSizeF &result, const QSizeF &size)
{
    if (result.width() < 0)
        result.setWidth(size.width());
    if (result.height() < 0)
        result.setHeight(size.height());
}
예제 #16
0
void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged)
{
    Q_Q(QDeclarativeLoader);
    if (!item || updatingSize)
        return;

    updatingSize = true;
    if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) {
        if (!itemWidthValid)
            q->setImplicitWidth(qmlItem->implicitWidth());
        else
            q->setImplicitWidth(qmlItem->width());
        if (loaderGeometryChanged && q->widthValid())
            qmlItem->setWidth(q->width());
        if (!itemHeightValid)
            q->setImplicitHeight(qmlItem->implicitHeight());
        else
            q->setImplicitHeight(qmlItem->height());
        if (loaderGeometryChanged && q->heightValid())
            qmlItem->setHeight(q->height());
    } else if (item && item->isWidget()) {
        QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
        QSizeF widgetSize = widget->size();
        q->setImplicitWidth(widgetSize.width());
        if (loaderGeometryChanged && q->widthValid())
            widgetSize.setWidth(q->width());
        q->setImplicitHeight(widgetSize.height());
        if (loaderGeometryChanged && q->heightValid())
            widgetSize.setHeight(q->height());
        if (widget->size() != widgetSize)
            widget->resize(widgetSize);
    }
    updatingSize = false;
}
QVariant XmlQSizeFSerializator::loadValue()
{
    QSizeF size;
    size.setWidth(node()->attribute("width").toDouble());
    size.setHeight(node()->attribute("height").toDouble());
    return size;
}
예제 #18
0
NS_IMETHODIMP
nsPrintSettingsQt::SetPaperHeight(double aPaperHeight)
{
    QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
    papersize.setHeight(aPaperHeight);
    mQPrinter->setPaperSize(papersize, GetQtUnit(mPaperSizeUnit));
    return NS_OK;
}
예제 #19
0
void PlotExporter::guessPlotDimensions(const QwtPlot *plot, const double currentWidth, QSizeF &dimensions)
{
  const QRect &plotDims = plot->geometry();
  const qreal plotRatio = static_cast<qreal>(plotDims.width()) / static_cast<qreal>(plotDims.height());

  dimensions.setWidth(currentWidth);
  dimensions.setHeight(currentWidth / plotRatio);
}
예제 #20
0
    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
    {
        QSizeF hint = QGraphicsWidget::sizeHint(which, constraint);

        if (which == Qt::PreferredSize) {
            qreal left, top, right, bottom;
            m_itemBackground->getContentsMargins(&left, &top, &right, &bottom);

            if (m_location == Plasma::TopEdge) {
                hint.setHeight(KIconLoader::SizeSmallMedium + m_background->marginSize(Plasma::BottomMargin) + top + bottom);
            } else if (m_location == Plasma::BottomEdge) {
                hint.setHeight(KIconLoader::SizeSmallMedium + m_background->marginSize(Plasma::TopMargin) + top + bottom);
            }
        }

        return hint;
    }
예제 #21
0
파일: caret.cpp 프로젝트: Narsil/QWave
QSizeF CaretInterface::textSize(const QString& text)
{
    QFontMetrics metrics(m_font);
    QSizeF s = metrics.size(Qt::TextSingleLine, text);
    s.setWidth( s.width() + 4 );
    s.setHeight( s.height() + 2 );
    return s;
}
예제 #22
0
void PrintLayout::printTable() const
{
	QTextDocument doc;
	QSizeF pageSize;
	pageSize.setWidth(pageRect.width());
	pageSize.setHeight(pageRect.height());
	doc.setPageSize(pageSize);

	QString styleSheet(
		"<style type='text/css'>" \
		"table {" \
		"	border-width: 1px;" \
		"	border-style: solid;" \
		"	border-color: #999999;" \
		"}" \
		"th {" \
		"	background-color: #eeeeee;" \
		"	font-size: small;" \
		"	padding: 3px 5px 3px 5px;" \
		"}" \
		"td {" \
		"	font-size: small;" \
		"	padding: 3px 5px 3px 5px;" \
		"}" \
		"</style>"
	);
	// setDefaultStyleSheet() doesn't work here?
	QString htmlText = styleSheet + "<table cellspacing='0' width='100%'>";
	QString htmlTextPrev;
	int pageCountNew = 1, pageCount;
	bool insertHeading = true;

	int i;
	struct dive *dive;
	for_each_dive(i, dive) {
		if (!dive->selected && printOptions->print_selected)
			continue;
		if (insertHeading) {
			htmlText += insertTableHeadingRow();
			insertHeading = false;
		}
		htmlTextPrev = htmlText;
		htmlText += insertTableDataRow(dive);
		doc.setHtml(htmlText);
		pageCount = pageCountNew;
		pageCountNew = doc.pageCount();
		/* if the page count increases after adding this row we 'revert'
		 * and add a heading instead. */
		if (pageCountNew > pageCount) {
			htmlText = htmlTextPrev;
			insertHeading = true;
			i--;
		}
	}
	htmlText += "</table>";
	doc.setHtml(htmlText);
	doc.print(printer);
}
예제 #23
0
void LabelGraphicsItem::setContentSize( const QSizeF &contentSize )
{
    QSizeF updatedSize = contentSize;
    if ( updatedSize.isEmpty() ) {
        updatedSize.setHeight( 0 );
        updatedSize.setWidth( 0 );
    }
    else {
        if ( d->m_minimumSize.width() > updatedSize.width() ) {
            updatedSize.setWidth( d->m_minimumSize.width() );
        }
        if ( d->m_minimumSize.height() > updatedSize.height() ) {
            updatedSize.setHeight( d->m_minimumSize.height() );
        }
    }

    FrameGraphicsItem::setContentSize( updatedSize );
}
예제 #24
0
파일: xml.cpp 프로젝트: Angeldude/MuseScore
QSizeF XmlReader::readSize()
      {
      Q_ASSERT(tokenType() == QXmlStreamReader::StartElement);
      QSizeF p;
      p.setWidth(doubleAttribute("w", 0.0));
      p.setHeight(doubleAttribute("h", 0.0));
      skipCurrentElement();
      return p;
      }
예제 #25
0
QSizeF RecycledListItem::effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
    QSizeF s = m_item->effectiveSizeHint(which,constraint);
    if (m_item2)
        s.setWidth(s.width()*2);
    if (s.height()<MinItemHeight)
        s.setHeight(MinItemHeight);
    return s;
}
예제 #26
0
void Note::checkSize(QSizeF & newSize) {
	QSizeF gripSize = m_resizeGrip->boundingRect().size();
	QSizeF size = m_graphicsTextItem->document()->size();
	if (size.height() + gripSize.height() + gripSize.height() > m_rect.height()) {
		prepareGeometryChange();
		m_rect.setHeight(size.height() + gripSize.height() + gripSize.height());
		newSize.setHeight(m_rect.height());
		positionGrip();
		this->update();
	}
}
예제 #27
0
QSizeF GraphicsNodeSocket::
getMinimalSize() const {
	QSizeF size;
	QFont font;
	QFontMetrics fm(font);
	int text_width = fm.width(_text);
	const qreal text_height = static_cast<qreal>(fm.height());
	size.setWidth(std::max(_min_width, _circle_radius*2 + _text_offset + text_width + _pen_width));
	size.setHeight(std::max(_min_height, text_height + _pen_width));
	return size;
}
예제 #28
0
/**
 * Reimplemented from UMLWidget::updateGeometry to calculate
 * minimum size for this widget based on the current state of this
 * widget.
 */
void ClassifierWidget::updateGeometry()
{
    // Min size including classifier and template box.
    QSizeF totalMinSize;
    UMLWidget::SizeHintOption sizeHintOption = UMLWidget::AddMargin;

    // Min size for classifier items and header (doesn't include template)
    QSizeF headerSize = textItemGroupAt(HeaderGroupIndex)->minimumSize();
    QSizeF attribOpSize = textItemGroupAt(AttribOpGroupIndex)->minimumSize();

    QSizeF classifierMinSize; // combined size
    classifierMinSize.setWidth(qMax(headerSize.width(), attribOpSize.width()));
    classifierMinSize.setHeight(headerSize.height() + attribOpSize.height());

    if (shouldDrawAsCircle()) {
        qreal minDiameter = 2 * ClassifierWidget::CircleMinimumRadius;
        // only header items are drawn, so total min size should include only that.
        totalMinSize.setWidth(qMax(headerSize.width(), minDiameter));
        totalMinSize.setHeight(headerSize.height() + minDiameter);
    } else {
        // Draw the bounding rectangle
        QSizeF templateBoxSize = textItemGroupAt(TemplateGroupIndex)->minimumSize();

        if (textItemGroupAt(TemplateGroupIndex)->textItemCount() == 0) {
            // If we don't have template params use entire size for header, params and operations.
            totalMinSize = classifierMinSize;
        }
        else {
            // minus margin() below because to overlap a bit.
            totalMinSize.setHeight(classifierMinSize.height() +
                    templateBoxSize.height() - margin());
            totalMinSize.setWidth(classifierMinSize.width() + .5 * templateBoxSize.width());
            // Dont add margin as we have already added manually
            sizeHintOption = UMLWidget::DontAddMargin;
        }

    }
    setMinimumSize(totalMinSize, sizeHintOption);
    setSize(totalMinSize);
    UMLWidget::updateGeometry();
}
예제 #29
0
QSizeF QGLE::qtSizeToGLE(QSizeF qt, double dpi)
{
	// DO NOT RELY ON THIS FOR ACCURACY!
	double gleX, gleY;
	qt.setWidth(qt.width() - 2*GS_OFFSET*dpi);
	qt.setHeight(qt.height() - 2*GS_OFFSET*dpi);
	QPointF rel = relQtToGLE(qt.width(), qt.height(), dpi);
	gleX = rel.x();
	gleY = rel.y();

	return(QSizeF(gleX,gleY));
}
예제 #30
0
void PopupLayer::Private::setAppropriateSize( const ViewportParams *viewport )
{
    qreal margin = 15.0;

    QSizeF maximumSize;
    maximumSize.setWidth( viewport->width() - margin );
    maximumSize.setHeight( viewport->height() - margin );

    QSizeF minimumSize( 100.0, 100.0 );

    m_popupItem->setSize( m_requestedSize.boundedTo( maximumSize ).expandedTo( minimumSize ) );
}