kchart

kchartPieConfigPage.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2000,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 "kchartPieConfigPage.h"
21#include "kchartPieConfigPage.moc"
22
23#include <tdeapplication.h>
24#include <tdelocale.h>
25#include <tqlayout.h>
26#include <tqlabel.h>
27#include <tdefontdialog.h>
28
29#include <tqcheckbox.h>
30#include <tqlineedit.h>
31#include <tqradiobutton.h>
32#include <tqpushbutton.h>
33#include <tqfont.h>
34#include <tqspinbox.h>
35
36#include "kchart_params.h"
37
38
39namespace KChart
40{
41
42KChartPieConfigPage::KChartPieConfigPage( KChartParams* params,
43 TQWidget* parent,
44 KDChartTableData* data) :
45 TQWidget( parent ),_params( params )
46{
47 // col=_params->colPie;
48 pos=-1;
49 TQGridLayout *grid = new TQGridLayout(this,10,4,KDialog::marginHint(),
50 KDialog::spacingHint());
51 // The listview
52 list = new TQListView( this );
53 list->resize( list->sizeHint() );
54 grid->addMultiCellWidget(list,0,9,0,0);
55 list->addColumn( i18n("Hide Piece") );
56 list->setRootIsDecorated( true );
57
58 TQLabel* label = new TQLabel( i18n( "Column active:" ), this );
59 label->resize( label->sizeHint() );
60 grid->addWidget( label,0,1);
61
62 column = new TQSpinBox(1, data->cols(), 1, this);
63 column->resize(100, column->sizeHint().height() );
64 grid->addWidget( column,1,1);
65
66 column->setValue(col+1);
67
68 label = new TQLabel( i18n( "Move piece to:" ), this );
69 label->resize( label->sizeHint() );
70 grid->addWidget( label,2,1);
71
72 dist = new TQSpinBox(0, 400, 1, this);
73 dist->resize(100, dist->sizeHint().height() );
74 grid->addWidget( dist,3,1);
75
76 label = new TQLabel( i18n( "Explode factor (%):" ), this );
77 label->resize( label->sizeHint() );
78 grid->addWidget( label,4,1);
79
80 explose = new TQSpinBox(0, 100, 1, this);
81 explose->resize(100, explose->sizeHint().height() );
82 grid->addWidget( explose,5,1);
83
84 grid->addColSpacing(0,list->width());
85 grid->addColSpacing(2,list->width());
86 grid->addColSpacing(3,list->width());
87
88
89 initList();
90 dist->setEnabled(false);
91
92 connect(column,TQ_SIGNAL(valueChanged(int)),this,TQ_SLOT(changeValue(int)));
93
94 connect( list, TQ_SIGNAL( selectionChanged(TQListViewItem *) ), this, TQ_SLOT( slotselected(TQListViewItem *) ) );
95}
96
97
98void KChartPieConfigPage::initList()
99{
100 //int index;
101 // PENDING(kalle) Put back in
102 // for( TQStringList::Iterator it = _params->legend.begin(); it != _params->legend.end(); ++it ) {
103// (void)new TQCheckListItem( list, (*it),TQCheckListItem::CheckBox ) ;
104
105// }
106 TQListViewItemIterator it( list );
107 //Select or not CheckBox
108 // PENDING(kalle) Put back in
109 // for( ; it.current(); ++it ) {
110// index = _params->legend.findIndex(((TQCheckListItem*)it.current())->text());
111// ((TQCheckListItem*)it.current())->setOn(_params->missing[_params->legend.count()*col+index]) ;
112// }
113// value.duplicate(_params->explode);
114}
115
116
117void KChartPieConfigPage::slotselected(TQListViewItem */*it*/)
118{
119 //column : 0
120 //cout <<"Select :"<<(it)->text(0).ascii()<<endl;
121 // PENDING(kalle) Put back in
122 // int index = _params->legend.findIndex((it)->text(0));
123 if(pos==-1)
124 dist->setEnabled(true);
125 else
126 value[pos]=dist->value();
127
128 // PENDING(kalle) Put back in
129 // pos=_params->legend.count()*col+index;
130 dist->setValue(value[pos]);
131}
132
133
134void KChartPieConfigPage::changeValue(int val)
135{
136 col=val-1;
137 TQListViewItemIterator it( list );
138 //Select or not CheckBox
139 ;
140 //int index=0;
141 for( ; it.current(); ++it ) {
142 // PENDING(kalle) Put back in
143 // index = _params->legend.findIndex(((TQCheckListItem*)it.current())->text());
144// ((TQCheckListItem*)it.current())->setOn(_params->missing[_params->legend.count()*col+index]) ;
145 }
146
147 if(pos!=-1) {
148 value[pos]=dist->value();
149 // PENDING(kalle) Put back in
150 // pos=_params->legend.count()*col+index;
151 dist->setValue(value[pos]);
152 }
153}
154
155
156void KChartPieConfigPage::init()
157{
158 TQListViewItemIterator it( list );
159 //Select or not CheckBox
160
161 //int index = 0;
162 for( ; it.current(); ++it ) {
163 // PENDING(kalle) Put back in
164 // index = _params->legend.findIndex(((TQCheckListItem*)it.current())->text());
165 // ((TQCheckListItem*)it.current())->setOn(_params->missing[_params->legend.count()*col+index]) ;
166 }
167
168 // PENDING(kalle) Put back in
169// value.duplicate(_params->explode);
170// if(pos!=-1) {
171// pos=_params->legend.count()*col;
172// dist->setValue( value[pos]);
173// }
174 explose->setValue((int)(_params->explodeFactor()*100));
175}
176
177
178void KChartPieConfigPage::apply()
179{
180 TQListViewItemIterator it( list );
181 //Select or not CheckBox
182 //int index = 0;
183 for( ; it.current(); ++it ) {
184 // PENDING(kalle) Put back in
185 // index = _params->legend.findIndex(((TQCheckListItem*)it.current())->text());
186// _params->missing[_params->legend.count()*col+index]=((TQCheckListItem*)it.current())->isOn() ;
187 }
188 // _params->colPie=col;
189
190 // PENDING(kalle) Put back in
191 // value[pos]=dist->value();
192// _params->explode.duplicate(value);
193 _params->setExplodeFactor(((double)(explose->value()))/100);
194}
195
196} //KChart namespace