QDjango
Loading...
Searching...
No Matches
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
23class QObject;
24class QSqlDatabase;
25class QSqlQuery;
26class QString;
27
34class QDJANGO_DB_EXPORT QDjango
35{
36public:
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
49private:
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
61template <class T>
62QDjangoMetaModel QDjango::registerModel()
63{
64 return registerModel(&T::staticMetaObject);
65}
66
67#endif
The QDjango class provides a set of static functions.
Definition QDjango.h:35
static bool dropTables()
Drops the database tables for all registered models.
Definition QDjango.cpp:286
static void setDebugEnabled(bool enabled)
Sets whether debugging information should be printed.
Definition QDjango.cpp:229
static bool createTables()
Creates the database tables for all registered models.
Definition QDjango.cpp:269
static QSqlDatabase database()
Returns the database used by QDjango.
Definition QDjango.cpp:166
static void setDatabase(QSqlDatabase database)
Sets the database used by QDjango.
Definition QDjango.cpp:198
static QDjangoMetaModel registerModel()
Definition QDjango.h:62
static bool isDebugEnabled()
Returns whether debugging information should be printed.
Definition QDjango.cpp:219