QDjango
QDjangoModel.h
1 /*
2  * Copyright (C) 2010-2015 Jeremy LainĂ©
3  * Contact: https://github.com/jlaine/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 
78 class QDJANGO_DB_EXPORT QDjangoModel : public QObject
79 {
80  Q_OBJECT
81  Q_PROPERTY(QVariant pk READ pk WRITE setPk)
82  Q_CLASSINFO("pk", "ignore_field=true")
83 
84 public:
85  QDjangoModel(QObject *parent = 0);
86 
87  QVariant pk() const;
88  void setPk(const QVariant &pk);
89 
90 public slots:
91  bool remove();
92  bool save();
93  QString toString() const;
94 
95 protected:
96  QObject *foreignKey(const char *name) const;
97  void setForeignKey(const char *name, QObject *value);
98 };
99 
100 #endif
The QDjangoModel class is the base class for all models.
Definition: QDjangoModel.h:78