kchart

kchartPieConfigPage.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 2000,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 "kchartPieConfigPage.h"
00021 #include "kchartPieConfigPage.moc"
00022 
00023 #include <kapplication.h>
00024 #include <klocale.h>
00025 #include <qlayout.h>
00026 #include <qlabel.h>
00027 #include <kfontdialog.h>
00028 
00029 #include <qcheckbox.h>
00030 #include <qlineedit.h>
00031 #include <qradiobutton.h>
00032 #include <qpushbutton.h>
00033 #include <qfont.h>
00034 #include <qspinbox.h>
00035 
00036 #include "kchart_params.h"
00037 
00038 
00039 namespace KChart
00040 {
00041 
00042 KChartPieConfigPage::KChartPieConfigPage( KChartParams* params,
00043                                           QWidget* parent,
00044                                           KDChartTableData* data) :
00045     QWidget( parent ),_params( params )
00046 {
00047     //    col=_params->colPie;
00048     pos=-1;
00049     QGridLayout *grid = new QGridLayout(this,10,4,KDialog::marginHint(), 
00050                     KDialog::spacingHint());
00051     // The listview
00052     list = new QListView( this );
00053     list->resize( list->sizeHint() );
00054     grid->addMultiCellWidget(list,0,9,0,0);
00055     list->addColumn( i18n("Hide Piece") );
00056     list->setRootIsDecorated( TRUE );
00057 
00058     QLabel* label = new QLabel( i18n( "Column active:" ), this );
00059     label->resize( label->sizeHint() );
00060     grid->addWidget( label,0,1);
00061 
00062     column = new QSpinBox(1, data->cols(), 1, this);
00063     column->resize(100, column->sizeHint().height() );
00064     grid->addWidget( column,1,1);
00065 
00066     column->setValue(col+1);
00067 
00068     label = new QLabel( i18n( "Move piece to:" ), this );
00069     label->resize( label->sizeHint() );
00070     grid->addWidget( label,2,1);
00071 
00072     dist = new QSpinBox(0, 400, 1, this);
00073     dist->resize(100, dist->sizeHint().height() );
00074     grid->addWidget( dist,3,1);
00075 
00076     label = new QLabel( i18n( "Explode factor (%):" ), this );
00077     label->resize( label->sizeHint() );
00078     grid->addWidget( label,4,1);
00079 
00080     explose = new QSpinBox(0, 100, 1, this);
00081     explose->resize(100, explose->sizeHint().height() );
00082     grid->addWidget( explose,5,1);
00083 
00084     grid->addColSpacing(0,list->width());
00085     grid->addColSpacing(2,list->width());
00086     grid->addColSpacing(3,list->width());
00087 
00088 
00089     initList();
00090     dist->setEnabled(false);
00091 
00092     connect(column,SIGNAL(valueChanged(int)),this,SLOT(changeValue(int)));
00093 
00094     connect( list, SIGNAL( selectionChanged(QListViewItem *) ), this, SLOT( slotselected(QListViewItem *) ) );
00095 }
00096 
00097 
00098 void KChartPieConfigPage::initList()
00099 {
00100     //int index;
00101     // PENDING(kalle) Put back in
00102     //     for( QStringList::Iterator it = _params->legend.begin(); it != _params->legend.end(); ++it ) {
00103 //         (void)new QCheckListItem( list, (*it),QCheckListItem::CheckBox ) ;
00104 
00105 //     }
00106     QListViewItemIterator it( list );
00107     //Select or not CheckBox
00108     // PENDING(kalle) Put back in
00109     //     for( ; it.current(); ++it )  {
00110 //         index = _params->legend.findIndex(((QCheckListItem*)it.current())->text());
00111 //         ((QCheckListItem*)it.current())->setOn(_params->missing[_params->legend.count()*col+index]) ;
00112 //     }
00113 //     value.duplicate(_params->explode);
00114 }
00115 
00116 
00117 void KChartPieConfigPage::slotselected(QListViewItem */*it*/)
00118 {
00119     //column : 0
00120     //cout <<"Select :"<<(it)->text(0).ascii()<<endl;
00121     // PENDING(kalle) Put back in
00122     //     int index = _params->legend.findIndex((it)->text(0));
00123     if(pos==-1)
00124     dist->setEnabled(true);
00125     else
00126     value[pos]=dist->value();
00127 
00128     // PENDING(kalle) Put back in
00129     //     pos=_params->legend.count()*col+index;
00130     dist->setValue(value[pos]);
00131 }
00132 
00133 
00134 void KChartPieConfigPage::changeValue(int val)
00135 {
00136     col=val-1;
00137     QListViewItemIterator it( list );
00138     //Select or not CheckBox
00139     ;
00140     //int index=0;
00141     for( ; it.current(); ++it ) {
00142         // PENDING(kalle) Put back in
00143         //         index = _params->legend.findIndex(((QCheckListItem*)it.current())->text());
00144 //         ((QCheckListItem*)it.current())->setOn(_params->missing[_params->legend.count()*col+index]) ;
00145     }
00146 
00147     if(pos!=-1) {
00148         value[pos]=dist->value();
00149         // PENDING(kalle) Put back in
00150         //         pos=_params->legend.count()*col+index;
00151         dist->setValue(value[pos]);
00152     }
00153 }
00154 
00155 
00156 void KChartPieConfigPage::init()
00157 {
00158     QListViewItemIterator it( list );
00159     //Select or not CheckBox
00160 
00161     //int index = 0;
00162     for( ; it.current(); ++it ) {
00163         // PENDING(kalle) Put back in
00164         //        index = _params->legend.findIndex(((QCheckListItem*)it.current())->text());
00165         //         ((QCheckListItem*)it.current())->setOn(_params->missing[_params->legend.count()*col+index]) ;
00166     }
00167 
00168     // PENDING(kalle) Put back in
00169 //     value.duplicate(_params->explode);
00170 //     if(pos!=-1) {
00171 //             pos=_params->legend.count()*col;
00172 //             dist->setValue(  value[pos]);
00173 //  }
00174     explose->setValue((int)(_params->explodeFactor()*100));
00175 }
00176 
00177 
00178 void KChartPieConfigPage::apply()
00179 {
00180     QListViewItemIterator it( list );
00181     //Select or not CheckBox
00182     //int index = 0;
00183     for( ; it.current(); ++it ) {
00184         // PENDING(kalle) Put back in
00185         //         index = _params->legend.findIndex(((QCheckListItem*)it.current())->text());
00186 //         _params->missing[_params->legend.count()*col+index]=((QCheckListItem*)it.current())->isOn() ;
00187     }
00188     //     _params->colPie=col;
00189 
00190     // PENDING(kalle) Put back in
00191     //     value[pos]=dist->value();
00192 //     _params->explode.duplicate(value);
00193     _params->setExplodeFactor(((double)(explose->value()))/100);
00194 }
00195 
00196 }  //KChart namespace
KDE Home | KDE Accessibility Home | Description of Access Keys