• 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
  • lib
  • marble
  • geodata
  • data
GeoDataListStyle.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 Mohammed Nafees <nafees.technocool@gmail.com>
9 //
10 
11 #include "GeoDataListStyle.h"
12 #include "GeoDataTypes.h"
13 #include "MarbleDirs.h"
14 
15 namespace Marble
16 {
17 
18 class GeoDataListStylePrivate
19 {
20 public:
21  GeoDataListStylePrivate();
22 
23  GeoDataListStyle::ListItemType m_listItemType;
24  QColor m_bgColor;
25 
26  QVector<GeoDataItemIcon*> m_vector;
27 };
28 
29 GeoDataListStylePrivate::GeoDataListStylePrivate() :
30  m_listItemType( GeoDataListStyle::Check ),
31  m_bgColor( Qt::white )
32 {
33 }
34 
35 GeoDataListStyle::GeoDataListStyle() :
36  d( new GeoDataListStylePrivate )
37 {
38 }
39 
40 GeoDataListStyle::GeoDataListStyle( const Marble::GeoDataListStyle &other ) :
41  GeoDataObject( other ), d( new GeoDataListStylePrivate( *other.d ) )
42 {
43 }
44 
45 GeoDataListStyle &GeoDataListStyle::operator=( const GeoDataListStyle &other )
46 {
47  GeoDataObject::operator=(other);
48  *d = *other.d;
49  return *this;
50 }
51 
52 bool GeoDataListStyle::operator==( const GeoDataListStyle &other ) const
53 {
54  if ( !GeoDataObject::equals( other ) ||
55  d->m_bgColor != other.d->m_bgColor ||
56  d->m_listItemType != other.d->m_listItemType ||
57  d->m_vector.size() != other.d->m_vector.size() )
58  {
59  return false;
60  }
61 
62  QVector<GeoDataItemIcon*>::const_iterator begin = d->m_vector.constBegin();
63  QVector<GeoDataItemIcon*>::const_iterator end = d->m_vector.constEnd();
64  QVector<GeoDataItemIcon*>::const_iterator otherBegin = other.d->m_vector.constBegin();
65 
66  for( ; begin != end; ++begin, ++otherBegin ) {
67  if ( **begin != **otherBegin ) {
68  return false;
69  }
70  }
71 
72  return true;
73 }
74 
75 bool GeoDataListStyle::operator!=( const GeoDataListStyle &other ) const
76 {
77  return !this->operator==( other );
78 }
79 
80 GeoDataListStyle::~GeoDataListStyle()
81 {
82  delete d;
83 }
84 
85 const char *GeoDataListStyle::nodeType() const
86 {
87  return GeoDataTypes::GeoDataListStyleType;
88 }
89 
90 GeoDataListStyle::ListItemType GeoDataListStyle::listItemType() const
91 {
92  return d->m_listItemType;
93 }
94 
95 void GeoDataListStyle::setListItemType( const ListItemType &type )
96 {
97  d->m_listItemType = type;
98 }
99 
100 QColor GeoDataListStyle::backgroundColor() const
101 {
102  return d->m_bgColor;
103 }
104 
105 void GeoDataListStyle::setBackgroundColor( const QColor &color )
106 {
107  d->m_bgColor = color;
108 }
109 
110 QVector<GeoDataItemIcon*> GeoDataListStyle::itemIconList() const
111 {
112  return d->m_vector;
113 }
114 
115 GeoDataItemIcon* GeoDataListStyle::child( int i )
116 {
117  return d->m_vector.at(i);
118 }
119 
120 const GeoDataItemIcon* GeoDataListStyle::child( int i ) const
121 {
122  return d->m_vector.at(i);
123 }
124 
125 int GeoDataListStyle::childPosition( const GeoDataItemIcon* object ) const
126 {
127  return d->m_vector.indexOf( const_cast<GeoDataItemIcon *>( object ) );
128 }
129 
130 void GeoDataListStyle::append( GeoDataItemIcon *other )
131 {
132  other->setParent( this );
133  d->m_vector.append( other );
134 }
135 
136 
137 void GeoDataListStyle::remove( int index )
138 {
139  d->m_vector.remove( index );
140 }
141 
142 int GeoDataListStyle::size() const
143 {
144  return d->m_vector.size();
145 }
146 
147 GeoDataItemIcon& GeoDataListStyle::at( int pos )
148 {
149  return *(d->m_vector[ pos ]);
150 }
151 
152 const GeoDataItemIcon& GeoDataListStyle::at( int pos ) const
153 {
154  return *(d->m_vector.at( pos ));
155 }
156 
157 GeoDataItemIcon& GeoDataListStyle::last()
158 {
159  return *(d->m_vector.last());
160 }
161 
162 const GeoDataItemIcon& GeoDataListStyle::last() const
163 {
164  return *(d->m_vector.last());
165 }
166 
167 GeoDataItemIcon& GeoDataListStyle::first()
168 {
169  return *(d->m_vector.first());
170 }
171 
172 const GeoDataItemIcon& GeoDataListStyle::first() const
173 {
174  return *(d->m_vector.first());
175 }
176 
177 void GeoDataListStyle::clear()
178 {
179  qDeleteAll(d->m_vector);
180  d->m_vector.clear();
181 }
182 
183 QVector<GeoDataItemIcon*>::Iterator GeoDataListStyle::begin()
184 {
185  return d->m_vector.begin();
186 }
187 
188 QVector<GeoDataItemIcon*>::Iterator GeoDataListStyle::end()
189 {
190  return d->m_vector.end();
191 }
192 
193 QVector<GeoDataItemIcon*>::ConstIterator GeoDataListStyle::constBegin() const
194 {
195  return d->m_vector.constBegin();
196 }
197 
198 QVector<GeoDataItemIcon*>::ConstIterator GeoDataListStyle::constEnd() const
199 {
200  return d->m_vector.constEnd();
201 }
202 
203 void GeoDataListStyle::pack( QDataStream& stream ) const
204 {
205  GeoDataObject::pack( stream );
206  stream << d->m_vector.count();
207 
208  for ( QVector <GeoDataItemIcon*>::const_iterator iterator = d->m_vector.constBegin();
209  iterator != d->m_vector.constEnd();
210  ++iterator )
211  {
212  const GeoDataItemIcon *itemIcon = *iterator;
213  itemIcon->pack( stream );
214  }
215 }
216 
217 void GeoDataListStyle::unpack( QDataStream& stream )
218 {
219  GeoDataObject::unpack( stream );
220 
221  int count;
222  stream >> count;
223 
224  int featureId;
225  stream >> featureId;
226 
227  GeoDataItemIcon *itemIcon = new GeoDataItemIcon;
228  itemIcon->unpack( stream );
229  d->m_vector.append( itemIcon );
230 }
231 
232 }
GeoDataListStyle.h
Marble::GeoDataListStyle::childPosition
int childPosition(const GeoDataItemIcon *child) const
Definition: GeoDataListStyle.cpp:125
Marble::GeoDataListStyle::begin
QVector< GeoDataItemIcon * >::Iterator begin()
Definition: GeoDataListStyle.cpp:183
Marble::GeoDataListStyle::first
GeoDataItemIcon & first()
Definition: GeoDataListStyle.cpp:167
Marble::GeoDataListStyle::GeoDataItemIcon
friend class GeoDataItemIcon
Definition: GeoDataListStyle.h:92
Marble::GeoDataListStyle::~GeoDataListStyle
~GeoDataListStyle()
Definition: GeoDataListStyle.cpp:80
QDataStream
Marble::GeoDataItemIcon
Definition: GeoDataItemIcon.h:24
Marble::GeoDataListStyle::clear
void clear()
Definition: GeoDataListStyle.cpp:177
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::GeoDataListStyle::setBackgroundColor
void setBackgroundColor(const QColor &color)
Definition: GeoDataListStyle.cpp:105
Marble::GeoDataObject::equals
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
Definition: GeoDataObject.cpp:126
Marble::GeoDataObject::pack
virtual void pack(QDataStream &stream) const
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:114
Marble::GeoDataListStyle::child
GeoDataItemIcon * child(int)
Definition: GeoDataListStyle.cpp:115
Marble::GeoDataListStyle::operator!=
bool operator!=(const GeoDataListStyle &other) const
Definition: GeoDataListStyle.cpp:75
Marble::GeoDataObject::setParent
virtual void setParent(GeoDataObject *parent)
Sets the parent of the object.
Definition: GeoDataObject.cpp:70
Marble::GeoDataListStyle::last
GeoDataItemIcon & last()
Definition: GeoDataListStyle.cpp:157
Marble::GeoDataListStyle::at
GeoDataItemIcon & at(int pos)
Definition: GeoDataListStyle.cpp:147
Marble::GeoDataListStyle::setListItemType
void setListItemType(const ListItemType &type)
Definition: GeoDataListStyle.cpp:95
Marble::GeoDataListStyle::itemIconList
QVector< GeoDataItemIcon * > itemIconList() const
Definition: GeoDataListStyle.cpp:110
Marble::GeoDataListStyle::operator==
bool operator==(const GeoDataListStyle &other) const
Definition: GeoDataListStyle.cpp:52
MarbleDirs.h
Marble::GeoDataListStyle::backgroundColor
QColor backgroundColor() const
Definition: GeoDataListStyle.cpp:100
Marble::GeoDataListStyle::ListItemType
ListItemType
Definition: GeoDataListStyle.h:45
Marble::GeoDataListStyle::size
int size() const
Definition: GeoDataListStyle.cpp:142
Marble::GeoDataListStyle::end
QVector< GeoDataItemIcon * >::Iterator end()
Definition: GeoDataListStyle.cpp:188
Marble::GeoDataListStyle::unpack
virtual void unpack(QDataStream &stream)
Reimplemented from Serializable.
Definition: GeoDataListStyle.cpp:217
QColor
Marble::GeoDataListStyle::constBegin
QVector< GeoDataItemIcon * >::ConstIterator constBegin() const
Definition: GeoDataListStyle.cpp:193
QVector
Marble::GeoDataObject::operator=
GeoDataObject & operator=(const GeoDataObject &)
Definition: GeoDataObject.cpp:54
Marble::GeoDataListStyle::listItemType
ListItemType listItemType() const
Definition: GeoDataListStyle.cpp:90
Marble::GeoDataListStyle::operator=
GeoDataListStyle & operator=(const GeoDataListStyle &other)
Definition: GeoDataListStyle.cpp:45
Marble::GeoDataListStyle::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoNode.
Definition: GeoDataListStyle.cpp:85
Marble::GeoDataTypes::GeoDataListStyleType
const char * GeoDataListStyleType
Definition: GeoDataTypes.cpp:90
Marble::GeoDataObject::unpack
virtual void unpack(QDataStream &steam)
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:120
Marble::GeoDataListStyle::remove
void remove(int index)
Definition: GeoDataListStyle.cpp:137
GeoDataTypes.h
Marble::GeoDataListStyle::pack
virtual void pack(QDataStream &stream) const
Reimplemented from Serializable.
Definition: GeoDataListStyle.cpp:203
Marble::GeoDataListStyle::constEnd
QVector< GeoDataItemIcon * >::ConstIterator constEnd() const
Definition: GeoDataListStyle.cpp:198
Marble::GeoDataListStyle::append
void append(GeoDataItemIcon *other)
Definition: GeoDataListStyle.cpp:130
Marble::GeoDataListStyle::GeoDataListStyle
GeoDataListStyle()
Definition: GeoDataListStyle.cpp:35
Marble::GeoDataListStyle
Definition: GeoDataListStyle.h:28
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