• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • objects
bogus_imp.cc
Go to the documentation of this file.
1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
2 
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 // 02110-1301, USA.
17 
18 #include "bogus_imp.h"
19 
20 #include <qstringlist.h>
21 #include <klocale.h>
22 
23 #include "../misc/rect.h"
24 
25 Coordinate BogusImp::attachPoint( ) const
26 {
27  return Coordinate::invalidCoord();
28 }
29 
30 void BogusImp::draw( KigPainter& ) const
31 {
32 }
33 
34 bool BogusImp::contains( const Coordinate&, int, const KigWidget& ) const
35 {
36  return false;
37 }
38 
39 bool BogusImp::inRect( const Rect&, int, const KigWidget& ) const
40 {
41  return false;
42 }
43 
44 DoubleImp::DoubleImp( const double d )
45  : mdata( d )
46 {
47 }
48 
49 IntImp::IntImp( const int d )
50  : mdata( d )
51 {
52 }
53 
54 StringImp::StringImp( const QString& d )
55  : mdata( d )
56 {
57 }
58 
59 DoubleImp* DoubleImp::copy() const
60 {
61  return new DoubleImp( mdata );
62 }
63 
64 IntImp* IntImp::copy() const
65 {
66  return new IntImp( mdata );
67 }
68 
69 StringImp* StringImp::copy() const
70 {
71  return new StringImp( mdata );
72 }
73 
74 ObjectImp* BogusImp::transform( const Transformation& ) const
75 {
76  return copy();
77 }
78 
79 InvalidImp* InvalidImp::copy() const
80 {
81  return new InvalidImp();
82 }
83 
84 InvalidImp::InvalidImp()
85 {
86 }
87 
88 void InvalidImp::fillInNextEscape( QString& s, const KigDocument& ) const
89 {
90  s = s.arg( "[invalid]" );
91 }
92 
93 void DoubleImp::fillInNextEscape( QString& s, const KigDocument& ) const
94 {
95  s = s.arg( mdata );
96 }
97 
98 void IntImp::fillInNextEscape( QString& s, const KigDocument& ) const
99 {
100  s = s.arg( mdata );
101 }
102 
103 void StringImp::fillInNextEscape( QString& s, const KigDocument& ) const
104 {
105  s = s.arg( mdata );
106 }
107 
108 HierarchyImp::HierarchyImp( const ObjectHierarchy& h )
109  : BogusImp(), mdata( h )
110 {
111 }
112 
113 HierarchyImp* HierarchyImp::copy() const
114 {
115  return new HierarchyImp( mdata );
116 }
117 
118 void InvalidImp::visit( ObjectImpVisitor* vtor ) const
119 {
120  vtor->visit( this );
121 }
122 
123 void DoubleImp::visit( ObjectImpVisitor* vtor ) const
124 {
125  vtor->visit( this );
126 }
127 
128 void IntImp::visit( ObjectImpVisitor* vtor ) const
129 {
130  vtor->visit( this );
131 }
132 
133 void StringImp::visit( ObjectImpVisitor* vtor ) const
134 {
135  vtor->visit( this );
136 }
137 
138 void HierarchyImp::visit( ObjectImpVisitor* vtor ) const
139 {
140  vtor->visit( this );
141 }
142 
143 TransformationImp::TransformationImp( const Transformation& h )
144  : mdata( h )
145 {
146 }
147 
148 TransformationImp* TransformationImp::copy() const
149 {
150  return new TransformationImp( mdata );
151 }
152 
153 void TransformationImp::visit( ObjectImpVisitor* vtor ) const
154 {
155  vtor->visit( this );
156 }
157 
158 bool InvalidImp::equals( const ObjectImp& rhs ) const
159 {
160  return !rhs.valid();
161 }
162 
163 bool DoubleImp::equals( const ObjectImp& rhs ) const
164 {
165  return rhs.inherits( DoubleImp::stype() ) &&
166  static_cast<const DoubleImp&>( rhs ).data() == mdata;
167 }
168 
169 bool IntImp::equals( const ObjectImp& rhs ) const
170 {
171  return rhs.inherits( IntImp::stype() ) &&
172  static_cast<const IntImp&>( rhs ).data() == mdata;
173 }
174 
175 bool StringImp::equals( const ObjectImp& rhs ) const
176 {
177  return rhs.inherits( StringImp::stype() ) &&
178  static_cast<const StringImp&>( rhs ).data() == mdata;
179 }
180 
181 bool HierarchyImp::equals( const ObjectImp& rhs ) const
182 {
183  return rhs.inherits( HierarchyImp::stype() ) &&
184  static_cast<const HierarchyImp&>( rhs ).data() == mdata;
185 }
186 
187 bool TransformationImp::equals( const ObjectImp& rhs ) const
188 {
189  return rhs.inherits( TransformationImp::stype() ) &&
190  static_cast<const TransformationImp&>( rhs ).data() == mdata;
191 }
192 
193 bool InvalidImp::canFillInNextEscape() const
194 {
195  return true;
196 }
197 
198 bool DoubleImp::canFillInNextEscape() const
199 {
200  return true;
201 }
202 
203 bool IntImp::canFillInNextEscape() const
204 {
205  return true;
206 }
207 
208 bool StringImp::canFillInNextEscape() const
209 {
210  return true;
211 }
212 
213 const ObjectImpType* InvalidImp::stype()
214 {
215  static const ObjectImpType t(
216  Parent::stype(), "invalid", "", "", "", "", "", "", "", "", "" );
217  return &t;
218 }
219 
220 const ObjectImpType* StringImp::stype()
221 {
222  static const ObjectImpType t(
223  Parent::stype(), "string",
224  "string", "", "", "", "", "", "", "", "" );
225  return &t;
226 }
227 const ObjectImpType* HierarchyImp::stype()
228 {
229  static const ObjectImpType t(
230  Parent::stype(), "hierarchy", "", "", "", "", "", "", "", "", "" );
231  return &t;
232 }
233 const ObjectImpType* TransformationImp::stype()
234 {
235  static const ObjectImpType t(
236  Parent::stype(), "transformation", "", "", "", "", "", "", "", "", "");
237  return &t;
238 }
239 
240 const ObjectImpType* InvalidImp::type() const
241 {
242  return InvalidImp::stype();
243 }
244 
245 const ObjectImpType* DoubleImp::type() const
246 {
247  return DoubleImp::stype();
248 }
249 
250 const ObjectImpType* IntImp::type() const
251 {
252  return IntImp::stype();
253 }
254 
255 const ObjectImpType* StringImp::type() const
256 {
257  return StringImp::stype();
258 }
259 
260 const ObjectImpType* HierarchyImp::type() const
261 {
262  return HierarchyImp::stype();
263 }
264 
265 const ObjectImpType* TransformationImp::type() const
266 {
267  return TransformationImp::stype();
268 }
269 
270 const ObjectImpType* DoubleImp::stype()
271 {
272  static const ObjectImpType t(
273  Parent::stype(), "double",
274  "double", "", "", "", "", "", "", "", "" );
275  return &t;
276 }
277 
278 const ObjectImpType* IntImp::stype()
279 {
280  static const ObjectImpType t(
281  Parent::stype(), "int",
282  "int", "", "", "", "", "", "", "", "" );
283  return &t;
284 }
285 
286 const ObjectImpType* BogusImp::stype()
287 {
288  static const ObjectImpType t(
289  Parent::stype(), "bogus",
290  "", "", "", "", "", "", "", "", "" );
291  return &t;
292 }
293 
294 const ObjectImpType* TestResultImp::stype()
295 {
296  static const ObjectImpType t(
297  Parent::stype(), "testresult", "", "", "", "", "", "", "", "", "" );
298  return &t;
299 
300 }
301 
302 TestResultImp::TestResultImp( bool t, const QString& s )
303  : StringImp( s ), mtruth( t )
304 {
305 }
306 
307 TestResultImp* TestResultImp::copy() const
308 {
309  return new TestResultImp( mtruth, data() );
310 }
311 
312 const ObjectImpType* TestResultImp::type() const
313 {
314  return stype();
315 }
316 
317 void TestResultImp::visit( ObjectImpVisitor* vtor ) const
318 {
319  vtor->visit( this );
320 }
321 
322 bool TestResultImp::equals( const ObjectImp& rhs ) const
323 {
324  return rhs.inherits( TestResultImp::stype() ) &&
325 // (FIXME?) static_cast<const TestResultImp&>( rhs ).mdata == mdata &&
326  static_cast<const TestResultImp&>( rhs ).mtruth == mtruth;
327 
328 }
329 
330 int TestResultImp::numberOfProperties() const
331 {
332  return Parent::numberOfProperties() + 1;
333 }
334 
335 const QByteArrayList TestResultImp::properties() const
336 {
337  QByteArrayList l = Parent::properties();
338  l << I18N_NOOP( "Test Result" );
339  assert( l.size() == TestResultImp::numberOfProperties() );
340  return l;
341 }
342 
343 const QByteArrayList TestResultImp::propertiesInternalNames() const
344 {
345  QByteArrayList s = Parent::propertiesInternalNames();
346  s << "test-result";
347  assert( s.size() == TestResultImp::numberOfProperties() );
348  return s;
349 }
350 
351 ObjectImp* TestResultImp::property( int which, const KigDocument& d ) const
352 {
353  if ( which < Parent::numberOfProperties() )
354  return Parent::property( which, d );
355  if ( which == Parent::numberOfProperties() )
356  return new StringImp( data() );
357  else assert( false );
358  return new InvalidImp;
359 }
360 
361 const char* TestResultImp::iconForProperty( int which ) const
362 {
363  if ( which < Parent::numberOfProperties() )
364  return Parent::iconForProperty( which );
365  if ( which == Parent::numberOfProperties() )
366  return ""; // test-result
367  else assert( false );
368  return "";
369 }
370 
371 const ObjectImpType* TestResultImp::impRequirementForProperty( int which ) const
372 {
373  if ( which < Parent::numberOfProperties() )
374  return Parent::impRequirementForProperty( which );
375  else return TestResultImp::stype();
376 }
377 
378 bool TestResultImp::isPropertyDefinedOnOrThroughThisImp( int which ) const
379 {
380  if ( which < Parent::numberOfProperties() )
381  return Parent::impRequirementForProperty( which );
382  else return false;
383 }
384 
385 Rect BogusImp::surroundingRect() const
386 {
387  return Rect::invalidRect();
388 }
HierarchyImp::stype
static const ObjectImpType * stype()
Definition: bogus_imp.cc:227
DoubleImp::fillInNextEscape
void fillInNextEscape(QString &s, const KigDocument &) const
Definition: bogus_imp.cc:93
InvalidImp::copy
InvalidImp * copy() const
Returns a copy of this ObjectImp.
Definition: bogus_imp.cc:79
ObjectImpType
Instances of this class represent a certain ObjectImp type.
Definition: object_imp.h:95
TestResultImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bogus_imp.cc:322
ObjectImp::inherits
bool inherits(const ObjectImpType *t) const
Returns true if this ObjectImp inherits the ObjectImp type represented by t.
Definition: object_imp.cc:279
BogusImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the BogusImp type.
Definition: bogus_imp.cc:286
DoubleImp::DoubleImp
DoubleImp(const double d)
Construct a new DoubleImp containing the value d.
Definition: bogus_imp.cc:44
ObjectHierarchy
Definition: object_hierarchy.h:30
IntImp::fillInNextEscape
void fillInNextEscape(QString &s, const KigDocument &) const
Definition: bogus_imp.cc:98
BogusImp::transform
ObjectImp * transform(const Transformation &) const
Return this ObjectImp, transformed by the transformation t.
Definition: bogus_imp.cc:74
StringImp::data
const QString & data() const
Get hold of the contained data.
Definition: bogus_imp.h:186
StringImp
This ObjectImp is a BogusImp containing only a string value.
Definition: bogus_imp.h:167
HierarchyImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bogus_imp.cc:181
TestResultImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bogus_imp.cc:312
StringImp::fillInNextEscape
void fillInNextEscape(QString &s, const KigDocument &) const
Definition: bogus_imp.cc:103
TestResultImp::propertiesInternalNames
const QByteArrayList propertiesInternalNames() const
Definition: bogus_imp.cc:343
BogusImp::attachPoint
Coordinate attachPoint() const
Returns a reference point where to attach labels; when this returns an invalidCoord then the attachme...
Definition: bogus_imp.cc:25
DoubleImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bogus_imp.cc:163
HierarchyImp::copy
HierarchyImp * copy() const
Returns a copy of this ObjectImp.
Definition: bogus_imp.cc:113
ObjectImpVisitor::visit
void visit(const ObjectImp *imp)
Definition: object_imp.cc:81
InvalidImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bogus_imp.cc:118
ObjectImp::impRequirementForProperty
virtual const ObjectImpType * impRequirementForProperty(int which) const
Definition: object_imp.cc:76
IntImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bogus_imp.cc:169
TestResultImp::properties
const QByteArrayList properties() const
Definition: bogus_imp.cc:335
ObjectImp::property
virtual ObjectImp * property(int which, const KigDocument &d) const
Definition: object_imp.cc:70
IntImp::copy
IntImp * copy() const
Returns a copy of this ObjectImp.
Definition: bogus_imp.cc:64
Rect
This file is part of Kig, a KDE program for Interactive Geometry...
Definition: rect.h:34
DoubleImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bogus_imp.cc:123
DoubleImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the DoubleImp type.
Definition: bogus_imp.cc:270
InvalidImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bogus_imp.cc:240
InvalidImp::fillInNextEscape
void fillInNextEscape(QString &s, const KigDocument &) const
Definition: bogus_imp.cc:88
TransformationImp::stype
static const ObjectImpType * stype()
Definition: bogus_imp.cc:233
StringImp::canFillInNextEscape
bool canFillInNextEscape() const
Definition: bogus_imp.cc:208
TestResultImp::impRequirementForProperty
const ObjectImpType * impRequirementForProperty(int which) const
Definition: bogus_imp.cc:371
DoubleImp::data
double data() const
Get hold of the contained data.
Definition: bogus_imp.h:108
BogusImp::inRect
bool inRect(const Rect &r, int width, const KigWidget &w) const
Definition: bogus_imp.cc:39
IntImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the IntImp type.
Definition: bogus_imp.cc:278
ObjectImp::propertiesInternalNames
virtual const QByteArrayList propertiesInternalNames() const
Definition: object_imp.cc:63
ObjectImp::stype
static const ObjectImpType * stype()
The ObjectImpType representing the base ObjectImp class.
Definition: object_imp.cc:284
IntImp
This ObjectImp is a BogusImp containing only an int value.
Definition: bogus_imp.h:128
StringImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bogus_imp.cc:255
Rect::invalidRect
static Rect invalidRect()
Definition: rect.cc:305
BogusImp
This is the base class for the so-called BogusImp's.
Definition: bogus_imp.h:37
Coordinate
The Coordinate class is the basic class representing a 2D location by its x and y components...
Definition: coordinate.h:33
HierarchyImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bogus_imp.cc:138
BogusImp::surroundingRect
Rect surroundingRect() const
Definition: bogus_imp.cc:385
BogusImp::draw
void draw(KigPainter &p) const
Definition: bogus_imp.cc:30
InvalidImp::InvalidImp
InvalidImp()
Construct a new InvalidImp.
Definition: bogus_imp.cc:84
ObjectImp::iconForProperty
virtual const char * iconForProperty(int which) const
Definition: object_imp.cc:187
InvalidImp::canFillInNextEscape
bool canFillInNextEscape() const
Definition: bogus_imp.cc:193
IntImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bogus_imp.cc:128
TestResultImp::copy
TestResultImp * copy() const
Returns a copy of this ObjectImp.
Definition: bogus_imp.cc:307
KigPainter
KigPainter is an extended QPainter.
Definition: kigpainter.h:51
TestResultImp::numberOfProperties
int numberOfProperties() const
Definition: bogus_imp.cc:330
bogus_imp.h
TestResultImp::stype
static const ObjectImpType * stype()
Definition: bogus_imp.cc:294
StringImp::StringImp
StringImp(const QString &d)
Construct a new StringImp containing the string d.
Definition: bogus_imp.cc:54
BogusImp::contains
bool contains(const Coordinate &p, int width, const KigWidget &w) const
Definition: bogus_imp.cc:34
Transformation
Class representing a transformation.
Definition: kigtransform.h:37
DoubleImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bogus_imp.cc:245
KigWidget
This class is the real widget showing the document.
Definition: kig_view.h:50
TransformationImp
Definition: bogus_imp.h:232
HierarchyImp
Definition: bogus_imp.h:203
IntImp::data
int data() const
Get hold of the contained data.
Definition: bogus_imp.h:147
IntImp::IntImp
IntImp(const int d)
Construct a new IntImp containing the value d.
Definition: bogus_imp.cc:49
TestResultImp::isPropertyDefinedOnOrThroughThisImp
bool isPropertyDefinedOnOrThroughThisImp(int which) const
Definition: bogus_imp.cc:378
HierarchyImp::HierarchyImp
HierarchyImp(const ObjectHierarchy &h)
Definition: bogus_imp.cc:108
TransformationImp::copy
TransformationImp * copy() const
Returns a copy of this ObjectImp.
Definition: bogus_imp.cc:148
TestResultImp::property
ObjectImp * property(int which, const KigDocument &d) const
Definition: bogus_imp.cc:351
HierarchyImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bogus_imp.cc:260
InvalidImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the InvalidImp type.
Definition: bogus_imp.cc:213
Coordinate::invalidCoord
static Coordinate invalidCoord()
Create an invalid Coordinate.
Definition: coordinate.cpp:171
StringImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bogus_imp.cc:133
TransformationImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bogus_imp.cc:187
HierarchyImp::data
const ObjectHierarchy & data() const
Definition: bogus_imp.h:213
TestResultImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bogus_imp.cc:317
DoubleImp
This ObjectImp is a BogusImp containing only a double value.
Definition: bogus_imp.h:89
KigDocument
KigDocument is the class holding the real data in a Kig document.
Definition: kig_document.h:36
TestResultImp::iconForProperty
const char * iconForProperty(int which) const
Definition: bogus_imp.cc:361
StringImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bogus_imp.cc:175
StringImp::stype
static const ObjectImpType * stype()
Returns the ObjectImpType representing the StringImp type.
Definition: bogus_imp.cc:220
ObjectImp::copy
virtual ObjectImp * copy() const =0
Returns a copy of this ObjectImp.
IntImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bogus_imp.cc:250
TransformationImp::visit
void visit(ObjectImpVisitor *vtor) const
Definition: bogus_imp.cc:153
DoubleImp::canFillInNextEscape
bool canFillInNextEscape() const
Definition: bogus_imp.cc:198
QByteArrayList
QList< QByteArray > QByteArrayList
Definition: objects/common.h:50
IntImp::canFillInNextEscape
bool canFillInNextEscape() const
Definition: bogus_imp.cc:203
TransformationImp::TransformationImp
TransformationImp(const Transformation &h)
Definition: bogus_imp.cc:143
ObjectImp
The ObjectImp class represents the behaviour of an object after it is calculated. ...
Definition: object_imp.h:226
ObjectImp::valid
bool valid() const
Returns true if this is a valid ObjectImp.
Definition: object_imp.cc:41
TestResultImp::TestResultImp
TestResultImp(bool truth, const QString &s)
Definition: bogus_imp.cc:302
StringImp::copy
StringImp * copy() const
Returns a copy of this ObjectImp.
Definition: bogus_imp.cc:69
InvalidImp::equals
bool equals(const ObjectImp &rhs) const
Returns true if this ObjectImp is equal to rhs.
Definition: bogus_imp.cc:158
TransformationImp::data
const Transformation & data() const
Definition: bogus_imp.h:242
TransformationImp::type
const ObjectImpType * type() const
Returns the lowermost ObjectImpType that this object is an instantiation of.
Definition: bogus_imp.cc:265
TestResultImp
Definition: bogus_imp.h:253
ObjectImp::numberOfProperties
virtual int numberOfProperties() const
Definition: object_imp.cc:58
ObjectImpVisitor
Definition: object_imp.h:56
DoubleImp::copy
DoubleImp * copy() const
Returns a copy of this ObjectImp.
Definition: bogus_imp.cc:59
ObjectImp::properties
virtual const QByteArrayList properties() const
Definition: object_imp.cc:51
InvalidImp
This ObjectImp represents an invalid object.
Definition: bogus_imp.h:61
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

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