QDjango
 All Classes Functions Typedefs Enumerations Enumerator Properties Groups Pages
QDjango.h
1 /*
2  * Copyright (C) 2010-2012 Jeremy LainĂ©
3  * Contact: http://code.google.com/p/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 
41 class QDJANGO_EXPORT QDjango
42 {
43 public:
44  static bool createTables();
45  static bool dropTables();
46 
47  static QSqlDatabase database();
48  static void setDatabase(QSqlDatabase database);
49 
50  static bool isDebugEnabled();
51  static void setDebugEnabled(bool enabled);
52 
53  template <class T>
54  static QDjangoMetaModel registerModel();
55 
56 private:
57  // backend specific
58  static QString noLimitSql();
59 
60  static QDjangoMetaModel registerModel(const QObject *model);
61  static QDjangoMetaModel metaModel(const QString &name);
62 
63  friend class QDjangoCompiler;
64  friend class QDjangoModel;
65  friend class QDjangoMetaModel;
66  friend class QDjangoQuerySetPrivate;
67 };
68 
71 template <class T>
73 {
74  T model;
75  return registerModel(&model);
76 }
77 
78 #endif