Debian Codegraph @

maz-db/src/MazDBQueryEngine.h

raw symbols SCIP
1 /* Copyright (C) 2017 Dan Chapman <[email protected]>
2
3 This file is part of Dekko email client for Ubuntu devices
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 2 of
8 the License or (at your option) version 3
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef MAZDBQUERYENGINE_H
19 #define MAZDBQUERYENGINE_H
20
21 #include <QObject>
22 #include <QQmlEngine>
23 #include <QJSEngine>
24 #include <QStringList>
25 #include <QQmlParserStatus>
26 #include <QJSValue>
27 #include "MazDBQuery.h"
28
29 class MazDBQueryEngine : public QObject, public QQmlParserStatus
30 {
31 Q_OBJECT
32 Q_INTERFACES(QQmlParserStatus)
33 Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
34 Q_PROPERTY(MazDBQuery* query READ query WRITE setQuery NOTIFY queryChanged)
35 public:
36 explicit MazDBQueryEngine(QObject *parent = 0);
37
38 MazDBQuery* query() const;
39 QString source() const;
40
41 bool queryStream(MazCallBack callback);
42 Q_INVOKABLE bool queryStream(QJSValue callback);
43
44 signals:
45 void queryChanged(MazDBQuery* query);
46 void sourceChanged();
47
48 public slots:
49 void setSource(const QString &src);
50 void setQuery(MazDBQuery* query);
51 void close() { m_db->close(); }
52
53 protected:
54 virtual void classBegin() override {}
55 virtual void componentComplete() override { }
56
57 private:
58 Q_DISABLE_COPY(MazDBQueryEngine)
59
60 MazDB *m_db;
61 MazDBQuery* m_query;
62 };
63
64 #endif // MAZDBQUERYENGINE_H