author | cniehaus <cniehaus> | 2002-09-15 16:18:47 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2002-09-15 16:18:47 (UTC) |
commit | 7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099 (patch) (side-by-side diff) | |
tree | 16e49af9eabdcf6621654a1f80488c65951fe4b5 /noncore/apps/checkbook/calcdlgui.cpp | |
parent | a013fbe2ba39e5ebd249766f223dbb67fe18027c (diff) | |
download | opie-7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099.zip opie-7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099.tar.gz opie-7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099.tar.bz2 |
wow... I just don't get my own code... Help needed
Diffstat (limited to 'noncore/apps/checkbook/calcdlgui.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/calcdlgui.cpp | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/noncore/apps/checkbook/calcdlgui.cpp b/noncore/apps/checkbook/calcdlgui.cpp index a86374b..e9b40d3 100644 --- a/noncore/apps/checkbook/calcdlgui.cpp +++ b/noncore/apps/checkbook/calcdlgui.cpp @@ -4,49 +4,52 @@ * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * - * ***********************************************************************/ + **************************************************************************/ #include "oxygen.h" -#include <qmenubar.h> -#include <qstatusbar.h> -#include <qpopupmenu.h> -#include <qlabel.h> -#include <qapplication.h> +#include "calcdlgui.h" +#include "kmolcalc.h" +#include <qlineedit.h> +#include <qmultilineedit.h> #include <qpushbutton.h> -#include <qfile.h> -#include <qdir.h> -#include <qvbox.h> -#include "calcdlg.h" -Oxygen::Oxygen() - : QMainWindow() +calcDlgUI::calcDlgUI() : CalcDlg() { - this->setCaption( "Oxygen" ); - vbox = new QVBox( this ); - QPushButton *setButton = new QPushButton( "Settings", vbox ); - connect ( setButton, SIGNAL( clicked() ), this, SLOT( slotSettings() ) ); - QPushButton *calcButton = new QPushButton( "Calculations", vbox ); - connect ( calcButton, SIGNAL( clicked() ), this, SLOT( slotCalculations() ) ); - QPushButton *pseButton = new QPushButton( "PSE", vbox ); - connect ( pseButton, SIGNAL( clicked() ), this, SLOT( slotPSE() ) ); - - setCentralWidget( vbox ); + kmolcalc = new KMolCalc; + connect( calculate, SIGNAL( clicked() ), this, SLOT( calc() ) ); + connect( clear_fields, SIGNAL( clicked() ), this, SLOT( clear() ) ); } - -void Oxygen::close() +void calcDlgUI::calc() { - QApplication::exit(); + QString compound( formula->text() ); + if ( compound.isEmpty() ) { + clear(); + return; + } + QString errors( kmolcalc->readFormula( compound ) ); + QString mw, ea; + double weight = kmolcalc->getWeight(); + if ( errors == "OK" ) { + mw.setNum( weight ); + ea = kmolcalc->getEmpFormula() + " :\n" + kmolcalc->getEA(); + } else { + mw = "???"; + ea = tr( "ERROR: \n" ) + errors + "\n"; + } + result->setText( mw ); + anal_display->setText( ea ); } -//SLOTS - -void Oxygen::slotCalculations(){ - CalcDlgUI *calcDlgUI = new calcDlgUI(); - calcDlgUI->show(); -}; +/** + * * Clear all text entry / result fields. + * */ +void calcDlgUI::clear() +{ + formula->clear(); + result->clear(); + anal_display->clear(); +} -void Oxygen::slotSettings(){ }; -void Oxygen::slotPSE(){ }; |