Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

calcdlgui.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002    application:             : Oxygen
00003 
00004    begin                    : September 2002
00005    copyright                : ( C ) 2002 by Carsten Niehaus
00006    email                    : cniehaus@handhelds.org
00007  **************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  * This program is free software; you can redistribute it and/or modify    *
00012  * it under the terms of the GNU General Public License as published by    *
00013  * the Free Software Foundation; either version 2 of the License, or       *
00014  * ( at your option ) any later version.                                   *
00015  *                                                                         *
00016  **************************************************************************/
00017 
00018 #include "calcdlgui.h"
00019 #include "kmolcalc.h"
00020 #include <qlineedit.h>
00021 #include <qmultilineedit.h>
00022 #include <qpushbutton.h>
00023 
00024 calcDlgUI::calcDlgUI() : CalcDlg()
00025 {
00026     kmolcalc = new KMolCalc;
00027     connect( calculate, SIGNAL( clicked() ), this, SLOT( calc() ) );
00028     connect( clear_fields, SIGNAL( clicked() ), this, SLOT( clear() ) );
00029     result->setReadOnly( true );
00030 }
00031 
00032 void calcDlgUI::calc()
00033 {
00034     QString compound( formula->text() );
00035     if ( compound.isEmpty() ) {
00036         clear();
00037         return;
00038     }
00039     QString errors( kmolcalc->readFormula( compound ) );
00040     QString mw, ea;
00041     double weight = kmolcalc->getWeight();
00042     if ( errors == "OK" ) {
00043         mw.setNum( weight );
00044         ea = kmolcalc->getEmpFormula() + " :\n" + kmolcalc->getEA();
00045     } else {
00046         mw = "???";
00047         ea = tr( "ERROR: \n" ).arg( errors )+ "\n";
00048     }
00049     result->setText( mw );
00050     anal_display->setText( ea );
00051 }
00052 
00056 void calcDlgUI::clear()
00057 {
00058     formula->clear();
00059     result->clear();
00060     anal_display->clear();
00061 }
00062 
00063 

Generated on Sat Nov 5 16:17:07 2005 for OPIE by  doxygen 1.4.2