Skip to content

Commit

Permalink
test provate classes
Browse files Browse the repository at this point in the history
  • Loading branch information
HamedMasafi committed Aug 8, 2020
1 parent f7160bd commit ef6a30a
Show file tree
Hide file tree
Showing 40 changed files with 218 additions and 193 deletions.
43 changes: 43 additions & 0 deletions src/nut/abstractquery.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**************************************************************************
**
** 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 <http://www.gnu.org/licenses/>.
**
**************************************************************************/

#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)
{

}

Nut::AbstractQueryPrivate::~AbstractQueryPrivate()
{

}

NUT_END_NAMESPACE
21 changes: 10 additions & 11 deletions src/nut/querybase_p.h → src/nut/abstractquery.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,36 @@
**
**************************************************************************/

#ifndef QUERYBASE_H
#define QUERYBASE_H
#ifndef NUT_ABSTRACTQUERY_H
#define NUT_ABSTRACTQUERY_H

#include <QtCore/QObject>
#include <QtCore/qglobal.h>
#include <QtCore/QExplicitlySharedDataPointer>

#include "defines.h"
#include "query_p.h"
#include "abstractquery_p.h"

NUT_BEGIN_NAMESPACE

//TODO: remove this class
class Table;
class AbstractTableSet;
class NUT_EXPORT QueryBase : public QObject
class AbstractQueryPrivate;
class NUT_EXPORT AbstractQuery : public QObject
{
Q_OBJECT

protected:
QExplicitlySharedDataPointer<QueryPrivate> d;
AbstractQueryPrivate *d_ptr;
Q_DECLARE_PRIVATE(AbstractQuery)

public:
explicit QueryBase(QObject *parent = nullptr);
explicit AbstractQuery(QObject *parent = nullptr);

protected:
// void addTableToSet(AbstractTableSet *set, Table *table);
// void addTableToSet(TableSetBase *set, Table *table);

public slots:
};

NUT_END_NAMESPACE

#endif // QUERYBASE_H
#endif // NUT_ABSTRACTQUERY_H
29 changes: 20 additions & 9 deletions src/nut/query_p.h → src/nut/abstractquery_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@
**
**************************************************************************/

#ifndef QUERY_P_H
#define QUERY_P_H
#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"

Expand All @@ -31,15 +42,15 @@ NUT_BEGIN_NAMESPACE

class Database;
class AbstractTableSet;
class QueryBase;
class AbstractQuery;
struct RelationModel;
class NUT_EXPORT QueryPrivate : public QSharedData {
QueryBase *q_ptr;
Q_DECLARE_PUBLIC(QueryBase)
class NUT_EXPORT AbstractQueryPrivate {
AbstractQuery *q_ptr;
Q_DECLARE_PUBLIC(AbstractQuery)

public:
explicit QueryPrivate(QueryBase *parent);
~QueryPrivate();
explicit AbstractQueryPrivate(AbstractQuery *parent);
~AbstractQueryPrivate();

QString sql;
QString className;
Expand All @@ -57,4 +68,4 @@ class NUT_EXPORT QueryPrivate : public QSharedData {

NUT_END_NAMESPACE

#endif // QUERY_P_H
#endif // NUT_QUERY_P_H
2 changes: 1 addition & 1 deletion src/nut/abstracttableset.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <QtCore/QSet>
#include <QtCore/QExplicitlySharedDataPointer>

#include "defines.h"
#include <QtNut/defines.h>

NUT_BEGIN_NAMESPACE

Expand Down
3 changes: 2 additions & 1 deletion src/nut/abstracttablesetdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#define NUT_ABSTRACTTABLESETDATA_H

#include <QtCore/QSharedData>
#include "defines.h"

#include <QtNut/defines.h>

NUT_BEGIN_NAMESPACE

Expand Down
7 changes: 4 additions & 3 deletions src/nut/bulkinserter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include <initializer_list>
#include <QtCore/QDebug>
#include "defines.h"
#include "phraselist.h"
#include "fieldphrase.h"
#include <QtNut/phraselist.h>
#include <QtNut/fieldphrase.h>

#include <QtNut/defines.h>

NUT_BEGIN_NAMESPACE

Expand Down
2 changes: 1 addition & 1 deletion src/nut/changelogtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define CHANGELOGTABLE_H

#include <QtCore/qglobal.h>
#include "table.h"
#include <QtNut/table.h>

NUT_BEGIN_NAMESPACE

Expand Down
4 changes: 2 additions & 2 deletions src/nut/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <QtCore/QSharedDataPointer>
#include <QtSql/QSqlDatabase>

#include "defines.h"
#include "tableset.h"
#include <QtNut/defines.h>
#include <QtNut/tableset.h>

NUT_BEGIN_NAMESPACE

Expand Down
6 changes: 3 additions & 3 deletions src/nut/database_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#ifndef DATABASE_P_H
#define DATABASE_P_H

#include "database.h"
#include "databasemodel.h"

#include <QtCore/QDebug>
#include <QtCore/QSharedData>

#include <QtNut/database.h>
#include <QtNut/databasemodel.h>

NUT_BEGIN_NAMESPACE

class ChangeLogTable;
Expand Down
2 changes: 1 addition & 1 deletion src/nut/databasemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <QtCore/QMap>
#include <QtCore/QString>

#include "defines.h"
#include <QtNut/defines.h>

class QJsonObject;

Expand Down
2 changes: 1 addition & 1 deletion src/nut/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#define NUT_NAMESPACE Nut

#include "defines_consts.h"
#include <QtNut/defines_consts.h>
#include <QtCore/QtGlobal>

#include <QtCore/QString>
Expand Down
3 changes: 2 additions & 1 deletion src/nut/generators/abstractsqlgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include <QtCore/qglobal.h>
#include <QtCore/QObject>
#include <QtCore/QStringList>
#include "phrase.h"

#include <QtNut/phrase.h>

class SqlSerializer;

Expand Down
3 changes: 2 additions & 1 deletion src/nut/generators/mysqlgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#define MYSQLGENERATOR_H

#include <QtCore/qglobal.h>
#include "abstractsqlgenerator.h"

#include <QtNut/abstractsqlgenerator.h>

NUT_BEGIN_NAMESPACE

Expand Down
3 changes: 2 additions & 1 deletion src/nut/generators/postgresqlgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#define POSTGRESQLGENERATOR_H

#include <QtCore/qglobal.h>
#include "abstractsqlgenerator.h"

#include <QtNut/abstractsqlgenerator.h>

NUT_BEGIN_NAMESPACE

Expand Down
3 changes: 2 additions & 1 deletion src/nut/generators/sqlitegenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#define SQLITEGENERATOR_H

#include <QtCore/qglobal.h>
#include "abstractsqlgenerator.h"

#include <QtNut/abstractsqlgenerator.h>

NUT_BEGIN_NAMESPACE

Expand Down
3 changes: 2 additions & 1 deletion src/nut/generators/sqlservergenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#define SQLSERVERGENERATOR_H

#include <QtCore/qglobal.h>
#include "abstractsqlgenerator.h"

#include <QtNut/abstractsqlgenerator.h>

NUT_BEGIN_NAMESPACE

Expand Down
10 changes: 5 additions & 5 deletions src/nut/nut.pro
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ HEADERS += \
$$PWD/changelogtable.h \
$$PWD/abstracttableset.h \
$$PWD/abstracttablesetdata.h \
$$PWD/querybase_p.h \
$$PWD/tablemodel.h \
$$PWD/query_p.h \
$$PWD/table.h \
$$PWD/database.h \
$$PWD/database_p.h \
Expand All @@ -49,7 +47,9 @@ HEADERS += \
$$PWD/phrases/phrasedatalist.h \
$$PWD/phrases/phraselist.h \
$$PWD/phrases/datephrase.h \
$$PWD/table_p.h
$$PWD/table_p.h \
$$PWD/abstractquery.h \
$$PWD/abstractquery_p.h

SOURCES += \
$$PWD/generators/abstractsqlgenerator.cpp \
Expand All @@ -64,7 +64,6 @@ SOURCES += \
$$PWD/databasemodel.cpp \
$$PWD/abstracttableset.cpp \
$$PWD/changelogtable.cpp \
$$PWD/querybase.cpp \
$$PWD/tablemodel.cpp \
$$PWD/table.cpp \
$$PWD/database.cpp \
Expand All @@ -79,7 +78,8 @@ SOURCES += \
$$PWD/phrases/phrasedata.cpp \
$$PWD/phrases/phrasedatalist.cpp \
$$PWD/phrases/phraselist.cpp \
$$PWD/phrases/datephrase.cpp
$$PWD/phrases/datephrase.cpp \
$$PWD/abstractquery.cpp

load(qt_module)

Expand Down
20 changes: 10 additions & 10 deletions src/nut/phrase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
#ifndef PHRASE_H
#define PHRASE_H

#include "conditionalphrase.h"
#include "abstractfieldphrase.h"
#include "fieldphrase.h"
#include "phraselist.h"
#include "assignmentphraselist.h"
#include "phrasedatalist.h"
#include "phrasedata.h"
#include "assignmentphrase.h"
#include "numericphrase.h"
#include "datephrase.h"
#include <QtNut/conditionalphrase.h>
#include <QtNut/abstractfieldphrase.h>
#include <QtNut/fieldphrase.h>
#include <QtNut/phraselist.h>
#include <QtNut/assignmentphraselist.h>
#include <QtNut/phrasedatalist.h>
#include <QtNut/phrasedata.h>
#include <QtNut/assignmentphrase.h>
#include <QtNut/numericphrase.h>
#include <QtNut/datephrase.h>

NUT_BEGIN_NAMESPACE

Expand Down
9 changes: 4 additions & 5 deletions src/nut/phrases/abstractfieldphrase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
#ifndef ABSTRACTFIELDPHRASE_H
#define ABSTRACTFIELDPHRASE_H

#include "defines.h"

#include "assignmentphrase.h"
#include "conditionalphrase.h"
#include "phraselist.h"
#include <QtNut/defines.h>
#include <QtNut/assignmentphrase.h>
#include <QtNut/conditionalphrase.h>
#include <QtNut/phraselist.h>

NUT_BEGIN_NAMESPACE

Expand Down
5 changes: 2 additions & 3 deletions src/nut/phrases/assignmentphrase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
#ifndef ASSIGNMENTPHRASE_H
#define ASSIGNMENTPHRASE_H

#include "defines.h"

#include "assignmentphraselist.h"
#include <QtNut/defines.h>
#include <QtNut/assignmentphraselist.h>

NUT_BEGIN_NAMESPACE

Expand Down
2 changes: 1 addition & 1 deletion src/nut/phrases/assignmentphraselist.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef ASSIGNMENTPHRASELIST_H
#define ASSIGNMENTPHRASELIST_H

#include "defines.h"
#include <QtNut/defines.h>

NUT_BEGIN_NAMESPACE

Expand Down
2 changes: 1 addition & 1 deletion src/nut/phrases/conditionalphrase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef CONDITIONALPHRASE_H
#define CONDITIONALPHRASE_H

#include "phrasedata.h"
#include <QtNut/phrasedata.h>

NUT_BEGIN_NAMESPACE

Expand Down
Loading

0 comments on commit ef6a30a

Please sign in to comment.