Diffstat (limited to 'noncore/apps/oxygen/kmolcalc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/oxygen/kmolcalc.cpp | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/noncore/apps/oxygen/kmolcalc.cpp b/noncore/apps/oxygen/kmolcalc.cpp index 7257c4a..0ba52da 100644 --- a/noncore/apps/oxygen/kmolcalc.cpp +++ b/noncore/apps/oxygen/kmolcalc.cpp | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * kmolcalc.cpp | 2 | * kmolcalc.cpp |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Tomislav Gountchev <tomi@idiom.com> | 4 | * Copyright (C) 2000,2001 Tomislav Gountchev <tomi@idiom.com> |
5 | * Copyright (C) 2002 Carsten Niehaus <cniehaus@handhelds.org> | 5 | * Copyright (C) 2002 Carsten Niehaus <cniehaus@handhelds.org> |
6 | */ | 6 | */ |
7 | 7 | ||
@@ -36,28 +36,9 @@ void KMolCalc::readElstable() { | |||
36 | if (elstable) delete elstable; | 36 | if (elstable) delete elstable; |
37 | elstable = new QDict<SubUnit> (197, TRUE); | 37 | elstable = new QDict<SubUnit> (197, TRUE); |
38 | elstable->setAutoDelete(TRUE); | 38 | elstable->setAutoDelete(TRUE); |
39 | QStringList files = "/home/opie/opie/noncore/apps/oxigen/kmolweights"; | 39 | mwfile = "/home/opie/opie/noncore/apps/oxygen/kmolweights"; |
40 | mwfile = "/home/opie/opie/noncore/apps/oxigen/kmolweights"; | ||
41 | QFile f(mwfile); | 40 | QFile f(mwfile); |
42 | QString* latest_f = &mwfile; | ||
43 | for (uint i=0; i<files.count(); i++) { | ||
44 | if (QFileInfo(QFile(files[i])).lastModified() > QFileInfo(QFile(*latest_f)).lastModified()) { | ||
45 | latest_f = &files[i]; | ||
46 | } | ||
47 | } | ||
48 | QFile lf(*latest_f); | ||
49 | if (f.exists()) readMwfile(f); | 41 | if (f.exists()) readMwfile(f); |
50 | if (!f.exists()) { | ||
51 | readMwfile(lf); | ||
52 | writeElstable(); | ||
53 | } else if (QFileInfo(f).lastModified() < QFileInfo(lf).lastModified()) { | ||
54 | // announce | ||
55 | QMessageBox::information | ||
56 | (0, "Warning:", "Found new global Mw file.\nLocal definitions will be updated.", QMessageBox::Ok); | ||
57 | readMwfile(lf); | ||
58 | writeElstable(); | ||
59 | } | ||
60 | |||
61 | } | 42 | } |
62 | 43 | ||
63 | 44 | ||
@@ -188,23 +169,6 @@ void KMolCalc::readMwfile(QFile& f) { | |||
188 | } | 169 | } |
189 | 170 | ||
190 | /** | 171 | /** |
191 | * Save the element definitions file. | ||
192 | */ | ||
193 | void KMolCalc::writeElstable() { | ||
194 | QFile f(mwfile); | ||
195 | if (! f.open(IO_WriteOnly)) return; //ERROR | ||
196 | QTextStream fs (&f); | ||
197 | QString line; | ||
198 | QDictIterator<SubUnit> it(*elstable); | ||
199 | while (it.current()) { | ||
200 | it.current()->writeOut(line); | ||
201 | fs << line << endl; | ||
202 | ++it; | ||
203 | } | ||
204 | f.close(); | ||
205 | } | ||
206 | |||
207 | /** | ||
208 | * Remove a group or element definition from ELSTABLE. | 172 | * Remove a group or element definition from ELSTABLE. |
209 | */ | 173 | */ |
210 | void KMolCalc::undefineGroup (const QString& name) { | 174 | void KMolCalc::undefineGroup (const QString& name) { |