first commit
This commit is contained in:
70
test/qxClientServer/qxClient/CMakeLists.txt
Normal file
70
test/qxClientServer/qxClient/CMakeLists.txt
Normal file
@@ -0,0 +1,70 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(qxClient LANGUAGES CXX)
|
||||
|
||||
include(../../../QxOrm.cmake)
|
||||
|
||||
if(_QX_ENABLE_QT_NETWORK)
|
||||
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Sql Gui Widgets REQUIRED)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
set(HEADERS
|
||||
./include/precompiled.h
|
||||
./include/export.h
|
||||
./include/main_dlg.h
|
||||
)
|
||||
|
||||
set(SRCS
|
||||
./src/main_dlg.cpp
|
||||
./src/main.cpp
|
||||
)
|
||||
|
||||
set(UIS
|
||||
./qt/ui/qxClient.ui
|
||||
)
|
||||
|
||||
if(COMMAND qt_wrap_ui)
|
||||
qt_wrap_ui(UIS_HDRS ${UIS})
|
||||
else() # (COMMAND qt_wrap_ui)
|
||||
qt5_wrap_ui(UIS_HDRS ${UIS})
|
||||
endif() # (COMMAND qt_wrap_ui)
|
||||
|
||||
add_executable(qxClient ${SRCS} ${HEADERS} ${UIS_HDRS})
|
||||
|
||||
target_compile_definitions(qxClient PRIVATE -D_BUILDING_QX_CLIENT)
|
||||
|
||||
if(COMMAND target_precompile_headers)
|
||||
target_precompile_headers(qxClient PRIVATE ./include/precompiled.h)
|
||||
endif() # (COMMAND target_precompile_headers)
|
||||
|
||||
target_link_libraries(qxClient ${QX_LIBRARIES} Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets QxOrm qxServiceClient)
|
||||
|
||||
set_target_properties(qxClient PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/../../_bin"
|
||||
)
|
||||
|
||||
set_target_properties(qxClient PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
||||
|
||||
else() # _QX_ENABLE_QT_NETWORK
|
||||
|
||||
message(STATUS "qxClient project not loaded because _QX_ENABLE_QT_NETWORK option not enabled (QxOrm QxService module is disabled)")
|
||||
|
||||
endif() # _QX_ENABLE_QT_NETWORK
|
||||
7
test/qxClientServer/qxClient/debug/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/debug/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
20
test/qxClientServer/qxClient/include/export.h
Normal file
20
test/qxClientServer/qxClient/include/export.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _QX_CLIENT_EXPORT_H_
|
||||
#define _QX_CLIENT_EXPORT_H_
|
||||
|
||||
#include "../../qxService/include/export.h"
|
||||
|
||||
#ifdef _BUILDING_QX_CLIENT
|
||||
#define QX_CLIENT_DLL_EXPORT QX_DLL_EXPORT_HELPER
|
||||
#else // _BUILDING_QX_CLIENT
|
||||
#define QX_CLIENT_DLL_EXPORT QX_DLL_IMPORT_HELPER
|
||||
#endif // _BUILDING_QX_CLIENT
|
||||
|
||||
#ifdef _BUILDING_QX_CLIENT
|
||||
#define QX_REGISTER_HPP_QX_CLIENT QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_CLIENT QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // _BUILDING_QX_CLIENT
|
||||
#define QX_REGISTER_HPP_QX_CLIENT QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_QX_CLIENT QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif // _BUILDING_QX_CLIENT
|
||||
|
||||
#endif // _QX_CLIENT_EXPORT_H_
|
||||
56
test/qxClientServer/qxClient/include/main_dlg.h
Normal file
56
test/qxClientServer/qxClient/include/main_dlg.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef _QX_CLIENT_MAIN_DLG_H_
|
||||
#define _QX_CLIENT_MAIN_DLG_H_
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef _QX_NO_PRECOMPILED_HEADER
|
||||
#ifndef Q_MOC_RUN
|
||||
#include "../include/precompiled.h" // Need to include precompiled header for the generated moc file
|
||||
#endif // Q_MOC_RUN
|
||||
#endif // _QX_NO_PRECOMPILED_HEADER
|
||||
|
||||
#include "../qt/ui/include/ui_qxClient.h"
|
||||
|
||||
#include "../../qxService/include/business_object/user.h"
|
||||
#include "../../qxService/include/business_object/user_search.h"
|
||||
|
||||
class main_dlg : public QWidget, private Ui::dlgClient
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
qx::service::QxClientAsync_ptr m_pDateTimeAsync; // To retrieve current server date-time without blocking GUI (async transaction)
|
||||
|
||||
public:
|
||||
|
||||
main_dlg(QWidget * parent = NULL) : QWidget(parent), Ui::dlgClient() { main_dlg::init(); }
|
||||
virtual ~main_dlg() { ; }
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
void updateLastTransactionLog(qx::service::QxTransaction_ptr transaction);
|
||||
void fillUser(user_ptr user);
|
||||
user_ptr fileUser();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void onClickBtnDateTime();
|
||||
void onClickBtnDateTimeAsync();
|
||||
void onClickBtnAddUser();
|
||||
void onClickBtnUpdateUser();
|
||||
void onClickBtnRemoveUser();
|
||||
void onClickBtnRemoveAllUsers();
|
||||
void onClickBtnFetchUser();
|
||||
void onClickBtnGetAllUsers();
|
||||
void onClickBtnSearchUsers();
|
||||
void onDateTimeAsyncFinished();
|
||||
void onUpdateServerConnection();
|
||||
|
||||
};
|
||||
|
||||
#endif // _QX_CLIENT_MAIN_DLG_H_
|
||||
9
test/qxClientServer/qxClient/include/precompiled.h
Normal file
9
test/qxClientServer/qxClient/include/precompiled.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _QX_CLIENT_PRECOMPILED_HEADER_H_
|
||||
#define _QX_CLIENT_PRECOMPILED_HEADER_H_
|
||||
|
||||
#include <QxOrm.h>
|
||||
#include <QxServices.h>
|
||||
|
||||
#include "export.h"
|
||||
|
||||
#endif // _QX_CLIENT_PRECOMPILED_HEADER_H_
|
||||
7
test/qxClientServer/qxClient/qt/moc/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/qt/moc/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
7
test/qxClientServer/qxClient/qt/rcc/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/qt/rcc/src/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
448
test/qxClientServer/qxClient/qt/ui/qxClient.ui
Normal file
448
test/qxClientServer/qxClient/qt/ui/qxClient.ui
Normal file
@@ -0,0 +1,448 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>dlgClient</class>
|
||||
<widget class="QWidget" name="dlgClient">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>541</width>
|
||||
<height>371</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>541</width>
|
||||
<height>371</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>541</width>
|
||||
<height>371</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>qxClient</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="grpServerInfos">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>10</y>
|
||||
<width>301</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Server infos transaction</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnDateTime">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>121</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get Server DateTime</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get Server DateTime</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnDateTime_Async">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>20</y>
|
||||
<width>151</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get Server DateTime Async</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get Server DateTime Async</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="grpTransaction">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>170</y>
|
||||
<width>521</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Log last client-server reply-request transaction</string>
|
||||
</property>
|
||||
<widget class="QPlainTextEdit" name="txtTransaction">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>501</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::NoWrap</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="grpUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>521</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>User transaction</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnGetAllUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Get All Users</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Get All</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnAddUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>51</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnUpdateUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Update User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnRemoveUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnRemoveAllUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove All Users</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove All</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnFetchUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>20</y>
|
||||
<width>71</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Fetch User</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fetch</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="lineUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>501</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblId">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>60</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>ID</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ID :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblFirstName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>60</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>First Name</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First Name :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblLastName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>60</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Last Name</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Last Name :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblBirthDate">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>380</x>
|
||||
<y>60</y>
|
||||
<width>51</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Birthdate</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Birthdate :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtId">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>60</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtFirstName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>First Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtLastName">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Last Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtBirthDate">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>440</x>
|
||||
<y>60</y>
|
||||
<width>71</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Birthdate</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnSearchUser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>450</x>
|
||||
<y>20</y>
|
||||
<width>61</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Search Users</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="grpServerConnection">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>211</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Server connection</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="lblIp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>20</y>
|
||||
<width>21</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ip</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ip :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblPort">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>20</y>
|
||||
<width>31</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Port :</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="spinPort">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>20</y>
|
||||
<width>51</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Port</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>32000</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtIp">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>20</y>
|
||||
<width>81</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ip</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>127.0.0.1</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
7
test/qxClientServer/qxClient/qt/ui/src/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/qt/ui/src/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
39
test/qxClientServer/qxClient/qxClient.pro
Normal file
39
test/qxClientServer/qxClient/qxClient.pro
Normal file
@@ -0,0 +1,39 @@
|
||||
include(../../../QxOrm.pri)
|
||||
|
||||
!contains(DEFINES, _QX_ENABLE_QT_NETWORK) {
|
||||
error(unable to use QxOrm QxService module : please define _QX_ENABLE_QT_NETWORK compilation option in QxOrm.pri configuration file)
|
||||
} # !contains(DEFINES, _QX_ENABLE_QT_NETWORK)
|
||||
|
||||
TEMPLATE = app
|
||||
DEFINES += _BUILDING_QX_CLIENT
|
||||
INCLUDEPATH += ../../../../QxOrm/include/
|
||||
DESTDIR = ../../../../QxOrm/test/_bin/
|
||||
|
||||
QT += gui
|
||||
greaterThan(QT_MAJOR_VERSION, 4) { QT += widgets }
|
||||
|
||||
!contains(DEFINES, _QX_NO_PRECOMPILED_HEADER) {
|
||||
PRECOMPILED_HEADER = ./include/precompiled.h
|
||||
} # !contains(DEFINES, _QX_NO_PRECOMPILED_HEADER)
|
||||
|
||||
LIBS += -L"../../../../QxOrm/lib"
|
||||
LIBS += -L"../../../../QxOrm/test/_bin"
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
TARGET = qxClientd
|
||||
LIBS += -l"QxOrmd"
|
||||
LIBS += -l"qxServiceClientd"
|
||||
} else {
|
||||
TARGET = qxClient
|
||||
LIBS += -l"QxOrm"
|
||||
LIBS += -l"qxServiceClient"
|
||||
} # CONFIG(debug, debug|release)
|
||||
|
||||
HEADERS += ./include/precompiled.h
|
||||
HEADERS += ./include/export.h
|
||||
HEADERS += ./include/main_dlg.h
|
||||
|
||||
SOURCES += ./src/main_dlg.cpp
|
||||
SOURCES += ./src/main.cpp
|
||||
|
||||
FORMS += ./qt/ui/qxClient.ui
|
||||
7
test/qxClientServer/qxClient/release/.gitignore
vendored
Normal file
7
test/qxClientServer/qxClient/release/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# git does not allow empty directories.
|
||||
# Yet, we need to add this empty directory on git.
|
||||
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
|
||||
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
|
||||
*
|
||||
# And then add an exception for this specifc file (so that we can commit it).
|
||||
!.gitignore
|
||||
22
test/qxClientServer/qxClient/src/main.cpp
Normal file
22
test/qxClientServer/qxClient/src/main.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtWidgets/qapplication.h>
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtGui/qapplication.h>
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
|
||||
#include "../include/precompiled.h"
|
||||
#include "../include/main_dlg.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
main_dlg dlg;
|
||||
dlg.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
223
test/qxClientServer/qxClient/src/main_dlg.cpp
Normal file
223
test/qxClientServer/qxClient/src/main_dlg.cpp
Normal file
@@ -0,0 +1,223 @@
|
||||
#include "../include/precompiled.h"
|
||||
|
||||
#include <QtGui/qcursor.h>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtWidgets/qmessagebox.h>
|
||||
#else // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QtGui/qmessagebox.h>
|
||||
#endif // (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
|
||||
#include "../include/main_dlg.h"
|
||||
|
||||
#include "../../qxService/include/service/server_infos.h"
|
||||
#include "../../qxService/include/service/user_service.h"
|
||||
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
#define QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT "dd/MM/yyyy"
|
||||
|
||||
void main_dlg::init()
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
QObject::connect(btnDateTime, SIGNAL(clicked()), this, SLOT(onClickBtnDateTime()));
|
||||
QObject::connect(btnDateTime_Async, SIGNAL(clicked()), this, SLOT(onClickBtnDateTimeAsync()));
|
||||
QObject::connect(btnAddUser, SIGNAL(clicked()), this, SLOT(onClickBtnAddUser()));
|
||||
QObject::connect(btnUpdateUser, SIGNAL(clicked()), this, SLOT(onClickBtnUpdateUser()));
|
||||
QObject::connect(btnRemoveUser, SIGNAL(clicked()), this, SLOT(onClickBtnRemoveUser()));
|
||||
QObject::connect(btnRemoveAllUser, SIGNAL(clicked()), this, SLOT(onClickBtnRemoveAllUsers()));
|
||||
QObject::connect(btnFetchUser, SIGNAL(clicked()), this, SLOT(onClickBtnFetchUser()));
|
||||
QObject::connect(btnGetAllUser, SIGNAL(clicked()), this, SLOT(onClickBtnGetAllUsers()));
|
||||
QObject::connect(btnSearchUser, SIGNAL(clicked()), this, SLOT(onClickBtnSearchUsers()));
|
||||
QObject::connect(txtIp, SIGNAL(editingFinished()), this, SLOT(onUpdateServerConnection()));
|
||||
QObject::connect(spinPort, SIGNAL(editingFinished()), this, SLOT(onUpdateServerConnection()));
|
||||
|
||||
txtBirthDate->setText(QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
txtBirthDate->setToolTip(QString("Birthdate : ") + QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
txtIp->setText("127.0.0.1");
|
||||
spinPort->setValue(7694);
|
||||
onUpdateServerConnection();
|
||||
}
|
||||
|
||||
void main_dlg::updateLastTransactionLog(qx::service::QxTransaction_ptr transaction)
|
||||
{
|
||||
if (! transaction) { txtTransaction->setPlainText(""); return; }
|
||||
#ifdef _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
QString text = qx::serialization::xml::to_string(* transaction);
|
||||
#else // _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
QString text = transaction->getInfos();
|
||||
#endif // _QX_ENABLE_BOOST_SERIALIZATION_XML
|
||||
txtTransaction->setPlainText(text.replace("\t", " "));
|
||||
qx_bool bMsgReturn = transaction->getMessageReturn();
|
||||
if (! bMsgReturn.getValue() && ! bMsgReturn.getDesc().isEmpty())
|
||||
{ QMessageBox::warning(this, "qxClient - transaction error", bMsgReturn.getDesc()); }
|
||||
}
|
||||
|
||||
void main_dlg::fillUser(user_ptr user)
|
||||
{
|
||||
if (! user) { return; }
|
||||
txtId->setText(QString::number(user->id));
|
||||
txtFirstName->setText(user->first_name);
|
||||
txtLastName->setText(user->last_name);
|
||||
txtBirthDate->setText(user->birth_date.toString(QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT));
|
||||
}
|
||||
|
||||
user_ptr main_dlg::fileUser()
|
||||
{
|
||||
user_ptr user_to_file = user_ptr(new user());
|
||||
user_to_file->id = txtId->text().toLong();
|
||||
user_to_file->first_name = txtFirstName->text();
|
||||
user_to_file->last_name = txtLastName->text();
|
||||
user_to_file->birth_date = QDateTime::fromString(txtBirthDate->text(), QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
return user_to_file;
|
||||
}
|
||||
|
||||
void main_dlg::onUpdateServerConnection()
|
||||
{
|
||||
qx::service::QxConnect::getSingleton()->setIp(txtIp->text());
|
||||
qx::service::QxConnect::getSingleton()->setPort(spinPort->value());
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnDateTime()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create service and call method to retrieve current server date-time
|
||||
server_infos service;
|
||||
service.get_current_date_time();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnDateTimeAsync()
|
||||
{
|
||||
if (m_pDateTimeAsync) { qDebug("[QxOrm] '%s' transaction is already running", "server_infos::get_current_date_time"); return; }
|
||||
// Create service and call method to retrieve current server date-time (async mode)
|
||||
server_infos_ptr service = server_infos_ptr(new server_infos());
|
||||
m_pDateTimeAsync.reset(new qx::service::QxClientAsync());
|
||||
QObject::connect(m_pDateTimeAsync.get(), SIGNAL(finished()), this, SLOT(onDateTimeAsyncFinished()));
|
||||
m_pDateTimeAsync->setService(service, "get_current_date_time");
|
||||
m_pDateTimeAsync->start();
|
||||
}
|
||||
|
||||
void main_dlg::onDateTimeAsyncFinished()
|
||||
{
|
||||
if (! m_pDateTimeAsync || ! m_pDateTimeAsync->getService()) { return; }
|
||||
updateLastTransactionLog(m_pDateTimeAsync->getService()->getTransaction());
|
||||
m_pDateTimeAsync.reset();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnAddUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user to add
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->user = fileUser();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.insert();
|
||||
// If transaction is ok => display user with new id added to database
|
||||
user_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->user : user_ptr());
|
||||
if (output) { fillUser(output); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnUpdateUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user to update
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->user = fileUser();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.update();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnRemoveUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user id to remove
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->id = txtId->text().toLong();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.remove();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnRemoveAllUsers()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create service to call
|
||||
user_service service;
|
||||
service.remove_all();
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnFetchUser()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create input parameters with user id to fetch
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->id = txtId->text().toLong();
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.fetch_by_id();
|
||||
// If transaction is ok => display user fetched on GUI
|
||||
user_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->user : user_ptr());
|
||||
if (output) { fillUser(output); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnGetAllUsers()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create service to call
|
||||
user_service service;
|
||||
service.fetch_all();
|
||||
// If transaction is ok => display in a message box the number of users fetched from database
|
||||
list_of_users_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->list_of_users : list_of_users_ptr());
|
||||
if (output) { QMessageBox::information(this, "qxClient - get all users", "database contains '" + QString::number(output->size()) + "' user(s)."); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void main_dlg::onClickBtnSearchUsers()
|
||||
{
|
||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// Create criteria to search users
|
||||
user_search_ptr criteria = user_search_ptr(new user_search());
|
||||
criteria->first_name = txtFirstName->text();
|
||||
criteria->last_name = txtLastName->text();
|
||||
criteria->birth_date = QDateTime::fromString(txtBirthDate->text(), QX_CLIENT_BIRTHDATE_QDATETIME_FORMAT);
|
||||
// Create input parameters with criteria to search users
|
||||
user_service_input_ptr input = user_service_input_ptr(new user_service_input());
|
||||
input->criteria = criteria;
|
||||
// Create service to call and set input parameters
|
||||
user_service service;
|
||||
service.setInputParameter(input);
|
||||
service.get_by_criteria();
|
||||
// If transaction is ok => display in a message box the number of users fetched from database
|
||||
list_of_users_ptr output = (service.isValidWithOutput() ? service.getOutputParameter()->list_of_users : list_of_users_ptr());
|
||||
if (output) { QMessageBox::information(this, "qxClient - search users", "database contains '" + QString::number(output->size()) + "' user(s) with input criteria."); }
|
||||
// Update transaction log
|
||||
updateLastTransactionLog(service.getTransaction());
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
Reference in New Issue
Block a user