QDjango
 All Classes Functions Typedefs Enumerations Enumerator Properties Groups Pages
QDjangoModel.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_MODEL_H
19 #define QDJANGO_MODEL_H
20 
21 #include <QObject>
22 #include <QVariant>
23 
24 #include "QDjango_p.h"
25 
72 class QDJANGO_EXPORT QDjangoModel : public QObject
73 {
74  Q_OBJECT
75  Q_PROPERTY(QVariant pk READ pk WRITE setPk)
76  Q_CLASSINFO("pk", "ignore_field=true")
77 
78 public:
79  QDjangoModel(QObject *parent = 0);
80 
81  QVariant pk() const;
82  void setPk(const QVariant &pk);
83 
84 public slots:
85  bool remove();
86  bool save();
87  QString toString() const;
88 
89 protected:
90  QObject *foreignKey(const char *name) const;
91  void setForeignKey(const char *name, QObject *value);
92 };
93 
94 #endif