build fix

This commit is contained in:
Andrei Yankovich 2022-01-16 14:13:00 +03:00
parent 4dcdd56b5b
commit ff6c7ae397
22 changed files with 104 additions and 277 deletions

View File

@ -25,9 +25,9 @@ if (ANDROID OR IOS)
endif()
if (NOT QT_VERSION_MAJOR)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Test QUIET)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
endif()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Test QUIET)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
include(submodules/CMake/QuasarApp.cmake)
@ -35,37 +35,30 @@ updateGitVars()
set(DoctorPill_VERSION "0.${GIT_COMMIT_COUNT}.${GIT_COMMIT_HASH}")
option(DOCTOR_PILL_GUI "Enable gui qml model for build" OFF)
option(DOCTOR_PILL_TESTS "Enable tests of this library" ON)
option(DOCTOR_PILL_EXAMPLE "Enable example app of this library" ON)
if (NOT DEFINED DOCTOR_PILL_TESTS)
set(DOCTOR_PILL_TESTS ON)
if (DEFINED TARGET_PLATFORM_TOOLCHAIN)
if (${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32")
set(DOCTOR_PILL_TESTS OFF)
set(DOCTOR_EXAMPLE_TESTS OFF)
endif()
endif()
if (ANDROID OR IOS)
if (DEFINED TARGET_PLATFORM_TOOLCHAIN)
if (${TARGET_PLATFORM_TOOLCHAIN} STREQUAL "wasm32")
set(DOCTOR_PILL_TESTS OFF)
set(DOCTOR_EXAMPLE_TESTS OFF)
set(DOCTOR_PILL_EXAMPLE OFF)
message("Disable DOCTOR_PILL_TESTS and DOCTOR_PILL_EXAMPLE for wasm paltform because wasm not support tests and an example.")
endif()
endif()
if (ANDROID OR IOS)
set(DOCTOR_PILL_TESTS OFF)
set(DOCTOR_PILL_EXAMPLE OFF)
message("Disable DOCTOR_PILL_TESTS and DOCTOR_PILL_EXAMPLE for mobile paltforms because ios and android not support tests and an example.")
endif()
if (NOT DEFINED DOCTOR_EXAMPLE_TESTS)
set(DOCTOR_EXAMPLE_TESTS ON)
if (NOT QT_VERSION_MAJOR)
set(DOCTOR_EXAMPLE_TESTS OFF)
endif()
endif()
initAll()
add_subdirectory(src/Library)
if (DEFINED DOCTOR_EXAMPLE_TESTS)
if (DEFINED DOCTOR_PILL_EXAMPLE)
add_subdirectory(src/Example)
endif()

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>Main.qml</file>
</qresource>
</RCC>

10
src/Example/Main.qml Normal file
View File

@ -0,0 +1,10 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
ApplicationWindow {
width: 800
height: 600
visible: true
}

View File

@ -5,6 +5,24 @@
//# of this license document, but changing it is not allowed.
//#
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <doctorpill.h>
int main(int argc, char *argv[]) {
return 0;
QCoreApplication::setOrganizationName("QuasarApp");
QCoreApplication::setApplicationName("DoctorPillExample");
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
if (!DP::init(&engine)) {
return -1;
}
engine.load("qrc:/Main.qml");
if (engine.rootObjects().isEmpty())
return -2;
return app.exec();
}

View File

@ -9,7 +9,6 @@ cmake_minimum_required(VERSION 3.14)
add_definitions(-DDOCTOR_PILL_LIBRARY)
file(GLOB SOURCE_CPP
"*.cpp"
"*DoctorPillCore/*.cpp"
@ -35,6 +34,10 @@ set(PRIVATE_INCUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/private")
add_library(${PROJECT_NAME} ${SOURCE_CPP} ${SOURCE_QRC} ${SOURCE_CPP_GUI})
target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core )
if (DOCTOR_PILL_GUI)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Quick REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::Quick )
endif()
target_include_directories(${PROJECT_NAME} PUBLIC ${PUBLIC_INCUDE_DIR})
target_include_directories(${PROJECT_NAME} PRIVATE ${PRIVATE_INCUDE_DIR})

View File

@ -5,22 +5,22 @@
//# of this license document, but changing it is not allowed.
//#
#include "pillsmodel.h"
#include "doctormodel.h"
#include <QHash>
namespace DP {
PillsModel::PillsModel(const QList<QSharedPointer<iPill>> &base):
DoctorModel::DoctorModel(const QList<QSharedPointer<iPill>> &base):
_doctor(base)
{
}
int PillsModel::rowCount(const QModelIndex &) const {
int DoctorModel::rowCount(const QModelIndex &) const {
return _viewData.count();
}
QVariant PillsModel::data(const QModelIndex &index, int role) const {
QVariant DoctorModel::data(const QModelIndex &index, int role) const {
if (index.row() < 0 || index.row() >= rowCount()) {
return "";
@ -47,7 +47,7 @@ QVariant PillsModel::data(const QModelIndex &index, int role) const {
return "Unknown";
}
QHash<int, QByteArray> PillsModel::roleNames() const {
QHash<int, QByteArray> DoctorModel::roleNames() const {
QHash<int, QByteArray> roles;
roles[Roles::Name] = "issueName";
@ -57,7 +57,7 @@ QHash<int, QByteArray> PillsModel::roleNames() const {
return roles;
}
void PillsModel::usePill(QString pillName) {
void DoctorModel::usePill(QString pillName) {
auto pill = _viewData.value(pillName, {});
if (!pill._pill)
@ -66,25 +66,25 @@ void PillsModel::usePill(QString pillName) {
_doctor.fix({pill._pill});
}
void PillsModel::diagnostic() {
void DoctorModel::diagnostic() {
_doctor.diagnostic();
}
void PillsModel::handleFixFailed(QList<QSharedPointer<iPill>> failed) {
void DoctorModel::handleFixFailed(QList<QSharedPointer<iPill>> failed) {
for (const auto &pill : qAsConst(failed)) {
_viewData[pill->name()]._status = static_cast<int>(IssueStatus::Failed);
}
}
void PillsModel::handleFixSuccessful(QList<QSharedPointer<iPill>> successful) {
void DoctorModel::handleFixSuccessful(QList<QSharedPointer<iPill>> successful) {
for (const auto &pill : qAsConst(successful)) {
_viewData[pill->name()]._status = static_cast<int>(IssueStatus::Solved);
}
}
void PillsModel::handleBugDetected(QList<QSharedPointer<iPill>> bugDetected) {
void DoctorModel::handleBugDetected(QList<QSharedPointer<iPill>> bugDetected) {
beginResetModel();

View File

@ -21,7 +21,7 @@ struct Issue {
/**
* @brief The PillsModel class This is gui model of available pills.
*/
class PillsModel: public QAbstractListModel
class DoctorModel: public QAbstractListModel
{
Q_OBJECT
@ -38,7 +38,7 @@ class PillsModel: public QAbstractListModel
};
public:
PillsModel(const QList<QSharedPointer<iPill>> &base);
DoctorModel(const QList<QSharedPointer<iPill>> &base);
void addPill(const QSharedPointer<iPill>& pill);
int rowCount(const QModelIndex &parent = {}) const override;

View File

@ -3,14 +3,13 @@ import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Layouts 1.15
import "Style"
CPage {
Page {
id: root;
property var model : null
implicitHeight: 0x0
title: qsTr("Doctor page. The Doctor can help you to fix your app.");
signal contactWithDevsPressed();
ColumnLayout {
Label {
@ -31,6 +30,9 @@ CPage {
Button {
id: contactButton
text: qsTr("Contact with Developers");
onClicked: {
contactWithDevsPressed();
}
}
ProgressBar {

View File

@ -6,12 +6,23 @@
//#
#include "doctorpill.h"
#include <QQmlApplicationEngine>
namespace DP {
namespace DoctorPill {
bool init(QQmlApplicationEngine *engine) {
if (!engine)
return false;
auto root = engine->rootContext();
if (!root)
return false;
bool init() {
initDoctorPillResources();
engine->addImportPath(":/");
return true;
}

View File

@ -10,10 +10,23 @@
#include "DoctorPillCore/ipill.h"
#include "DoctorPillCore/doctortest.h"
inline void initDoctorPillResources() { Q_INIT_RESOURCE(DoctorPill); }
inline void initDoctorPillResources() {
Q_INIT_RESOURCE(DoctorPill);
}
namespace DoctorPill {
class QQmlApplicationEngine;
bool DOCTOR_PILL_EXPORT init();
/**
* @brief DP This is base name space of the DoctorPill(DP) library. Please if you use the gui application and gui models then invoke the DP::init method before use this library.
*/
namespace DP {
};
/**
* @brief init This function initialize the qml gui classes of the DoctorPill library.
* @note if you do not use GUI then this function do nothing.
* @param engine This is qml engine pointer if this pointer is invalid then finction return false.
* @return return true if the library initialized successful else false.
*/
bool DOCTOR_PILL_EXPORT init(QQmlApplicationEngine *engine);
}

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

View File

@ -1,31 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>DP::PillsModel</name>
<message>
<source>Failed to fix bugs!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of incoplite bugs: %0</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bug fixed successfull!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>List of fixed bugs: %0</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DoctorView</name>
<message>
<source>Doctor page. The Doctor can help you to fix your app.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Attention: Please use this page only if you knows what you do. If your application works correctly then please - do nothing.</source>
<translation type="unfinished"></translation>

@ -1 +1 @@
Subproject commit 279845091b1998a023d91c8c333bb7f6f069ac84
Subproject commit 8f3c0c4fac3fa8474321fa3737eee59798b7436e

View File

@ -9,6 +9,8 @@ cmake_minimum_required(VERSION 3.14)
set(CURRENT_PROJECT ${PROJECT_NAME}Test)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Test REQUIRED)
file(GLOB SOURCE_CPP
"*.cpp" "*.qrc"
"units/*.cpp" "units/*.qrc"