27#include "kspread_dlg_series.h"
28#include "kspread_doc.h"
29#include "kspread_editors.h"
30#include "kspread_sheet.h"
31#include "kspread_view.h"
37#include <tqbuttongroup.h>
38#include <tqgroupbox.h>
39#include <tdemessagebox.h>
40#include <knumvalidator.h>
42#include <tqradiobutton.h>
43#include <tqcheckbox.h>
44#include <tqlineedit.h>
45#include <tqwhatsthis.h>
50SeriesDlg::SeriesDlg( View* parent, const char* name, const TQPoint &_marker)
51 : KDialogBase( parent, name,true,i18n( "Series"),Ok|Cancel )
55 TQWidget *page = new TQWidget( this );
58 TQBoxLayout *grid1 = new TQHBoxLayout(page);
59 grid1->setSpacing( spacingHint() );
61 TQButtonGroup* gb1 = new TQButtonGroup( 2, TQt::Vertical,
62 i18n( "Insert Values"), page );
63 column = new TQRadioButton( i18n( "Vertical"), gb1 );
64 TQWhatsThis::add(column, i18n( "Insert the series vertically, one below the other") );
65 row = new TQRadioButton( i18n( "Horizontal"), gb1 );
66 TQWhatsThis::add(row, i18n( "Insert the series horizontally, from left to right") );
68 column->setChecked( true);
70 TQButtonGroup* gb2 = new TQButtonGroup( 2, TQt::Vertical,
72 linear = new TQRadioButton( i18n( "Linear (2,4,6,...)"), gb2 );
73 TQWhatsThis::add(linear, i18n( "Generate a series from 'start' to 'end' and for each step add "
74 "the value provided in step. This creates a series where each value "
75 "is 'step' larger than the value before it.") );
76 geometric = new TQRadioButton( i18n( "Geometric (2,4,8,...)"), gb2 );
77 TQWhatsThis::add(geometric, i18n( "Generate a series from 'start' to 'end' and for each step multiply "
78 "the value with the value provided in step. Using a step of 5 produces a list like: "
79 "5, 25, 125, 625 since 5 multiplied by 5 (step) equals 25, and that multiplied by 5 equals 125, "
80 "which multiplied by the same step-value of 5 equals 625.") );
82 linear->setChecked( true);
84 TQGroupBox* gb = new TQGroupBox( 1, TQt::Vertical, i18n( "Parameters"), page );
85 TQWidget *params = new TQWidget( gb );
86 TQGridLayout *params_layout = new TQGridLayout( params, 3, 2 );
87 params_layout->setSpacing( spacingHint() );
88 params_layout->setAutoAdd( true );
90 new TQLabel( i18n( "Start value:" ), params );
91 start= new KDoubleNumInput(-999999.999, 999999.99, 0.0, 1.0, 3, params);
93 new TQLabel( i18n( "Stop value:" ), params );
94 end= new KDoubleNumInput(-999999.999, 999999.99, 0.0, 1.0, 3, params);
96 new TQLabel( i18n( "Step value:" ), params );
97 step= new KDoubleNumInput(-999999.999, 999999.99, 0.0, 1.0, 3, params);
101 grid1->addWidget(gb1);
102 grid1->addWidget(gb2);
106 connect( this, TQ_SIGNAL( okClicked() ), this, TQ_SLOT( slotOk() ) );
110void SeriesDlg::slotOk()
116 double dstep, dend, dstart;
118 m_pSheet = m_pView->activeSheet();
120 if(column->isChecked())
122 else if(row->isChecked())
125 if (linear->isChecked())
127 else if (geometric->isChecked())
130 dstart = start->value();
132 dstep = step->value();
133 if ( type == Geometric )
135 if ( dstart < 0 || dend < 0 )
137 KMessageBox::error( this, i18n( "End and start value must be positive.") );
140 if ( dstart > dend && dstep >= 1)
142 KMessageBox::error( this, i18n( "End value must be greater than the start value or the step must be less than '1'.") );
145 if ( dstart == 0 || dend == 0 || dstep == 0)
147 KMessageBox::error( this, i18n( "None of the Start, Stop or Step values may be equal to zero.") );
152 KMessageBox::error( this, i18n( "Step value must be different from 1") );
159 if (linear->isChecked() && dstep == 0)
161 KMessageBox::error( this, i18n( "The step value must be greater than zero; "
162 "otherwise, the linear series is infinite.") );
174 else if ( type == Linear && dend < dstart )
176 KMessageBox::error( this,
177 i18n( "If the start value is greater than the end value the step must be less than zero.") );
181 else if (type != Linear)
183 KMessageBox::error( this, i18n( "Step is negative.") );
190 KMessageBox::error( this,
191 i18n( "If the step is negative, the start value must be greater then the end value.") );
198 m_pView->doc()->emitBeginOperation( false );
200 m_pSheet->setSeries( marker, dstart, dend, dstep, mode, type );
202 Cell * cell = m_pSheet->cellAt( marker.x(), marker.y() );
203 if ( cell-> text() != 0L )
204 m_pView->editWidget()->setText( cell-> text() );
206 m_pView->editWidget()->setText( "" );
208 m_pView->slotUpdateView( m_pView->activeSheet() );
213#include "kspread_dlg_series.moc"
For every cell in the spread sheet there is a Cell object.
TQString text() const Return the text the user entered.
The View class displays a KSpread document.
|