1 /*
2     SPDX-FileCopyrightText: 2010 Matteo Agostinelli <agostinelli@gmail.com>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QAtomicInt>
10 #include <QObject>
11 
12 class KJob;
13 
14 class QalculateEngine : public QObject
15 {
16     Q_OBJECT
17 public:
18     explicit QalculateEngine(QObject *parent = nullptr);
19     ~QalculateEngine() override;
20 
lastResult()21     QString lastResult() const
22     {
23         return m_lastResult;
24     }
25 
26 public Q_SLOTS:
27     QString evaluate(const QString &expression, bool *isApproximate = nullptr);
28     void updateExchangeRates();
29 
30     void copyToClipboard(bool flag = true);
31 
32 protected Q_SLOTS:
33     void updateResult(KJob *);
34 
35 Q_SIGNALS:
36     void resultReady(const QString &);
37     void formattedResultReady(const QString &);
38 
39 private:
40     QString m_lastResult;
41     static QAtomicInt s_counter;
42 };
43