Commit 2980da78 authored by Fredrik Edemar's avatar Fredrik Edemar

Fix some things:

* Strange label on the "edit plot function"-dialog
* Check the max- and minvalue in polar and parametric dialog.
* Prevent to edit/delete a function that doesn't exist ( trigger crash) in FktDlg.
* Ability to show polar and parametric graphs again

CCMAIL:bmlmessmer@web.de
CCMAIL:kdmoeller@foni.net

svn path=/trunk/kdeedu/kmplot/; revision=315952
parent 6eb10cee
......@@ -56,6 +56,11 @@ FktDlg::~FktDlg()
void FktDlg::slotDelete()
{
if ( lb_fktliste->currentItem()== -1)
{
PushButtonDel->setEnabled(false);
return;
}
int ix, num;
if ( ( num = lb_fktliste->currentItem() ) == -1 ) return ;
......@@ -80,6 +85,11 @@ void FktDlg::slotDelete()
void FktDlg::slotEdit()
{
if ( lb_fktliste->currentItem()==-1 )
{
PushButtonEdit->setEnabled(false);
return;
}
int num = lb_fktliste->currentItem();
int index = getIx( lb_fktliste->text( num ).section( ";", 0, 0) );
......@@ -134,6 +144,7 @@ void FktDlg::slotEditFunction( int index, int num )
{
EditFunction* editFunction = new EditFunction( m_parser, this );
if ( index==-1&&num==-1) editFunction->setCaption(i18n( "New Function Plot" ));
else editFunction->setCaption(i18n( "Edit Function Plot" ));
editFunction->initDialog( index );
if( editFunction->exec() == QDialog::Accepted )
{
......
......@@ -427,17 +427,15 @@ void MainDlg::slotQuickEdit(const QString& tmp_f_str )
view->parser()->fixFunctionName(f_str);
int index = view->parser()->addfkt( f_str );
if( index == -1 )
{
view->parser()->errmsg();
m_quickEdit->setFocus();
m_quickEdit->selectAll();
view->parser()->delfkt( index );
return;
}
view->parser()->fktext[index].f_mode = 1;
view->parser()->fktext[index].anti_mode = 0;
view->parser()->fktext[index].anti_use_precision = false;
view->parser()->fktext[ index ].extstr = f_str;
view->parser()->getext( index );
m_quickEdit->clear();
......
......@@ -37,10 +37,10 @@
#include <kapplication.h>
#include <kcolorbutton.h>
#include <kiconloader.h>
#include <kmessagebox.h>
#include <knuminput.h>
#include <klineedit.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <knuminput.h>
#include <kpushbutton.h>
#include <kdebug.h>
......
......@@ -28,8 +28,10 @@
// KDE includes
#include <kapplication.h>
#include <kcolorbutton.h>
#include <knuminput.h>
#include <klineedit.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <knuminput.h>
#include <kdebug.h>
......@@ -37,6 +39,7 @@
#include "keditparametric.h"
#include "keditparametric.moc"
#include "xparser.h"
#include "View.h"
KEditParametric::KEditParametric( XParser* parser, QWidget* parent, const char* name ) :
QEditParametric( parent, name )
......@@ -113,14 +116,44 @@ void KEditParametric::accept()
if( checkBoxHide->isChecked() )
m_parser->fktext[ index ].f_mode = 0;
else
m_parser->fktext[ index ].f_mode = 1;
if( checkBoxRange->isChecked() )
{
// TODO: check empty boundaries and syntax
m_parser->fktext[ index ].str_dmin = min->text();
m_parser->fktext[ index ].dmin = m_parser->eval( min->text() );
if ( m_parser->errmsg())
{
min->setFocus();
min->selectAll();
return;
}
m_parser->fktext[ index ].str_dmax = max->text();
m_parser->fktext[ index ].dmax = m_parser->eval( max->text() );
if ( m_parser->errmsg())
{
max->setFocus();
max->selectAll();
return;
}
if ( m_parser->fktext[ index ].dmin >= m_parser->fktext[ index ].dmax)
{
KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value"));
min->setFocus();
min->selectAll();
m_parser->delfkt( index );
return;
}
if ( m_parser->fktext[ index ].dmin<View::xmin || m_parser->fktext[ index ].dmax>View::xmax )
{
KMessageBox::error(this,i18n("Please insert a minimum and maximum range between %1 and %2").arg(View::xmin).arg(View::xmax) );
min->setFocus();
min->selectAll();
m_parser->delfkt( index );
return;
}
}
m_parser->fktext[ index ].linewidth = kIntNumInputLineWidth->value();
......@@ -187,4 +220,4 @@ const QString KEditParametric::functionItem()
void KEditParametric::slotHelp()
{
kapp->invokeHelp( "", "kmplot" );
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@
#include "qeditparametric.h"
class View;
class XParser;
/** @short Dialog window editing a parametric plot and its properties. */
......
......@@ -28,8 +28,11 @@
// KDE includes
#include <kapplication.h>
#include <kcolorbutton.h>
#include <knuminput.h>
#include <klineedit.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <knuminput.h>
#include <kdebug.h>
......@@ -37,6 +40,7 @@
#include "keditpolar.h"
#include "keditpolar.moc"
#include "xparser.h"
#include "View.h"
KEditPolar::KEditPolar( XParser* parser, QWidget* parent, const char* name ) :
QEditPolar( parent, name )
......@@ -91,6 +95,7 @@ void KEditPolar::accept()
this->raise();
kLineEditYFunction->setFocus();
kLineEditYFunction->selectAll();
m_parser->delfkt( index );
return;
}
m_parser->fktext[ index ].extstr = functionItem();
......@@ -98,20 +103,50 @@ void KEditPolar::accept()
if( checkBoxHide->isChecked() )
m_parser->fktext[ index ].f_mode = 0;
else
m_parser->fktext[index].f_mode = 1;
if( checkBoxRange->isChecked() )
{
// TODO: check empty boundaries and syntax
m_parser->fktext[ index ].str_dmin = min->text();
m_parser->fktext[ index ].dmin = m_parser->eval( min->text() );
if ( m_parser->errmsg() )
{
min->setFocus();
min->selectAll();
m_parser->delfkt( index );
return;
}
m_parser->fktext[ index ].str_dmax = max->text();
m_parser->fktext[ index ].dmax = m_parser->eval( max->text() );
if ( m_parser->errmsg())
{
max->setFocus();
max->selectAll();
m_parser->delfkt( index );
return;
}
if ( m_parser->fktext[ index ].dmin >= m_parser->fktext[ index ].dmax)
{
KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value"));
min->setFocus();
min->selectAll();
m_parser->delfkt( index );
return;
}
if ( m_parser->fktext[ index ].dmin<View::xmin || m_parser->fktext[ index ].dmax>View::xmax )
{
KMessageBox::error(this,i18n("Please insert a minimum and maximum range between %1 and %2").arg(View::xmin).arg(View::xmax) );
min->setFocus();
min->selectAll();
m_parser->delfkt( index );
return;
}
}
m_parser->fktext[ index ].linewidth = kIntNumInputLineWidth->value();
m_parser->fktext[ index ].color = kColorButtonColor->color().rgb();
m_parser->fktext[ index ].anti_mode = 0;
m_parser->fktext[ index ].anti_use_precision = false;
// call inherited method
QEditPolar::accept();
......@@ -125,4 +160,4 @@ const QString KEditPolar::functionItem()
void KEditPolar::slotHelp()
{
kapp->invokeHelp( "", "kmplot" );
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@
#include "qeditpolar.h"
class View;
class XParser;
/** @short Dialog window editing a polar plot and its properties. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment