summaryrefslogtreecommitdiffstats
path: root/kchart/kdchart/KDChartObjectFactory.cpp
blob: b1dac73eff347b6e3cd5a387627e10f3d2737de9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
#include "KDChartObjectFactory.h"
#include <KDChartParams.h>
#include <KDChartTable.h>
#include <tqsargument.h>
#include <tqdatetime.h>
#include <KDChartEnums.h>
#include <tqfont.h>
#include <KDChartTextPiece.h>
#include <tqcolor.h>
#include <KDChartWidget.h>
#include <KDChartPropertySet.h>
#include "factories/TQtFactory.h"
#include "factories/TQFontFactory.h"

// PENDING(blackie) Clean up code in this file, so it uses the correct getter methods like getBool.
KDChartObjectFactory::KDChartObjectFactory()
{
    registerClass( TQString::tqfromLatin1( "KDChartWidget" ) );
    registerClass( TQString::tqfromLatin1( "KDChartParams" ), new KDChartParams );
    registerClass( TQString::tqfromLatin1( "KDChartTableData" ) );
    registerClass( TQString::tqfromLatin1( "KDChartAxisParams" ), new KDChartAxisParams );
    registerClass( TQString::tqfromLatin1( "KDChartEnums" ), 0, new KDChartEnums );
    registerClass( TQString::tqfromLatin1( "KDChartTextPiece" ) );
    registerClass( TQString::tqfromLatin1( "KDChartCustomBox" ), new KDChartCustomBox );
    registerClass( TQString::tqfromLatin1( "KDChartPropertySet" ), new KDChartPropertySet );
    registerClass( TQString::tqfromLatin1( "KDFrame" ), TQString(), new KDFrame );

    registerClass( TQString::tqfromLatin1( "TQt" ), TQString(), new TQtFactory() );
    registerClass( TQString::tqfromLatin1( "TQFont" ), TQString(), new TQFontFactory );
}

TQObject* KDChartObjectFactory::create( const TQString& className, const TQSArgumentList& args, TQObject* /*context*/ )
{
    if ( className == TQString::tqfromLatin1( "KDChartWidget" ) )
         return createKDChartWidget( args );

    if ( className == TQString::tqfromLatin1("KDChartParams") )
        return new KDChartParams();

    else if ( className == TQString::tqfromLatin1("KDChartTableData") )
        return createKDChartTableData( args );

    else if ( className == TQString::tqfromLatin1("KDChartAxisParams") )
        return new KDChartAxisParams();


    else if ( className == TQString::tqfromLatin1( "KDChartTextPiece" ) )
        return createKDChartTextPiece( args );

    else if ( className == TQString::tqfromLatin1( "KDChartCustomBox" ) )
        return createKDChartCustomBox( args );

    else if ( className == TQString::tqfromLatin1( "KDChartPropertySet" ) )
        return createKDChartPropertySet( args );

    else
        return 0;
}

TQObject* KDChartObjectFactory::createKDChartWidget( const TQSArgumentList& args )
{
    if ( !checkArgCount( "KDChartWidget", args.count(), 2, 2 ) ) return 0;
    if ( !checkArgsIsTQtClass( args, 1, "KDChartParams", "KDChartWidget" ) ) return 0;
    if ( !checkArgsIsTQtClass( args, 2, "KDChartTableDataBase", "KDChartWidget" ) ) return 0;
    KDChartParams* params = static_cast<KDChartParams*>( args[0].qobject() );
    KDChartTableDataBase* data = static_cast<KDChartTableDataBase*>( args[1].qobject() );

    return new KDChartWidget( params, data );

}

TQObject* KDChartObjectFactory::createKDChartTableData( const TQSArgumentList& args )
{
    if ( args.count() != 2 ) {
        throwError( TQObject::tr( "wrong number of arguments to KDChartTableData" ) );
        return 0;
    }
    TQSArgument arg1 = args[0];
    TQSArgument arg2 = args[1];

    if ( arg1.type() != TQSArgument::Variant || !isNumber(arg1.variant()) ) {
        throwError( TQObject::tr( "wrong type for argument 1 of KDChartTableData" ) );
        return 0;
    }
    if ( arg2.type() != TQSArgument::Variant || !isNumber(arg2.variant() ) ) {
         throwError( TQObject::tr( "wrong type for argument 2 of KDChartTableData" ) );
        return 0;
    }
    return new KDChartTableData( arg1.variant().toUInt(), arg2.variant().toUInt() );
}


TQObject* KDChartObjectFactory::createKDChartTextPiece( const TQSArgumentList& args )
{
    if ( !checkArgCount( "KDChartTextPiece", args.count(), 2, 2 ) ) return 0;
    TQSArgument arg1 = args[0];
    TQSArgument arg2 = args[1];

    TQString str;
    if ( !getString( args, 1, &str, "KDChartTextPiece" ) ) return 0;
    if ( !checkIsTQtVariant( args, 2, TQVariant::Font, TQString::tqfromLatin1( "TQFont" ), "KDChartTextPiece" ) ) return 0;
    TQFont font = args[1].variant().toFont();

    return new KDChartTextPiece( str, font );
}

TQObject* KDChartObjectFactory::createKDChartCustomBox( const TQSArgumentList& args )
{
    int tmp;

    if ( args.count() == 0 )
        return new KDChartCustomBox();


    if ( args[0].type() == TQSArgument::Variant && isNumber( args[0].variant() ) ) {
        if ( args.count() < 8 ) {
            throwError( TQObject::tr( "Too few arguments to KDChartCustomBox" ) );
            return 0;
        }

        int rotation;
        if ( !getNumber( args, 1, &rotation, "KDChartCustomBox" ) ) return 0;

        if (!checkArgsIsTQtClass( args, 2, "KDChartTextPiece", "KDChartCustomBox" )) return 0;
        KDChartTextPiece* content = static_cast<KDChartTextPiece*>( args[1].qobject() );

        int fontSize;
        if ( !getNumber( args, 3, &fontSize, "KDChartCustomBox" ) ) return 0;


        bool fontScaleGlobal;
        if ( !getBool( args, 4, &fontScaleGlobal, "KDChartCustomBox" ) ) return 0;

        int deltaX;
        if ( !getNumber( args, 5, &deltaX, "KDChartCustomBox" ) ) return 0;

        int deltaY;
        if ( !getNumber( args, 6, &deltaY, "KDChartCustomBox" ) ) return 0;

        int width;
        if ( !getNumber( args, 7, &width, "KDChartCustomBox" ) ) return 0;

        int height;
        if ( !getNumber( args, 8, &height, "KDChartCustomBox" ) ) return 0;

        TQColor color = TQt::black;
        if ( args.count() >= 9 ) {
            if ( !checkIsTQtVariant( args, 9, TQVariant::Color, TQString::tqfromLatin1( "TQColor" ), "KDChartCustomBox" ) ) return 0;
            color = args[8].variant().toColor();
        }

        TQBrush paper = TQt::NoBrush;
        if ( args.count() >= 10 ) {
            if ( !checkIsTQtVariant( args, 10, TQVariant::Brush, TQString::tqfromLatin1( "TQBrush" ), "KDChartCustomBox" ) ) return 0;
            paper = args[9].variant().toBrush();
        }

        uint area = KDChartEnums::AreaInnermost;
        if ( args.count() >= 11 ) {
            if ( !getNumber( args, 11, &area, "KDChartCustomBox" ) ) return 0;
        }

        KDChartEnums::PositionFlag position = KDChartEnums::PosTopLeft;
        if ( args.count() >= 12 ) {
            if ( !getNumber( args, 12, &tmp, "KDChartCustomBox" ) ) return 0;
            position = (KDChartEnums::PositionFlag) tmp;
        }

        uint align = TQt::AlignTop + TQt::AlignLeft;
        if ( args.count() >= 13 ) {
            if ( !getNumber( args, 13, &align, "KDChartCustomBox" ) ) return 0;
        }

        uint dataRow = 0;
        if ( args.count() >= 14 ) {
            if ( !getNumber( args, 14, &dataRow, "KDChartCustomBox" ) ) return 0;
        }

        uint dataCol = 0;
        if ( args.count() >= 15 ) {
            if ( !getNumber( args, 15, &dataCol, "KDChartCustomBox" ) ) return 0;
        }

        uint data3rd = 0;
        if ( args.count() >= 16 ) {
            if ( !getNumber( args, 16, &data3rd, "KDChartCustomBox" ) ) return 0;
        }

        uint deltaAlign = KDCHART_AlignAuto;
        if ( args.count() >= 17 ) {
            if ( !getNumber( args, 17, &deltaAlign, "KDChartCustomBox" ) ) return 0;
        }

        bool deltaScaleGlobal = true;
        if ( args.count() >= 18 ) {
            if ( !getBool( args, 18, &deltaScaleGlobal, "KDChartCustomBox" ) ) return 0;
        }

        return new KDChartCustomBox( rotation, *content, fontSize, fontScaleGlobal, deltaX, deltaY,
                                     width, height, color, paper, area, position, align, dataRow,
                                     dataCol, data3rd, deltaAlign, deltaScaleGlobal );
    }

    if (!checkArgsIsTQtClass( args, 1, "KDChartTextPiece", "KDChartCustomBox" )) return 0;
    KDChartTextPiece* content = static_cast<KDChartTextPiece*>( args[0].qobject() );

    if ( args.count() < 2 ) {
        throwError( TQObject::tr( "Too few arguments to KDChartCustomBox" ) );
        return 0;
    }

    int fontSize;
    if ( ! getNumber( args, 2, &fontSize, "KDChartCustomBox" ) ) return 0;

    bool fontScaleGlobal = true;
    if ( args.count() > 2 && !getBool( args, 3, &fontScaleGlobal, "KDChartCustomBox" ) ) return 0;

    if ( args.count() <= 3 )
        return new KDChartCustomBox( *content, fontSize, fontScaleGlobal );

    checkArgCount( "KDChartCustomBox", args.count(), 7, 17 );

    int deltaX;
    if ( !getNumber( args, 4, &deltaX, "KDChartCustomBox" ) ) return 0;

    int deltaY;
    if ( !getNumber( args, 5, &deltaY, "KDChartCustomBox" ) ) return 0;

    int width;
    if ( !getNumber( args, 6, &width, "KDChartCustomBox" ) ) return 0;

    int height;
    if ( !getNumber( args, 7, &height, "KDChartCustomBox" ) ) return 0;


    TQColor color = TQt::black;
    if ( args.count() >= 8 ) {
        if ( !checkIsTQtVariant( args, 8, TQVariant::Color, TQString::tqfromLatin1( "TQColor" ), "KDChartCustomBox" ) ) return 0;
        color = args[7].variant().toColor();
    }

    TQBrush paper = TQt::NoBrush;
    if ( args.count() >= 9 ) {
        if ( !checkIsTQtVariant( args, 9, TQVariant::Brush, TQString::tqfromLatin1( "TQBrush" ), "KDChartCustomBox" ) ) return 0;
        paper = args[8].variant().toBrush();
    }

    uint area = KDChartEnums::AreaInnermost;
    if ( args.count() >= 10 ) {
        if ( !getNumber( args, 10, &area, "KDChartCustomBox" ) ) return 0;
    }

    KDChartEnums::PositionFlag position = KDChartEnums::PosTopLeft;
    if ( args.count() >= 11 ) {
        if ( !getNumber( args, 11, &tmp, "KDChartCustomBox" ) ) return 0;
        position = (KDChartEnums::PositionFlag) tmp;
    }

    uint align = TQt::AlignTop + TQt::AlignLeft;
    if ( args.count() >= 12 ) {
        if ( !getNumber( args, 12, &align, "KDChartCustomBox" ) ) return 0;
    }

    uint dataRow = 0;
    if ( args.count() >= 13 ) {
        if ( !getNumber( args, 13, &dataRow, "KDChartCustomBox" ) ) return 0;
    }

    uint dataCol = 0;
    if ( args.count() >= 14 ) {
        if ( !getNumber( args, 14, &dataCol, "KDChartCustomBox" ) ) return 0;
    }

    uint data3rd = 0;
    if ( args.count() >= 15 ) {
        if ( !getNumber( args, 15, &data3rd, "KDChartCustomBox" ) ) return 0;
    }

    uint deltaAlign = KDCHART_AlignAuto;
    if ( args.count() >= 16 ) {
        if ( !getNumber( args, 16, &deltaAlign, "KDChartCustomBox" ) ) return 0;
    }

    bool deltaScaleGlobal = true;
    if ( args.count() >= 17 ) {
        if ( !getBool( args, 17, &deltaScaleGlobal, "KDChartCustomBox" ) ) return 0;
    }


    return new KDChartCustomBox( *content, fontSize, fontScaleGlobal, deltaX, deltaY, width, height, color,
                                 paper, area, position, align, dataRow, dataCol, data3rd, deltaAlign, deltaScaleGlobal );
}

TQObject* KDChartObjectFactory::createKDChartPropertySet(const TQSArgumentList& args )
{
    if ( args.count() == 0 )
        return new KDChartPropertySet();

    TQString name;
    if ( !getString( args, 1, &name, "KDChartPropertySet"  ) ) return 0;

    if ( args.count() == 1 )
        return new KDChartPropertySet( name );

    int i;
    if ( !getNumber( args, 2, &i, "KDChartPropertySet" ) ) return 0;
    if ( args.count() == 2 )
        return new KDChartPropertySet( name, i );

    if ( !checkArgCount( "KDChartPropertySet", args.count(), 33, 33 ) ) return 0;

    int idLineWidth = i;

    int lineWidth;
    if ( !getNumber( args, 3,&lineWidth, "KDChartPropertySet" ) ) return 0;

    int idLineColor;
    if ( !getNumber( args, 4,&idLineColor, "KDChartPropertySet" ) ) return 0;


    if ( !checkIsTQtVariant( args, 5, TQVariant::Color, TQString::tqfromLatin1( "TQColor" ), "KDChartPropertySet" ) ) return 0;
    TQColor lineColor = args[4].variant().toColor();

    int idLineStyle;
    if ( !getNumber( args, 6,&idLineStyle, "KDChartPropertySet" ) ) return 0;



    if ( !getNumber( args, 7,&i, "KDChartPropertySet" ) ) return 0;
    Qt::PenStyle lineStyle = (Qt::PenStyle) i;

    int idShowMarker;
    if ( !getNumber( args, 8,&idShowMarker, "KDChartPropertySet" ) ) return 0;

    bool showMarker;
    if ( !getBool( args, 9, &showMarker, "KDChartPropertySet" ) ) return 0;

    int idExtraLinesAlign;
    if ( !getNumber( args, 10,&idExtraLinesAlign, "KDChartPropertySet" ) ) return 0;

    uint extraLinesAlign;
    if ( !getNumber( args, 11,&extraLinesAlign, "KDChartPropertySet" ) ) return 0;

    int idExtraLinesInFront;
    if ( !getNumber( args, 12,&idExtraLinesInFront, "KDChartPropertySet" ) ) return 0;

    bool extraLinesInFront;
    if ( !getBool( args, 13, &extraLinesInFront, "KDChartPropertySet" ) ) return 0;

    int idExtraLinesLength;
    if ( !getNumber( args, 14,&idExtraLinesLength, "KDChartPropertySet" ) ) return 0;

    int extraLinesLength;
    if ( !getNumber( args, 15,&extraLinesLength, "KDChartPropertySet" ) ) return 0;

    int idExtraLinesWidth;
    if ( !getNumber( args, 16,&idExtraLinesWidth, "KDChartPropertySet" ) ) return 0;

    int extraLinesWidth;
    if ( !getNumber( args, 17,&extraLinesWidth, "KDChartPropertySet" ) ) return 0;

    int idExtraLinesColor;
    if ( !getNumber( args, 18,&idExtraLinesColor, "KDChartPropertySet" ) ) return 0;

    if ( !checkIsTQtVariant( args, 19, TQVariant::Color, TQString::tqfromLatin1( "TQColor" ), "KDChartPropertySet" ) ) return 0;
    TQColor extraLinesColor = args[18].variant().toColor();

    int idExtraLinesStyle;
    if ( !getNumber( args, 20,&idExtraLinesStyle, "KDChartPropertySet" ) ) return 0;

    if ( !getNumber( args, 21,&i, "KDChartPropertySet" ) ) return 0;
    Qt::PenStyle extraLinesStyle = (Qt::PenStyle) i;

    int idExtraMarkersAlign;
    if ( !getNumber( args, 22,&idExtraMarkersAlign, "KDChartPropertySet" ) ) return 0;

    uint extraMarkersAlign;
    if ( !getNumber( args, 23,&extraMarkersAlign, "KDChartPropertySet" ) ) return 0;

    int idExtraMarkersSize;
    if ( !getNumber( args, 24,&idExtraMarkersSize, "KDChartPropertySet" ) ) return 0;

    if ( !checkIsTQtVariant( args, 25, TQVariant::Size, TQString::tqfromLatin1( "TQSize" ), "KDChartPropertySet" ) ) return 0;
    TQSize extraMarkersSize = args[24].variant().toSize();

    int idExtraMarkersColor;
    if ( !getNumber( args, 26,&idExtraMarkersColor, "KDChartPropertySet" ) ) return 0;

    if ( !checkIsTQtVariant( args, 27, TQVariant::Color, TQString::tqfromLatin1( "TQColor" ), "KDChartPropertySet" ) ) return 0;
    TQColor extraMarkersColor = args[26].variant().toColor();

    int idExtraMarkersStyle;
    if ( !getNumber( args, 28,&idExtraMarkersStyle, "KDChartPropertySet" ) ) return 0;

    int extraMarkersStyle;
    if ( !getNumber( args, 29,&extraMarkersStyle, "KDChartPropertySet" ) ) return 0;

    int idShowBar;
    if ( !getNumber( args, 30,&idShowBar, "KDChartPropertySet" ) ) return 0;

    bool showBar;
    if ( !getBool( args, 31, &showBar, "KDChartPropertySet" ) ) return 0;

    int idBarColor;
    if ( !getNumber( args, 32,&idBarColor, "KDChartPropertySet" ) ) return 0;

    if ( !checkIsTQtVariant( args, 33, TQVariant::Color, TQString::tqfromLatin1( "TQColor" ), "KDChartPropertySet" ) ) return 0;
    TQColor barColor = args[32].variant().toColor();

    KDChartPropertySet* set = new KDChartPropertySet;
    set->setName( name );
    set->setLineWidth( idLineWidth, lineWidth );
    set->setLineColor( idLineColor, lineColor );
    set->setLineStyle( idLineStyle, lineStyle );
    set->setShowMarker( idShowMarker, showMarker );
    set->setExtraLinesAlign( idExtraLinesAlign, extraLinesAlign );
    set->setExtraLinesInFront( idExtraLinesInFront, extraLinesInFront );
    set->setExtraLinesLength( idExtraLinesLength, extraLinesLength );
    set->setExtraLinesWidth( idExtraLinesWidth, extraLinesWidth );
    set->setExtraLinesColor( idExtraLinesColor, extraLinesColor );
    set->setExtraLinesStyle( idExtraLinesStyle, extraLinesStyle );
    set->setExtraMarkersAlign( idExtraMarkersAlign, extraMarkersAlign );
    set->setExtraMarkersSize( idExtraMarkersSize, extraMarkersSize );
    set->setExtraMarkersColor( idExtraMarkersColor, extraMarkersColor );
    set->setExtraMarkersStyle( idExtraMarkersStyle, extraMarkersStyle );
    set->setShowBar( idShowMarker, showBar );
    set->setBarColor( idBarColor, barColor );
    return set;
}


bool KDChartObjectFactory::isNumber( const TQVariant& v )
{
    return ( v.type() == TQVariant::Int || v.type() == TQVariant::UInt || v.type() == TQVariant::Double );
}

    // PENDING(blackie) rework order of parameters so it matches the other methods
bool KDChartObjectFactory::checkArgCount( const TQString& className, int count, int min, int max )
{
    if ( count < min ) {
        throwError( TQObject::tr( "Too few arguments when creating %1 object." ).tqarg( className ) );
        return false;
    }
    if ( count > max ) {
        throwError( TQObject::tr( "Too many arguments when creating %1 object." ).tqarg( className ) );
        return false;
    }
    return true;
}


bool KDChartObjectFactory::checkArgsIsTQtClass( const TQSArgumentList& args, int index, const char* expected, const char* constructing )
{
    const TQSArgument& arg = args[index-1];
    if ( arg.type() != TQSArgument::TQObjectPtr || !arg.qobject()->inherits( expected ) ) {
        throwError( TQObject::tr( "Invalid type for argument no %1 to %2, must be a %3" ).tqarg(index).tqarg(constructing).tqarg(expected) );
        return false;
    }
    return true;
}


bool KDChartObjectFactory::getString( const TQSArgumentList& args, int index, TQString* str, const char* constructing  )
{
    const TQSArgument& arg = args[index-1];
    if ( arg.type() != TQSArgument::Variant || arg.variant().type() != TQVariant::String ) {
        throwError( TQObject::tr( "Invalid type for argument %1 to %2, must be a string" ).tqarg(index).tqarg(constructing) );
        return false;
    }
    else {
        *str = arg.variant().toString();
        return true;
    }
}

bool KDChartObjectFactory::getNumber( const TQSArgumentList& args, int index, double* number, const char* constructing )
{
    const TQSArgument& arg = args[index-1];
    if ( arg.type() != TQSArgument::Variant || !isNumber(arg.variant()) ) {
        throwError( TQObject::tr( "Invalid type for argument %1 to %2, must be a number" ).tqarg(index).tqarg( constructing ) );
        return false;
    }
    else {
        *number = arg.variant().toDouble();
        return true;
    }
}

bool KDChartObjectFactory::getNumber( const TQSArgumentList& args, int index, int* number, const char* constructing )
{
    double tmp;
    bool ok = getNumber( args, index, &tmp, constructing );
    *number = static_cast<int>( tmp );
    return ok;
}

bool KDChartObjectFactory::getNumber( const TQSArgumentList& args, int index, uint* number, const char* constructing )
{
    double tmp;
    bool ok = getNumber( args, index, &tmp, constructing );
    *number = static_cast<uint>( tmp );
    return ok;
}



bool KDChartObjectFactory::getBool( const TQSArgumentList& args, int index, bool* b, const char* constructing )
{
    const TQSArgument& arg = args[index-1];
    if ( arg.type() != TQSArgument::Variant || arg.variant().type() != TQVariant::Bool ) {
        throwError( TQObject::tr( "Invalid type for argument %1 to %2, must be a boolean" ).tqarg(index).tqarg( constructing ) );
        return false;
    }
    else {
        *b = arg.variant().toBool();
        return true;
    }
}

bool KDChartObjectFactory::checkIsTQtVariant( const TQSArgumentList& args, int index, TQVariant::Type expected, const TQString& variantName, const char* constructing )
{
    const TQSArgument& arg = args[index-1];
    if ( arg.type() != TQSArgument::Variant || arg.variant().type() != expected ) {
        throwError( TQObject::tr( "Invalid type for argument %1 to %2, must be a %3").tqarg(index).tqarg(constructing).tqarg(variantName) );
        return false;
    }
    else
        return true;
}