-
Notifications
You must be signed in to change notification settings - Fork 0
/
qmladapter.h
67 lines (48 loc) · 1.69 KB
/
qmladapter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef QMLADAPTER_H
#define QMLADAPTER_H
#include <QObject>
#include <QQmlEngine>
//#include <evaluator.h>
class QMLAdapter : public QObject
{
Q_OBJECT
public:
explicit QMLAdapter(QObject *parent = nullptr);
Q_INVOKABLE QString getMolecularWeight() const;
Q_INVOKABLE QString getEquivalent() const;
Q_INVOKABLE QString getError() const;
Q_INVOKABLE QString getResult() const;
signals:
void molecularWeightChanged();
void equivalentCalculated();
void resultCalculated();
void errorHappend();
public slots:
void calculateLigation(
const QString& vector_mass, const QString& vector_length,
const QString& insert_length, const QString& molar_vector_insert_right,
const QString& molar_vector_insert_left
);
void calculateVolume(
const QString& formula_input, const QString& molar_concentration,
const QString& molar_weight, bool is_normal_concentration = false);
void calculateConcentration(
const QString& formula_input, const QString& volume,
const QString& molar_weight, bool is_normal_concentration = false);
void calculateMass(
const QString& formula_input, const QString& volume,
const QString& molar_concentration, bool is_normal_concentration = false);
private:
float calculateMolecularWeight(const QString& formula);
void setMolecularWeight(const QString& weight);
void setEquivalent(const QString& new_equivalent);
void setResult(const QString& new_result);
void setError(const QString& error);
void cleareError();
private:
QString molecular_weight;
QString equivalent;
QString error;
QString result;
};
#endif // QMLADAPTER_H