diff --git a/src/nut/abstractquery.cpp b/src/nut/abstractquery.cpp deleted file mode 100644 index 2ea87ed..0000000 --- a/src/nut/abstractquery.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************************** -** -** 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 . -** -**************************************************************************/ - -#include "abstractquery.h" -#include "abstractquery_p.h" - -NUT_BEGIN_NAMESPACE - -AbstractQuery::AbstractQuery(QObject *parent) : QObject(parent) - , d_ptr(new AbstractQueryPrivate(this)) -{ - -} - -Nut::AbstractQueryPrivate::AbstractQueryPrivate(Nut::AbstractQuery *parent) : - q_ptr(parent), skip(0), take(0) -{ - -} - -Nut::AbstractQueryPrivate::~AbstractQueryPrivate() -{ - -} - -NUT_END_NAMESPACE diff --git a/src/nut/abstractquery.h b/src/nut/abstractquery.h deleted file mode 100644 index 8618e72..0000000 --- a/src/nut/abstractquery.h +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************************************** -** -** 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_ABSTRACTQUERY_H -#define NUT_ABSTRACTQUERY_H - -#include -#include -#include - -#include "defines.h" -#include "abstractquery_p.h" - -NUT_BEGIN_NAMESPACE - -class AbstractQueryPrivate; -class NUT_EXPORT AbstractQuery : public QObject -{ - Q_OBJECT - -protected: - AbstractQueryPrivate *d_ptr; - Q_DECLARE_PRIVATE(AbstractQuery) - -public: - explicit AbstractQuery(QObject *parent = nullptr); - -protected: - // void addTableToSet(TableSetBase *set, Table *table); - -public slots: -}; - -NUT_END_NAMESPACE - -#endif // NUT_ABSTRACTQUERY_H diff --git a/src/nut/abstractquery_p.h b/src/nut/abstractquery_p.h deleted file mode 100644 index e432869..0000000 --- a/src/nut/abstractquery_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************** -** -** 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_QUERY_P_H -#define NUT_QUERY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -#include "phrase.h" - -#include -#include -#include - -NUT_BEGIN_NAMESPACE - -class Database; -class AbstractTableSet; -class AbstractQuery; -struct RelationModel; -class NUT_EXPORT AbstractQueryPrivate { - AbstractQuery *q_ptr; - Q_DECLARE_PUBLIC(AbstractQuery) - -public: - explicit AbstractQueryPrivate(AbstractQuery *parent); - ~AbstractQueryPrivate(); - - QString sql; - QString className; - QString tableName; - QString select; - Database *database; - AbstractTableSet *tableSet; - QStringList joins; - QList relations; - int skip; - int take; - PhraseList orderPhrase, fieldPhrase; - ConditionalPhrase wherePhrase; -}; - -NUT_END_NAMESPACE - -#endif // NUT_QUERY_P_H diff --git a/src/nut/nut.pro b/src/nut/nut.pro index b6a4057..3181c1c 100644 --- a/src/nut/nut.pro +++ b/src/nut/nut.pro @@ -47,9 +47,7 @@ HEADERS += \ $$PWD/phrases/phrasedatalist.h \ $$PWD/phrases/phraselist.h \ $$PWD/phrases/datephrase.h \ - $$PWD/table_p.h \ - $$PWD/abstractquery.h \ - $$PWD/abstractquery_p.h + $$PWD/table_p.h SOURCES += \ $$PWD/generators/abstractsqlgenerator.cpp \ @@ -78,8 +76,7 @@ SOURCES += \ $$PWD/phrases/phrasedata.cpp \ $$PWD/phrases/phrasedatalist.cpp \ $$PWD/phrases/phraselist.cpp \ - $$PWD/phrases/datephrase.cpp \ - $$PWD/abstractquery.cpp + $$PWD/phrases/datephrase.cpp load(qt_module) diff --git a/src/nut/query.h b/src/nut/query.h index 661b253..928aa81 100644 --- a/src/nut/query.h +++ b/src/nut/query.h @@ -36,8 +36,6 @@ #endif #include -#include - #include #include #include @@ -79,16 +77,19 @@ struct NUT_EXPORT QueryData { r->wherePhrase = wherePhrase; return r; } + + QueryData() = default; + QueryData(Database *db) : database(db) + { } }; template -class Query : public AbstractQuery +class Query { QueryData *d; - bool m_autoDelete; public: - explicit Query(Database *database, AbstractTableSet *tableSet, bool autoDelete); + explicit Query(Database *database, AbstractTableSet *tableSet); Query (const Query &other); Query (Query &&other); @@ -168,8 +169,6 @@ Q_OUTOFLINE_TEMPLATE QList Query::select(const std::function Query::select(const std::function -Q_OUTOFLINE_TEMPLATE Query::Query(Database *database, AbstractTableSet *tableSet, - bool autoDelete) - : AbstractQuery(database), d(new QueryData), m_autoDelete(autoDelete) +Q_OUTOFLINE_TEMPLATE Query::Query(Database *database, AbstractTableSet *tableSet) + : d(new QueryData(database)) { //Q_D(AbstractQuery); @@ -196,12 +194,12 @@ Q_OUTOFLINE_TEMPLATE Query::Query(Database *database, AbstractTableSet *table } template -Q_OUTOFLINE_TEMPLATE Query::Query(const Query &other) : AbstractQuery() { +Q_OUTOFLINE_TEMPLATE Query::Query(const Query &other) { d = other.d->clone(); } template -Q_OUTOFLINE_TEMPLATE Query::Query(Query &&other) : AbstractQuery() { +Q_OUTOFLINE_TEMPLATE Query::Query(Query &&other) { d = std::move(other.d); other.d = nullptr; } @@ -393,10 +391,6 @@ Q_OUTOFLINE_TEMPLATE RowList Query::toList(int count) } //while } // while -#ifndef NUT_SHARED_POINTER - if (m_autoDelete) - deleteLater(); -#endif return returnList; } @@ -423,8 +417,6 @@ Q_OUTOFLINE_TEMPLATE QList Query::select(const FieldPhrase f) ret.append(v.value()); } - if (m_autoDelete) - deleteLater(); return ret; } @@ -644,8 +636,6 @@ Q_OUTOFLINE_TEMPLATE int Query::update(const AssignmentPhraseList &ph) QSqlQuery q = d->database->exec(d->sql); - if (m_autoDelete) - deleteLater(); return q.numRowsAffected(); } @@ -658,8 +648,6 @@ Q_OUTOFLINE_TEMPLATE int Query::remove() d->tableName, d->wherePhrase); QSqlQuery q = d->database->exec(d->sql); - if (m_autoDelete) - deleteLater(); return q.numRowsAffected(); } diff --git a/src/nut/tableset.h b/src/nut/tableset.h index 8cd813a..cb143a7 100644 --- a/src/nut/tableset.h +++ b/src/nut/tableset.h @@ -63,7 +63,7 @@ public: Row at(int i) const; Row operator[](int i) const; - Query query(bool autoDelete = true); + Query query(); BulkInserter *bulkInserter(); }; @@ -80,9 +80,9 @@ Q_OUTOFLINE_TEMPLATE TableSet::TableSet(Table *parent) : AbstractTableSet(par } template -Q_OUTOFLINE_TEMPLATE Query TableSet::query(bool autoDelete) +Q_OUTOFLINE_TEMPLATE Query TableSet::query() { - return Query(data->database, this, autoDelete); + return Query(data->database, this); } template