• 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
  • 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 "OpenDesktopItem.h"
13 #include <QPainter>
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 bool OpenDesktopItem::initialized() const
33 {
34  return size() != QSizeF(-1, -1);
35 }
36 
37 bool OpenDesktopItem::operator<( const AbstractDataPluginItem *other ) const
38 {
39  // Custom avatars will have more priority than default ones
40  QString noAvatar = "http://opendesktop.org/usermanager/nopic.png";
41  const OpenDesktopItem* item = dynamic_cast<const OpenDesktopItem*>( other );
42 
43  if( item )
44  {
45  if( this->avatarUrl().toString() == noAvatar && item->avatarUrl().toString() != noAvatar )
46  return false;
47 
48  else if( this->avatarUrl().toString() != noAvatar && item->avatarUrl().toString() == noAvatar )
49  return true;
50  }
51 
52  return this > other;
53 }
54 
55 void OpenDesktopItem::addDownloadedFile( const QString& url, const QString& type )
56 {
57  if( type == "avatar" ) {
58  m_pixmap.load( url );
59  setSize( m_pixmap.size() );
60  emit updated();
61  }
62 }
63 
64 void OpenDesktopItem::paint( QPainter *painter )
65 {
66  painter->drawPixmap(0, 0, m_pixmap);
67 }
68 
69 void OpenDesktopItem::updateToolTip()
70 {
71  QString toolTip;
72  toolTip += "<html><head><meta name='qrichtext' content='1' />";
73  toolTip += "<style type='text/css'>";
74  toolTip += "body { font-family:'Sans Serif'; font-size:9pt; font-weight:400; }";
75  toolTip += "np, li { white-space: pre-wrap; }";
76  toolTip += "p { margin: 0; -qt-block-indent:0; text-indent:0px }";
77  toolTip += "</style></head><body><table>";
78  toolTip += "<tr><td align='right'>Fullname:</td><td>%1</td></tr>";
79  toolTip += "<tr><td align='right'>Location:</td><td>%2</td></tr>";
80  toolTip += "<tr><td align='right'>Role:</td><td>%3</td></tr>";
81  toolTip += "</table></body></html>";
82  setToolTip( toolTip.arg( fullName() ).arg( location() ).arg( role() ) );
83 }
84 
85 QAction *OpenDesktopItem::action()
86 {
87  m_action->setText( id() );
88  return m_action;
89 }
90 
91 void OpenDesktopItem::openBrowser()
92 {
93  PopupLayer *popup = m_marbleWidget->popupLayer();
94  popup->setCoordinates( coordinate(), Qt::AlignRight | Qt::AlignVCenter );
95  popup->setUrl( profileUrl() );
96  popup->setSize( QSizeF( 900, 600 ) );
97  popup->popup();
98 }
99 
100 QUrl OpenDesktopItem::profileUrl() const
101 {
102  return QUrl( QString( "http://opendesktop.org/usermanager/search.php?username=%1" ).arg( id() ) );
103 }
104 
105 QUrl OpenDesktopItem::avatarUrl() const
106 {
107  return m_avatarUrl;
108 }
109 
110 void OpenDesktopItem::setAvatarUrl( const QUrl url )
111 {
112  m_avatarUrl = url;
113 }
114 
115 QString OpenDesktopItem::fullName() const
116 {
117  return m_fullName;
118 }
119 
120 void OpenDesktopItem::setFullName( const QString fullName )
121 {
122  m_fullName = fullName;
123  updateToolTip();
124 }
125 
126 QString OpenDesktopItem::location() const
127 {
128  return m_location;
129 }
130 
131 void OpenDesktopItem::setLocation( const QString location )
132 {
133  m_location = location;
134  updateToolTip();
135 }
136 
137 QString OpenDesktopItem::role() const
138 {
139  return m_role;
140 }
141 
142 void OpenDesktopItem::setRole( const QString role )
143 {
144  m_role = role;
145  updateToolTip();
146 }
147 
148 void OpenDesktopItem::setMarbleWidget(MarbleWidget *widget)
149 {
150  m_marbleWidget = widget;
151 }
152 
153 // This is needed for all QObjects (see MOC)
154 #include "OpenDesktopItem.moc"
QAction::setText
void setText(const QString &text)
Marble::OpenDesktopItem::setLocation
void setLocation(const QString location)
Definition: OpenDesktopItem.cpp:131
QPixmap::size
QSize size() const
Marble::OpenDesktopItem::role
QString role() const
Definition: OpenDesktopItem.cpp:137
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:64
Marble::PopupLayer
The PopupLayer class.
Definition: PopupLayer.h:34
Marble::AbstractDataPluginItem::toolTip
QString toolTip() const
Returns the item's tool tip.
Definition: AbstractDataPluginItem.cpp:71
Marble::PopupLayer::popup
void popup()
Make the dialog pop up.
Definition: PopupLayer.cpp:117
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:37
QUrl::toString
QString toString(QFlags< QUrl::FormattingOption > options) const
Marble::OpenDesktopItem::setRole
void setRole(const QString role)
Definition: OpenDesktopItem.cpp:142
Marble::MarbleWidget::popupLayer
PopupLayer * popupLayer()
Definition: MarbleWidget.cpp:1226
Marble::OpenDesktopItem::avatarUrl
QUrl avatarUrl() const
Definition: OpenDesktopItem.cpp:105
Marble::OpenDesktopItem
Definition: OpenDesktopItem.h:26
Marble::MarbleWidget
A widget class that displays a view of the earth.
Definition: MarbleWidget.h:104
Marble::OpenDesktopItem::addDownloadedFile
void addDownloadedFile(const QString &url, const QString &type)
Definition: OpenDesktopItem.cpp:55
QObject
QPainter::drawPixmap
void drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)
QPainter
Marble::MarbleGraphicsItem::ItemCoordinateCache
Definition: MarbleGraphicsItem.h:41
Marble::OpenDesktopItem::setAvatarUrl
void setAvatarUrl(const QUrl url)
Definition: OpenDesktopItem.cpp:110
Marble::OpenDesktopItem::updateToolTip
void updateToolTip()
Definition: OpenDesktopItem.cpp:69
Marble::OpenDesktopItem::~OpenDesktopItem
~OpenDesktopItem()
Definition: OpenDesktopItem.cpp:27
QString
Marble::OpenDesktopItem::profileUrl
QUrl profileUrl() const
Definition: OpenDesktopItem.cpp:100
QPixmap::load
bool load(const QString &fileName, const char *format, QFlags< Qt::ImageConversionFlag > flags)
Marble::OpenDesktopItem::action
QAction * action()
Returns the action of this specific item.
Definition: OpenDesktopItem.cpp:85
Marble::OpenDesktopItem::initialized
bool initialized() const
Definition: OpenDesktopItem.cpp:32
Marble::OpenDesktopItem::openBrowser
void openBrowser()
Definition: OpenDesktopItem.cpp:91
QUrl
ViewportParams.h
This file contains the headers for ViewportParams.
Marble::OpenDesktopItem::setMarbleWidget
void setMarbleWidget(MarbleWidget *widget)
Definition: OpenDesktopItem.cpp:148
PopupLayer.h
QSizeF
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:139
QAction
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:120
Marble::PopupLayer::setCoordinates
void setCoordinates(const GeoDataCoordinates &coordinates, Qt::Alignment alignment)
Sets coordinates.
Definition: PopupLayer.cpp:133
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
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:126
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Marble::PopupLayer::setSize
void setSize(const QSizeF &size)
Sets size of popup item.
Definition: PopupLayer.cpp:163
Marble::OpenDesktopItem::fullName
QString fullName() const
Definition: OpenDesktopItem.cpp:115
Marble::AbstractDataPluginItem::updated
void updated()
OpenDesktopItem.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 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