generatotrs moved to seprate folder
This commit is contained in:
parent
a35c9f8ffb
commit
d6a9e7c58d
20
nut.pri
20
nut.pri
|
|
@ -3,20 +3,20 @@ QT += core sql
|
||||||
INCLUDEPATH += $$PWD/include
|
INCLUDEPATH += $$PWD/include
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
$$PWD/src/generators/sqlgeneratorbase_p.h \
|
||||||
|
$$PWD/src/generators/postgresqlgenerator.h \
|
||||||
|
$$PWD/src/generators/mysqlgenerator.h \
|
||||||
|
$$PWD/src/generators/sqlitegenerator.h \
|
||||||
|
$$PWD/src/generators/sqlservergenerator.h \
|
||||||
$$PWD/src/tableset.h \
|
$$PWD/src/tableset.h \
|
||||||
$$PWD/src/defines_p.h \
|
$$PWD/src/defines_p.h \
|
||||||
$$PWD/src/defines.h \
|
$$PWD/src/defines.h \
|
||||||
$$PWD/src/query.h \
|
$$PWD/src/query.h \
|
||||||
$$PWD/src/databasemodel.h \
|
$$PWD/src/databasemodel.h \
|
||||||
$$PWD/src/sqlgeneratorbase_p.h \
|
|
||||||
$$PWD/src/postgresqlgenerator.h \
|
|
||||||
$$PWD/src/changelogtable.h \
|
$$PWD/src/changelogtable.h \
|
||||||
$$PWD/src/tablesetbase_p.h \
|
$$PWD/src/tablesetbase_p.h \
|
||||||
$$PWD/src/querybase_p.h \
|
$$PWD/src/querybase_p.h \
|
||||||
$$PWD/src/mysqlgenerator.h \
|
|
||||||
$$PWD/src/sqlitegenerator.h \
|
|
||||||
$$PWD/src/tablemodel.h \
|
$$PWD/src/tablemodel.h \
|
||||||
$$PWD/src/sqlservergenerator.h \
|
|
||||||
$$PWD/src/wherephrase.h \
|
$$PWD/src/wherephrase.h \
|
||||||
$$PWD/src/query_p.h \
|
$$PWD/src/query_p.h \
|
||||||
$$PWD/src/table.h \
|
$$PWD/src/table.h \
|
||||||
|
|
@ -26,18 +26,18 @@ HEADERS += \
|
||||||
$$PWD/src/serializableobject.h
|
$$PWD/src/serializableobject.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
$$PWD/src/generators/sqlgeneratorbase.cpp \
|
||||||
|
$$PWD/src/generators/postgresqlgenerator.cpp \
|
||||||
|
$$PWD/src/generators/mysqlgenerator.cpp \
|
||||||
|
$$PWD/src/generators/sqlitegenerator.cpp \
|
||||||
|
$$PWD/src/generators/sqlservergenerator.cpp \
|
||||||
$$PWD/src/tableset.cpp \
|
$$PWD/src/tableset.cpp \
|
||||||
$$PWD/src/query.cpp \
|
$$PWD/src/query.cpp \
|
||||||
$$PWD/src/databasemodel.cpp \
|
$$PWD/src/databasemodel.cpp \
|
||||||
$$PWD/src/tablesetbase.cpp \
|
$$PWD/src/tablesetbase.cpp \
|
||||||
$$PWD/src/sqlgeneratorbase.cpp \
|
|
||||||
$$PWD/src/postgresqlgenerator.cpp \
|
|
||||||
$$PWD/src/changelogtable.cpp \
|
$$PWD/src/changelogtable.cpp \
|
||||||
$$PWD/src/querybase.cpp \
|
$$PWD/src/querybase.cpp \
|
||||||
$$PWD/src/mysqlgenerator.cpp \
|
|
||||||
$$PWD/src/sqlitegenerator.cpp \
|
|
||||||
$$PWD/src/tablemodel.cpp \
|
$$PWD/src/tablemodel.cpp \
|
||||||
$$PWD/src/sqlservergenerator.cpp \
|
|
||||||
$$PWD/src/wherephrase.cpp \
|
$$PWD/src/wherephrase.cpp \
|
||||||
$$PWD/src/table.cpp \
|
$$PWD/src/table.cpp \
|
||||||
$$PWD/src/database.cpp \
|
$$PWD/src/database.cpp \
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,10 @@
|
||||||
#include "database_p.h"
|
#include "database_p.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "tablemodel.h"
|
#include "tablemodel.h"
|
||||||
#include "postgresqlgenerator.h"
|
#include "generators/postgresqlgenerator.h"
|
||||||
#include "mysqlgenerator.h"
|
#include "generators/mysqlgenerator.h"
|
||||||
#include "sqlitegenerator.h"
|
#include "generators/sqlitegenerator.h"
|
||||||
#include "sqlservergenerator.h"
|
#include "generators/sqlservergenerator.h"
|
||||||
#include "query.h"
|
#include "query.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,19 @@ DatabaseModel::DatabaseModel(const DatabaseModel &other) : QList<TableModel*>(ot
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DatabaseModel::DatabaseModel(const QJsonObject &json) : QList<TableModel*>()
|
||||||
|
{
|
||||||
|
setVersion(json.value(QT_STRINGIFY(version)).toString());
|
||||||
|
|
||||||
|
foreach (QString key, json.keys()) {
|
||||||
|
if(!json.value(key).isObject())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TableModel *sch = new TableModel(json.value(key).toObject(), key);
|
||||||
|
append(sch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TableModel *DatabaseModel::tableByName(QString tableName) const
|
TableModel *DatabaseModel::tableByName(QString tableName) const
|
||||||
{
|
{
|
||||||
for(int i = 0; i < size(); i++){
|
for(int i = 0; i < size(); i++){
|
||||||
|
|
@ -89,8 +102,7 @@ QJsonObject DatabaseModel::toJson() const
|
||||||
{
|
{
|
||||||
QJsonObject obj;
|
QJsonObject obj;
|
||||||
|
|
||||||
// obj.insert(QT_STRINGIFY(versionMajor), QJsonValue(_versionMajor));
|
obj.insert(QT_STRINGIFY(version), QJsonValue(_version));
|
||||||
// obj.insert(QT_STRINGIFY(versionMinor), QJsonValue(_versionMinor));
|
|
||||||
|
|
||||||
for(int i = 0; i < size(); i++){
|
for(int i = 0; i < size(); i++){
|
||||||
TableModel *s = at(i);
|
TableModel *s = at(i);
|
||||||
|
|
@ -100,6 +112,11 @@ QJsonObject DatabaseModel::toJson() const
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DatabaseModel::operator QJsonObject()
|
||||||
|
{
|
||||||
|
return toJson();
|
||||||
|
}
|
||||||
|
|
||||||
RelationModel *DatabaseModel::relationByClassNames(const QString &masterClassName, const QString &childClassName)
|
RelationModel *DatabaseModel::relationByClassNames(const QString &masterClassName, const QString &childClassName)
|
||||||
{
|
{
|
||||||
TableModel *childTable = tableByClassName(childClassName);
|
TableModel *childTable = tableByClassName(childClassName);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ class DatabaseModel : public QList<TableModel *>
|
||||||
public:
|
public:
|
||||||
DatabaseModel(const QString &name = QString::null);
|
DatabaseModel(const QString &name = QString::null);
|
||||||
DatabaseModel(const DatabaseModel &other);
|
DatabaseModel(const DatabaseModel &other);
|
||||||
|
DatabaseModel(const QJsonObject &json);
|
||||||
|
|
||||||
TableModel *tableByName(QString tableName) const;
|
TableModel *tableByName(QString tableName) const;
|
||||||
TableModel *tableByClassName(QString className) const;
|
TableModel *tableByClassName(QString className) const;
|
||||||
|
|
@ -50,8 +51,10 @@ public:
|
||||||
|
|
||||||
bool operator==(const DatabaseModel &other) const;
|
bool operator==(const DatabaseModel &other) const;
|
||||||
|
|
||||||
|
Q_DECL_DEPRECATED
|
||||||
static DatabaseModel fromJson(QJsonObject &json);
|
static DatabaseModel fromJson(QJsonObject &json);
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
operator QJsonObject();
|
||||||
|
|
||||||
QString version() const;
|
QString version() const;
|
||||||
void setVersion(QString version);
|
void setVersion(QString version);
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,15 @@
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
DbGeography::DbGeography(QObject *parent) : m_longitude(0), m_latitude(0)
|
DbGeography::DbGeography() : m_longitude(0), m_latitude(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DbGeography::DbGeography(const DbGeography &other)
|
DbGeography::DbGeography(const DbGeography &other)
|
||||||
{
|
{
|
||||||
setLatitude(other.latitude());
|
|
||||||
setLongitude(other.longitude());
|
setLongitude(other.longitude());
|
||||||
|
setLatitude(other.latitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
DbGeography::DbGeography(const QVariant &value)
|
DbGeography::DbGeography(const QVariant &value)
|
||||||
|
|
@ -47,14 +47,23 @@ DbGeography::DbGeography(const QVariant &value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal DbGeography::longitude() const
|
||||||
|
{
|
||||||
|
return m_longitude;
|
||||||
|
}
|
||||||
|
|
||||||
qreal DbGeography::latitude() const
|
qreal DbGeography::latitude() const
|
||||||
{
|
{
|
||||||
return m_latitude;
|
return m_latitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal DbGeography::longitude() const
|
void DbGeography::setLongitude(qreal longitude)
|
||||||
|
|
||||||
{
|
{
|
||||||
return m_longitude;
|
if (qFuzzyCompare(m_longitude, longitude))
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_longitude = longitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DbGeography::setLatitude(qreal latitude)
|
void DbGeography::setLatitude(qreal latitude)
|
||||||
|
|
@ -64,32 +73,9 @@ void DbGeography::setLatitude(qreal latitude)
|
||||||
|
|
||||||
m_latitude = latitude;
|
m_latitude = latitude;
|
||||||
}
|
}
|
||||||
|
DbGeography::operator QVariant()
|
||||||
void DbGeography::setLongitude(qreal longitude)
|
|
||||||
{
|
|
||||||
if (qFuzzyCompare(m_longitude, longitude))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_longitude = longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*QVariant Nut::DbGeography::operator QVariant()
|
|
||||||
{
|
{
|
||||||
return QVariant::fromValue(QString("%1,%2").arg(longitude()).arg(latitude()));
|
return QVariant::fromValue(QString("%1,%2").arg(longitude()).arg(latitude()));
|
||||||
}*/
|
|
||||||
|
|
||||||
QString DbGeography::toString()
|
|
||||||
{
|
|
||||||
return QString("%1,%2").arg(longitude()).arg(latitude());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DbGeography::fromString(const QString &s)
|
|
||||||
{
|
|
||||||
QStringList parts = s.split(',');
|
|
||||||
if (parts.count() == 2) {
|
|
||||||
setLongitude(parts[0].toDouble());
|
|
||||||
setLatitude(parts[1].toDouble());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NUT_END_NAMESPACE
|
NUT_END_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -28,26 +28,23 @@
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class NUT_EXPORT DbGeography //: public QObject
|
class NUT_EXPORT DbGeography
|
||||||
{
|
{
|
||||||
qreal m_latitude;
|
|
||||||
qreal m_longitude;
|
qreal m_longitude;
|
||||||
|
qreal m_latitude;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DbGeography(QObject *parent = 0);
|
explicit DbGeography();
|
||||||
DbGeography(const DbGeography &other);
|
DbGeography(const DbGeography &other);
|
||||||
DbGeography(const QVariant &value);
|
DbGeography(const QVariant &value);
|
||||||
|
|
||||||
qreal latitude() const;
|
|
||||||
qreal longitude() const;
|
qreal longitude() const;
|
||||||
|
qreal latitude() const;
|
||||||
|
|
||||||
void setLatitude(qreal latitude);
|
|
||||||
void setLongitude(qreal longitude);
|
void setLongitude(qreal longitude);
|
||||||
|
void setLatitude(qreal latitude);
|
||||||
|
|
||||||
//QVariant operator QVariant();
|
operator QVariant();
|
||||||
|
|
||||||
QString toString();
|
|
||||||
void fromString(const QString &s);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NUT_END_NAMESPACE
|
NUT_END_NAMESPACE
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "mysqlgenerator.h"
|
#include "mysqlgenerator.h"
|
||||||
#include "tablemodel.h"
|
#include "../tablemodel.h"
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "postgresqlgenerator.h"
|
#include "postgresqlgenerator.h"
|
||||||
#include "table.h"
|
#include "../table.h"
|
||||||
#include "tablemodel.h"
|
#include "../tablemodel.h"
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -24,12 +24,12 @@
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include "database.h"
|
|
||||||
#include "databasemodel.h"
|
|
||||||
#include "sqlgeneratorbase_p.h"
|
#include "sqlgeneratorbase_p.h"
|
||||||
#include "table.h"
|
#include "../database.h"
|
||||||
#include "tablemodel.h"
|
#include "../table.h"
|
||||||
#include "wherephrase.h"
|
#include "../databasemodel.h"
|
||||||
|
#include "../tablemodel.h"
|
||||||
|
#include "../wherephrase.h"
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include "wherephrase.h"
|
#include "../wherephrase.h"
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -33,8 +33,6 @@ struct FieldModel;
|
||||||
class DatabaseModel;
|
class DatabaseModel;
|
||||||
class TableModel;
|
class TableModel;
|
||||||
class Database;
|
class Database;
|
||||||
//struct PhraseData;
|
|
||||||
//class WherePhrase;
|
|
||||||
class SqlGeneratorBase : public QObject
|
class SqlGeneratorBase : public QObject
|
||||||
{
|
{
|
||||||
// Q_OBJECT
|
// Q_OBJECT
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "sqlitegenerator.h"
|
#include "sqlitegenerator.h"
|
||||||
#include "table.h"
|
#include "../table.h"
|
||||||
#include "tablemodel.h"
|
#include "../tablemodel.h"
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -19,8 +19,8 @@
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "sqlservergenerator.h"
|
#include "sqlservergenerator.h"
|
||||||
#include "table.h"
|
#include "../table.h"
|
||||||
#include "tablemodel.h"
|
#include "../tablemodel.h"
|
||||||
|
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "databasemodel.h"
|
#include "databasemodel.h"
|
||||||
#include "tablesetbase_p.h"
|
#include "tablesetbase_p.h"
|
||||||
#include "sqlgeneratorbase_p.h"
|
#include "generators/sqlgeneratorbase_p.h"
|
||||||
#include "querybase_p.h"
|
#include "querybase_p.h"
|
||||||
#include "wherephrase.h"
|
#include "wherephrase.h"
|
||||||
#include "tablemodel.h"
|
#include "tablemodel.h"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "table.h"
|
#include "table.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "sqlgeneratorbase_p.h"
|
#include "generators/sqlgeneratorbase_p.h"
|
||||||
|
|
||||||
NUT_BEGIN_NAMESPACE
|
NUT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue