• 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
  • opendesktop
OpenDesktopItem.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 2010 Utku Aydın <utkuaydin34@gmail.com>
9 // Copyright 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
10 //
11 
12 #include <QPainter>
13 #include "OpenDesktopItem.h"
14 #include "ViewportParams.h"
15 #include "layers/PopupLayer.h"
16 
17 using namespace Marble;
18 
19 OpenDesktopItem::OpenDesktopItem(QObject *parent):
20  AbstractDataPluginItem(parent)
21 {
22  m_action = new QAction( this );
23  connect( m_action, SIGNAL(triggered()), this, SLOT(openBrowser()) );
24  setCacheMode( ItemCoordinateCache );
25 }
26 
27 OpenDesktopItem::~OpenDesktopItem()
28 {
29  delete m_action;
30 }
31 
32 QString OpenDesktopItem::itemType() const
33 {
34  // Our itemType:
35  return "openDesktopItem";
36 }
37 
38 bool OpenDesktopItem::initialized() const
39 {
40  return size() != QSizeF(-1, -1);
41 }
42 
43 bool OpenDesktopItem::operator<( const AbstractDataPluginItem *other ) const
44 {
45  // Custom avatars will have more priority than default ones
46  QString noAvatar = "http://opendesktop.org/usermanager/nopic.png";
47  const OpenDesktopItem* item = dynamic_cast<const OpenDesktopItem*>( other );
48 
49  if( item )
50  {
51  if( this->avatarUrl().toString() == noAvatar && item->avatarUrl().toString() != noAvatar )
52  return false;
53 
54  else if( this->avatarUrl().toString() != noAvatar && item->avatarUrl().toString() == noAvatar )
55  return true;
56  }
57 
58  return this > other;
59 }
60 
61 void OpenDesktopItem::addDownloadedFile( const QString& url, const QString& type )
62 {
63  if( type == "avatar" ) {
64  m_pixmap.load( url );
65  setSize( m_pixmap.size() );
66  emit updated();
67  }
68 }
69 
70 void OpenDesktopItem::paint( QPainter *painter )
71 {
72  painter->drawPixmap(0, 0, m_pixmap);
73 }
74 
75 void OpenDesktopItem::updateToolTip()
76 {
77  QString toolTip;
78  toolTip += "<html><head><meta name='qrichtext' content='1' />";
79  toolTip += "<style type='text/css'>";
80  toolTip += "body { font-family:'Sans Serif'; font-size:9pt; font-weight:400; }";
81  toolTip += "np, li { white-space: pre-wrap; }";
82  toolTip += "p { margin: 0; -qt-block-indent:0; text-indent:0px }";
83  toolTip += "</style></head><body><table>";
84  toolTip += "<tr><td align='right'>Fullname:</td><td>%1</td></tr>";
85  toolTip += "<tr><td align='right'>Location:</td><td>%2</td></tr>";
86  toolTip += "<tr><td align='right'>Role:</td><td>%3</td></tr>";
87  toolTip += "</table></body></html>";
88  setToolTip( toolTip.arg( fullName() ).arg( location() ).arg( role() ) );
89 }
90 
91 QAction *OpenDesktopItem::action()
92 {
93  m_action->setText( id() );
94  return m_action;
95 }
96 
97 void OpenDesktopItem::openBrowser()
98 {
99  PopupLayer *popup = m_marbleWidget->popupLayer();
100  popup->setCoordinates( coordinate(), Qt::AlignRight | Qt::AlignVCenter );
101  popup->setUrl( profileUrl() );
102  popup->setSize( QSizeF( 900, 600 ) );
103  popup->setVisible( true );
104 }
105 
106 QUrl OpenDesktopItem::profileUrl() const
107 {
108  return QUrl( QString( "http://opendesktop.org/usermanager/search.php?username=%1" ).arg( id() ) );
109 }
110 
111 QUrl OpenDesktopItem::avatarUrl() const
112 {
113  return m_avatarUrl;
114 }
115 
116 void OpenDesktopItem::setAvatarUrl( const QUrl url )
117 {
118  m_avatarUrl = url;
119 }
120 
121 QString OpenDesktopItem::fullName() const
122 {
123  return m_fullName;
124 }
125 
126 void OpenDesktopItem::setFullName( const QString fullName )
127 {
128  m_fullName = fullName;
129  updateToolTip();
130 }
131 
132 QString OpenDesktopItem::location() const
133 {
134  return m_location;
135 }
136 
137 void OpenDesktopItem::setLocation( const QString location )
138 {
139  m_location = location;
140  updateToolTip();
141 }
142 
143 QString OpenDesktopItem::role() const
144 {
145  return m_role;
146 }
147 
148 void OpenDesktopItem::setRole( const QString role )
149 {
150  m_role = role;
151  updateToolTip();
152 }
153 
154 void OpenDesktopItem::setMarbleWidget(MarbleWidget *widget)
155 {
156  m_marbleWidget = widget;
157 }
158 
159 // This is needed for all QObjects (see MOC)
160 #include "OpenDesktopItem.moc"
QPainter
Marble::OpenDesktopItem::setLocation
void setLocation(const QString location)
Definition: OpenDesktopItem.cpp:137
Marble::OpenDesktopItem::role
QString role() const
Definition: OpenDesktopItem.cpp:143
Marble::MarbleGraphicsItem::setSize
void setSize(const QSizeF &size)
Set the size of the item.
Definition: MarbleGraphicsItem.cpp:197
Marble::AbstractDataPluginItem
Definition: AbstractDataPluginItem.h:28
Marble::OpenDesktopItem::paint
void paint(QPainter *painter)
Paints the item in item coordinates.
Definition: OpenDesktopItem.cpp:70
Marble::PopupLayer
The PopupLayer class.
Definition: PopupLayer.h:39
Marble::AbstractDataPluginItem::toolTip
QString toolTip() const
Returns the item's tool tip.
Definition: AbstractDataPluginItem.cpp:71
Marble::MarbleGraphicsItem::size
QSizeF size() const
Returns the size of the item.
Definition: MarbleGraphicsItem.cpp:136
Marble::OpenDesktopItem::operator<
bool operator<(const AbstractDataPluginItem *other) const
Definition: OpenDesktopItem.cpp:43
QObject
Marble::OpenDesktopItem::setRole
void setRole(const QString role)
Definition: OpenDesktopItem.cpp:148
Marble::MarbleWidget::popupLayer
PopupLayer * popupLayer()
Definition: MarbleWidget.cpp:1408
Marble::OpenDesktopItem::avatarUrl
QUrl avatarUrl() const
Definition: OpenDesktopItem.cpp:111
Marble::OpenDesktopItem
Definition: OpenDesktopItem.h:26
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:102
Marble::OpenDesktopItem::addDownloadedFile
void addDownloadedFile(const QString &url, const QString &type)
Definition: OpenDesktopItem.cpp:61
Marble::MarbleGraphicsItem::ItemCoordinateCache
Definition: MarbleGraphicsItem.h:41
Marble::OpenDesktopItem::setAvatarUrl
void setAvatarUrl(const QUrl url)
Definition: OpenDesktopItem.cpp:116
Marble::OpenDesktopItem::updateToolTip
void updateToolTip()
Definition: OpenDesktopItem.cpp:75
Marble::OpenDesktopItem::~OpenDesktopItem
~OpenDesktopItem()
Definition: OpenDesktopItem.cpp:27
Marble::OpenDesktopItem::profileUrl
QUrl profileUrl() const
Definition: OpenDesktopItem.cpp:106
Marble::OpenDesktopItem::action
QAction * action()
Returns the action of this specific item.
Definition: OpenDesktopItem.cpp:91
Marble::OpenDesktopItem::initialized
bool initialized() const
Definition: OpenDesktopItem.cpp:38
Marble::OpenDesktopItem::openBrowser
void openBrowser()
Definition: OpenDesktopItem.cpp:97
ViewportParams.h
This file contains the headers for ViewportParams.
Marble::OpenDesktopItem::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Definition: OpenDesktopItem.cpp:154
Marble::PopupLayer::setVisible
void setVisible(bool visible)
Set visibility of the item.
Definition: PopupLayer.cpp:78
PopupLayer.h
Marble::MarbleGraphicsItem::setCacheMode
void setCacheMode(CacheMode mode)
Set the cache mode of the item.
Definition: MarbleGraphicsItem.cpp:159
Marble::PopupLayer::setUrl
void setUrl(const QUrl &url)
Sets URL of the browser.
Definition: PopupLayer.cpp:103
Marble::OpenDesktopItem::itemType
QString itemType() const
Returns the type of this specific item.
Definition: OpenDesktopItem.cpp:32
Marble::BillboardGraphicsItem::coordinate
GeoDataCoordinates coordinate() const
Definition: BillboardGraphicsItem.cpp:93
Marble::OpenDesktopItem::OpenDesktopItem
OpenDesktopItem(QObject *parent)
Definition: OpenDesktopItem.cpp:19
Marble::OpenDesktopItem::setFullName
void setFullName(const QString fullName)
Definition: OpenDesktopItem.cpp:126
Marble::PopupLayer::setCoordinates
void setCoordinates(const GeoDataCoordinates &coordinates, Qt::Alignment alignment)
Sets coordinates.
Definition: PopupLayer.cpp:97
Marble::AbstractDataPluginItem::setToolTip
void setToolTip(const QString &toolTip)
Set the tool tip for the item.
Definition: AbstractDataPluginItem.cpp:76
Marble::OpenDesktopItem::location
QString location() const
Definition: OpenDesktopItem.cpp:132
Marble::PopupLayer::setSize
void setSize(const QSizeF &size)
Sets size of popup item.
Definition: PopupLayer.cpp:128
Marble::OpenDesktopItem::fullName
QString fullName() const
Definition: OpenDesktopItem.cpp:121
Marble::AbstractDataPluginItem::updated
void updated()
OpenDesktopItem.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:51 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