kchart

kchartDataConfigPage.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001,2002,2003,2004 Laurent Montel <montel@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "kchartDataConfigPage.h"
00021 
00022 #include "kchartDataConfigPage.moc"
00023 
00024 #include <kapplication.h>
00025 #include <klocale.h>
00026 #include <kcolorbutton.h>
00027 #include <kdebug.h>
00028 
00029 #include <qhbox.h>
00030 #include <qlayout.h>
00031 #include <qlabel.h>
00032 #include <qlineedit.h>
00033 #include <qlistbox.h>
00034 #include <qbuttongroup.h>
00035 #include <qvbuttongroup.h>
00036 #include <qpushbutton.h>
00037 #include <qradiobutton.h>
00038 #include <qcheckbox.h>
00039 #include <qpainter.h>
00040 #include <qwhatsthis.h>
00041 
00042 #include <kfontdialog.h>
00043 
00044 // For IRIX
00045 namespace std {}
00046 
00047 using namespace std;
00048 
00049 #include "kchart_params.h"
00050 #include "kchart_part.h"
00051 
00052 namespace KChart
00053 {
00054 
00055 KChartDataConfigPage::KChartDataConfigPage( KChartParams* params,
00056                         QWidget* parent, 
00057                         KDChartTableData *dat) 
00058     : QWidget( parent ), m_params( params ), data(dat)
00059 {
00060     QGridLayout *grid1 = new QGridLayout(this, 4, 1, KDialog::marginHint(),
00061                      KDialog::spacingHint());
00062 
00063     // The Data Area
00064     QButtonGroup *gb1 = new QVButtonGroup( i18n( "Data Area" ), this );
00065 
00066     // ================================================================
00067     // This code is copied from kchartWizardSelectDataFormatPage.cc
00068     QHBox   *hbox = new QHBox( gb1 );
00069     (void) new QLabel( i18n("Area: "), hbox);
00070     m_dataArea = new QLineEdit( hbox );
00071     //grid1->addWidget(gb1, 0, 0);
00072 
00073     // The row/column as label checkboxes. 
00074     m_firstRowAsLabel = new QCheckBox( i18n( "First row as label" ), gb1);
00075     m_firstColAsLabel = new QCheckBox( i18n( "First column as label" ), gb1);
00076 
00077     grid1->addWidget(gb1, 0, 0);
00078 
00079     // The Data Format button group
00080     QButtonGroup *gb = new QVButtonGroup( i18n( "Data Format" ), this );
00081 
00082     m_rowMajor = new QRadioButton( i18n( "Data in rows" ), gb );
00083     m_rowMajor->resize( m_rowMajor->sizeHint() );
00084 
00085     m_colMajor = new QRadioButton( i18n( "Data in columns" ), gb );
00086     m_colMajor->resize( m_colMajor->sizeHint() );
00087 
00088     grid1->addWidget(gb, 2, 0);
00089 
00090     QWhatsThis::add(this, i18n("This configuration page can be used to swap the interpretation of rows and columns."));
00091     QWhatsThis::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."));
00092 
00093     QWhatsThis::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."));
00094     m_colMajor->resize( m_colMajor->sizeHint() );
00095     grid1->addWidget(gb, 1, 0);
00096     grid1->setColStretch(3, 0);
00097 
00098     grid1->activate();
00099 }
00100 
00101 
00102 void KChartDataConfigPage::init()
00103 {
00104     if (m_params->dataDirection() == KChartParams::DataRows)
00105     m_rowMajor->setChecked(true);
00106     else
00107     m_colMajor->setChecked(true);
00108 
00109     m_firstRowAsLabel->setChecked( m_params->firstRowAsLabel() );
00110     m_firstColAsLabel->setChecked( m_params->firstColAsLabel() );
00111 }
00112 
00113 
00114 void KChartDataConfigPage::defaults()
00115 {
00116     m_colMajor->setChecked( true );
00117     m_firstRowAsLabel->setChecked( false );
00118     m_firstColAsLabel->setChecked( false );
00119 }
00120 
00121 
00122 void KChartDataConfigPage::apply()
00123 {
00124     if (m_rowMajor->isChecked())
00125     m_params->setDataDirection( KChartParams::DataRows );
00126     else
00127     m_params->setDataDirection( KChartParams::DataColumns );
00128 
00129     m_params->setFirstRowAsLabel( m_firstRowAsLabel->isChecked() );
00130     m_params->setFirstColAsLabel( m_firstColAsLabel->isChecked() );
00131 }
00132 
00133 
00134 }  //KChart namespace
KDE Home | KDE Accessibility Home | Description of Access Keys