From 7a8dc6b0a16db160a1e50fde8f298eb9e3cb0099 Mon Sep 17 00:00:00 2001 From: cniehaus Date: Sun, 15 Sep 2002 16:18:47 +0000 Subject: wow... I just don't get my own code... Help needed --- diff --git a/noncore/apps/checkbook/calcdlg.ui b/noncore/apps/checkbook/calcdlg.ui index 7637ca8..e0b19f9 100644 --- a/noncore/apps/checkbook/calcdlg.ui +++ b/noncore/apps/checkbook/calcdlg.ui @@ -11,7 +11,7 @@ 0 0 - 222 + 218 274 @@ -100,26 +100,6 @@ - QLabel - - name - TextLabel2_4 - - - geometry - - 1 - 86 - 298 - 16 - - - - text - Result: - - - QLayoutWidget name @@ -203,7 +183,7 @@ QLineEdit name - LineEdit2 + result geometry @@ -215,6 +195,26 @@ + + QLabel + + name + TextLabel2_4 + + + geometry + + 1 + 86 + 298 + 16 + + + + text + Result: + + 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 @@ -5,48 +5,51 @@ * the Free Software Foundation; either version 2 of the License, or * * ( at your option ) any later version. * * * - * ***********************************************************************/ + **************************************************************************/ #include "oxygen.h" -#include -#include -#include -#include -#include +#include "calcdlgui.h" +#include "kmolcalc.h" +#include +#include #include -#include -#include -#include -#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(){ }; diff --git a/noncore/apps/checkbook/calcdlgui.h b/noncore/apps/checkbook/calcdlgui.h index 1e923ee..33a1ec1 100644 --- a/noncore/apps/checkbook/calcdlgui.h +++ b/noncore/apps/checkbook/calcdlgui.h @@ -1,22 +1,27 @@ -#include -#include -#include +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * 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 -#include +#include "calcdlg.h" class QVBox; +class KMolCalc; -class Oxygen : public QMainWindow +class calcDlgUI : public CalcDlg { Q_OBJECT public: - Oxygen(); - QVBox *vbox; - private slots: - void slotCalculations(); - void slotSettings(); - void slotPSE(); - void close(); + calcDlgUI(); + KMolCalc *kmolcalc; + + public slots: + void calc(); + void clear(); }; diff --git a/noncore/apps/checkbook/kmolcalc.cpp b/noncore/apps/checkbook/kmolcalc.cpp index e5ab736..50e1375 100644 --- a/noncore/apps/checkbook/kmolcalc.cpp +++ b/noncore/apps/checkbook/kmolcalc.cpp @@ -2,6 +2,7 @@ * kmolcalc.cpp * * Copyright (C) 2000 Tomislav Gountchev + * Copyright (C) 2002 Carsten Niehaus */ /** @@ -13,6 +14,7 @@ #include "kmolcalc.h" #include #include +#include #include @@ -35,7 +37,7 @@ void KMolCalc::readElstable() { elstable = new QDict (197, TRUE); elstable->setAutoDelete(TRUE); QStringList files;// = // KGlobal::dirs()->findAllResources("appdata", "kmolweights"); -// mwfile = locateLocal("data", "kmol")+"/kmolweights"; + mwfile = "/home/opie/opie/noncore/apps/oxigen/kmolweights"; QFile f(mwfile); QString* latest_f = &mwfile; for (uint i=0; i #include #include "calcdlg.h" +#include "calcdlgui.h" Oxygen::Oxygen() : QMainWindow() @@ -43,8 +44,8 @@ void Oxygen::close() //SLOTS void Oxygen::slotCalculations(){ - CalcDlgUI *calcDlgUI = new calcDlgUI(); - calcDlgUI->show(); + calcDlgUI *CalcDlgUI = new calcDlgUI(); + CalcDlgUI->show(); }; void Oxygen::slotSettings(){ }; diff --git a/noncore/apps/checkbook/oxygen.pro b/noncore/apps/checkbook/oxygen.pro index f8e0197..c5448e7 100644 --- a/noncore/apps/checkbook/oxygen.pro +++ b/noncore/apps/checkbook/oxygen.pro @@ -2,11 +2,13 @@ TEMPLATE = app CONFIG = qt warn_on release HEADERS = oxygen.h \ kmolcalc.h \ - kmolelements.h + kmolelements.h \ + calcdlgui.h SOURCES = main.cpp \ oxygen.cpp \ kmolcalc.cpp \ + calcdlgui.cpp \ kmolelements.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -- cgit v0.9.0.2