kchart

kchartWizard.cpp
1
2#include "kchartWizard.h"
3#include "kchartWizardSelectDataPage.h"
4#include "kchartWizardSelectChartTypePage.h"
5#include "kchartWizardSelectChartSubTypePage.h"
6#include "kchartWizardSetupDataPage.h"
7#include "kchartWizardLabelsLegendPage.h"
8#include "kchartWizardSetupAxesPage.h"
9#include "kchartWizardSelectDataFormatPage.h"
10
11#include <tqlineedit.h>
12#include <tqwidget.h>
13#include <tqpushbutton.h>
14
15#include <tdeglobal.h>
16#include <kiconloader.h>
17#include <kdebug.h>
18
19#include "kchart_params.h"
20
21namespace KChart
22{
23
24KChartWizard::KChartWizard ( KChartPart* _chart, TQWidget *parent, const char* name,
25 bool modal, WFlags f ) :
26 KWizard( parent, name, modal, f ),
27 m_chart( _chart )
28{
29 // First page: select the data range
30 m_dataFormatPage = new KChartWizardSelectDataFormatPage(this, m_chart);
31 addPage( m_dataFormatPage, i18n("Data"));
32 setFinishEnabled(m_dataFormatPage, true);
33 setHelpEnabled(m_dataFormatPage, false);
34
35 // Second page: select the major chart type
36 m_chartTypePage = new KChartWizardSelectChartTypePage( this, m_chart );
37 addPage( m_chartTypePage, i18n( "Select Chart Type" ) );
38 //finishButton()->setEnabled( true );
39 setFinishEnabled(m_chartTypePage, true);
40 setHelpEnabled(m_chartTypePage, false);
41
42 // Third page: select the minor chart type
43 m_chartSubtypePage = new KChartWizardSelectChartSubTypePage( this, m_chart );
44 addPage( m_chartSubtypePage, i18n( "Select Chart Sub-type" ) );
45 setFinishEnabled(m_chartSubtypePage, true);
46 setHelpEnabled(m_chartSubtypePage, false);
47
48 // Fourth page: labels/legends setup
49 m_labelsLegendPage = new KChartWizardLabelsLegendPage( this, m_chart );
50 addPage( m_labelsLegendPage, i18n( "Labels & Legend" ) );
51 setFinishEnabled(m_labelsLegendPage, true);
52 setHelpEnabled(m_labelsLegendPage, false);
53
54 // Fifth page: axes setup
55 m_axespage = new KChartWizardSetupAxesPage( this, m_chart );
56 addPage( m_axespage, i18n( "Setup Axes" ) );
57 setFinishEnabled(m_axespage, true);
58 setNextEnabled(m_axespage, false);
59 setHelpEnabled(m_axespage, false);
60
61 // connect( this, TQ_SIGNAL( finished() ), _selectdatapage, TQ_SLOT( apply() ) );
62 connect(this, TQ_SIGNAL(finished()), m_dataFormatPage, TQ_SLOT(apply()));
63 connect(this, TQ_SIGNAL(finished()), m_chartTypePage, TQ_SLOT(apply()));
64 connect(this ,TQ_SIGNAL(finished()), m_chartSubtypePage, TQ_SLOT(apply()));
65 connect(this, TQ_SIGNAL(finished()), m_labelsLegendPage, TQ_SLOT(apply()));
66 connect(this, TQ_SIGNAL(finished()), m_axespage, TQ_SLOT(apply()));
67
68 connect( m_chartTypePage, TQ_SIGNAL( chartChange( int ) ),
69 this, TQ_SLOT( subType( int ) ) );
70 adjustSize();
71
72 subType( m_chart->params()->chartType() );
73 kdDebug(35001) << "kchartwizard created" << endl;
74}
75
76
77KChartWizard::~KChartWizard()
78{
79 // delete _selectdatapage;
80 delete m_chartTypePage;
81 delete m_chartSubtypePage;
82 //delete _setupdatapage;
83 delete m_labelsLegendPage;
84 delete m_axespage;
85 delete m_dataFormatPage;
86}
87
88void KChartWizard::subType(int _type)
89{
90 KChartParams::ChartType type = (KChartParams::ChartType) _type;
91 if (type == KChartParams::Bar ||
92 type == KChartParams::Line ||
93 type == KChartParams::Area ||
94 type == KChartParams::HiLo ||
95 type == KChartParams::Polar) {
96 m_chartSubtypePage->chartSubType = true;
97 } else {
98 m_chartSubtypePage->chartSubType = false;
99 }
100 m_chartSubtypePage->changeSubTypeName( type );
101 if( ( type == KChartParams::Bar && m_chart->params()->threeDBars() )
102 || ( type == KChartParams::Pie && m_chart->params()->threeDPies() ) ) {
103 m_axespage->chart3d = true;
104 } else {
105 m_axespage->chart3d = false;
106 }
107
108#if 0 // No second Y axis so far /ingwa
109 if ( m_chart->params()->axisVisible( KDChartAxisParams::AxisPosRight ) ) {
110 m_labelsLegendPage->ytitle2 = true;
111 } else {
112 m_labelsLegendPage->ytitle2 = false;
113 }
114#endif
115}
116
117
118bool KChartWizard::appropriate( TQWidget * w ) const
119{
120 // Show the sub-type page only if has anything to show
121 if ( w == m_chartSubtypePage )
122 return m_chartSubtypePage->chartSubType;
123 else
124 return true;
125}
126
127
128void KChartWizard::next()
129{
130 // Some sort of a hack. We want the chart-subtype-page to get
131 // dynamically built when it's going to be shown
132 //if ( currentPage() == _charttypePage )
133 //_chartSubtypePage->createChildren();
134
135 TQWizard::next();
136}
137
138void KChartWizard::accept()
139{
140 emit finished();
141 TQWizard::accept();
142}
143
144void KChartWizard::reject()
145{
146 emit cancelled();
147 TQWizard::reject();
148}
149
150void KChartWizard::setDataArea( const TQString &dataArea )
151{
152 m_dataFormatPage->setDataArea( dataArea );
153}
154
155
156TQString KChartWizard::dataArea() const
157{
158 return m_dataFormatPage->dataArea();
159}
160
161
162void KChartWizard::emitNeedNewData( const char* area, int rowcol,
163 bool firstRowIsLegend,
164 bool firstColIsLabel )
165{
166 emit needNewData( area, rowcol, firstRowIsLegend, firstColIsLabel );
167}
168
169} //KChart namespace
170
171#include "kchartWizard.moc"