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

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • render
  • annotate
GeoWidgetBubble.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 2009 Andrew Manson <g.real.ate@gmail.com>
9 // Copyright 2013 Thibaut Gridel <tgridel@free.fr>
10 //
11 
12 #include "GeoWidgetBubble.h"
13 
14 #include "TextEditor.h"
15 
16 #include "MarbleColors.h"
17 
18 #include <QPainter>
19 #include <QWidget>
20 
21 
22 namespace Marble
23 {
24 
25 GeoWidgetBubble::GeoWidgetBubble( GeoDataPlacemark *placemark )
26  : m_widget( new TextEditor( placemark ) ),
27  m_hidden( true ),
28  m_widgetInitialized( false ),
29  m_offset( QPoint( 10, 10 ) )
30 {
31  m_widget->setVisible(false);
32  m_widget->setPalette( QPalette( Qt::lightGray, Qt::lightGray ) );
33 }
34 
35 GeoWidgetBubble::~GeoWidgetBubble()
36 {
37  delete m_widget;
38 }
39 
40 void GeoWidgetBubble::paint( QPainter *painter )
41 {
42  if ( !m_widgetInitialized && m_widget ) {
43  QWidget *widget = dynamic_cast<QWidget*>( painter->device() );
44  if ( widget ) {
45  setParentWidget( widget );
46  }
47  }
48 
49  if ( !m_hidden ) {
50  if ( m_widgetInitialized ) {
51 
52  m_widget->setVisible( true );
53  QSize widgetSize = m_widget->size();
54  //how wide and high the border is
55  //sum of both sides of the border
56  QSize borderSize( 40, 40 );
57  QPoint borderOffset( -10, -10 );
58 
59  //position of the bubble
60  QPoint position = m_screenPosition + m_offset;
61  m_widget->move( position ) ;
62 
63  painter->save();
64 
65  //draw the border
66  painter->setPen( QPen( Oxygen::aluminumGray4 ) );
67  painter->setBrush( QBrush( QColor( 255, 255, 255), Qt::SolidPattern ) );
68  painter->drawRoundedRect( QRect( position + borderOffset, widgetSize + borderSize ), 10, 10 );
69 
70  painter->restore();
71  }
72  } else {
73  m_widget->hide();
74  }
75 }
76 
77 void GeoWidgetBubble::setParentWidget( QWidget *parent )
78 {
79  m_widget->setParent( parent );
80  m_widget->setVisible( true );
81  m_widgetInitialized = true;
82 }
83 
84 void GeoWidgetBubble::moveTo( const QPoint &pos )
85 {
86  m_screenPosition = pos;
87 }
88 
89 void GeoWidgetBubble::setHidden( bool hide )
90 {
91  if ( m_hidden == hide ) {
92  return;
93  }
94 
95  m_hidden = hide;
96  m_widget->setVisible( m_hidden );
97 
98  if ( m_widgetInitialized ) {
99  m_widget->parentWidget()->update();
100  }
101 }
102 
103 bool GeoWidgetBubble::isHidden() const
104 {
105  return m_hidden;
106 }
107 
108 }
QWidget
MarbleColors.h
QWidget::setPalette
void setPalette(const QPalette &)
GeoWidgetBubble.h
Marble::GeoWidgetBubble::GeoWidgetBubble
GeoWidgetBubble(GeoDataPlacemark *placemark)
Definition: GeoWidgetBubble.cpp:25
QWidget::setVisible
virtual void setVisible(bool visible)
QPainter::save
void save()
QBrush
Marble::TextEditor
Definition: TextEditor.h:28
QPoint
QWidget::setParent
void setParent(QWidget *parent)
Marble::GeoWidgetBubble::~GeoWidgetBubble
~GeoWidgetBubble()
Definition: GeoWidgetBubble.cpp:35
QWidget::update
void update()
Marble::GeoWidgetBubble::moveTo
void moveTo(const QPoint &screenPos)
Definition: GeoWidgetBubble.cpp:84
QWidget::size
size
QRect
TextEditor.h
Marble::Oxygen::aluminumGray4
QColor const aluminumGray4
Definition: MarbleColors.h:92
QPainter::setPen
void setPen(const QColor &color)
QPainter::drawRoundedRect
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
QPainter
QPainter::device
QPaintDevice * device() const
Marble::GeoWidgetBubble::setParentWidget
void setParentWidget(QWidget *parent)
Definition: GeoWidgetBubble.cpp:77
QWidget::move
void move(int x, int y)
QPainter::setBrush
void setBrush(const QBrush &brush)
Marble::GeoWidgetBubble::paint
void paint(QPainter *p)
Definition: GeoWidgetBubble.cpp:40
Marble::GeoWidgetBubble::setHidden
void setHidden(bool hide)
Definition: GeoWidgetBubble.cpp:89
QWidget::hide
void hide()
QColor
QSize
QPainter::restore
void restore()
QWidget::parentWidget
QWidget * parentWidget() const
QPen
Marble::GeoWidgetBubble::isHidden
bool isHidden() const
Definition: GeoWidgetBubble.cpp:103
Marble::GeoDataPlacemark
a class representing a point of interest on the map
Definition: GeoDataPlacemark.h:54
QPalette
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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
  • 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