00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdlib.h>
00021
00022 #include "kchartSubTypeChartPage.h"
00023 #include "kchartSubTypeChartPage.moc"
00024
00025 #include <kapplication.h>
00026 #include <klocale.h>
00027 #include <kiconloader.h>
00028 #include <kdebug.h>
00029 #include <qvbuttongroup.h>
00030 #include <qradiobutton.h>
00031 #include <qspinbox.h>
00032 #include <qlabel.h>
00033 #include <qhgroupbox.h>
00034 #include <qlayout.h>
00035 #include <qwhatsthis.h>
00036 #include <qvbox.h>
00037
00038 #include "kchart_params.h"
00039
00040 #include "kchart_factory.h"
00041
00042 namespace KChart
00043 {
00044
00045 KChartHiloSubTypeChartPage::KChartHiloSubTypeChartPage( KChartParams* params,
00046 QWidget* parent ) :
00047 KChartSubTypeChartPage( params, parent )
00048 {
00049 QHBoxLayout* toplevel = new QHBoxLayout( this, 10 );
00050 QVButtonGroup* subtypeBG = new QVButtonGroup( i18n( "Sub-type" ), this );
00051 QWhatsThis::add(subtypeBG, i18n("Select the desired sub-type of a chart. The available sub-types depend on the chart type. Some chart types have no sub-type at all, in which case this configuration page is not shown."));
00052 toplevel->addWidget( subtypeBG, AlignCenter| AlignVCenter );
00053 normal = new QRadioButton( i18n( "Normal" ), subtypeBG );
00054 subtypeBG->insert( normal, KDChartParams::AreaNormal );
00055 stacked = new QRadioButton(i18n("HiLoClose"), subtypeBG );
00056 subtypeBG->insert( stacked, KDChartParams::AreaStacked );
00057 percent = new QRadioButton( i18n("HiLoOpenClose"), subtypeBG );
00058 subtypeBG->insert( percent, KDChartParams::AreaPercent );
00059 subtypeBG->setFixedWidth( subtypeBG->sizeHint().width() );
00060 connect( subtypeBG, SIGNAL( clicked( int ) ),
00061 this, SLOT( slotChangeSubType( int ) ) );
00062
00063 QHGroupBox* exampleGB = new QHGroupBox( i18n( "Example" ), this );
00064 QWhatsThis::add(exampleGB, i18n("Preview the sub-type you choose."));
00065 toplevel->addWidget( exampleGB, 2 );
00066 exampleLA = new QLabel( exampleGB );
00067 exampleLA->setAlignment( AlignCenter | AlignVCenter );
00068
00069 }
00070
00071 void KChartHiloSubTypeChartPage::init()
00072 {
00073 switch( m_params->hiLoChartSubType() ) {
00074 case KDChartParams::HiLoNormal:
00075 normal->setChecked( true );
00076 break;
00077 case KDChartParams::HiLoClose:
00078 stacked->setChecked( true );
00079 break;
00080 case KDChartParams::HiLoOpenClose:
00081 percent->setChecked( true );
00082 break;
00083 default:
00084 {
00085 kdDebug( 35001 ) << "Error in stack_type" << endl;
00086 abort();
00087 break;
00088 }
00089 }
00090
00091 slotChangeSubType( m_params->hiLoChartSubType() );
00092 }
00093
00094 void KChartHiloSubTypeChartPage::slotChangeSubType( int type )
00095 {
00096 switch( type ) {
00097 case KDChartParams::HiLoNormal:
00098 exampleLA->setPixmap( UserIcon( "chart_hilo_normal", KChartFactory::global() ) );
00099 break;
00100 case KDChartParams::HiLoClose:
00101 exampleLA->setPixmap( UserIcon( "chart_hilo_close", KChartFactory::global() ) );
00102 break;
00103 case KDChartParams::HiLoOpenClose:
00104 exampleLA->setPixmap( UserIcon( "chart_hilo_openclose", KChartFactory::global() ) );
00105 break;
00106 };
00107 }
00108
00109
00110
00111 void KChartHiloSubTypeChartPage::apply()
00112 {
00113 if( normal->isChecked() )
00114 m_params->setHiLoChartSubType( KDChartParams::HiLoNormal );
00115 else if( stacked->isChecked() )
00116 m_params->setHiLoChartSubType( KDChartParams::HiLoClose );
00117 else if( percent->isChecked() )
00118 m_params->setHiLoChartSubType( KDChartParams::HiLoOpenClose );
00119 else {
00120 kdDebug( 35001 ) << "Error in groupbutton" << endl;
00121 }
00122 }
00123
00124 KChartAreaSubTypeChartPage::KChartAreaSubTypeChartPage( KChartParams* params,
00125 QWidget* parent ) :
00126 KChartSubTypeChartPage( params, parent )
00127 {
00128 QHBoxLayout* toplevel = new QHBoxLayout( this, 10 );
00129 QVButtonGroup* subtypeBG = new QVButtonGroup( i18n( "Sub-type" ), this );
00130 QWhatsThis::add(subtypeBG, i18n("Select the desired sub-type of a chart. The available sub-types depend on the chart type. Some chart types have no sub-type at all, in which case this configuration page is not shown."));
00131 toplevel->addWidget( subtypeBG, AlignCenter| AlignVCenter );
00132 normal = new QRadioButton( i18n( "Normal" ), subtypeBG );
00133 subtypeBG->insert( normal, KDChartParams::AreaNormal );
00134 stacked = new QRadioButton( i18n( "Stacked" ), subtypeBG );
00135 subtypeBG->insert( stacked, KDChartParams::AreaStacked );
00136 percent = new QRadioButton( i18n( "Percent" ), subtypeBG );
00137 subtypeBG->insert( percent, KDChartParams::AreaPercent );
00138 subtypeBG->setFixedWidth( subtypeBG->sizeHint().width() );
00139 connect( subtypeBG, SIGNAL( clicked( int ) ),
00140 this, SLOT( slotChangeSubType( int ) ) );
00141
00142 QHGroupBox* exampleGB = new QHGroupBox( i18n( "Example" ), this );
00143 QWhatsThis::add(exampleGB, i18n("Preview the sub-type you choose."));
00144 toplevel->addWidget( exampleGB, 2 );
00145 exampleLA = new QLabel( exampleGB );
00146 exampleLA->setAlignment( AlignCenter | AlignVCenter );
00147
00148 }
00149
00150
00151 void KChartAreaSubTypeChartPage::init()
00152 {
00153 switch( m_params->areaChartSubType() ) {
00154 case KDChartParams::AreaNormal:
00155 normal->setChecked( true );
00156 break;
00157 case KDChartParams::AreaStacked:
00158 stacked->setChecked( true );
00159 break;
00160 case KDChartParams::AreaPercent:
00161 percent->setChecked( true );
00162 break;
00163 default:
00164 {
00165 kdDebug( 35001 ) << "Error in stack_type" << endl;
00166 abort();
00167 break;
00168 }
00169 }
00170
00171 slotChangeSubType( m_params->areaChartSubType() );
00172 }
00173
00174 void KChartAreaSubTypeChartPage::slotChangeSubType( int type )
00175 {
00176 switch( type ) {
00177 case KDChartParams::AreaNormal:
00178 exampleLA->setPixmap( UserIcon( "chart_area_normal", KChartFactory::global() ) );
00179 break;
00180 case KDChartParams::AreaStacked:
00181 exampleLA->setPixmap( UserIcon( "chart_area_stacked", KChartFactory::global() ) );
00182 break;
00183 case KDChartParams::AreaPercent:
00184 exampleLA->setPixmap( UserIcon( "chart_area_percent", KChartFactory::global() ) );
00185 break;
00186 };
00187 }
00188
00189
00190
00191 void KChartAreaSubTypeChartPage::apply()
00192 {
00193 if( normal->isChecked() )
00194 m_params->setAreaChartSubType( KDChartParams::AreaNormal );
00195 else if( stacked->isChecked() )
00196 m_params->setAreaChartSubType( KDChartParams::AreaStacked );
00197 else if( percent->isChecked() )
00198 m_params->setAreaChartSubType( KDChartParams::AreaPercent );
00199 else {
00200 kdDebug( 35001 ) << "Error in groupbutton" << endl;
00201 }
00202 }
00203
00204 KChartBarSubTypeChartPage::KChartBarSubTypeChartPage( KChartParams* params,
00205 QWidget* parent ) :
00206 KChartSubTypeChartPage( params, parent )
00207 {
00208 QHBoxLayout* toplevel = new QHBoxLayout( this, 10 );
00209 QVBox *left = new QVBox( this );
00210 QVButtonGroup* subtypeBG = new QVButtonGroup( i18n( "Sub-type" ), left );
00211 QWhatsThis::add(subtypeBG, i18n("Select the desired sub-type of a chart. The available sub-types depend on the chart type. Some chart types have no sub-type at all, in which case this configuration page is not shown."));
00212
00213 toplevel->addWidget( left, AlignCenter );
00214
00215 normal = new QRadioButton( i18n( "Normal" ), subtypeBG );
00216 subtypeBG->insert( normal, KDChartParams::BarNormal );
00217 stacked = new QRadioButton( i18n( "Stacked" ), subtypeBG );
00218 subtypeBG->insert( stacked, KDChartParams::BarStacked );
00219 percent = new QRadioButton( i18n( "Percent" ), subtypeBG );
00220 subtypeBG->insert( percent, KDChartParams::BarPercent );
00221
00222 subtypeBG->setFixedWidth( subtypeBG->sizeHint().width() );
00223 connect( subtypeBG, SIGNAL( clicked( int ) ),
00224 this, SLOT( slotChangeSubType( int ) ) );
00225
00226
00227 new QLabel( i18n( "Number of lines: "), left );
00228 m_numLines = new QSpinBox( left );
00229
00230 new QLabel( "", left);
00231 left->setStretchFactor( left, 1 );
00232
00233 QHGroupBox* exampleGB = new QHGroupBox( i18n( "Example" ), this );
00234 QWhatsThis::add(exampleGB, i18n("Preview the sub-type you choose."));
00235 toplevel->addWidget( exampleGB, 2 );
00236 exampleLA = new QLabel( exampleGB );
00237 exampleLA->setAlignment( AlignCenter | AlignVCenter );
00238 }
00239
00240 void KChartBarSubTypeChartPage::init()
00241 {
00242
00243 switch( m_params->barChartSubType() ) {
00244 case KDChartParams::BarNormal:
00245 normal->setChecked( true );
00246 break;
00247 case KDChartParams::BarStacked:
00248 stacked->setChecked( true );
00249 break;
00250 case KDChartParams::BarPercent:
00251 percent->setChecked( true );
00252 break;
00253 default:
00254 {
00255 kdDebug( 35001 ) << "Error in stack_type" << endl;
00256 break;
00257 }
00258 }
00259
00260 m_numLines->setValue( m_params->barNumLines() );
00261
00262 slotChangeSubType( m_params->barChartSubType() );
00263 }
00264
00265
00266 void KChartBarSubTypeChartPage::slotChangeSubType( int type )
00267 {
00268 switch( type ) {
00269 case KDChartParams::BarStacked:
00270 exampleLA->setPixmap( UserIcon( "chart_bar_layer", KChartFactory::global() ) );
00271 break;
00272 case KDChartParams::BarNormal:
00273 exampleLA->setPixmap( UserIcon( "chart_bar_beside", KChartFactory::global() ) );
00274 break;
00275 case KDChartParams::BarPercent:
00276 exampleLA->setPixmap( UserIcon( "chart_bar_percent", KChartFactory::global() ) );
00277 break;
00278 };
00279 }
00280
00281
00282 void KChartBarSubTypeChartPage::apply()
00283 {
00284 if( normal->isChecked() ) {
00285 m_params->setBarChartSubType( KDChartParams::BarNormal );
00286 } else if( stacked->isChecked() ) {
00287 m_params->setBarChartSubType( KDChartParams::BarStacked );
00288 } else if( percent->isChecked() ) {
00289 m_params->setBarChartSubType( KDChartParams::BarPercent );
00290 } else {
00291 kdDebug( 35001 ) << "Error in groupbutton" << endl;
00292 }
00293
00294
00295 m_params->setBarNumLines( m_numLines->value() );
00296 }
00297
00298 KChartLineSubTypeChartPage::KChartLineSubTypeChartPage( KChartParams* params,
00299 QWidget* parent ) :
00300 KChartSubTypeChartPage( params, parent )
00301 {
00302 QHBoxLayout* toplevel = new QHBoxLayout( this, 10 );
00303 QVButtonGroup* subtypeBG = new QVButtonGroup( i18n( "Sub-type" ), this );
00304 QWhatsThis::add(subtypeBG, i18n("Select the desired sub-type of a chart. The available sub-types depend on the chart type. Some chart types have no sub-type at all, in which case this configuration page is not shown."));
00305 toplevel->addWidget( subtypeBG, AlignCenter| AlignVCenter );
00306 normal = new QRadioButton( i18n( "Normal" ), subtypeBG );
00307 subtypeBG->insert( normal, KDChartParams::AreaNormal );
00308 stacked = new QRadioButton( i18n( "Stacked" ), subtypeBG );
00309 subtypeBG->insert( stacked, KDChartParams::AreaStacked );
00310 percent = new QRadioButton( i18n( "Percent" ), subtypeBG );
00311 subtypeBG->insert( percent, KDChartParams::AreaPercent );
00312 subtypeBG->setFixedWidth( subtypeBG->sizeHint().width() );
00313 connect( subtypeBG, SIGNAL( clicked( int ) ),
00314 this, SLOT( slotChangeSubType( int ) ) );
00315
00316 QHGroupBox* exampleGB = new QHGroupBox( i18n( "Example" ), this );
00317 QWhatsThis::add(exampleGB, i18n("Preview the sub-type you choose."));
00318 toplevel->addWidget( exampleGB, 2 );
00319 exampleLA = new QLabel( exampleGB );
00320 exampleLA->setAlignment( AlignCenter | AlignVCenter );
00321
00322 }
00323
00324 void KChartLineSubTypeChartPage::init()
00325 {
00326 switch( m_params->lineChartSubType() ) {
00327 case KDChartParams::LineNormal:
00328 normal->setChecked( true );
00329 break;
00330 case KDChartParams::LineStacked:
00331 stacked->setChecked( true );
00332 break;
00333 case KDChartParams::LinePercent:
00334 percent->setChecked( true );
00335 break;
00336 default:
00337 {
00338 kdDebug( 35001 ) << "Error in stack_type" << endl;
00339 abort();
00340 break;
00341 }
00342 }
00343
00344 slotChangeSubType( m_params->lineChartSubType() );
00345 }
00346
00347 void KChartLineSubTypeChartPage::slotChangeSubType( int type )
00348 {
00349 switch( type ) {
00350 case KDChartParams::AreaNormal:
00351 exampleLA->setPixmap( UserIcon( "chart_line_normal", KChartFactory::global() ) );
00352 break;
00353 case KDChartParams::AreaStacked:
00354 exampleLA->setPixmap( UserIcon( "chart_line_stacked", KChartFactory::global() ) );
00355 break;
00356 case KDChartParams::AreaPercent:
00357 exampleLA->setPixmap( UserIcon( "chart_line_percent", KChartFactory::global() ) );
00358 break;
00359 };
00360 }
00361
00362
00363
00364 void KChartLineSubTypeChartPage::apply()
00365 {
00366 if( normal->isChecked() )
00367 m_params->setLineChartSubType( KDChartParams::LineNormal );
00368 else if( stacked->isChecked() )
00369 m_params->setLineChartSubType( KDChartParams::LineStacked );
00370 else if( percent->isChecked() )
00371 m_params->setLineChartSubType( KDChartParams::LinePercent );
00372 else {
00373 kdDebug( 35001 ) << "Error in groupbutton" << endl;
00374 }
00375 }
00376
00377 KChartPolarSubTypeChartPage::KChartPolarSubTypeChartPage( KChartParams* params,
00378 QWidget* parent ) :
00379 KChartSubTypeChartPage( params, parent )
00380 {
00381 QHBoxLayout* toplevel = new QHBoxLayout( this, 10 );
00382 QVButtonGroup* subtypeBG = new QVButtonGroup( i18n( "Sub-type" ), this );
00383 QWhatsThis::add(subtypeBG, i18n("Select the desired sub-type of a chart. The available sub-types depend on the chart type. Some chart types have no sub-type at all, in which case this configuration page is not shown."));
00384 toplevel->addWidget( subtypeBG, AlignCenter| AlignVCenter );
00385 normal = new QRadioButton( i18n( "Normal" ), subtypeBG );
00386 subtypeBG->insert( normal, KDChartParams::AreaNormal );
00387 stacked = new QRadioButton( i18n( "Stacked" ), subtypeBG );
00388 subtypeBG->insert( stacked, KDChartParams::AreaStacked );
00389 percent = new QRadioButton( i18n( "Percent" ), subtypeBG );
00390 subtypeBG->insert( percent, KDChartParams::AreaPercent );
00391 subtypeBG->setFixedWidth( subtypeBG->sizeHint().width() );
00392 connect( subtypeBG, SIGNAL( clicked( int ) ),
00393 this, SLOT( slotChangeSubType( int ) ) );
00394
00395 QHGroupBox* exampleGB = new QHGroupBox( i18n( "Example" ), this );
00396 QWhatsThis::add(exampleGB, i18n("Preview the sub-type you choose."));
00397 toplevel->addWidget( exampleGB, 2 );
00398 exampleLA = new QLabel( exampleGB );
00399 exampleLA->setAlignment( AlignCenter | AlignVCenter );
00400
00401 }
00402
00403 void KChartPolarSubTypeChartPage::init()
00404 {
00405 switch( m_params->polarChartSubType() ) {
00406 case KDChartParams::PolarNormal:
00407 normal->setChecked( true );
00408 break;
00409 case KDChartParams::PolarStacked:
00410 stacked->setChecked( true );
00411 break;
00412 case KDChartParams::PolarPercent:
00413 percent->setChecked( true );
00414 break;
00415 default:
00416 {
00417 kdDebug( 35001 ) << "Error in stack_type" << endl;
00418 abort();
00419 break;
00420 }
00421 }
00422
00423 slotChangeSubType( m_params->lineChartSubType() );
00424 }
00425
00426 void KChartPolarSubTypeChartPage::slotChangeSubType( int type )
00427 {
00428 switch( type ) {
00429 case KDChartParams::PolarNormal:
00430 exampleLA->setPixmap( UserIcon( "chart_polar_normal", KChartFactory::global() ) );
00431 break;
00432 case KDChartParams::PolarStacked:
00433 exampleLA->setPixmap( UserIcon( "chart_polar_stacked", KChartFactory::global() ) );
00434 break;
00435 case KDChartParams::PolarPercent:
00436 exampleLA->setPixmap( UserIcon( "chart_polar_percent", KChartFactory::global() ) );
00437 break;
00438 };
00439 }
00440
00441
00442
00443 void KChartPolarSubTypeChartPage::apply()
00444 {
00445 if( normal->isChecked() )
00446 m_params->setPolarChartSubType( KDChartParams::PolarNormal );
00447 else if( stacked->isChecked() )
00448 m_params->setPolarChartSubType( KDChartParams::PolarStacked );
00449 else if( percent->isChecked() )
00450 m_params->setPolarChartSubType( KDChartParams::PolarPercent );
00451 else {
00452 kdDebug( 35001 ) << "Error in groupbutton" << endl;
00453 }
00454 }
00455
00456 }