From 6efc4f4ee4360fc2e8cd0d6f3685790b1cfc90a1 Mon Sep 17 00:00:00 2001 From: Hamed Masafi Date: Wed, 12 Aug 2020 18:16:56 +0430 Subject: [PATCH] make sub projects for better file groupping --- src/nut/config/config.pri | 8 + src/nut/config/nut_config.h | 20 ++ .../{defines_consts.h => config/nut_consts.h} | 6 +- src/nut/config/nut_global.h | 12 ++ src/nut/{defines.h => config/nut_macros.h} | 179 +----------------- src/nut/config/nut_namespace.h | 137 ++++++++++++++ src/nut/{ => core}/abstracttableset.cpp | 8 +- src/nut/{ => core}/abstracttableset.h | 2 +- src/nut/{ => core}/abstracttablesetdata.h | 2 +- src/nut/{ => core}/bulkinserter.cpp | 0 src/nut/{ => core}/bulkinserter.h | 2 +- src/nut/{ => core}/bulkinserter_p.h | 0 src/nut/{ => core}/changelogtable.cpp | 0 src/nut/{ => core}/changelogtable.h | 0 src/nut/core/core.pri | 25 +++ src/nut/{ => core}/database.cpp | 2 +- src/nut/{ => core}/database.h | 2 +- src/nut/{ => core}/database_p.h | 0 src/nut/{ => core}/query.cpp | 0 src/nut/{ => core}/query.h | 8 +- src/nut/{ => core}/table.cpp | 4 + src/nut/{ => core}/table.h | 2 +- src/nut/{ => core}/table_p.h | 3 +- src/nut/{ => core}/tableset.cpp | 0 src/nut/{ => core}/tableset.h | 6 +- src/nut/generators/generators.pri | 15 ++ src/nut/{ => models}/databasemodel.cpp | 0 src/nut/{ => models}/databasemodel.h | 2 +- src/nut/models/models.pri | 14 ++ src/nut/{ => models}/sqlmodel.cpp | 0 src/nut/{ => models}/sqlmodel.h | 4 +- src/nut/{ => models}/sqlmodel_p.h | 2 +- src/nut/{ => models}/tablemodel.cpp | 2 +- src/nut/{ => models}/tablemodel.h | 2 +- src/nut/{src.pri => nut.pri} | 2 +- src/nut/nut.pro | 77 +------- src/nut/phrase.cpp | 44 ----- src/nut/phrase.h | 39 +--- src/nut/phrases/abstractfieldphrase.h | 2 +- src/nut/phrases/assignmentphrase.h | 2 +- src/nut/phrases/assignmentphraselist.h | 2 +- src/nut/phrases/fieldphrase.h | 2 +- src/nut/phrases/fieldphrase_bool.h | 2 +- src/nut/phrases/fieldphrase_qstring.h | 2 +- src/nut/phrases/phrasedata.h | 2 +- src/nut/phrases/phraselist.h | 2 +- src/nut/phrases/phrases.pri | 27 +++ src/nut/serializableobject.cpp | 2 - src/nut/serializableobject.h | 15 -- src/nut/tuple.cpp | 2 - src/nut/tuple.h | 18 -- src/nut/types/dbgeography.h | 2 +- src/nut/types/types.pri | 7 + sync.profile | 2 +- 54 files changed, 320 insertions(+), 402 deletions(-) create mode 100644 src/nut/config/config.pri create mode 100644 src/nut/config/nut_config.h rename src/nut/{defines_consts.h => config/nut_consts.h} (96%) create mode 100644 src/nut/config/nut_global.h rename src/nut/{defines.h => config/nut_macros.h} (64%) create mode 100644 src/nut/config/nut_namespace.h rename src/nut/{ => core}/abstracttableset.cpp (98%) rename src/nut/{ => core}/abstracttableset.h (98%) rename src/nut/{ => core}/abstracttablesetdata.h (98%) rename src/nut/{ => core}/bulkinserter.cpp (100%) rename src/nut/{ => core}/bulkinserter.h (96%) rename src/nut/{ => core}/bulkinserter_p.h (100%) rename src/nut/{ => core}/changelogtable.cpp (100%) rename src/nut/{ => core}/changelogtable.h (100%) create mode 100644 src/nut/core/core.pri rename src/nut/{ => core}/database.cpp (99%) rename src/nut/{ => core}/database.h (98%) rename src/nut/{ => core}/database_p.h (100%) rename src/nut/{ => core}/query.cpp (100%) rename src/nut/{ => core}/query.h (99%) rename src/nut/{ => core}/table.cpp (98%) rename src/nut/{ => core}/table.h (98%) rename src/nut/{ => core}/table_p.h (90%) rename src/nut/{ => core}/tableset.cpp (100%) rename src/nut/{ => core}/tableset.h (99%) create mode 100644 src/nut/generators/generators.pri rename src/nut/{ => models}/databasemodel.cpp (100%) rename src/nut/{ => models}/databasemodel.h (98%) create mode 100644 src/nut/models/models.pri rename src/nut/{ => models}/sqlmodel.cpp (100%) rename src/nut/{ => models}/sqlmodel.h (96%) rename src/nut/{ => models}/sqlmodel_p.h (94%) rename src/nut/{ => models}/tablemodel.cpp (99%) rename src/nut/{ => models}/tablemodel.h (99%) rename src/nut/{src.pri => nut.pri} (98%) create mode 100644 src/nut/phrases/phrases.pri delete mode 100644 src/nut/serializableobject.cpp delete mode 100644 src/nut/serializableobject.h delete mode 100644 src/nut/tuple.cpp delete mode 100644 src/nut/tuple.h create mode 100644 src/nut/types/types.pri diff --git a/src/nut/config/config.pri b/src/nut/config/config.pri new file mode 100644 index 0000000..c3c880a --- /dev/null +++ b/src/nut/config/config.pri @@ -0,0 +1,8 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/nut_config.h \ + $$PWD/nut_consts.h \ + $$PWD/nut_global.h \ + $$PWD/nut_macros.h \ + $$PWD/nut_namespace.h diff --git a/src/nut/config/nut_config.h b/src/nut/config/nut_config.h new file mode 100644 index 0000000..fd8e780 --- /dev/null +++ b/src/nut/config/nut_config.h @@ -0,0 +1,20 @@ +#ifndef NUT_CONFIG_H +#define NUT_CONFIG_H + +#if defined(NUT_SHARED) || !defined(NUT_STATIC) +# ifdef NUT_STATIC +# error "Both NUT_SHARED and NUT_STATIC defined, please make up your mind" +# endif +# ifndef NUT_SHARED +# define NUT_SHARED +# endif +# if defined(NUT_BUILD_LIB) +# define NUT_EXPORT Q_DECL_EXPORT +# else +# define NUT_EXPORT Q_DECL_IMPORT +# endif +#else +# define NUT_EXPORT +#endif + +#endif // NUT_CONFIG_H diff --git a/src/nut/defines_consts.h b/src/nut/config/nut_consts.h similarity index 96% rename from src/nut/defines_consts.h rename to src/nut/config/nut_consts.h index 380fc1b..8d74aeb 100644 --- a/src/nut/defines_consts.h +++ b/src/nut/config/nut_consts.h @@ -18,8 +18,8 @@ ** **************************************************************************/ -#ifndef DEFINES_P_H -#define DEFINES_P_H +#ifndef NUT_CONSTS_H +#define NUT_CONSTS_H #define __NAME "name" #define __TYPE "type" @@ -56,4 +56,4 @@ # define NUT_WRAP_NAMESPACE(x) x #endif -#endif // DEFINES_P_H +#endif // NUT_CONSTS_H diff --git a/src/nut/config/nut_global.h b/src/nut/config/nut_global.h new file mode 100644 index 0000000..0159842 --- /dev/null +++ b/src/nut/config/nut_global.h @@ -0,0 +1,12 @@ +#ifndef NUT_GLOBAL_H +#define NUT_GLOBAL_H + +#define NUT_NAMESPACE Nut + +#include +#include +#include +#include +#include + +#endif // NUT_GLOBAL_H diff --git a/src/nut/defines.h b/src/nut/config/nut_macros.h similarity index 64% rename from src/nut/defines.h rename to src/nut/config/nut_macros.h index aa6725e..52cd802 100644 --- a/src/nut/defines.h +++ b/src/nut/config/nut_macros.h @@ -1,51 +1,6 @@ -/************************************************************************** -** -** This file is part of Nut project. -** https://github.com/HamedMasafi/Nut -** -** Nut is free software: you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** Nut is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public License -** along with Nut. If not, see . -** -**************************************************************************/ +#ifndef NUT_MACROS_H +#define NUT_MACROS_H -#ifndef SYNTAX_DEFINES_H -#define SYNTAX_DEFINES_H - -#define NUT_NAMESPACE Nut - -#include -#include - -#include -#include -#include -#include - -#if defined(NUT_SHARED) || !defined(NUT_STATIC) -# ifdef NUT_STATIC -# error "Both NUT_SHARED and NUT_STATIC defined, please make up your mind" -# endif -# ifndef NUT_SHARED -# define NUT_SHARED -# endif -# if defined(NUT_BUILD_LIB) -# define NUT_EXPORT Q_DECL_EXPORT -# else -# define NUT_EXPORT Q_DECL_IMPORT -# endif -#else -# define NUT_EXPORT -#endif #define NUT_INFO(type, name, value) \ Q_CLASSINFO(__nut_NAME_PERFIX type #name #value, \ @@ -180,132 +135,4 @@ public slots: \ #define NUT_NOT_NULL(x) NUT_INFO(__nut_NOT_NULL, x, 1) #define NUT_INDEX(name, field, order) -NUT_BEGIN_NAMESPACE - -inline bool nutClassInfo(const QMetaClassInfo &classInfo, - QString &type, QString &name, QVariant &value) -{ - if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) - return false; - - QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); - if (parts.count() != 3) - return false; - - type = parts[0]; - name = parts[1]; - value = QVariant::fromValue(parts[2]); - return true; -} - -inline bool nutClassInfoString(const QMetaClassInfo &classInfo, - QString &type, QString &name, QString &value) -{ - if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) - return false; - - QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); - if (parts.count() != 3) - return false; - - type = parts[0]; - name = parts[1]; - value = parts[2]; - return true; -} - -inline bool nutClassInfoBool(const QMetaClassInfo &classInfo, - QString &type, QString &name, bool &value) -{ - if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) - return false; - - QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); - if (parts.count() != 3) - return false; - - QString buffer = parts[2].toLower(); - if (buffer != QStringLiteral("true") && buffer != QStringLiteral("false")) - return false; - - type = parts[0]; - name = parts[1]; - value = (buffer == QStringLiteral("true")); - return true; -} - -inline bool nutClassInfoInt(const QMetaClassInfo &classInfo, - QString &type, QString &name, bool &value) -{ - if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) - return false; - - QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); - if (parts.count() != 3) - return false; - bool ok; - type = parts[0]; - name = parts[1]; - value = parts[2].toInt(&ok); - return ok; -} - -#ifdef NUT_SHARED_POINTER -template -using RowList = QList>; - -template -using RowSet = QSet>; - -template -using Row = QSharedPointer; - -template -inline Row create() { - return QSharedPointer(new T); -} - -template -inline Row create(QObject *parent) { - return QSharedPointer(new T(parent)); -} - -template -inline Row createFrom(T *row) { - return QSharedPointer(row); -} -template -inline Row createFrom(const QSharedPointer row) { - return row; -} - -#else -template -using RowList = QList; - -template -using RowSet = QSet; - -template -using Row = T*; - -template -inline Row create() { - return new T; -} - -template -inline T *get(const Row row) { - return row; -} - -template -inline T *get(const QSharedPointer row) { - return row.data(); -} - -#endif - -NUT_END_NAMESPACE - -#endif // SYNTAX_DEFINES_H +#endif // NUT_MACROS_H diff --git a/src/nut/config/nut_namespace.h b/src/nut/config/nut_namespace.h new file mode 100644 index 0000000..b87c38d --- /dev/null +++ b/src/nut/config/nut_namespace.h @@ -0,0 +1,137 @@ +#ifndef NUT_NAMESPACE_H +#define NUT_NAMESPACE_H + +#include + +#include +#include +#include +#include + +NUT_BEGIN_NAMESPACE + +inline bool nutClassInfo(const QMetaClassInfo &classInfo, + QString &type, QString &name, QVariant &value) +{ + if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) + return false; + + QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); + if (parts.count() != 3) + return false; + + type = parts[0]; + name = parts[1]; + value = QVariant::fromValue(parts[2]); + return true; +} + +inline bool nutClassInfoString(const QMetaClassInfo &classInfo, + QString &type, QString &name, QString &value) +{ + if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) + return false; + + QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); + if (parts.count() != 3) + return false; + + type = parts[0]; + name = parts[1]; + value = parts[2]; + return true; +} + +inline bool nutClassInfoBool(const QMetaClassInfo &classInfo, + QString &type, QString &name, bool &value) +{ + if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) + return false; + + QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); + if (parts.count() != 3) + return false; + + QString buffer = parts[2].toLower(); + if (buffer != QStringLiteral("true") && buffer != QStringLiteral("false")) + return false; + + type = parts[0]; + name = parts[1]; + value = (buffer == QStringLiteral("true")); + return true; +} + +inline bool nutClassInfoInt(const QMetaClassInfo &classInfo, + QString &type, QString &name, bool &value) +{ + if (!QString::fromUtf8(classInfo.name()).startsWith(QStringLiteral(__nut_NAME_PERFIX))) + return false; + + QStringList parts = QString::fromUtf8(classInfo.value()).split(QStringLiteral("\n")); + if (parts.count() != 3) + return false; + bool ok; + type = parts[0]; + name = parts[1]; + value = parts[2].toInt(&ok); + return ok; +} + +#ifdef NUT_RAW_POINTER +template +using RowList = QList; + +template +using RowSet = QSet; + +template +using Row = T*; + +template +inline Row create() { + return new T; +} + +template +inline T *get(const Row row) { + return row; +} + +template +inline T *get(const QSharedPointer row) { + return row.data(); +} +#else +template +using RowList = QList>; + +template +using RowSet = QSet>; + +template +using Row = QSharedPointer; + +template +inline Row create() { + return QSharedPointer(new T); +} + +template +inline Row create(QObject *parent) { + return QSharedPointer(new T(parent)); +} + +template +inline Row createFrom(T *row) { + return QSharedPointer(row); +} +template +inline Row createFrom(const QSharedPointer row) { + return row; +} +#endif + +NUT_END_NAMESPACE + +#endif // NUT_NAMESPACE_H diff --git a/src/nut/abstracttableset.cpp b/src/nut/core/abstracttableset.cpp similarity index 98% rename from src/nut/abstracttableset.cpp rename to src/nut/core/abstracttableset.cpp index cfec831..af90d81 100644 --- a/src/nut/abstracttableset.cpp +++ b/src/nut/core/abstracttableset.cpp @@ -63,10 +63,10 @@ int AbstractTableSet::save(Database *db, bool cleanUp) || t->status() == Table::Deleted) { rowsAffected += t->save(db); if (cleanUp) -#ifdef NUT_SHARED_POINTER - remove(t); -#else +#ifdef NUT_RAW_POINTER t->deleteLater(); +#else + remove(t); #endif } } @@ -79,7 +79,7 @@ int AbstractTableSet::save(Database *db, bool cleanUp) void AbstractTableSet::clearChilds() { -#ifndef NUT_SHARED_POINTER +#ifdef NUT_RAW_POINTER foreach (Table *t, data->childs) t->deleteLater(); #endif diff --git a/src/nut/abstracttableset.h b/src/nut/core/abstracttableset.h similarity index 98% rename from src/nut/abstracttableset.h rename to src/nut/core/abstracttableset.h index 5644005..f5f8f45 100644 --- a/src/nut/abstracttableset.h +++ b/src/nut/core/abstracttableset.h @@ -26,7 +26,7 @@ #include #include -#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/abstracttablesetdata.h b/src/nut/core/abstracttablesetdata.h similarity index 98% rename from src/nut/abstracttablesetdata.h rename to src/nut/core/abstracttablesetdata.h index c53448c..f2b60ac 100644 --- a/src/nut/abstracttablesetdata.h +++ b/src/nut/core/abstracttablesetdata.h @@ -23,7 +23,7 @@ #include -#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/bulkinserter.cpp b/src/nut/core/bulkinserter.cpp similarity index 100% rename from src/nut/bulkinserter.cpp rename to src/nut/core/bulkinserter.cpp diff --git a/src/nut/bulkinserter.h b/src/nut/core/bulkinserter.h similarity index 96% rename from src/nut/bulkinserter.h rename to src/nut/core/bulkinserter.h index ae837f6..d977397 100644 --- a/src/nut/bulkinserter.h +++ b/src/nut/core/bulkinserter.h @@ -6,7 +6,7 @@ #include #include -#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/bulkinserter_p.h b/src/nut/core/bulkinserter_p.h similarity index 100% rename from src/nut/bulkinserter_p.h rename to src/nut/core/bulkinserter_p.h diff --git a/src/nut/changelogtable.cpp b/src/nut/core/changelogtable.cpp similarity index 100% rename from src/nut/changelogtable.cpp rename to src/nut/core/changelogtable.cpp diff --git a/src/nut/changelogtable.h b/src/nut/core/changelogtable.h similarity index 100% rename from src/nut/changelogtable.h rename to src/nut/core/changelogtable.h diff --git a/src/nut/core/core.pri b/src/nut/core/core.pri new file mode 100644 index 0000000..aa46c3e --- /dev/null +++ b/src/nut/core/core.pri @@ -0,0 +1,25 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/abstracttableset.h \ + $$PWD/abstracttablesetdata.h \ + $$PWD/bulkinserter.h \ + $$PWD/bulkinserter_p.h \ + $$PWD/changelogtable.h \ + $$PWD/database.h \ + $$PWD/database_p.h \ + $$PWD/query.h \ + $$PWD/table.h \ + $$PWD/table_p.h \ + $$PWD/tableset.h + +SOURCES += \ + $$PWD/abstracttableset.cpp \ + $$PWD/bulkinserter.cpp \ + $$PWD/changelogtable.cpp \ + $$PWD/database.cpp \ + $$PWD/query.cpp \ + $$PWD/table.cpp \ + $$PWD/tableset.cpp + + diff --git a/src/nut/database.cpp b/src/nut/core/database.cpp similarity index 99% rename from src/nut/database.cpp rename to src/nut/core/database.cpp index de16341..9eced3d 100644 --- a/src/nut/database.cpp +++ b/src/nut/core/database.cpp @@ -33,7 +33,7 @@ #include "table.h" #include "tableset.h" #include "database_p.h" -#include "defines.h" +#include "config/nut_global.h" #include "tablemodel.h" #include "postgresqlgenerator.h" #include "mysqlgenerator.h" diff --git a/src/nut/database.h b/src/nut/core/database.h similarity index 98% rename from src/nut/database.h rename to src/nut/core/database.h index c88c9d6..9b3ac31 100644 --- a/src/nut/database.h +++ b/src/nut/core/database.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include NUT_BEGIN_NAMESPACE diff --git a/src/nut/database_p.h b/src/nut/core/database_p.h similarity index 100% rename from src/nut/database_p.h rename to src/nut/core/database_p.h diff --git a/src/nut/query.cpp b/src/nut/core/query.cpp similarity index 100% rename from src/nut/query.cpp rename to src/nut/core/query.cpp diff --git a/src/nut/query.h b/src/nut/core/query.h similarity index 99% rename from src/nut/query.h rename to src/nut/core/query.h index 743b6c1..8ff4737 100644 --- a/src/nut/query.h +++ b/src/nut/core/query.h @@ -31,7 +31,7 @@ #include #include -#ifdef NUT_SHARED_POINTER +#ifndef NUT_RAW_POINTER #include #endif @@ -351,10 +351,10 @@ Q_OUTOFLINE_TEMPLATE RowList Query::toList(int count) Row row; if (data.table->className() == d->className) { row = Nut::create(); -#ifdef NUT_SHARED_POINTER - returnList.append(row.objectCast()); -#else +#ifdef NUT_RAW_POINTER returnList.append(dynamic_cast(table)); +#else + returnList.append(row.objectCast()); #endif d->tableSet->add(row); diff --git a/src/nut/table.cpp b/src/nut/core/table.cpp similarity index 98% rename from src/nut/table.cpp rename to src/nut/core/table.cpp index b5afe44..866c5c9 100644 --- a/src/nut/table.cpp +++ b/src/nut/core/table.cpp @@ -43,6 +43,10 @@ NUT_BEGIN_NAMESPACE * This should be fixed to v1.2 */ +/*! + * \class Table + * \brief Base class for all tables + */ Table::Table(QObject *parent) : QObject(parent), d(new TablePrivate) { } diff --git a/src/nut/table.h b/src/nut/core/table.h similarity index 98% rename from src/nut/table.h rename to src/nut/core/table.h index ec73c6a..55e1051 100644 --- a/src/nut/table.h +++ b/src/nut/core/table.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/src/nut/table_p.h b/src/nut/core/table_p.h similarity index 90% rename from src/nut/table_p.h rename to src/nut/core/table_p.h index ef10672..954bffb 100644 --- a/src/nut/table_p.h +++ b/src/nut/core/table_p.h @@ -4,7 +4,8 @@ #include #include -#include +#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/tableset.cpp b/src/nut/core/tableset.cpp similarity index 100% rename from src/nut/tableset.cpp rename to src/nut/core/tableset.cpp diff --git a/src/nut/tableset.h b/src/nut/core/tableset.h similarity index 99% rename from src/nut/tableset.h rename to src/nut/core/tableset.h index d28ddfb..bd0450c 100644 --- a/src/nut/tableset.h +++ b/src/nut/core/tableset.h @@ -100,10 +100,10 @@ Q_OUTOFLINE_TEMPLATE int TableSet::length() const template Q_OUTOFLINE_TEMPLATE Row TableSet::at(int i) const { -#ifdef NUT_SHARED_POINTER - return data->childs.at(i).template objectCast(); -#else +#ifdef NUT_RAW_POINTER return reinterpret_cast(data->childs.at(i)); +#else + return data->childs.at(i).template objectCast(); #endif } diff --git a/src/nut/generators/generators.pri b/src/nut/generators/generators.pri new file mode 100644 index 0000000..2a81bbe --- /dev/null +++ b/src/nut/generators/generators.pri @@ -0,0 +1,15 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/abstractsqlgenerator.h \ + $$PWD/postgresqlgenerator.h \ + $$PWD/mysqlgenerator.h \ + $$PWD/sqlitegenerator.h \ + $$PWD/sqlservergenerator.h + +SOURCES += \ + $$PWD/abstractsqlgenerator.cpp \ + $$PWD/postgresqlgenerator.cpp \ + $$PWD/mysqlgenerator.cpp \ + $$PWD/sqlitegenerator.cpp \ + $$PWD/sqlservergenerator.cpp diff --git a/src/nut/databasemodel.cpp b/src/nut/models/databasemodel.cpp similarity index 100% rename from src/nut/databasemodel.cpp rename to src/nut/models/databasemodel.cpp diff --git a/src/nut/databasemodel.h b/src/nut/models/databasemodel.h similarity index 98% rename from src/nut/databasemodel.h rename to src/nut/models/databasemodel.h index 5b8e17c..3dcbb6c 100644 --- a/src/nut/databasemodel.h +++ b/src/nut/models/databasemodel.h @@ -25,7 +25,7 @@ #include #include -#include +#include class QJsonObject; diff --git a/src/nut/models/models.pri b/src/nut/models/models.pri new file mode 100644 index 0000000..9203dc1 --- /dev/null +++ b/src/nut/models/models.pri @@ -0,0 +1,14 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/databasemodel.h \ + $$PWD/sqlmodel.h \ + $$PWD/sqlmodel_p.h \ + $$PWD/tablemodel.h + +SOURCES += \ + $$PWD/databasemodel.cpp \ + $$PWD/sqlmodel.cpp \ + $$PWD/tablemodel.cpp + + diff --git a/src/nut/sqlmodel.cpp b/src/nut/models/sqlmodel.cpp similarity index 100% rename from src/nut/sqlmodel.cpp rename to src/nut/models/sqlmodel.cpp diff --git a/src/nut/sqlmodel.h b/src/nut/models/sqlmodel.h similarity index 96% rename from src/nut/sqlmodel.h rename to src/nut/models/sqlmodel.h index 3a87d76..50f6815 100644 --- a/src/nut/sqlmodel.h +++ b/src/nut/models/sqlmodel.h @@ -25,7 +25,7 @@ #include #include -#include +#include NUT_BEGIN_NAMESPACE @@ -55,7 +55,7 @@ public: void append(Row
table); // void append(Table *table); QVariant headerData(int section, Qt::Orientation orientation, int role) const; - Row at(const int &i) const; + Row
at(const int &i) const; void setRenderer(const std::function &renderer); diff --git a/src/nut/sqlmodel_p.h b/src/nut/models/sqlmodel_p.h similarity index 94% rename from src/nut/sqlmodel_p.h rename to src/nut/models/sqlmodel_p.h index ea57486..0e2dba1 100644 --- a/src/nut/sqlmodel_p.h +++ b/src/nut/models/sqlmodel_p.h @@ -6,7 +6,7 @@ #include -#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/tablemodel.cpp b/src/nut/models/tablemodel.cpp similarity index 99% rename from src/nut/tablemodel.cpp rename to src/nut/models/tablemodel.cpp index e36f23e..da2d52e 100644 --- a/src/nut/tablemodel.cpp +++ b/src/nut/models/tablemodel.cpp @@ -25,7 +25,7 @@ #include #include "tablemodel.h" -#include "defines.h" +#include "nut_global.h" NUT_BEGIN_NAMESPACE diff --git a/src/nut/tablemodel.h b/src/nut/models/tablemodel.h similarity index 99% rename from src/nut/tablemodel.h rename to src/nut/models/tablemodel.h index 255e9c6..54a28e1 100644 --- a/src/nut/tablemodel.h +++ b/src/nut/models/tablemodel.h @@ -24,7 +24,7 @@ #include #include -#include +#include class QJsonObject; diff --git a/src/nut/src.pri b/src/nut/nut.pri similarity index 98% rename from src/nut/src.pri rename to src/nut/nut.pri index 0c29459..380d07c 100644 --- a/src/nut/src.pri +++ b/src/nut/nut.pri @@ -10,7 +10,7 @@ HEADERS += \ $$PWD/types/dbgeography.h \ $$PWD/tableset.h \ $$PWD/defines_consts.h \ - $$PWD/defines.h \ + $$PWD/nut_global.h \ $$PWD/query.h \ $$PWD/databasemodel.h \ $$PWD/changelogtable.h \ diff --git a/src/nut/nut.pro b/src/nut/nut.pro index 7beb4ab..1b83798 100644 --- a/src/nut/nut.pro +++ b/src/nut/nut.pro @@ -9,79 +9,18 @@ DEFINES += QT_DEPRECATED_WARNINGS NUT_SHARED NUT_BUILD_LIB DEFINES += NUT_SHARED_POINTER -INCLUDEPATH += \ - $$PWD/generators \ - $$PWD/phrases \ - $$PWD/types +include(config/config.pri) +include(core/core.pri) +include(generators/generators.pri) +include(types/types.pri) +include(phrases/phrases.pri) +include(models/models.pri) HEADERS += \ - $$PWD/generators/abstractsqlgenerator.h \ - $$PWD/generators/postgresqlgenerator.h \ - $$PWD/generators/mysqlgenerator.h \ - $$PWD/generators/sqlitegenerator.h \ - $$PWD/generators/sqlservergenerator.h \ - $$PWD/types/dbgeography.h \ - $$PWD/tableset.h \ - $$PWD/defines_consts.h \ - $$PWD/defines.h \ - $$PWD/query.h \ - $$PWD/bulkinserter.h \ - $$PWD/databasemodel.h \ - $$PWD/changelogtable.h \ - $$PWD/abstracttableset.h \ - $$PWD/abstracttablesetdata.h \ - $$PWD/tablemodel.h \ - $$PWD/table.h \ - $$PWD/database.h \ - $$PWD/database_p.h \ - $$PWD/serializableobject.h \ - $$PWD/sqlmodel.h \ - $$PWD/sqlmodel_p.h \ - $$PWD/phrase.h \ - $$PWD/phrases/abstractfieldphrase.h \ - $$PWD/phrases/assignmentphrase.h \ - $$PWD/phrases/assignmentphraselist.h \ - $$PWD/phrases/conditionalphrase.h \ - $$PWD/phrases/fieldphrase.h \ - $$PWD/phrases/phrasedata.h \ - $$PWD/phrases/phrasedatalist.h \ - $$PWD/phrases/phraselist.h \ - $$PWD/phrases/fieldphrase_date.h \ - $$PWD/table_p.h \ - $$PWD/bulkinserter_p.h \ - $$PWD/phrases/fieldphrase_bool.h \ - $$PWD/phrases/fieldphrase_qstring.h + $$PWD/phrase.h SOURCES += \ - $$PWD/generators/abstractsqlgenerator.cpp \ - $$PWD/generators/postgresqlgenerator.cpp \ - $$PWD/generators/mysqlgenerator.cpp \ - $$PWD/generators/sqlitegenerator.cpp \ - $$PWD/generators/sqlservergenerator.cpp \ - $$PWD/types/dbgeography.cpp \ - $$PWD/tableset.cpp \ - $$PWD/query.cpp \ - $$PWD/bulkinserter.cpp \ - $$PWD/databasemodel.cpp \ - $$PWD/abstracttableset.cpp \ - $$PWD/changelogtable.cpp \ - $$PWD/tablemodel.cpp \ - $$PWD/table.cpp \ - $$PWD/database.cpp \ - $$PWD/serializableobject.cpp \ - $$PWD/sqlmodel.cpp \ - $$PWD/phrase.cpp \ - $$PWD/phrases/abstractfieldphrase.cpp \ - $$PWD/phrases/assignmentphrase.cpp \ - $$PWD/phrases/assignmentphraselist.cpp \ - $$PWD/phrases/conditionalphrase.cpp \ - $$PWD/phrases/fieldphrase.cpp \ - $$PWD/phrases/phrasedata.cpp \ - $$PWD/phrases/phrasedatalist.cpp \ - $$PWD/phrases/phraselist.cpp \ - $$PWD/phrases/fieldphrase_date.cpp \ - $$PWD/phrases/fieldphrase_bool.cpp \ - $$PWD/phrases/fieldphrase_qstring.cpp + $$PWD/phrase.cpp load(qt_module) diff --git a/src/nut/phrase.cpp b/src/nut/phrase.cpp index 57e513c..1f47186 100644 --- a/src/nut/phrase.cpp +++ b/src/nut/phrase.cpp @@ -19,47 +19,3 @@ **************************************************************************/ #include "phrase.h" - -#include - -NUT_BEGIN_NAMESPACE - - - - - -//AssignmentPhrase::AssignmentPhrase(AssignmentPhrase *l, const AssignmentPhrase *r) -//{ -//// data = new PhraseData(l->data, PhraseData::Append, r->data); -// qFatal("SS"); -//} - - - - - - -//AssignmentPhraseList operator &(const AssignmentPhrase &l, const AssignmentPhrase &r) -//{ -// return AssignmentPhraseList(l, r); -//} - -//AssignmentPhraseList operator &(const AssignmentPhrase &l, AssignmentPhrase &&r) -//{ -// r.data = 0; -// return AssignmentPhraseList(l, r); -//} - -//AssignmentPhraseList operator &(AssignmentPhrase &&l, const AssignmentPhrase &r) -//{ -// l.data = 0; -// return AssignmentPhraseList(l, r); -//} - -//AssignmentPhraseList operator &(AssignmentPhrase &&l, AssignmentPhrase &&r) -//{ -// r.data = l.data = 0; -// return AssignmentPhraseList(l, r); -//} - -NUT_END_NAMESPACE diff --git a/src/nut/phrase.h b/src/nut/phrase.h index ab9d4f9..c517ccb 100644 --- a/src/nut/phrase.h +++ b/src/nut/phrase.h @@ -21,6 +21,7 @@ #ifndef PHRASE_H #define PHRASE_H +#include #include #include #include @@ -34,42 +35,4 @@ #include #include -NUT_BEGIN_NAMESPACE - -#define SPECIALIZATION_NUMERIC_MEMBER(type, op, cond) \ -ConditionalPhrase operator op(const QVariant &other) \ -{ \ - return ConditionalPhrase(this, cond, other); \ -} - -class AbstractFieldPhrase; -class AssignmentPhrase; -class PhraseList; - -//AssignmentPhraseList operator &(const AssignmentPhrase &l, const AssignmentPhrase &r); -//AssignmentPhraseList operator &(const AssignmentPhrase &l, AssignmentPhrase &&r); -//AssignmentPhraseList operator &(AssignmentPhrase &&l, const AssignmentPhrase &r); -//AssignmentPhraseList operator &(AssignmentPhrase &&l, AssignmentPhrase &&r); - - -//ConditionalPhrase operator <(AbstractFieldPhrase &l, ConditionalPhrase &&other) -//{ -// return ConditionalPhrase(&l, PhraseData::Less, other); -//} - -//template -//class FieldPhrase : public AbstractFieldPhrase -//{ -//public: -// FieldPhrase(const char *className, const char *s) : -// AbstractFieldPhrase(className, s) -// {} - -// AssignmentPhrase operator =(const QVariant &other) { -// return AssignmentPhrase(this, other); -// } -//}; - -NUT_END_NAMESPACE - #endif // PHRASE_H diff --git a/src/nut/phrases/abstractfieldphrase.h b/src/nut/phrases/abstractfieldphrase.h index a4340be..8f2326e 100644 --- a/src/nut/phrases/abstractfieldphrase.h +++ b/src/nut/phrases/abstractfieldphrase.h @@ -21,7 +21,7 @@ #ifndef ABSTRACTFIELDPHRASE_H #define ABSTRACTFIELDPHRASE_H -#include +#include #include #include #include diff --git a/src/nut/phrases/assignmentphrase.h b/src/nut/phrases/assignmentphrase.h index fc2711f..8eeb244 100644 --- a/src/nut/phrases/assignmentphrase.h +++ b/src/nut/phrases/assignmentphrase.h @@ -21,7 +21,7 @@ #ifndef ASSIGNMENTPHRASE_H #define ASSIGNMENTPHRASE_H -#include +#include #include NUT_BEGIN_NAMESPACE diff --git a/src/nut/phrases/assignmentphraselist.h b/src/nut/phrases/assignmentphraselist.h index 7e0c897..1e7c2b4 100644 --- a/src/nut/phrases/assignmentphraselist.h +++ b/src/nut/phrases/assignmentphraselist.h @@ -21,7 +21,7 @@ #ifndef ASSIGNMENTPHRASELIST_H #define ASSIGNMENTPHRASELIST_H -#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/phrases/fieldphrase.h b/src/nut/phrases/fieldphrase.h index 5071668..909cc4f 100644 --- a/src/nut/phrases/fieldphrase.h +++ b/src/nut/phrases/fieldphrase.h @@ -21,7 +21,7 @@ #ifndef FIELDPHRASE_H #define FIELDPHRASE_H -#include +#include #include NUT_BEGIN_NAMESPACE diff --git a/src/nut/phrases/fieldphrase_bool.h b/src/nut/phrases/fieldphrase_bool.h index ad3e111..eb7277c 100644 --- a/src/nut/phrases/fieldphrase_bool.h +++ b/src/nut/phrases/fieldphrase_bool.h @@ -1,7 +1,7 @@ #ifndef NUT_FIELDPHRASE_BOOL_H #define NUT_FIELDPHRASE_BOOL_H -#include +#include #include #include diff --git a/src/nut/phrases/fieldphrase_qstring.h b/src/nut/phrases/fieldphrase_qstring.h index ede4490..754d971 100644 --- a/src/nut/phrases/fieldphrase_qstring.h +++ b/src/nut/phrases/fieldphrase_qstring.h @@ -1,7 +1,7 @@ #ifndef NUT_FIELDPHRASE_QSTRING_H #define NUT_FIELDPHRASE_QSTRING_H -#include +#include #include #include diff --git a/src/nut/phrases/phrasedata.h b/src/nut/phrases/phrasedata.h index 11fe522..48937ab 100644 --- a/src/nut/phrases/phrasedata.h +++ b/src/nut/phrases/phrasedata.h @@ -21,7 +21,7 @@ #ifndef PHRASEDATA_H #define PHRASEDATA_H -#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/phrases/phraselist.h b/src/nut/phrases/phraselist.h index 42620fc..5c02818 100644 --- a/src/nut/phrases/phraselist.h +++ b/src/nut/phrases/phraselist.h @@ -21,7 +21,7 @@ #ifndef PHRASELIST_H #define PHRASELIST_H -#include +#include #include NUT_BEGIN_NAMESPACE diff --git a/src/nut/phrases/phrases.pri b/src/nut/phrases/phrases.pri new file mode 100644 index 0000000..33c0c1b --- /dev/null +++ b/src/nut/phrases/phrases.pri @@ -0,0 +1,27 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/abstractfieldphrase.h \ + $$PWD/assignmentphrase.h \ + $$PWD/assignmentphraselist.h \ + $$PWD/conditionalphrase.h \ + $$PWD/fieldphrase.h \ + $$PWD/phrasedata.h \ + $$PWD/phrasedatalist.h \ + $$PWD/phraselist.h \ + $$PWD/fieldphrase_date.h \ + $$PWD/fieldphrase_bool.h \ + $$PWD/fieldphrase_qstring.h + +SOURCES += \ + $$PWD/abstractfieldphrase.cpp \ + $$PWD/assignmentphrase.cpp \ + $$PWD/assignmentphraselist.cpp \ + $$PWD/conditionalphrase.cpp \ + $$PWD/fieldphrase.cpp \ + $$PWD/phrasedata.cpp \ + $$PWD/phrasedatalist.cpp \ + $$PWD/phraselist.cpp \ + $$PWD/fieldphrase_date.cpp \ + $$PWD/fieldphrase_bool.cpp \ + $$PWD/fieldphrase_qstring.cpp diff --git a/src/nut/serializableobject.cpp b/src/nut/serializableobject.cpp deleted file mode 100644 index 0a09db5..0000000 --- a/src/nut/serializableobject.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "serializableobject.h" - diff --git a/src/nut/serializableobject.h b/src/nut/serializableobject.h deleted file mode 100644 index d234359..0000000 --- a/src/nut/serializableobject.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SERIALIZABLEOBJECT_H -#define SERIALIZABLEOBJECT_H - -#include - -class SerializableObject -{ -public: - SerializableObject() = default; - - virtual void load(const QVariant &value) = 0; - virtual QVariant save() = 0; -}; - -#endif // SERIALIZABLEOBJECT_H diff --git a/src/nut/tuple.cpp b/src/nut/tuple.cpp deleted file mode 100644 index c87288d..0000000 --- a/src/nut/tuple.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "tuple.h" - diff --git a/src/nut/tuple.h b/src/nut/tuple.h deleted file mode 100644 index e3131fa..0000000 --- a/src/nut/tuple.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef TUPLE_H -#define TUPLE_H - -#include - -//class AbstractTuple -//{ -// Q_GADGET -//}; - -//template -//class Tuple -//{ -//public: -// T _1; -//}; - -#endif // TUPLE_H diff --git a/src/nut/types/dbgeography.h b/src/nut/types/dbgeography.h index 18b1770..f3a4747 100644 --- a/src/nut/types/dbgeography.h +++ b/src/nut/types/dbgeography.h @@ -25,7 +25,7 @@ #include #include -#include +#include NUT_BEGIN_NAMESPACE diff --git a/src/nut/types/types.pri b/src/nut/types/types.pri new file mode 100644 index 0000000..23679fa --- /dev/null +++ b/src/nut/types/types.pri @@ -0,0 +1,7 @@ + INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/dbgeography.h + +SOURCES += \ + $$PWD/dbgeography.cpp diff --git a/sync.profile b/sync.profile index 384554f..99aea03 100644 --- a/sync.profile +++ b/sync.profile @@ -2,4 +2,4 @@ "QtNut" => "$basedir/src/nut", ); -$publicclassregexp = "^QtJsonSerializer::(?!__private::|MetaWriters::Implementations::|TypeExtractors::|Exception).+"; +$publicclassregexp = ".+";