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 
77 class QDJANGO_EXPORT QDjangoModel : public QObject
78 {
79  Q_OBJECT
80  Q_PROPERTY(QVariant pk READ pk WRITE setPk)
81  Q_CLASSINFO("pk", "ignore_field=true")
82 
83 public:
84  QDjangoModel(QObject *parent = 0);
85 
86  QVariant pk() const;
87  void setPk(const QVariant &pk);
88 
89 public slots:
90  bool remove();
91  bool save();
92  QString toString() const;
93 
94 protected:
95  QObject *foreignKey(const char *name) const;
96  void setForeignKey(const char *name, QObject *value);
97 };
98 
99 #endif