7#include "LabelGraphicsItem.h"
8#include "LabelGraphicsItem_p.h"
12#include <QApplication>
18LabelGraphicsItemPrivate::LabelGraphicsItemPrivate(
LabelGraphicsItem *labelGraphicsItem,
19 MarbleGraphicsItem *parent)
20 : FrameGraphicsItemPrivate(labelGraphicsItem, parent)
24QFont LabelGraphicsItemPrivate::font()
29void LabelGraphicsItem::setContentSize(
const QSizeF &contentSize )
32 QSizeF updatedSize = contentSize;
38 if ( d->m_minimumSize.width() > updatedSize.
width() ) {
39 updatedSize.
setWidth( d->m_minimumSize.width() );
41 if ( d->m_minimumSize.height() > updatedSize.
height() ) {
42 updatedSize.
setHeight( d->m_minimumSize.height() );
46 FrameGraphicsItem::setContentSize( updatedSize );
51LabelGraphicsItem::LabelGraphicsItem( MarbleGraphicsItem *parent )
52 : FrameGraphicsItem(new LabelGraphicsItemPrivate(this, parent))
56LabelGraphicsItem::~LabelGraphicsItem()
60QString LabelGraphicsItem::text()
const
66void LabelGraphicsItem::setText(
const QString& text )
72 QSizeF size = metrics.boundingRect( text ).size() +
QSizeF( 14, 2 );
73 setContentSize( size );
76QImage LabelGraphicsItem::image()
const
82void LabelGraphicsItem::setImage(
const QImage& image,
const QSize& size )
88 setContentSize( image.
size() );
91 setContentSize( size );
95QIcon LabelGraphicsItem::icon()
const
101void LabelGraphicsItem::setIcon(
const QIcon& icon,
const QSize& size )
106 setContentSize( size );
109QSizeF LabelGraphicsItem::minimumSize()
const
112 return d->m_minimumSize;
115void LabelGraphicsItem::setMinimumSize(
const QSizeF& size )
118 const QSizeF oldContentSize = contentSize();
119 d->m_minimumSize = size;
120 setContentSize( oldContentSize );
123void LabelGraphicsItem::clear()
129 setContentSize(
QSizeF( 0.0, 0.0 ) );
132void LabelGraphicsItem::paintContent(
QPainter *painter )
137 if ( !d->m_text.isNull() ) {
144 else if ( !d->m_image.isNull() ) {
148 else if ( !d->m_icon.isNull() ) {
149 d->m_icon.paint( painter,
A label item provides an Item that displays text or images/pixmaps.
Binds a QML item to a specific geodetic location in screen coordinates.
void drawImage(const QPoint &point, const QImage &image)
void drawText(const QPoint &position, const QString &text)
void setFont(const QFont &font)
void setPen(Qt::PenStyle style)
bool isEmpty() const const
qreal height() const const
bool isEmpty() const const
void setHeight(qreal height)
void setWidth(qreal width)
qreal width() const const