157 lines
3.8 KiB
C++
Raw Normal View History

2022-01-13 21:51:56 +03:00
//#
2022-12-24 22:00:37 +03:00
//# Copyright (C) 2021-2023 QuasarApp.
2022-01-14 19:55:51 +03:00
//# Distributed under the GPLv3 software license, see the accompanying
2022-01-13 21:51:56 +03:00
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
2022-01-16 14:13:00 +03:00
#include <QGuiApplication>
#include <QQmlApplicationEngine>
2022-01-16 19:51:07 +03:00
#include <QQmlContext>
2022-01-23 20:16:20 +03:00
#include <doctorpillgui.h>
2022-01-16 19:51:07 +03:00
#include <thread>
class EmptyPill: public DP::iPill {
// iPill interface
public:
QString name() const override {
return "EmptyPill";
};
2022-02-03 11:44:16 +03:00
int id() const override {
return typeid (this).hash_code();
};
2022-01-16 19:51:07 +03:00
QString description() const override {
return "Pill For Test. This pill cant be fixed ";
};
protected:
2022-07-11 16:57:22 +03:00
bool diagnostic() override {
2022-01-17 17:31:44 +03:00
std::this_thread::sleep_for(std::chrono::seconds(1));
2022-01-16 19:51:07 +03:00
return true;
};
2022-07-11 16:57:22 +03:00
bool fix() override {
2022-01-17 17:31:44 +03:00
return true;
};
};
class EmptyPill1: public DP::iPill {
// iPill interface
public:
QString name() const override {
return "EmptyPill1";
};
QString description() const override {
return "Pill For Test. This pill cant be fixed ";
};
2022-02-03 11:44:16 +03:00
int id() const override {
return typeid (this).hash_code();
};
2022-01-17 17:31:44 +03:00
protected:
2022-07-11 16:57:22 +03:00
bool diagnostic() override {
2022-01-17 17:31:44 +03:00
std::this_thread::sleep_for(std::chrono::seconds(1));
return true;
};
2022-07-11 16:57:22 +03:00
bool fix() override {
2022-01-17 17:31:44 +03:00
return true;
};
2022-02-03 11:44:16 +03:00
2022-01-17 17:31:44 +03:00
};
class EmptyPill2: public DP::iPill {
// iPill interface
public:
QString name() const override {
return "EmptyPill2";
};
2022-02-03 11:44:16 +03:00
int id() const override {
return typeid (this).hash_code();
};
2022-01-17 17:31:44 +03:00
QString description() const override {
return "Pill For Test. This pill cant be fixed ";
};
protected:
2022-07-11 16:57:22 +03:00
bool diagnostic() override {
2022-01-17 17:31:44 +03:00
std::this_thread::sleep_for(std::chrono::seconds(1));
return true;
};
2022-07-11 16:57:22 +03:00
bool fix() override {
2022-01-17 17:31:44 +03:00
return true;
};
};
class LongPill: public DP::iPill {
// iPill interface
public:
QString name() const override {
return "Long Pill ";
};
2022-02-03 11:44:16 +03:00
int id() const override {
return typeid (this).hash_code();
};
2022-01-17 17:31:44 +03:00
QString description() const override {
return "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
" Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,"
" when an unknown printer took a galley of type and scrambled it to make a type specimen book."
" It has survived not only five centuries,"
" but also the leap into electronic typesetting,"
" remaining essentially unchanged."
" It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,"
" and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. ";
};
protected:
2022-07-11 16:57:22 +03:00
bool diagnostic() override {
2022-01-17 17:31:44 +03:00
std::this_thread::sleep_for(std::chrono::seconds(1));
return true;
};
2022-07-11 16:57:22 +03:00
bool fix() override {
2022-01-17 17:31:44 +03:00
return true;
2022-01-16 19:51:07 +03:00
};
};
2022-01-16 14:13:00 +03:00
2022-01-13 21:51:56 +03:00
int main(int argc, char *argv[]) {
2022-01-16 14:13:00 +03:00
QCoreApplication::setOrganizationName("QuasarApp");
QCoreApplication::setApplicationName("DoctorPillExample");
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
if (!DP::init(&engine)) {
return -1;
}
2022-01-17 17:31:44 +03:00
DP::DoctorModel model({QSharedPointer<EmptyPill>::create(),
QSharedPointer<LongPill>::create(),
QSharedPointer<EmptyPill1>::create(),
QSharedPointer<EmptyPill2>::create()});
2022-01-16 19:51:07 +03:00
2022-01-16 14:13:00 +03:00
engine.load("qrc:/Main.qml");
if (engine.rootObjects().isEmpty())
return -2;
2022-01-16 19:51:07 +03:00
QQmlContext* rootContext = engine.rootContext();
if (rootContext)
2022-01-18 17:25:02 +03:00
rootContext->setContextProperty("doctorPillModel", &model);
2022-01-16 19:51:07 +03:00
2022-01-16 14:13:00 +03:00
return app.exec();
2022-01-13 21:51:56 +03:00
}