QDjango
|
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_MODEL_H 00019 #define QDJANGO_MODEL_H 00020 00021 #include <QObject> 00022 #include <QVariant> 00023 00024 #include "QDjango_p.h" 00025 00072 class QDJANGO_EXPORT QDjangoModel : public QObject 00073 { 00074 Q_OBJECT 00075 Q_PROPERTY(QVariant pk READ pk WRITE setPk) 00076 Q_CLASSINFO("pk", "ignore_field=true") 00077 00078 public: 00079 QDjangoModel(QObject *parent = 0); 00080 00081 QVariant pk() const; 00082 void setPk(const QVariant &pk); 00083 00084 public slots: 00085 bool remove(); 00086 bool save(); 00087 QString toString() const; 00088 00089 protected: 00090 QObject *foreignKey(const char *name) const; 00091 void setForeignKey(const char *name, QObject *value); 00092 }; 00093 00094 #endif