moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kmplot / kmplot / coordsconfigdialog.cpp
blob96f7ddf0b6abcc4bc5287f9f22b891327bee1579
1 /*
2 * KmPlot - a math. function plotter for the KDE-Desktop
4 * Copyright (C) 2004 Fredrik Edemar
5 * f_edemar@linux.se
7 * This file is part of the KDE Project.
8 * KmPlot is part of the KDE-EDU Project.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #include <klocale.h>
27 #include <klineedit.h>
28 #include <kmessagebox.h>
29 #include <qradiobutton.h>
31 #include "settings.h"
32 #include "settingspagecoords.h"
33 #include "coordsconfigdialog.h"
35 CoordsConfigDialog::CoordsConfigDialog(XParser *p, QWidget *parent)
36 : KConfigDialog(parent, "coords", Settings::self()), m_parser(p)
38 configAxesDialog = new SettingsPageCoords( 0, "coordsSettings" );
39 addPage(configAxesDialog , i18n( "Coords" ), "coords", i18n( "Edit Coordinate System" ) );
40 setHelp("axes-config");
43 CoordsConfigDialog::~CoordsConfigDialog()
47 bool CoordsConfigDialog::evalX()
49 double const min = m_parser->eval( configAxesDialog->kcfg_XMin->text() );
50 if ( m_parser->parserError()!=0 )
51 return false;
52 double const max = m_parser->eval( configAxesDialog->kcfg_XMax->text() );
53 if ( m_parser->parserError()!=0 )
54 return false;
55 if ( min >= max )
57 KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value"));
58 return false;
60 return true;
62 bool CoordsConfigDialog::evalY()
64 double const min = m_parser->eval( configAxesDialog->kcfg_YMin->text() );
65 if ( m_parser->parserError()!=0 )
66 return false;
67 double const max = m_parser->eval( configAxesDialog->kcfg_YMax->text() );
68 if ( m_parser->parserError()!=0 )
69 return false;
70 if ( min >= max )
72 KMessageBox::error(this,i18n("The minimum range value must be lower than the maximum range value"));
73 return false;
75 return true;
78 void CoordsConfigDialog::slotOk()
80 if ( !(configAxesDialog->radioButton1_4->isChecked() && !evalX()) && !(configAxesDialog->radioButton1_4_2->isChecked() && !evalY()))
81 KConfigDialog::slotOk();
84 void CoordsConfigDialog::slotApply()
86 if ( !(configAxesDialog->radioButton1_4->isChecked() && !evalX()) && !(configAxesDialog->radioButton1_4_2->isChecked() && !evalY()))
87 KConfigDialog::slotApply();
90 #include "coordsconfigdialog.moc"