Nut  0.1
databasemodel.h
1 /**************************************************************************
2 **
3 ** This file is part of Nut project.
4 ** https://github.com/HamedMasafi/Nut
5 **
6 ** Nut is free software: you can redistribute it and/or modify
7 ** it under the terms of the GNU Lesser General Public License as published by
8 ** the Free Software Foundation, either version 3 of the License, or
9 ** (at your option) any later version.
10 **
11 ** Nut is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU Lesser General Public License for more details.
15 **
16 ** You should have received a copy of the GNU Lesser General Public License
17 ** along with Nut. If not, see <http://www.gnu.org/licenses/>.
18 **
19 **************************************************************************/
20 
21 #ifndef DATABASEMODEL_H
22 #define DATABASEMODEL_H
23 
24 #include <QtCore/QList>
25 
26 QT_BEGIN_NAMESPACE
27 
28 class TableModel;
29 struct RelationModel;
30 class QJsonObject;
31 class DatabaseModel : public QList<TableModel*>
32 {
33  int _versionMajor, _versionMinor;
34 public:
35  DatabaseModel();
36 
37  TableModel *model(QString tableName) const;
38  TableModel *modelByClass(QString className) const;
39 
40  RelationModel *relationByClassNames(QString masterClassName, QString childClassName);
41  RelationModel *relationByTableNames(QString masterTableName, QString childTableName);
42 
43  bool operator ==(const DatabaseModel &other) const;
44 
45  static DatabaseModel fromJson(QJsonObject &json);
46  QJsonObject toJson() const;
47 
48  int versionMajor() const;
49  void setVersionMajor(int versionMajor);
50 
51  int versionMinor() const;
52  void setVersionMinor(int versionMinor);
53 };
54 
55 QT_END_NAMESPACE
56 
57 #endif // DATABASEMODEL_H