QDjango
QDjango.h
00001 /*
00002  * Copyright (C) 2010-2012 Jeremy Lainé
00003  * Contact: http://code.google.com/p/qdjango/
00004  *
00005  * This file is part of the QDjango Library.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  */
00017 
00018 #ifndef QDJANGO_H
00019 #define QDJANGO_H
00020 
00021 #include "QDjangoMetaModel.h"
00022 
00023 class QObject;
00024 class QSqlDatabase;
00025 class QSqlQuery;
00026 class QString;
00027 
00041 class QDJANGO_EXPORT QDjango
00042 {
00043 public:
00044     static bool createTables();
00045     static bool dropTables();
00046 
00047     static QSqlDatabase database();
00048     static void setDatabase(QSqlDatabase database);
00049 
00050     static bool isDebugEnabled();
00051     static void setDebugEnabled(bool enabled);
00052 
00053     template <class T>
00054     static QDjangoMetaModel registerModel();
00055 
00056 private:
00057     // backend specific
00058     static QString noLimitSql();
00059 
00060     static QDjangoMetaModel registerModel(const QObject *model);
00061     static QDjangoMetaModel metaModel(const QString &name);
00062 
00063     friend class QDjangoCompiler;
00064     friend class QDjangoModel;
00065     friend class QDjangoMetaModel;
00066     friend class QDjangoQuerySetPrivate;
00067 };
00068 
00071 template <class T>
00072 QDjangoMetaModel QDjango::registerModel()
00073 {
00074     T model;
00075     return registerModel(&model);
00076 }
00077 
00078 #endif
 All Classes Functions Typedefs Enumerations Enumerator Properties