• 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
  • 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 namespace Marble
22 {
23 
24 GeoWidgetBubble::GeoWidgetBubble( GeoDataPlacemark *placemark )
25  : m_widget( new TextEditor( placemark ) ),
26  m_hidden( true ),
27  m_widgetInitialized( false ),
28  m_offset( QPoint( 10, 10 ) )
29 {
30  m_widget->setVisible(false);
31  m_widget->setPalette( QPalette(Qt::lightGray, Qt::lightGray) );
32 }
33 
34 GeoWidgetBubble::~GeoWidgetBubble()
35 {
36  delete m_widget;
37 }
38 
39 void GeoWidgetBubble::paint( QPainter* painter )
40 {
41  if( !m_widgetInitialized && ( m_widget!=0) ) {
42  QWidget *widget = dynamic_cast<QWidget*>( painter->device() );
43  if ( widget ) {
44  setParentWidget( widget );
45  }
46  }
47 
48  if( !m_hidden ) {
49 
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 ),
69  10, 10 );
70 
71  painter->restore();
72  }
73  }
74  else {
75  m_widget->hide();
76  }
77 
78 }
79 
80 void GeoWidgetBubble::setParentWidget( QWidget* parent )
81 {
82  m_widget->setParent( parent );
83  m_widget->setVisible( true );
84  m_widgetInitialized = true;
85 }
86 
87 void GeoWidgetBubble::moveTo( const QPoint &pos )
88 {
89  m_screenPosition = pos;
90 }
91 
92 void GeoWidgetBubble::setHidden( bool hide )
93 {
94  if( m_hidden == hide ) {
95  return;
96  }
97 
98  m_hidden = hide;
99  m_widget->setVisible( m_hidden );
100 
101  if ( m_widgetInitialized ) {
102  m_widget->parentWidget()->update();
103  }
104 }
105 
106 bool GeoWidgetBubble::isHidden() const
107 {
108  return m_hidden;
109 }
110 
111 }
QPainter
MarbleColors.h
GeoWidgetBubble.h
Marble::GeoWidgetBubble::GeoWidgetBubble
GeoWidgetBubble(GeoDataPlacemark *placemark)
Definition: GeoWidgetBubble.cpp:24
QWidget
Marble::TextEditor
Definition: TextEditor.h:28
Marble::GeoWidgetBubble::~GeoWidgetBubble
~GeoWidgetBubble()
Definition: GeoWidgetBubble.cpp:34
Marble::GeoWidgetBubble::moveTo
void moveTo(const QPoint &screenPos)
Definition: GeoWidgetBubble.cpp:87
TextEditor.h
Marble::Oxygen::aluminumGray4
QColor const aluminumGray4
Definition: MarbleColors.h:92
Marble::GeoWidgetBubble::setParentWidget
void setParentWidget(QWidget *parent)
Definition: GeoWidgetBubble.cpp:80
Marble::GeoWidgetBubble::paint
void paint(QPainter *p)
Definition: GeoWidgetBubble.cpp:39
Marble::GeoWidgetBubble::setHidden
void setHidden(bool hide)
Definition: GeoWidgetBubble.cpp:92
Marble::GeoWidgetBubble::isHidden
bool isHidden() const
Definition: GeoWidgetBubble.cpp:106
Marble::GeoDataPlacemark
a class representing a point of interest on the map
Definition: GeoDataPlacemark.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 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