kchart

kchartDataConfigPage.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001,2002,2003,2004 Laurent Montel <montel@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "kchartDataConfigPage.h"
21
22#include "kchartDataConfigPage.moc"
23
24#include <tdeapplication.h>
25#include <tdelocale.h>
26#include <kcolorbutton.h>
27#include <kdebug.h>
28
29#include <tqhbox.h>
30#include <tqlayout.h>
31#include <tqlabel.h>
32#include <tqlineedit.h>
33#include <tqlistbox.h>
34#include <tqbuttongroup.h>
35#include <tqvbuttongroup.h>
36#include <tqpushbutton.h>
37#include <tqradiobutton.h>
38#include <tqcheckbox.h>
39#include <tqpainter.h>
40#include <tqwhatsthis.h>
41
42#include <tdefontdialog.h>
43
44// For IRIX
45namespace std {}
46
47using namespace std;
48
49#include "kchart_params.h"
50#include "kchart_part.h"
51
52namespace KChart
53{
54
55KChartDataConfigPage::KChartDataConfigPage( KChartParams* params,
56 TQWidget* parent,
57 KDChartTableData *dat)
58 : TQWidget( parent ), m_params( params ), data(dat),
59 m_firstRowAsLabel(0), m_firstColAsLabel(0)
60{
61 TQGridLayout *grid1 = new TQGridLayout(this, 4, 1, KDialog::marginHint(),
62 KDialog::spacingHint());
63
64 // The Data Area
65 if ( !m_params->part()->canChangeValue() ) {
66 TQButtonGroup *gb1 = new TQVButtonGroup( i18n( "Data Area" ), this );
67
68 // ================================================================
69 // This code is copied from kchartWizardSelectDataFormatPage.cpp
70 TQHBox *hbox = new TQHBox( gb1 );
71 (void) new TQLabel( i18n("Area: "), hbox);
72 m_dataArea = new TQLineEdit( hbox );
73
74 // The row/column as label checkboxes.
75 m_firstRowAsLabel = new TQCheckBox( i18n( "First row as label" ), gb1);
76 m_firstColAsLabel = new TQCheckBox( i18n( "First column as label" ), gb1);
77
78 grid1->addWidget(gb1, 0, 0);
79 }
80
81 // The Data Format button group
82 TQButtonGroup *gb = new TQVButtonGroup( i18n( "Data Format" ), this );
83
84 m_rowMajor = new TQRadioButton( i18n( "Data in rows" ), gb );
85 m_rowMajor->resize( m_rowMajor->sizeHint() );
86
87 m_colMajor = new TQRadioButton( i18n( "Data in columns" ), gb );
88 m_colMajor->resize( m_colMajor->sizeHint() );
89
90 grid1->addWidget(gb, 2, 0);
91
92 TQWhatsThis::add(this, i18n("This configuration page can be used to swap the interpretation of rows and columns."));
93 TQWhatsThis::add(m_rowMajor, i18n("By default one row is considered to be a data set and each column holds the individual values of the data series. This sets the data in rows on your chart."));
94
95 TQWhatsThis::add(m_colMajor, i18n("Here you can choose to have each column hold one data set. Note that the values are not really swapped but only their interpretation."));
96 m_colMajor->resize( m_colMajor->sizeHint() );
97 grid1->addWidget(gb, 1, 0);
98 grid1->setColStretch(3, 0);
99
100 grid1->activate();
101}
102
103
104void KChartDataConfigPage::init()
105{
106 if (m_params->dataDirection() == KChartParams::DataRows)
107 m_rowMajor->setChecked(true);
108 else
109 m_colMajor->setChecked(true);
110
111 if ( !m_params->part()->canChangeValue() ) {
112 m_firstRowAsLabel->setChecked( m_params->firstRowAsLabel() );
113 m_firstColAsLabel->setChecked( m_params->firstColAsLabel() );
114
115 m_dataArea->setText( m_params->dataArea() );
116 }
117}
118
119
120void KChartDataConfigPage::defaults()
121{
122 m_colMajor->setChecked( true );
123
124 if ( !m_params->part()->canChangeValue() ) {
125 m_firstRowAsLabel->setChecked( false );
126 m_firstColAsLabel->setChecked( false );
127
128 m_dataArea->setText( "" );
129 }
130}
131
132
133void KChartDataConfigPage::apply()
134{
135 if (m_rowMajor->isChecked())
136 m_params->setDataDirection( KChartParams::DataRows );
137 else
138 m_params->setDataDirection( KChartParams::DataColumns );
139
140 if ( !m_params->part()->canChangeValue() ) {
141 m_params->setFirstRowAsLabel( m_firstRowAsLabel->isChecked() );
142 m_params->setFirstColAsLabel( m_firstColAsLabel->isChecked() );
143
144 m_params->setDataArea( m_dataArea->text() );
145 }
146}
147
148
149} //KChart namespace