• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • layers
PopupLayer.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Mohammed Nafees <nafees.technocool@gmail.com>
9 // Copyright 2012 Dennis Nienhüser <earthwings@gentoo.org>
10 // Copyright 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
11 //
12 
13 #include "PopupLayer.h"
14 #include "MarbleWidget.h"
15 #include "PopupItem.h"
16 
17 #include <QMouseEvent>
18 #include <QApplication>
19 #include <QAction>
20 
21 namespace Marble
22 {
23 
24 PopupLayer::PopupLayer( MarbleWidget *marbleWidget, QObject *parent ) :
25  QObject( parent ),
26  m_popupItem( new PopupItem( this ) ),
27  m_widget( marbleWidget ),
28  m_adjustMap( false )
29 {
30  connect( m_popupItem, SIGNAL(repaintNeeded()), this, SIGNAL(repaintNeeded()) );
31  connect( m_popupItem, SIGNAL(hide()), this, SLOT(hidePopupItem()) );
32 }
33 
34 PopupLayer::~PopupLayer()
35 {
36 }
37 
38 QStringList PopupLayer::renderPosition() const
39 {
40  return QStringList( "ALWAYS_ON_TOP" );
41 }
42 
43 QString PopupLayer::renderPolicy() const
44 {
45  return "ALWAYS";
46 }
47 
48 bool PopupLayer::render( GeoPainter *painter, ViewportParams *viewport,
49  const QString&, GeoSceneLayer* )
50 {
51  if ( visible() ) {
52  setAppropriateSize( viewport );
53  if ( m_adjustMap ) {
54  m_widget->centerOn( m_popupItem->coordinate(), true );
55  m_adjustMap = false;
56  }
57  m_popupItem->paintEvent( painter, viewport );
58  }
59 
60  return true;
61 }
62 
63 bool PopupLayer::eventFilter( QObject *object, QEvent *e )
64 {
65  return visible() && m_popupItem->eventFilter( object, e );
66 }
67 
68 qreal PopupLayer::zValue() const
69 {
70  return 4711.23;
71 }
72 
73 bool PopupLayer::visible() const
74 {
75  return m_popupItem->visible();
76 }
77 
78 void PopupLayer::setVisible( bool visible )
79 {
80  m_popupItem->setVisible( visible );
81  if ( !visible ) {
82  disconnect( m_popupItem, SIGNAL(repaintNeeded()), this, SIGNAL(repaintNeeded()) );
83  m_popupItem->clearHistory();
84  emit repaintNeeded();
85  }
86  else {
87  connect( m_popupItem, SIGNAL(repaintNeeded()), this, SIGNAL(repaintNeeded()) );
88  }
89 }
90 
91 void PopupLayer::popup()
92 {
93  m_adjustMap = true;
94  setVisible( true );
95 }
96 
97 void PopupLayer::setCoordinates(const GeoDataCoordinates &coordinates , Qt::Alignment alignment)
98 {
99  m_popupItem->setCoordinate( coordinates );
100  m_popupItem->setAlignment( alignment );
101 }
102 
103 void PopupLayer::setUrl( const QUrl &url )
104 {
105  m_popupItem->setUrl( url );
106 }
107 
108 void PopupLayer::setContent( const QString &html )
109 {
110  m_popupItem->setContent( html );
111  emit repaintNeeded();
112 }
113 
114 void PopupLayer::setBackgroundColor(const QColor &color)
115 {
116  if(color.isValid()) {
117  m_popupItem->setBackgroundColor(color);
118  }
119 }
120 
121 void PopupLayer::setTextColor(const QColor &color)
122 {
123  if(color.isValid()) {
124  m_popupItem->setTextColor(color);
125  }
126 }
127 
128 void PopupLayer::setSize( const QSizeF &size )
129 {
130  m_requestedSize = size;
131 }
132 
133 void PopupLayer::setAppropriateSize( const ViewportParams *viewport )
134 {
135  qreal margin = 15.0;
136 
137  QSizeF maximumSize;
138  maximumSize.setWidth( viewport->width() / 2.0 - margin );
139  maximumSize.setHeight( viewport->height() - 2.0 * margin );
140 
141  QSizeF minimumSize( 240.0, 240.0 );
142 
143  m_popupItem->setSize( m_requestedSize.boundedTo( maximumSize ).expandedTo( minimumSize ) );
144 }
145 
146 void PopupLayer::setPosition( const QPointF &position )
147 {
149  Q_UNUSED( position );
150 }
151 
152 void PopupLayer::hidePopupItem()
153 {
154  setVisible( false );
155 }
156 
157 }
158 
159 #include "PopupLayer.moc"
Marble::PopupLayer::visible
bool visible() const
Is popup item visible.
Definition: PopupLayer.cpp:73
Marble::GeoDataCoordinates
A 3d point representation.
Definition: GeoDataCoordinates.h:52
Marble::PopupLayer::eventFilter
virtual bool eventFilter(QObject *, QEvent *)
Definition: PopupLayer.cpp:63
Marble::MarbleGraphicsItem::setSize
void setSize(const QSizeF &size)
Set the size of the item.
Definition: MarbleGraphicsItem.cpp:197
Marble::GeoPainter
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:98
Marble::PopupItem::setUrl
void setUrl(const QUrl &url)
Set URL for web window.
Definition: PopupItem.cpp:92
Marble::PopupItem::setTextColor
void setTextColor(const QColor &color)
Sets text color of the header.
Definition: PopupItem.cpp:114
Marble::PopupLayer::setBackgroundColor
void setBackgroundColor(const QColor &color)
Sets background color of the header.
Definition: PopupLayer.cpp:114
Marble::PopupLayer::popup
void popup()
Make the dialog pop up.
Definition: PopupLayer.cpp:91
PopupItem.h
Marble::PopupLayer::repaintNeeded
void repaintNeeded()
Marble::PopupLayer::setPosition
void setPosition(const QPointF &position)
Sets the position of the dialog to the given screen position.
Definition: PopupLayer.cpp:146
QObject
Marble::ViewportParams::height
int height() const
Definition: ViewportParams.cpp:255
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:102
Marble::PopupItem
The PopupItem Class.
Definition: PopupItem.h:37
Marble::PopupItem::setContent
void setContent(const QString &html)
Set content of the popup.
Definition: PopupItem.cpp:106
Marble::GeoSceneLayer
Layer of a GeoScene document.
Definition: GeoSceneLayer.h:43
Marble::ViewportParams::width
int width() const
Definition: ViewportParams.cpp:250
Marble::PopupLayer::renderPolicy
QString renderPolicy() const
Definition: PopupLayer.cpp:43
Marble::PopupLayer::PopupLayer
PopupLayer(MarbleWidget *widget, QObject *parent=0)
Definition: PopupLayer.cpp:24
Marble::PopupLayer::render
bool render(GeoPainter *painter, ViewportParams *viewport, const QString &, GeoSceneLayer *)
Renders the content provided by the layer on the viewport.
Definition: PopupLayer.cpp:48
Marble::PopupLayer::setContent
void setContent(const QString &html)
Sets content of the browser.
Definition: PopupLayer.cpp:108
Marble::PopupLayer::setTextColor
void setTextColor(const QColor &color)
Sets text color of the header.
Definition: PopupLayer.cpp:121
Marble::PopupItem::eventFilter
virtual bool eventFilter(QObject *, QEvent *e)
Definition: PopupItem.cpp:221
Marble::PopupItem::clearHistory
void clearHistory()
Definition: PopupItem.cpp:324
Marble::MarbleGraphicsItem::visible
bool visible() const
Returns if the item is visible.
Definition: MarbleGraphicsItem.cpp:177
Marble::PopupLayer::renderPosition
QStringList renderPosition() const
Preferred level in the layer stack for the rendering.
Definition: PopupLayer.cpp:38
Marble::PopupLayer::~PopupLayer
~PopupLayer()
Definition: PopupLayer.cpp:34
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
Marble::MarbleWidget::centerOn
void centerOn(const qreal lon, const qreal lat, bool animated=false)
Center the view on a geographical point.
Definition: MarbleWidget.cpp:626
Marble::PopupItem::setBackgroundColor
void setBackgroundColor(const QColor &color)
Sets background color of the bubble.
Definition: PopupItem.cpp:124
Marble::PopupLayer::zValue
qreal zValue() const
Returns the z value of the layer (default: 0.0).
Definition: PopupLayer.cpp:68
Marble::PopupLayer::setVisible
void setVisible(bool visible)
Set visibility of the item.
Definition: PopupLayer.cpp:78
PopupLayer.h
Marble::PopupLayer::setUrl
void setUrl(const QUrl &url)
Sets URL of the browser.
Definition: PopupLayer.cpp:103
Marble::BillboardGraphicsItem::coordinate
GeoDataCoordinates coordinate() const
Definition: BillboardGraphicsItem.cpp:93
Marble::MarbleGraphicsItem::setVisible
void setVisible(bool visible)
Makes the item visible or invisible, depending on visible.
Definition: MarbleGraphicsItem.cpp:182
MarbleWidget.h
This file contains the headers for MarbleWidget.
Marble::PopupLayer::setCoordinates
void setCoordinates(const GeoDataCoordinates &coordinates, Qt::Alignment alignment)
Sets coordinates.
Definition: PopupLayer.cpp:97
Marble::MarbleGraphicsItem::paintEvent
bool paintEvent(QPainter *painter, const ViewportParams *viewport)
Paints the item on the screen in view coordinates.
Definition: MarbleGraphicsItem.cpp:38
Marble::BillboardGraphicsItem::setCoordinate
void setCoordinate(const GeoDataCoordinates &coordinates)
Definition: BillboardGraphicsItem.cpp:98
Marble::PopupLayer::setSize
void setSize(const QSizeF &size)
Sets size of popup item.
Definition: PopupLayer.cpp:128
Marble::BillboardGraphicsItem::setAlignment
void setAlignment(Qt::Alignment alignment)
Definition: BillboardGraphicsItem.cpp:133
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal