moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kig / objects / bogus_imp.cc
blob4cd4396bb28309935990d6b3f9558364faa5f949
1 // Copyright (C) 2002 Dominique Devriese <devriese@kde.org>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA
16 // 02111-1307, USA.
18 #include "bogus_imp.h"
20 #include <qcstring.h>
21 #include <qstringlist.h>
22 #include <klocale.h>
24 #include "../misc/rect.h"
26 Coordinate BogusImp::attachPoint( ) const
28 return Coordinate::invalidCoord();
31 void BogusImp::draw( KigPainter& ) const
35 bool BogusImp::contains( const Coordinate&, int, const KigWidget& ) const
37 return false;
40 bool BogusImp::inRect( const Rect&, int, const KigWidget& ) const
42 return false;
45 DoubleImp::DoubleImp( const double d )
46 : mdata( d )
50 IntImp::IntImp( const int d )
51 : mdata( d )
55 StringImp::StringImp( const QString& d )
56 : mdata( d )
60 DoubleImp* DoubleImp::copy() const
62 return new DoubleImp( mdata );
65 IntImp* IntImp::copy() const
67 return new IntImp( mdata );
70 StringImp* StringImp::copy() const
72 return new StringImp( mdata );
75 ObjectImp* BogusImp::transform( const Transformation& ) const
77 return copy();
80 InvalidImp* InvalidImp::copy() const
82 return new InvalidImp();
85 InvalidImp::InvalidImp()
89 void InvalidImp::fillInNextEscape( QString& s, const KigDocument& ) const
91 s = s.arg( "[invalid]" );
94 void DoubleImp::fillInNextEscape( QString& s, const KigDocument& ) const
96 s = s.arg( mdata );
99 void IntImp::fillInNextEscape( QString& s, const KigDocument& ) const
101 s = s.arg( mdata );
104 void StringImp::fillInNextEscape( QString& s, const KigDocument& ) const
106 s = s.arg( mdata );
109 HierarchyImp::HierarchyImp( const ObjectHierarchy& h )
110 : BogusImp(), mdata( h )
114 HierarchyImp* HierarchyImp::copy() const
116 return new HierarchyImp( mdata );
119 void InvalidImp::visit( ObjectImpVisitor* vtor ) const
121 vtor->visit( this );
124 void DoubleImp::visit( ObjectImpVisitor* vtor ) const
126 vtor->visit( this );
129 void IntImp::visit( ObjectImpVisitor* vtor ) const
131 vtor->visit( this );
134 void StringImp::visit( ObjectImpVisitor* vtor ) const
136 vtor->visit( this );
139 void HierarchyImp::visit( ObjectImpVisitor* vtor ) const
141 vtor->visit( this );
144 TransformationImp::TransformationImp( const Transformation& h )
145 : mdata( h )
149 TransformationImp* TransformationImp::copy() const
151 return new TransformationImp( mdata );
154 void TransformationImp::visit( ObjectImpVisitor* vtor ) const
156 vtor->visit( this );
159 bool InvalidImp::equals( const ObjectImp& rhs ) const
161 return !rhs.valid();
164 bool DoubleImp::equals( const ObjectImp& rhs ) const
166 return rhs.inherits( DoubleImp::stype() ) &&
167 static_cast<const DoubleImp&>( rhs ).data() == mdata;
170 bool IntImp::equals( const ObjectImp& rhs ) const
172 return rhs.inherits( IntImp::stype() ) &&
173 static_cast<const IntImp&>( rhs ).data() == mdata;
176 bool StringImp::equals( const ObjectImp& rhs ) const
178 return rhs.inherits( StringImp::stype() ) &&
179 static_cast<const StringImp&>( rhs ).data() == mdata;
182 bool HierarchyImp::equals( const ObjectImp& rhs ) const
184 return rhs.inherits( HierarchyImp::stype() ) &&
185 static_cast<const HierarchyImp&>( rhs ).data() == mdata;
188 bool TransformationImp::equals( const ObjectImp& rhs ) const
190 return rhs.inherits( TransformationImp::stype() ) &&
191 static_cast<const TransformationImp&>( rhs ).data() == mdata;
194 bool InvalidImp::canFillInNextEscape() const
196 return true;
199 bool DoubleImp::canFillInNextEscape() const
201 return true;
204 bool IntImp::canFillInNextEscape() const
206 return true;
209 bool StringImp::canFillInNextEscape() const
211 return true;
214 const ObjectImpType* InvalidImp::stype()
216 static const ObjectImpType t(
217 Parent::stype(), "invalid", "", "", "", "", "", "", "", "", "" );
218 return &t;
221 const ObjectImpType* StringImp::stype()
223 static const ObjectImpType t(
224 Parent::stype(), "string",
225 "string", "", "", "", "", "", "", "", "" );
226 return &t;
228 const ObjectImpType* HierarchyImp::stype()
230 static const ObjectImpType t(
231 Parent::stype(), "hierarchy", "", "", "", "", "", "", "", "", "" );
232 return &t;
234 const ObjectImpType* TransformationImp::stype()
236 static const ObjectImpType t(
237 Parent::stype(), "transformation", "", "", "", "", "", "", "", "", "");
238 return &t;
241 const ObjectImpType* InvalidImp::type() const
243 return InvalidImp::stype();
246 const ObjectImpType* DoubleImp::type() const
248 return DoubleImp::stype();
251 const ObjectImpType* IntImp::type() const
253 return IntImp::stype();
256 const ObjectImpType* StringImp::type() const
258 return StringImp::stype();
261 const ObjectImpType* HierarchyImp::type() const
263 return HierarchyImp::stype();
266 const ObjectImpType* TransformationImp::type() const
268 return TransformationImp::stype();
271 const ObjectImpType* DoubleImp::stype()
273 static const ObjectImpType t(
274 Parent::stype(), "double",
275 "double", "", "", "", "", "", "", "", "" );
276 return &t;
279 const ObjectImpType* IntImp::stype()
281 static const ObjectImpType t(
282 Parent::stype(), "int",
283 "int", "", "", "", "", "", "", "", "" );
284 return &t;
287 const ObjectImpType* BogusImp::stype()
289 static const ObjectImpType t(
290 Parent::stype(), "bogus",
291 "", "", "", "", "", "", "", "", "" );
292 return &t;
295 const ObjectImpType* TestResultImp::stype()
297 static const ObjectImpType t(
298 Parent::stype(), "testresult", "", "", "", "", "", "", "", "", "" );
299 return &t;
303 TestResultImp::TestResultImp( const QString& s )
304 : mdata( s )
308 TestResultImp* TestResultImp::copy() const
310 return new TestResultImp( mdata );
313 const ObjectImpType* TestResultImp::type() const
315 return stype();
318 void TestResultImp::visit( ObjectImpVisitor* vtor ) const
320 vtor->visit( this );
323 bool TestResultImp::equals( const ObjectImp& rhs ) const
325 return rhs.inherits( TestResultImp::stype() ) &&
326 static_cast<const TestResultImp&>( rhs ).mdata == mdata;
330 const uint TestResultImp::numberOfProperties() const
332 return Parent::numberOfProperties() + 1;
335 const QCStringList TestResultImp::properties() const
337 QCStringList l = Parent::properties();
338 l << I18N_NOOP( "Test Result" );
339 assert( l.size() == TestResultImp::numberOfProperties() );
340 return l;
343 const QCStringList TestResultImp::propertiesInternalNames() const
345 QCStringList s = Parent::propertiesInternalNames();
346 s << "test-result";
347 assert( s.size() == TestResultImp::numberOfProperties() );
348 return s;
351 ObjectImp* TestResultImp::property( uint which, const KigDocument& d ) const
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;
361 const char* TestResultImp::iconForProperty( uint which ) const
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 "";
371 const ObjectImpType* TestResultImp::impRequirementForProperty( uint which ) const
373 if ( which < Parent::numberOfProperties() )
374 return Parent::impRequirementForProperty( which );
375 else return TestResultImp::stype();
378 bool TestResultImp::isPropertyDefinedOnOrThroughThisImp( uint which ) const
380 if ( which < Parent::numberOfProperties() )
381 return Parent::impRequirementForProperty( which );
382 else return false;
385 Rect BogusImp::surroundingRect() const
387 return Rect::invalidRect();