7#include "AbstractFloatItem.h"
12#include <QContextMenuEvent>
18#include "DialogConfigurationInterface.h"
19#include "GeoPainter.h"
20#include "MarbleDebug.h"
25class AbstractFloatItemPrivate
28 AbstractFloatItemPrivate() : m_contextMenu( nullptr )
32 ~AbstractFloatItemPrivate()
46 QFont AbstractFloatItemPrivate::s_font =
QFont( QStringLiteral(
"Sans Serif"), 10 );
48 QFont AbstractFloatItemPrivate::s_font =
QFont( QStringLiteral(
"Sans Serif"), 8 );
51AbstractFloatItem::AbstractFloatItem(
const MarbleModel *marbleModel,
const QPointF &point,
const QSizeF &size )
52 : RenderPlugin( marbleModel ),
54 d( new AbstractFloatItemPrivate() )
56 setCacheMode( ItemCoordinateCache );
57 setFrame( RectFrame );
59 setContentSize( size );
63AbstractFloatItem::~AbstractFloatItem()
72 updated.
insert(QStringLiteral(
"position"), position().toPoint());
74 updated.
insert(QStringLiteral(
"position"), position());
83 setPosition(settings.
value(QStringLiteral(
"position"), position()).toPointF());
87 setPosition(
QPointF( coordinates.
at( 0 ).toFloat(), coordinates.
at( 1 ).toFloat() ) );
91 setPosition(settings.
value(QStringLiteral(
"position"), position()).toPointF());
94 RenderPlugin::setSettings(settings);
99 return RenderPlugin::PanelRenderType;
102QPen AbstractFloatItem::pen()
const
107void AbstractFloatItem::setPen(
const QPen &pen )
113QFont AbstractFloatItem::font()
const
118void AbstractFloatItem::setFont(
const QFont &font )
124QString AbstractFloatItem::renderPolicy()
const
126 return QStringLiteral(
"ALWAYS");
134void AbstractFloatItem::setVisible(
bool visible )
138 RenderPlugin::setVisible( visible );
141bool AbstractFloatItem::visible()
const
145 return RenderPlugin::visible();
148void AbstractFloatItem::setPositionLocked(
bool lock )
153 flags &= ~ScreenGraphicsItem::ItemIsMovable;
156 flags |= ScreenGraphicsItem::ItemIsMovable;
162bool AbstractFloatItem::positionLocked()
const
164 return ( flags() & ScreenGraphicsItem::ItemIsMovable ) == 0;
167bool AbstractFloatItem::eventFilter(
QObject *
object,
QEvent *e )
169 if ( !enabled() || !visible() ) {
175 QWidget *widget = qobject_cast<QWidget *>(
object );
177 if( widget !=
nullptr && menuEvent !=
nullptr && contains( menuEvent->
pos() ) )
179 contextMenuEvent( widget, menuEvent );
187 if( helpEvent !=
nullptr && contains( helpEvent->
pos() ) )
189 toolTipEvent( helpEvent );
195 return ScreenGraphicsItem::eventFilter(
object, e );
203void AbstractFloatItem::toolTipEvent (
QHelpEvent *e )
219void AbstractFloatItem::show()
224void AbstractFloatItem::hide()
229QMenu* AbstractFloatItem::contextMenu()
231 if ( !d->m_contextMenu )
233 d->m_contextMenu =
new QMenu;
235 QAction *lockAction = d->m_contextMenu->addAction(
QIcon(QStringLiteral(
":/icons/unlock.png")), tr(
"&Lock"));
238 connect( lockAction, SIGNAL(triggered(
bool)),
this, SLOT(setPositionLocked(
bool)) );
240 if(!(flags() & ItemIsHideable)) {
241 QAction *hideAction = d->m_contextMenu->addAction( tr(
"&Hide" ) );
242 connect( hideAction, SIGNAL(triggered()),
this, SLOT(hide()) );
245 DialogConfigurationInterface *configInterface = qobject_cast<DialogConfigurationInterface *>(
this );
246 QDialog *dialog = configInterface ? configInterface->configDialog() :
nullptr;
249 d->m_contextMenu->addSeparator();
250 QAction *configAction = d->m_contextMenu->addAction(
QIcon(QStringLiteral(
":/icons/settings-configure.png")), tr(
"&Configure..."));
251 connect( configAction, SIGNAL(triggered()), dialog, SLOT(exec()) );
255 Q_ASSERT( d->m_contextMenu );
256 return d->m_contextMenu;
261#include "moc_AbstractFloatItem.cpp"
A painter that allows to draw geometric primitives on the map.
Layer of a GeoScene document.
RenderType
A Type of plugin.
A public class that controls what is visible in the viewport of a Marble map.
Binds a QML item to a specific geodetic location in screen coordinates.
iterator insert(const Key &key, const T &value)
T value(const Key &key) const const
const QPoint & pos() const const
const_reference at(qsizetype i) const const