kchart

kchartWizard.cc

00001 
00002 #include "kchartWizard.h"
00003 #include "kchartWizardSelectDataPage.h"
00004 #include "kchartWizardSelectChartTypePage.h"
00005 #include "kchartWizardSelectChartSubTypePage.h"
00006 #include "kchartWizardSetupDataPage.h"
00007 #include "kchartWizardLabelsLegendPage.h"
00008 #include "kchartWizardSetupAxesPage.h"
00009 #include "kchartWizardSelectDataFormatPage.h"
00010 
00011 #include <qlineedit.h>
00012 #include <qwidget.h>
00013 #include <qpushbutton.h>
00014 
00015 #include <kglobal.h>
00016 #include <kiconloader.h>
00017 #include <kdebug.h>
00018 
00019 #include "kchart_params.h"
00020 
00021 namespace KChart
00022 {
00023 
00024 KChartWizard::KChartWizard ( KChartPart* _chart, QWidget *parent, const char* name,
00025                              bool modal, WFlags f ) :
00026     KWizard( parent, name, modal, f ),
00027     m_chart( _chart )
00028 {
00029     // First page: select the data range
00030     m_dataFormatPage = new KChartWizardSelectDataFormatPage(this, m_chart);
00031     addPage( m_dataFormatPage, i18n("Data"));
00032     setFinishEnabled(m_dataFormatPage, true);
00033     setHelpEnabled(m_dataFormatPage, false);
00034     
00035     // Second page: select the major chart type
00036     m_chartTypePage = new KChartWizardSelectChartTypePage( this, m_chart );
00037     addPage( m_chartTypePage, i18n( "Select Chart Type" ) );
00038     //finishButton()->setEnabled( TRUE );
00039     setFinishEnabled(m_chartTypePage, true);
00040     setHelpEnabled(m_chartTypePage, false);
00041 
00042     // Third page: select the minor chart type
00043     m_chartSubtypePage = new KChartWizardSelectChartSubTypePage( this, m_chart );
00044     addPage( m_chartSubtypePage, i18n( "Select Chart Sub-type" ) );
00045     setFinishEnabled(m_chartSubtypePage, true);
00046     setHelpEnabled(m_chartSubtypePage, false);
00047 
00048     // Fourth page: labels/legends setup
00049     m_labelsLegendPage = new KChartWizardLabelsLegendPage( this, m_chart );
00050     addPage( m_labelsLegendPage, i18n( "Labels & Legend" ) );
00051     setFinishEnabled(m_labelsLegendPage, true);
00052     setHelpEnabled(m_labelsLegendPage, false);
00053 
00054     // Fifth page: axes setup
00055     m_axespage = new KChartWizardSetupAxesPage( this, m_chart );
00056     addPage( m_axespage, i18n( "Setup Axes" ) );
00057     setFinishEnabled(m_axespage, true);
00058     setNextEnabled(m_axespage, false);
00059     setHelpEnabled(m_axespage, false);
00060 
00061     // connect( this, SIGNAL( finished() ), _selectdatapage, SLOT( apply() ) );
00062     connect(this, SIGNAL(finished()), m_dataFormatPage,   SLOT(apply()));
00063     connect(this, SIGNAL(finished()), m_chartTypePage,    SLOT(apply()));
00064     connect(this ,SIGNAL(finished()), m_chartSubtypePage, SLOT(apply()));
00065     connect(this, SIGNAL(finished()), m_labelsLegendPage, SLOT(apply()));
00066     connect(this, SIGNAL(finished()), m_axespage,         SLOT(apply()));
00067 
00068     connect( m_chartTypePage, SIGNAL( chartChange( int ) ),
00069              this,            SLOT( subType( int ) ) );
00070     adjustSize();
00071 
00072     subType( m_chart->params()->chartType() );
00073     kdDebug(35001) << "kchartwizard created" << endl;
00074 }
00075 
00076 
00077 KChartWizard::~KChartWizard()
00078 {
00079     //  delete _selectdatapage;
00080     delete m_chartTypePage;
00081     delete m_chartSubtypePage;
00082     //delete _setupdatapage;
00083     delete m_labelsLegendPage;
00084     delete m_axespage;
00085     delete m_dataFormatPage;
00086 }
00087 
00088 void KChartWizard::subType(int _type)
00089 {
00090     KChartParams::ChartType  type = (KChartParams::ChartType) _type;
00091     if (type == KChartParams::Bar ||
00092         type == KChartParams::Line ||
00093         type == KChartParams::Area ||
00094         type == KChartParams::HiLo ||
00095         type == KChartParams::Polar) {
00096         m_chartSubtypePage->chartSubType = true;
00097     } else {
00098         m_chartSubtypePage->chartSubType = false;
00099     }
00100     m_chartSubtypePage->changeSubTypeName( type );
00101     if( ( type == KChartParams::Bar && m_chart->params()->threeDBars() ) 
00102     || ( type == KChartParams::Pie && m_chart->params()->threeDPies() ) ) {
00103     m_axespage->chart3d = true;
00104     } else {
00105         m_axespage->chart3d = false;
00106     }
00107 
00108 #if 0               // No second Y axis so far /ingwa
00109     if ( m_chart->params()->axisVisible( KDChartAxisParams::AxisPosRight ) ) {
00110         m_labelsLegendPage->ytitle2 = true;
00111     } else {
00112         m_labelsLegendPage->ytitle2 = false;
00113     }
00114 #endif
00115 }
00116 
00117 
00118 bool KChartWizard::appropriate( QWidget * w ) const
00119 {
00120     // Show the sub-type page only if has anything to show
00121     if ( w == m_chartSubtypePage )
00122         return m_chartSubtypePage->chartSubType;
00123     else
00124         return true;
00125 }
00126 
00127 
00128 void KChartWizard::next()
00129 {
00130     // Some sort of a hack. We want the chart-subtype-page to get
00131     // dynamically built when it's going to be shown
00132     //if ( currentPage() == _charttypePage )
00133     //_chartSubtypePage->createChildren();
00134 
00135     QWizard::next();
00136 }
00137 
00138 void KChartWizard::accept()
00139 {
00140     emit finished();
00141     QWizard::accept();
00142 }
00143 
00144 void KChartWizard::reject()
00145 {
00146     emit cancelled();
00147     QWizard::reject();
00148 }
00149 
00150 void KChartWizard::setDataArea( const QString &area )
00151 {
00152     m_dataFormatPage->setDataArea( area );
00153 }
00154 
00155 
00156 QString KChartWizard::dataArea() const
00157 {
00158     return m_dataFormatPage->dataArea();
00159 }
00160 
00161 
00162 void KChartWizard::emitNeedNewData( const char* area, int rowcol,
00163                     bool firstRowIsLegend,
00164                     bool firstColIsLabel )
00165 {
00166     emit needNewData( area, rowcol, firstRowIsLegend, firstColIsLabel );
00167 }
00168 
00169 }  //KChart namespace
00170 
00171 #include "kchartWizard.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys