Skip to content

Commit

Permalink
Formatted, fixed bugs with start 2D-model and fixed ui
Browse files Browse the repository at this point in the history
  • Loading branch information
MinyazevR committed Jul 1, 2024
1 parent b42a39c commit e491363
Show file tree
Hide file tree
Showing 9 changed files with 418 additions and 415 deletions.
569 changes: 289 additions & 280 deletions checker.cpp

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,32 @@ class Checker : public QObject
{
Q_OBJECT

public:
Checker(const QString &tasksPath);

void reviewTasks(const QFileInfoList &qrsInfos, const QFileInfoList &fieldsInfos, const QHash<QString
, QVariant> &options);
struct Task {
public:
explicit Checker(const QString &tasksPath);

void reviewTasks(const QFileInfoList &qrsInfos,
const QFileInfoList &fieldsInfos,
const QHash<QString, QVariant> &options);
struct Task
{
QFileInfo qrs;
const QFileInfoList &fieldsInfos;
const QStringList &patcherOptions;
const QStringList &runnerOptions;
};

struct TaskReport {
struct TaskReport
{
QString name;
QString task;
QString time;
QString message;
QString level;

bool operator <(const TaskReport& other) const { return task < other.task; }
bool operator<(const TaskReport &other) const { return task < other.task; }
};

private:
private:
typedef QList<TaskReport> task_results_t;

static void reduceFunction(QHash<QString, task_results_t> &result, const task_results_t &intermediate);
Expand All @@ -54,15 +57,15 @@ class Checker : public QObject

static QPair<QString, QString> handleJsonReport(const QString &filename);

const QString createHtmlReport(const QHash<QString, QList<TaskReport> > &result);
QString createHtmlReport(const QHash<QString, QList<TaskReport>> &result);

const QStringList generateRunnerOptions(const QHash<QString, QVariant> &options);
static QStringList generateRunnerOptions(const QHash<QString, QVariant> &options);

const QStringList generatePatcherOptions(const QHash<QString, QVariant> &options);
static QStringList generatePatcherOptions(const QHash<QString, QVariant> &options);

static bool isErrorMessage(const QString &message);

static bool isErrorReport(const TaskReport &message);
static bool isErrorReport(const TaskReport &report);

static QString getErrorMessage(const QString &message);

Expand Down
41 changes: 20 additions & 21 deletions htmlTemplates.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
// %1 - task folder name
// %2 - time and date
QString reportHeader =
"<section class=\"u-clearfix u-section-1\" id==\"sec-c7e3=\">"
"<div class=\"u-clearfix u-sheet u-sheet-1\">"
"<p class=\"u-align-left u-large-text u-text u-text-variant u-text-1\">"
"<span style=\"font-weight: 700;\">"
"%1<br>%2"
"</span></p></div></section><section class=\"u-align-center u-clearfix u-section-2\" id=\"sec-82ab\">"
"<div class=\"u-clearfix u-sheet u-sheet-1\">"
"<div class=\"u-expanded-width u-table u-table-responsive u-table-1\">"
"<table class=\"u-table-entity u-table-entity-1\">"
"<colgroup><col width=\"25%\"><col width=\"25%\"><col width=\"25%\"><col width=\"25%\"></colgroup>"
"<tbody class=\"u-align-left u-custom-font u-font-montserrat u-table-alt-palette-1-light-3 u-table-body\">"
"<tr style=\"height: 28px;\">"
"<td class=\"u-custom-font u-first-column u-font-montserrat u-table-cell u-table-cell-1\">"
"Имя<br></td><td class=\"u-table-cell\" spellcheck=\"false\">Тест</td>"
"<td class=\"u-table-cell\" spellcheck=\"false\">Статус<br></td><td class=\"u-table-cell\" spellcheck=\"false\">"
"Время исполнения<br></td></tr>";
"<section class=\"u-clearfix u-section-1\" id==\"sec-c7e3=\">"
"<div class=\"u-clearfix u-sheet u-sheet-1\">"
"<p class=\"u-align-left u-large-text u-text u-text-variant u-text-1\">"
"<span style=\"font-weight: 700;\">"
"%1<br>%2"
"</span></p></div></section><section class=\"u-align-center u-clearfix u-section-2\" id=\"sec-82ab\">"
"<div class=\"u-clearfix u-sheet u-sheet-1\">"
"<div class=\"u-expanded-width u-table u-table-responsive u-table-1\">"
"<table class=\"u-table-entity u-table-entity-1\">"
"<colgroup><col width=\"25%\"><col width=\"25%\"><col width=\"25%\"><col width=\"25%\"></colgroup>"
"<tbody class=\"u-align-left u-custom-font u-font-montserrat u-table-alt-palette-1-light-3 u-table-body\">"
"<tr style=\"height: 28px;\">"
"<td class=\"u-custom-font u-first-column u-font-montserrat u-table-cell u-table-cell-1\">"
"Имя<br></td><td class=\"u-table-cell\" spellcheck=\"false\">Тест</td>"
"<td class=\"u-table-cell\" spellcheck=\"false\">Статус<br></td><td class=\"u-table-cell\" spellcheck=\"false\">"
"Время исполнения<br></td></tr>";

QString greenCssClass = "u-custom-color-1 u-text-black";
QString yellowCssClass = "u-palette-3-light-1 u-text-black";
Expand All @@ -46,8 +46,7 @@ QString blackCssClass = "u-custom-color-2";
// %4 - status
// %5 - execution time
QString taskReport =
"<tr style=\"height: 58px;\">"
"<td style=\"font-weight: bold\" class=\"u-custom-font u-first-column u-font-montserrat %1 u-table-cell\">%2</td>"
"<td class=\"u-table-cell\">%3</td><td class=\"u-table-cell\">%4</td><td class=\"u-table-cell\">%5</td>"
"</tr>";

"<tr style=\"height: 58px;\">"
"<td style=\"font-weight: bold\" class=\"u-custom-font u-first-column u-font-montserrat %1 u-table-cell\">%2</td>"
"<td class=\"u-table-cell\">%3</td><td class=\"u-table-cell\">%4</td><td class=\"u-table-cell\">%5</td>"
"</tr>";
11 changes: 5 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@
#include "mainwindow.h"

#include <QApplication>
#include <QDebug>
#include <QProcessEnvironment>
#include <QStyleFactory>
#include <QTranslator>
#include <QProcessEnvironment>
#include <QDebug>

int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setStyle(QStyleFactory::create("Fusion"));
QApplication a(argc, argv);

QTranslator translator;
const QString translation_file = ":/translations/checkapp_" + QLocale::system().name() + ".qm";
if (!translator.load(translation_file)) {
qDebug() << "Failed to load translation file: " << translation_file;
}
else {
a.installTranslator(&translator);
} else {
a.installTranslator(&translator);
}

MainWindow w;
Expand Down
35 changes: 18 additions & 17 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QtConcurrent/QtConcurrent>
#include <QFileDialog>
#include <QMessageBox>
#include <QProgressDialog>
#include <QSettings>
#include <QtConcurrent/QtConcurrent>

#include "checker.h"
#include "optionsAliases.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, mUi(new Ui::MainWindow)
, mTasksDir(QDir::currentPath())
, mLocalSettings(QDir::toNativeSeparators(mTasksDir.absolutePath() + "/checkapp.ini"))
: QMainWindow(parent)
, mUi(new Ui::MainWindow)
, mTasksDir(QDir::currentPath())
, mLocalSettings(QDir::toNativeSeparators(mTasksDir.absolutePath() + "/checkapp.ini"))
{
mUi->setupUi(this);

connect(mUi->backgroundOption, &QGroupBox::toggled, this, [this](bool state){
connect(mUi->backgroundOption, &QGroupBox::toggled, this, [this](bool state) {
mDirOptions[mTasksPath][backgroundOption] = !state;
mUi->closeOnSuccessOption->setEnabled(state);
});
Expand All @@ -49,16 +49,16 @@ MainWindow::~MainWindow()

void MainWindow::on_runCheckButton_clicked()
{
auto qrsList = mTasksDir.entryInfoList({"*.qrs"}, QDir::Files);
auto qrsList = mTasksDir.entryInfoList({ "*.qrs" }, QDir::Files);
if (qrsList.isEmpty()) {
qrsList = mTasksDir.entryInfoList({"*.tsj"}, QDir::Files);
qrsList = mTasksDir.entryInfoList({ "*.tsj" }, QDir::Files);
}
if (qrsList.isEmpty()) {
showNoQrsTsjMessage();
return;
}

auto fields = mFieldsDir.entryInfoList({"*.xml"}, QDir::Files);
auto fields = mFieldsDir.entryInfoList({ "*.xml" }, QDir::Files);
if (fields.isEmpty()) {
showNoFieldsMessage();
return;
Expand All @@ -70,7 +70,7 @@ void MainWindow::on_runCheckButton_clicked()
void MainWindow::on_chooseField_clicked()
{
mFieldsDir = chooseDirectoryDialog();
if (mFieldsDir.entryInfoList({"*.xml"}, QDir::Files).isEmpty()) {
if (mFieldsDir.entryInfoList({ "*.xml" }, QDir::Files).isEmpty()) {
showNoFieldsMessage();
}

Expand All @@ -82,7 +82,7 @@ void MainWindow::on_chooseField_clicked()
void MainWindow::on_openTasks_clicked()
{
mTasksDir = chooseDirectoryDialog();
if (mTasksDir.entryInfoList({"*.qrs", "*.tsj"}, QDir::Files).isEmpty()) {
if (mTasksDir.entryInfoList({ "*.qrs", "*.tsj" }, QDir::Files).isEmpty()) {
showNoQrsTsjMessage();
return;
}
Expand Down Expand Up @@ -135,15 +135,16 @@ QDir MainWindow::chooseDirectoryDialog()
return dialog.directory();
}


void MainWindow::resetUiOptions(const QHash<QString, QVariant> &options)
{
mUi->closeOnSuccessOption->setCheckState(options[closeSuccessOption].toBool() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
mUi->closeOnSuccessOption->setCheckState(options[closeSuccessOption].toBool() ? Qt::CheckState::Checked
: Qt::CheckState::Unchecked);
mUi->backgroundOption->setChecked(!options[backgroundOption].toBool());
mUi->wPPCheckBox->setCheckState(options[patchField].toBool() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
mUi->wPcheckBox->setCheckState(options[patchWP].toBool() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
mUi->resetPCheckBox->setCheckState(options[resetRP].toBool() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
mUi->showConsoleCheckBox->setCheckState(options[consoleOption].toBool() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
mUi->showConsoleCheckBox->setCheckState(options[consoleOption].toBool() ? Qt::CheckState::Checked
: Qt::CheckState::Unchecked);
mUi->xmlFieldsDir->setText(options[xmlFieldsDir].toString());
}

Expand All @@ -152,7 +153,7 @@ void MainWindow::loadSettings()
QSettings settings(mLocalSettings, QSettings::IniFormat);
auto groups = settings.childGroups();
for (auto &&g : groups) {
QHash <QString, QVariant> options;
QHash<QString, QVariant> options;

settings.beginGroup(g);

Expand All @@ -170,10 +171,10 @@ void MainWindow::saveSettings()
{
QSettings settings(mLocalSettings, QSettings::IniFormat);
auto mDirOptionsKeys = mDirOptions.keys();
for (auto &&dir: mDirOptionsKeys) {
for (auto &&dir : mDirOptionsKeys) {
settings.beginGroup(dir);
auto options = mDirOptions[dir].keys();
for (auto &&option: options) {
for (auto &&option : options) {
settings.setValue(option, mDirOptions[dir][option]);
}
settings.endGroup();
Expand Down
26 changes: 14 additions & 12 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;

private slots:
private slots:
void on_chooseField_clicked();

void on_openTasks_clicked();
Expand All @@ -44,20 +46,20 @@ private slots:

void on_showConsoleCheckBox_stateChanged(int state);

void on_closeOnSuccessOption_stateChanged(int arg1);
void on_closeOnSuccessOption_stateChanged(int state);

private:
QDir chooseDirectoryDialog();
private:
static QDir chooseDirectoryDialog();

void resetUiOptions(const QHash <QString, QVariant> &options);
void resetUiOptions(const QHash<QString, QVariant> &options);

void loadSettings();

void saveSettings();

void showNoQrsTsjMessage();
static void showNoQrsTsjMessage();

void showNoFieldsMessage();
static void showNoFieldsMessage();

Ui::MainWindow *mUi;
QDir mTasksDir;
Expand All @@ -66,5 +68,5 @@ private slots:
QDir mStudioDir;
QString mLocalSettings;

QHash <QString, QHash <QString, QVariant>> mDirOptions;
QHash<QString, QHash<QString, QVariant>> mDirOptions;
};
Loading

0 comments on commit e491363

Please sign in to comment.