QDjango: QDjango.h Source File

QDjango

QDjango.h
1 /*
2 * Copyright (C) 2010-2015 Jeremy Lainé
3 * Contact: https://github.com/jlaine/qdjango
4 *
5 * This file is part of the QDjango Library.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 */
17
18 #ifndef QDJANGO_H
19 #define QDJANGO_H
20
21 #include "QDjangoMetaModel.h"
22
23 class QObject;
24 class QSqlDatabase;
25 class QSqlQuery;
26 class QString;
27
34 class QDJANGO_DB_EXPORT QDjango
35 {
36 public:
37 static bool createTables();
38 static bool dropTables();
39
40 static QSqlDatabase database();
41 static void setDatabase(QSqlDatabase database);
42
43 static bool isDebugEnabled();
44 static void setDebugEnabled(bool enabled);
45
46 template <class T>
47 static QDjangoMetaModel registerModel();
48
49 private:
50 static QDjangoMetaModel registerModel(const QMetaObject *meta);
51 static QDjangoMetaModel metaModel(const char *name);
52
53 friend class QDjangoCompiler;
54 friend class QDjangoModel;
55 friend class QDjangoMetaModel;
56 friend class QDjangoQuerySetPrivate;
57 };
58
61 template <class T>
62 QDjangoMetaModel QDjango::registerModel()
63 {
64 return registerModel(&T::staticMetaObject);
65 }
66
67 #endif
QDjango
The QDjango class provides a set of static functions.
Definition: QDjango.h:35
QDjangoModel
The QDjangoModel class is the base class for all models.
Definition: QDjangoModel.h:79
QDjangoMetaModel
The QDjangoMetaModel class holds the database schema for a model.
Definition: QDjangoMetaModel.h:66
QDjango::registerModel
static QDjangoMetaModel registerModel()
Definition: QDjango.h:62