This commit is contained in:
Hamed Masafi 2020-07-28 18:36:40 +04:30
commit db24b160fb
37 changed files with 167 additions and 90 deletions

View File

@ -59,10 +59,14 @@ jobs:
run: |
qmake CONFIG+=install_ok QT_PLATFORM=${{matrix.platform}} "QT_TOOL_PATH=${{steps.qt.outputs.qtdir}}/Tools" nut.pro
${{steps.qt.outputs.make}} qmake_all
<<<<<<< HEAD
- name: make module
run: |
${{steps.qt.outputs.make}}
${{steps.qt.outputs.make}} INSTALL_ROOT="${{steps.qt.outputs.installdir}}" install
=======
>>>>>>> 29aaab8228f2f4c9d7c6651941f6614130c02d1d
- name: upload module to releases
uses: Skycoder42/action-upload-release@master
if: startsWith(github.ref, 'refs/tags/')
@ -70,7 +74,11 @@ jobs:
repo_token: ${{secrets.GITHUB_TOKEN}}
directory: ${{steps.qt.outputs.outdir}}
platform: ${{matrix.platform}}
<<<<<<< HEAD
asset_name: nut-${{matrix.platform}}-${{matrix.version}}
=======
asset_name: qtautoupdater-${{matrix.platform}}-${{matrix.version}}
>>>>>>> 29aaab8228f2f4c9d7c6651941f6614130c02d1d
tag: ${{github.ref}}
overwrite: true

View File

@ -33,4 +33,4 @@ Bitcoin address: 1Dn1WHKkaxanXe4cTGDk4cFRRABxLUpEVj
![Wallet address](btc-qr.png)
For more information read [Wiki](wiki).
For more information read [Wiki](wiki).

View File

@ -11,7 +11,7 @@ NUT_BEGIN_NAMESPACE
class PhraseList;
class Database;
class BulkInserter
class NUT_EXPORT BulkInserter
{
Database *_database;
QString _className;

View File

@ -26,7 +26,7 @@
NUT_BEGIN_NAMESPACE
class ChangeLogTable : public Table
class NUT_EXPORT ChangeLogTable : public Table
{
Q_OBJECT

View File

@ -30,7 +30,7 @@
NUT_BEGIN_NAMESPACE
class ChangeLogTable;
class DatabasePrivate //: public QSharedData
class NUT_EXPORT DatabasePrivate //: public QSharedData
{
Database *q_ptr;
Q_DECLARE_PUBLIC(Database)

View File

@ -33,7 +33,7 @@ NUT_BEGIN_NAMESPACE
class TableModel;
struct RelationModel;
class DatabaseModel : public QList<TableModel *>
class NUT_EXPORT DatabaseModel : public QList<TableModel *>
{
QString _databaseClassName;
int _version;

View File

@ -31,10 +31,20 @@
#include <QVariant>
#include <QMetaClassInfo>
#ifdef NUT_COMPILE_STATIC
# define NUT_EXPORT
#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 Q_DECL_EXPORT
# define NUT_EXPORT
#endif
#define NUT_INFO(type, name, value) \
@ -45,7 +55,7 @@
Q_CLASSINFO(__nut_NAME_PERFIX type #name #value, \
type "\n" #name "\n" value)
#define NUT_FIELD_PERFIX
#define NUT_FIELD_PREFIX
#define NUT_FIELD_POSTFIX Field
// Database
@ -165,7 +175,7 @@ public slots: \
#define NUT_AUTO_INCREMENT(x) NUT_INFO(__nut_AUTO_INCREMENT, x, 0)
#define NUT_PRIMARY_AUTO_INCREMENT(x) NUT_INFO(__nut_PRIMARY_KEY_AI, x, 0)\
NUT_PRIMARY_KEY(X) NUT_AUTO_INCREMENT(X)
NUT_PRIMARY_KEY(x) NUT_AUTO_INCREMENT(x)
#define NUT_DISPLAY_NAME(field, name) NUT_INFO(__nut_DISPLAY, field, name)
#define NUT_UNIQUE(x) NUT_INFO(__nut_UNIQUE, x, 0)
#define NUT_LEN(field, len) NUT_INFO(__nut_LEN, field, len)

View File

@ -26,7 +26,7 @@
NUT_BEGIN_NAMESPACE
class MySqlGenerator : public SqlGeneratorBase
class NUT_EXPORT MySqlGenerator : public SqlGeneratorBase
{
public:
explicit MySqlGenerator(Database *parent = nullptr);

View File

@ -26,7 +26,7 @@
NUT_BEGIN_NAMESPACE
class PostgreSqlGenerator : public SqlGeneratorBase
class NUT_EXPORT PostgreSqlGenerator : public SqlGeneratorBase
{
private:
bool readInsideParentese(QString &text, QString &out);

View File

@ -37,7 +37,7 @@ class DatabaseModel;
class TableModel;
class Database;
struct RelationModel;
class SqlGeneratorBase : public QObject
class NUT_EXPORT SqlGeneratorBase : public QObject
{
// Q_OBJECT

View File

@ -26,7 +26,7 @@
NUT_BEGIN_NAMESPACE
class SqliteGenerator : public SqlGeneratorBase
class NUT_EXPORT SqliteGenerator : public SqlGeneratorBase
{
public:
explicit SqliteGenerator(Database *parent = nullptr);

View File

@ -26,7 +26,7 @@
NUT_BEGIN_NAMESPACE
class SqlServerGenerator : public SqlGeneratorBase
class NUT_EXPORT SqlServerGenerator : public SqlGeneratorBase
{
public:
explicit SqlServerGenerator(Database *parent = nullptr);

View File

@ -35,7 +35,7 @@ ConditionalPhrase::ConditionalPhrase(const ConditionalPhrase &other)
}
#ifdef Q_COMPILER_RVALUE_REFS
ConditionalPhrase::ConditionalPhrase(const ConditionalPhrase &&other)
ConditionalPhrase::ConditionalPhrase(ConditionalPhrase &&other)
{
this->data = qMove(other.data);
}

View File

@ -33,6 +33,7 @@ ConditionalPhrase operator op(const QVariant &other) \
{ \
return ConditionalPhrase(this, cond, other); \
}
class NUT_EXPORT ConditionalPhrase
{
public:
@ -42,7 +43,7 @@ public:
ConditionalPhrase();
ConditionalPhrase(const ConditionalPhrase &other);
#ifdef Q_COMPILER_RVALUE_REFS
ConditionalPhrase(const ConditionalPhrase &&other);
ConditionalPhrase(ConditionalPhrase &&other);
#endif
explicit ConditionalPhrase(const PhraseData *data);
ConditionalPhrase(AbstractFieldPhrase *, PhraseData::Condition);
@ -69,24 +70,24 @@ public:
#define DECLARE_CONDITIONALPHRASE_OPERATORS(op) \
ConditionalPhrase operator op(const ConditionalPhrase &l, const ConditionalPhrase &r); \
ConditionalPhrase operator op(const ConditionalPhrase &l, ConditionalPhrase &&r); \
ConditionalPhrase operator op(ConditionalPhrase &&l, const ConditionalPhrase &r); \
ConditionalPhrase operator op(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator op(const ConditionalPhrase &l, const ConditionalPhrase &r); \
ConditionalPhrase NUT_EXPORT operator op(const ConditionalPhrase &l, ConditionalPhrase &&r); \
ConditionalPhrase NUT_EXPORT operator op(ConditionalPhrase &&l, const ConditionalPhrase &r); \
ConditionalPhrase NUT_EXPORT operator op(ConditionalPhrase &&l, ConditionalPhrase &&r);
DECLARE_CONDITIONALPHRASE_OPERATORS(==)
DECLARE_CONDITIONALPHRASE_OPERATORS(&&)
DECLARE_CONDITIONALPHRASE_OPERATORS(||)
ConditionalPhrase operator <(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase operator <=(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase operator >(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase operator >=(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator <(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator <=(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator >(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator >=(AbstractFieldPhrase &l, ConditionalPhrase &&r);
ConditionalPhrase operator <(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase operator <=(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase operator >(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase operator >=(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator <(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator <=(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator >(ConditionalPhrase &&l, ConditionalPhrase &&r);
ConditionalPhrase NUT_EXPORT operator >=(ConditionalPhrase &&l, ConditionalPhrase &&r);
NUT_END_NAMESPACE

View File

@ -27,27 +27,33 @@
NUT_BEGIN_NAMESPACE
template<typename T, typename enable = void>
class NUT_EXPORT FieldPhrase : public AbstractFieldPhrase
template<typename T>
class FieldPhrase : public AbstractFieldPhrase
{
public:
FieldPhrase(const char *className, const char *s) :
AbstractFieldPhrase(className, s)
{}
AssignmentPhrase operator =(const QVariant &other) {
return AssignmentPhrase(this, other);
}
ConditionalPhrase operator ==(const QVariant &other) {
return ConditionalPhrase(this, PhraseData::Equal, other);
}
virtual ~FieldPhrase() {}
AssignmentPhrase operator =(const QVariant &other);
ConditionalPhrase operator ==(const QVariant &other);
};
template<typename T>
Q_OUTOFLINE_TEMPLATE AssignmentPhrase FieldPhrase<T>::operator =(const QVariant &other) {
return AssignmentPhrase(this, other);
}
template<typename T>
Q_OUTOFLINE_TEMPLATE ConditionalPhrase FieldPhrase<T>::operator ==(const QVariant &other) {
return ConditionalPhrase(this, PhraseData::Equal, other);
}
template<>
class NUT_EXPORT FieldPhrase<QString> : public AbstractFieldPhrase
class FieldPhrase<QString> : public AbstractFieldPhrase
{
public:
FieldPhrase(const char *className, const char *s) :
@ -75,7 +81,7 @@ public:
}
template<>
class NUT_EXPORT FieldPhrase<bool> : public AbstractFieldPhrase
class FieldPhrase<bool> : public AbstractFieldPhrase
{
public:
FieldPhrase(const char *className, const char *s) :

View File

@ -12,23 +12,13 @@ NUT_BEGIN_NAMESPACE
return ConditionalPhrase(this, cond, other); \
}
template <typename T>
class FieldPhrase<T, typename std::enable_if<
std::is_floating_point<T>::value || std::is_integral<T>::value
>::type>
: public AbstractFieldPhrase
class NumericFieldPhrase : public AbstractFieldPhrase
{
public:
FieldPhrase(const char *className, const char *s) :
NumericFieldPhrase(const char *className, const char *s) :
AbstractFieldPhrase(className, s)
{}
AssignmentPhrase operator =(const QVariant &other) {
return AssignmentPhrase(this, other);
}
AssignmentPhrase operator =(ConditionalPhrase &&other) {
return AssignmentPhrase(new PhraseData(data, PhraseData::Equal, other.data));
}
ConditionalPhrase between(const QVariant &min, const QVariant &max)
{
return ConditionalPhrase(this, PhraseData::Between,
@ -65,25 +55,32 @@ public:
#define SPECIALIZATION_NUMERIC_TYPE(type) \
template<> \
class FieldPhrase<type> : public NumericPhrase \
class FieldPhrase<type> : public NumericFieldPhrase \
{ \
public: \
FieldPhrase(const char *className, const char *s) : \
NumericPhrase(className, s) \
NumericFieldPhrase(className, s) \
{} \
AssignmentPhrase operator =(const QVariant &other) { \
return AssignmentPhrase(this, other); \
} \
AssignmentPhrase operator =(ConditionalPhrase &&other) { \
return AssignmentPhrase(new PhraseData(data, PhraseData::Equal, other.data)); \
} \
};
//SPECIALIZATION_NUMERIC_TYPE(qint8)
//SPECIALIZATION_NUMERIC_TYPE(qint16)
//SPECIALIZATION_NUMERIC_TYPE(qint32)
//SPECIALIZATION_NUMERIC_TYPE(qint64)
SPECIALIZATION_NUMERIC_TYPE(qint8)
SPECIALIZATION_NUMERIC_TYPE(qint16)
SPECIALIZATION_NUMERIC_TYPE(qint32)
SPECIALIZATION_NUMERIC_TYPE(qint64)
//SPECIALIZATION_NUMERIC_TYPE(quint8)
//SPECIALIZATION_NUMERIC_TYPE(quint16)
//SPECIALIZATION_NUMERIC_TYPE(quint32)
//SPECIALIZATION_NUMERIC_TYPE(quint64)
SPECIALIZATION_NUMERIC_TYPE(quint8)
SPECIALIZATION_NUMERIC_TYPE(quint16)
SPECIALIZATION_NUMERIC_TYPE(quint32)
SPECIALIZATION_NUMERIC_TYPE(quint64)
//SPECIALIZATION_NUMERIC_TYPE(qreal)
SPECIALIZATION_NUMERIC_TYPE(qreal)
SPECIALIZATION_NUMERIC_TYPE(float)
NUT_END_NAMESPACE

View File

@ -49,7 +49,7 @@
NUT_BEGIN_NAMESPACE
template <class T>
class NUT_EXPORT Query : public QueryBase
class Query : public QueryBase
{
QueryPrivate *d_ptr;
Q_DECLARE_PRIVATE(Query)

View File

@ -33,7 +33,7 @@ class Database;
class TableSetBase;
class QueryBase;
struct RelationModel;
class QueryPrivate : public QSharedData {
class NUT_EXPORT QueryPrivate : public QSharedData {
QueryBase *q_ptr;
Q_DECLARE_PUBLIC(QueryBase)

View File

@ -33,7 +33,7 @@ NUT_BEGIN_NAMESPACE
//TODO: remove this class
class Table;
class TableSetBase;
class QueryBase : public QObject
class NUT_EXPORT QueryBase : public QObject
{
Q_OBJECT

View File

@ -10,7 +10,7 @@ NUT_BEGIN_NAMESPACE
class SqlModel;
class Table;
class TableModel;
class SqlModelPrivate : public QSharedData {
class NUT_EXPORT SqlModelPrivate : public QSharedData {
public:
explicit SqlModelPrivate(SqlModel *parent);

View File

@ -65,5 +65,4 @@ SOURCES += \
$$PWD/phrases/phraselist.cpp \
$$PWD/phrases/datephrase.cpp
include($$PWD/../3rdparty/serializer/src/src.pri)

View File

@ -4,7 +4,73 @@ TARGET = nut
TEMPLATE = lib
CONFIG += c++11
DEFINES += QT_DEPRECATED_WARNINGS NUT_COMPILE_STATIC
DEFINES += QT_DEPRECATED_WARNINGS NUT_SHARED NUT_BUILD_LIB
include($$PWD/src.pri)
include($$PWD/../ci-test-init.pri)
DEFINES += NUT_SHARED_POINTER
HEADERS += \
$$PWD/generators/sqlgeneratorbase_p.h \
$$PWD/generators/postgresqlgenerator.h \
$$PWD/generators/mysqlgenerator.h \
$$PWD/generators/sqlitegenerator.h \
$$PWD/generators/sqlservergenerator.h \
$$PWD/tablesetbasedata.h \
$$PWD/types/dbgeography.h \
$$PWD/tableset.h \
$$PWD/defines_p.h \
$$PWD/defines.h \
$$PWD/query.h \
$$PWD/databasemodel.h \
$$PWD/changelogtable.h \
$$PWD/tablesetbase_p.h \
$$PWD/querybase_p.h \
$$PWD/tablemodel.h \
$$PWD/query_p.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/datephrase.h \
$$PWD/table_p.h
SOURCES += \
$$PWD/generators/sqlgeneratorbase.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/databasemodel.cpp \
$$PWD/tablesetbase.cpp \
$$PWD/changelogtable.cpp \
$$PWD/querybase.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/datephrase.cpp
include($$PWD/../3rdparty/serializer/src/src.pri)

View File

@ -51,6 +51,7 @@ public:
Modified,
Deleted
};
Q_ENUM(Status)
int save(Database *db);

View File

@ -20,7 +20,7 @@ public:
TableModel *model;
int status;
Table::Status status;
QSet<QString> changedProperties;
TableSetBase *parentTableSet;
QSet<TableSetBase*> childTableSets;

View File

@ -30,7 +30,7 @@ class QJsonObject;
NUT_BEGIN_NAMESPACE
class TableModel;
struct FieldModel{
struct NUT_EXPORT FieldModel{
explicit FieldModel() : name(QString()), defaultValue(QString())
{

View File

@ -43,7 +43,7 @@ class BulkInserter;
class Database;
template<class T>
class NUT_EXPORT TableSet : public TableSetBase
class TableSet : public TableSetBase
{
public:
typedef T value_type;

View File

@ -33,7 +33,7 @@ NUT_BEGIN_NAMESPACE
class Table;
class Database;
class TableSetBaseData;
class TableSetBase : public QObject
class NUT_EXPORT TableSetBase : public QObject
{
public:

View File

@ -1,11 +1,12 @@
win32 {
CONFIG(debug,debug|release): LIBDIR = $$absolute_path($$OUT_PWD/../../src/debug)
CONFIG(release,debug|release): LIBDIR = $$absolute_path($$OUT_PWD/../../src/release)
CONFIG(debug,debug|release): LIBDIR = $$absolute_path($$OUT_PWD/../../src/debug)
CONFIG(release,debug|release): LIBDIR = $$absolute_path($$OUT_PWD/../../src/release)
} else {
LIBDIR = $$absolute_path($$OUT_PWD/../../src)
LIBDIR = $$absolute_path($$OUT_PWD/../../src)
}
LIBS += -L$$LIBDIR -lnut
INCLUDEPATH += $$PWD/../../src $$PWD/../common
DEFINES += NUT_SHARED_POINTER
DEFINES += NUT_PATH=\\\"$$PWD/../../\\\"

View File

@ -24,4 +24,3 @@ HEADERS += \
../common/score.h \
tst_basic.h
include($$PWD/../../ci-test-init.pri)

View File

@ -24,4 +24,3 @@ HEADERS += \
../common/score.h \
tst_benchmark.h
include($$PWD/../../ci-test-init.pri)

View File

@ -16,5 +16,3 @@ HEADERS += \
db.h \
sampletable.h \
tst_datatypes.h
include($$PWD/../../ci-test-init.pri)

View File

@ -17,4 +17,3 @@ HEADERS += \
sampletable.h \
tst_datetime.h
include($$PWD/../../ci-test-init.pri)

View File

@ -12,5 +12,3 @@ SOURCES += \
HEADERS += \
tst_generators.h
include($$PWD/../../ci-test-init.pri)

View File

@ -15,5 +15,3 @@ HEADERS += \
tst_json.h \
db.h \
sampletable.h
include($$PWD/../../ci-test-init.pri)

View File

@ -13,4 +13,3 @@ SOURCES += \
HEADERS += \
tst_phrases.h
include($$PWD/../../ci-test-init.pri)

View File

@ -17,4 +17,3 @@ HEADERS += \
test.h \
tst_uuid.h
include($$PWD/../../ci-test-init.pri)

View File

@ -23,4 +23,3 @@ HEADERS += \
db3.h \
table3.h
include($$PWD/../../ci-test-init.pri)