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
44using namespace std;
45
46#include "kchart_params.h"
47#include "kchart_part.h"
48
49namespace KChart
50{
51
52KChartDataConfigPage::KChartDataConfigPage( KChartParams* params,
53 TQWidget* parent,
54 KDChartTableData *dat)
55 : TQWidget( parent ), m_params( params ), data(dat),
56 m_firstRowAsLabel(0), m_firstColAsLabel(0)
57{
58 TQGridLayout *grid1 = new TQGridLayout(this, 4, 1, KDialog::marginHint(),
59 KDialog::spacingHint());
60
61 // The Data Area
62 if ( !m_params->part()->canChangeValue() ) {
63 TQButtonGroup *gb1 = new TQVButtonGroup( i18n( "Data Area" ), this );
64
65 // ================================================================
66 // This code is copied from kchartWizardSelectDataFormatPage.cpp
67 TQHBox *hbox = new TQHBox( gb1 );
68 (void) new TQLabel( i18n("Area: "), hbox);
69 m_dataArea = new TQLineEdit( hbox );
70
71 // The row/column as label checkboxes.
72 m_firstRowAsLabel = new TQCheckBox( i18n( "First row as label" ), gb1);
73 m_firstColAsLabel = new TQCheckBox( i18n( "First column as label" ), gb1);
74
75 grid1->addWidget(gb1, 0, 0);
76 }
77
78 // The Data Format button group
79 TQButtonGroup *gb = new TQVButtonGroup( i18n( "Data Format" ), this );
80
81 m_rowMajor = new TQRadioButton( i18n( "Data in rows" ), gb );
82 m_rowMajor->resize( m_rowMajor->sizeHint() );
83
84 m_colMajor = new TQRadioButton( i18n( "Data in columns" ), gb );
85 m_colMajor->resize( m_colMajor->sizeHint() );
86
87 grid1->addWidget(gb, 2, 0);
88
89 TQWhatsThis::add(this, i18n("This configuration page can be used to swap the interpretation of rows and columns."));
90 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."));
91
92 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."));
93 m_colMajor->resize( m_colMajor->sizeHint() );
94 grid1->addWidget(gb, 1, 0);
95 grid1->setColStretch(3, 0);
96
97 grid1->activate();
98}
99
100
101void KChartDataConfigPage::init()
102{
103 if (m_params->dataDirection() == KChartParams::DataRows)
104 m_rowMajor->setChecked(true);
105 else
106 m_colMajor->setChecked(true);
107
108 if ( !m_params->part()->canChangeValue() ) {
109 m_firstRowAsLabel->setChecked( m_params->firstRowAsLabel() );
110 m_firstColAsLabel->setChecked( m_params->firstColAsLabel() );
111
112 m_dataArea->setText( m_params->dataArea() );
113 }
114}
115
116
117void KChartDataConfigPage::defaults()
118{
119 m_colMajor->setChecked( true );
120
121 if ( !m_params->part()->canChangeValue() ) {
122 m_firstRowAsLabel->setChecked( false );
123 m_firstColAsLabel->setChecked( false );
124
125 m_dataArea->setText( "" );
126 }
127}
128
129
130void KChartDataConfigPage::apply()
131{
132 if (m_rowMajor->isChecked())
133 m_params->setDataDirection( KChartParams::DataRows );
134 else
135 m_params->setDataDirection( KChartParams::DataColumns );
136
137 if ( !m_params->part()->canChangeValue() ) {
138 m_params->setFirstRowAsLabel( m_firstRowAsLabel->isChecked() );
139 m_params->setFirstColAsLabel( m_firstColAsLabel->isChecked() );
140
141 m_params->setDataArea( m_dataArea->text() );
142 }
143}
144
145
146} //KChart namespace