• 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
  • foursquare
FoursquareItem.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 Utku Aydın <utkuaydin34@gmail.com>
9 //
10 
11 #include "FoursquareItem.h"
12 #include "GeoPainter.h"
13 #include "ViewportParams.h"
14 
15 #include <QFontMetrics>
16 #include <QPixmap>
17 #include <QSvgRenderer>
18 
19 namespace Marble
20 {
21 
22 QFont FoursquareItem::s_font = QFont( "Sans Serif", 8 );
23 
24 FoursquareItem::FoursquareItem(QObject* parent)
25  : AbstractDataPluginItem( parent )
26 {
27  setSize( QSize( 0, 0 ) );
28 }
29 
30 FoursquareItem::~FoursquareItem()
31 {
32 }
33 
34 QString FoursquareItem::itemType() const
35 {
36  return "foursquareItem";
37 }
38 
39 bool FoursquareItem::initialized() const
40 {
41  // Find something logical for this
42  return true;
43 }
44 
45 bool FoursquareItem::operator<( const AbstractDataPluginItem *other ) const
46 {
47  const FoursquareItem* item = dynamic_cast<const FoursquareItem*>( other );
48  return item && this->usersCount() > item->usersCount();
49 }
50 
51 QString FoursquareItem::name() const
52 {
53  return m_name;
54 }
55 
56 void FoursquareItem::setName(const QString& name)
57 {
58  if( name != m_name ) {
59  m_name = name;
60  QFontMetrics const fontMetrics( s_font );
61  setSize( QSizeF( fontMetrics.width( m_name ) + 10, fontMetrics.height() + 10 ) );
62  emit nameChanged();
63  }
64 }
65 
66 QString FoursquareItem::category() const
67 {
68  return m_category;
69 }
70 
71 void FoursquareItem::setCategory(const QString& category)
72 {
73  if( category != m_category ) {
74  m_category = category;
75  emit categoryChanged();
76  }
77 }
78 
79 QString FoursquareItem::address() const
80 {
81  return m_address;
82 }
83 
84 void FoursquareItem::setAddress(const QString& address)
85 {
86  if( address != m_address ) {
87  m_address = address;
88  emit addressChanged();
89  }
90 }
91 
92 QString FoursquareItem::city() const
93 {
94  return m_city;
95 }
96 void FoursquareItem::setCity(const QString& city)
97 {
98  if( city != m_city ) {
99  m_city = city;
100  emit cityChanged();
101  }
102 }
103 
104 QString FoursquareItem::country() const
105 {
106  return m_country;
107 }
108 
109 void FoursquareItem::setCountry(const QString& country)
110 {
111  if( country != m_country ) {
112  m_country = country;
113  emit countryChanged();
114  }
115 }
116 
117 int FoursquareItem::usersCount() const
118 {
119  return m_usersCount;
120 }
121 
122 void FoursquareItem::setUsersCount(const int count)
123 {
124  if( count != m_usersCount ) {
125  m_usersCount = count;
126  emit usersCountChanged();
127  }
128 }
129 
130 QString FoursquareItem::categoryIconUrl() const
131 {
132  return m_categoryIconUrl;
133 }
134 
135 void FoursquareItem::setCategoryIconUrl(const QString& url)
136 {
137  if( url != m_categoryIconUrl ) {
138  m_categoryIconUrl = url;
139  emit categoryIconUrlChanged();
140  }
141 }
142 
143 QString FoursquareItem::categoryLargeIconUrl() const
144 {
145  return m_categoryLargeIconUrl;
146 }
147 
148 void FoursquareItem::setCategoryLargeIconUrl(const QString& url)
149 {
150  if( url != m_categoryLargeIconUrl ) {
151  m_categoryLargeIconUrl = url;
152  emit categoryLargeIconUrlChanged();
153  }
154 }
155 
156 void FoursquareItem::paint( QPainter* painter )
157 {
158  // Save the old painter state.
159  painter->save();
160  painter->setPen( QPen( QColor( Qt::white ) ) );
161  painter->setFont( s_font );
162 
163  // Draw the text into the given rect.
164  QRect rect = QRect( QPoint( 0, 0 ), size().toSize() );
165  QRect boundingRect = QRect( QPoint( rect.top(), rect.left() ), QSize( rect.width(), rect.height() ) );
166  QPainterPath painterPath;
167  painterPath.addRoundedRect( boundingRect, 5, 5 );
168  painter->setClipPath( painterPath );
169  painter->drawPath( painterPath );
170  painter->fillPath( painterPath, QBrush( QColor( "#39AC39" ) ) );
171  painter->drawText( rect.adjusted( 5, 5, -5, -5 ), 0, m_name );
172 
173  painter->restore();
174 }
175 
176 }
177 
178 #include "FoursquareItem.moc"
QPainter
Marble::FoursquareItem
Definition: FoursquareItem.h:20
Marble::FoursquareItem::setCategory
void setCategory(const QString &category)
Definition: FoursquareItem.cpp:71
Marble::MarbleGraphicsItem::setSize
void setSize(const QSizeF &size)
Set the size of the item.
Definition: MarbleGraphicsItem.cpp:197
Marble::FoursquareItem::usersCount
int usersCount() const
Marble::AbstractDataPluginItem
Definition: AbstractDataPluginItem.h:28
Marble::FoursquareItem::addressChanged
void addressChanged()
Marble::FoursquareItem::usersCountChanged
void usersCountChanged()
Marble::FoursquareItem::setCategoryLargeIconUrl
void setCategoryLargeIconUrl(const QString &url)
Definition: FoursquareItem.cpp:148
Marble::MarbleGraphicsItem::size
QSizeF size() const
Returns the size of the item.
Definition: MarbleGraphicsItem.cpp:136
Marble::FoursquareItem::operator<
bool operator<(const AbstractDataPluginItem *other) const
Definition: FoursquareItem.cpp:45
QObject
Marble::FoursquareItem::initialized
bool initialized() const
Definition: FoursquareItem.cpp:39
Marble::FoursquareItem::countryChanged
void countryChanged()
Marble::FoursquareItem::setName
void setName(const QString &name)
Definition: FoursquareItem.cpp:56
Marble::FoursquareItem::address
QString address() const
Marble::FoursquareItem::categoryLargeIconUrlChanged
void categoryLargeIconUrlChanged()
Marble::FoursquareItem::~FoursquareItem
~FoursquareItem()
Definition: FoursquareItem.cpp:30
GeoPainter.h
Marble::FoursquareItem::setAddress
void setAddress(const QString &address)
Definition: FoursquareItem.cpp:84
Marble::FoursquareItem::category
QString category() const
Marble::FoursquareItem::categoryIconUrlChanged
void categoryIconUrlChanged()
Marble::FoursquareItem::categoryLargeIconUrl
QString categoryLargeIconUrl() const
Marble::FoursquareItem::setUsersCount
void setUsersCount(const int count)
Definition: FoursquareItem.cpp:122
Marble::FoursquareItem::categoryIconUrl
QString categoryIconUrl() const
ViewportParams.h
This file contains the headers for ViewportParams.
Marble::FoursquareItem::setCountry
void setCountry(const QString &country)
Definition: FoursquareItem.cpp:109
Marble::FoursquareItem::setCity
void setCity(const QString &city)
Definition: FoursquareItem.cpp:96
Marble::FoursquareItem::name
QString name() const
Marble::FoursquareItem::FoursquareItem
FoursquareItem(QObject *parent=0)
Definition: FoursquareItem.cpp:24
Marble::FoursquareItem::city
QString city() const
Marble::FoursquareItem::country
QString country() const
Marble::FoursquareItem::categoryChanged
void categoryChanged()
FoursquareItem.h
Marble::FoursquareItem::nameChanged
void nameChanged()
Marble::FoursquareItem::setCategoryIconUrl
void setCategoryIconUrl(const QString &url)
Definition: FoursquareItem.cpp:135
Marble::FoursquareItem::paint
void paint(QPainter *painter)
Paints the item in item coordinates.
Definition: FoursquareItem.cpp:156
Marble::FoursquareItem::usersCount
QString usersCount
Definition: FoursquareItem.h:29
Marble::FoursquareItem::cityChanged
void cityChanged()
Marble::FoursquareItem::itemType
QString itemType() const
Returns the type of this specific item.
Definition: FoursquareItem.cpp:34
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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