Skip to content

Commit

Permalink
Never use tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
MinyazevR committed Jul 1, 2024
1 parent e491363 commit 6602d61
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 135 deletions.
9 changes: 1 addition & 8 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,4 @@ StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: AlignWithSpaces
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...
UseTab: Never
44 changes: 22 additions & 22 deletions checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class Checker : public QObject
{
Q_OBJECT
Q_OBJECT

public:
explicit Checker(const QString &tasksPath);
Expand All @@ -29,49 +29,49 @@ class Checker : public QObject
const QHash<QString, QVariant> &options);
struct Task
{
QFileInfo qrs;
const QFileInfoList &fieldsInfos;
const QStringList &patcherOptions;
const QStringList &runnerOptions;
};
QFileInfo qrs;
const QFileInfoList &fieldsInfos;
const QStringList &patcherOptions;
const QStringList &runnerOptions;
};

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

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

private:
typedef QList<TaskReport> task_results_t;
typedef QList<TaskReport> task_results_t;

static void reduceFunction(QHash<QString, task_results_t> &result, const task_results_t &intermediate);
static void reduceFunction(QHash<QString, task_results_t> &result, const task_results_t &intermediate);

static task_results_t checkTask(const Task *task);
static task_results_t checkTask(const Task *task);

static QString executeProcess(const QString &program, const QStringList &options);
static QString executeProcess(const QString &program, const QStringList &options);

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

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

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

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

static bool isErrorMessage(const QString &message);
static bool isErrorMessage(const QString &message);

static bool isErrorReport(const TaskReport &report);

static QString getErrorMessage(const QString &message);
static QString getErrorMessage(const QString &message);

const QString &mTasksPath;
const QString &mTasksPath;

void createTasksEnvironment();
void createTasksEnvironment();

void removeTasksEnvironment();
void removeTasksEnvironment();
};
20 changes: 10 additions & 10 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setStyle(QStyleFactory::create("Fusion"));
QApplication a(argc, argv);
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;
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);
}
}

MainWindow w;
w.show();
return a.exec();
MainWindow w;
w.show();
return a.exec();
}
158 changes: 79 additions & 79 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,167 +30,167 @@ MainWindow::MainWindow(QWidget *parent)
, mTasksDir(QDir::currentPath())
, mLocalSettings(QDir::toNativeSeparators(mTasksDir.absolutePath() + "/checkapp.ini"))
{
mUi->setupUi(this);
mUi->setupUi(this);

connect(mUi->backgroundOption, &QGroupBox::toggled, this, [this](bool state) {
mDirOptions[mTasksPath][backgroundOption] = !state;
mUi->closeOnSuccessOption->setEnabled(state);
});
mDirOptions[mTasksPath][backgroundOption] = !state;
mUi->closeOnSuccessOption->setEnabled(state);
});

loadSettings();
mUi->runCheckButton->setEnabled(!mTasksPath.isEmpty());
loadSettings();
mUi->runCheckButton->setEnabled(!mTasksPath.isEmpty());
}

MainWindow::~MainWindow()
{
saveSettings();
delete mUi;
saveSettings();
delete mUi;
}

void MainWindow::on_runCheckButton_clicked()

Check warning on line 50 in mainwindow.cpp

View workflow job for this annotation

GitHub Actions / format

mainwindow.cpp:50:18 [readability-convert-member-functions-to-static]

method 'on_runCheckButton_clicked' can be made static
{
auto qrsList = mTasksDir.entryInfoList({ "*.qrs" }, QDir::Files);
if (qrsList.isEmpty()) {
if (qrsList.isEmpty()) {
qrsList = mTasksDir.entryInfoList({ "*.tsj" }, QDir::Files);
}
if (qrsList.isEmpty()) {
showNoQrsTsjMessage();
return;
}
}
if (qrsList.isEmpty()) {
showNoQrsTsjMessage();
return;
}

auto fields = mFieldsDir.entryInfoList({ "*.xml" }, QDir::Files);
if (fields.isEmpty()) {
showNoFieldsMessage();
return;
}
Checker checker(mTasksPath);
checker.reviewTasks(qrsList, fields, mDirOptions[mTasksPath]);
if (fields.isEmpty()) {
showNoFieldsMessage();
return;
}
Checker checker(mTasksPath);
checker.reviewTasks(qrsList, fields, mDirOptions[mTasksPath]);
}

void MainWindow::on_chooseField_clicked()
{
mFieldsDir = chooseDirectoryDialog();
mFieldsDir = chooseDirectoryDialog();
if (mFieldsDir.entryInfoList({ "*.xml" }, QDir::Files).isEmpty()) {
showNoFieldsMessage();
}
showNoFieldsMessage();
}

auto path = QDir::toNativeSeparators(mFieldsDir.absolutePath());
mUi->xmlFieldsDir->setText(path);
mDirOptions[mTasksPath][xmlFieldsDir] = path;
auto path = QDir::toNativeSeparators(mFieldsDir.absolutePath());
mUi->xmlFieldsDir->setText(path);
mDirOptions[mTasksPath][xmlFieldsDir] = path;
}

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

mTasksPath = QDir::toNativeSeparators(mTasksDir.absolutePath());
mUi->currentTasksDir->setText(mTasksPath);
mTasksPath = QDir::toNativeSeparators(mTasksDir.absolutePath());
mUi->currentTasksDir->setText(mTasksPath);

if (!mDirOptions.contains(mTasksPath)) {
mDirOptions[mTasksPath] = defaultOptions;
}
if (!mDirOptions.contains(mTasksPath)) {
mDirOptions[mTasksPath] = defaultOptions;
}

auto xmlField = mDirOptions[mTasksPath][xmlFieldsDir].toString();
mFieldsDir = xmlField.isEmpty() ? mTasksDir : QDir(xmlField);
mDirOptions[mTasksPath][xmlFieldsDir] = xmlField.isEmpty() ? mTasksPath : xmlField;
auto xmlField = mDirOptions[mTasksPath][xmlFieldsDir].toString();
mFieldsDir = xmlField.isEmpty() ? mTasksDir : QDir(xmlField);
mDirOptions[mTasksPath][xmlFieldsDir] = xmlField.isEmpty() ? mTasksPath : xmlField;

resetUiOptions(mDirOptions[mTasksPath]);
mUi->runCheckButton->setEnabled(true);
resetUiOptions(mDirOptions[mTasksPath]);
mUi->runCheckButton->setEnabled(true);
}

void MainWindow::on_wPcheckBox_stateChanged(int state)
{
mDirOptions[mTasksPath][patchWP] = state == Qt::CheckState::Checked;
mDirOptions[mTasksPath][patchWP] = state == Qt::CheckState::Checked;
}

void MainWindow::on_wPPCheckBox_stateChanged(int state)
{
mDirOptions[mTasksPath][patchField] = state == Qt::CheckState::Checked;
mDirOptions[mTasksPath][patchField] = state == Qt::CheckState::Checked;
}

void MainWindow::on_resetPCheckBox_stateChanged(int state)
{
mDirOptions[mTasksPath][resetRP] = state == Qt::CheckState::Checked;
mDirOptions[mTasksPath][resetRP] = state == Qt::CheckState::Checked;
}

void MainWindow::on_showConsoleCheckBox_stateChanged(int state)
{
mDirOptions[mTasksPath][consoleOption] = state == Qt::CheckState::Checked;
mDirOptions[mTasksPath][consoleOption] = state == Qt::CheckState::Checked;
}

void MainWindow::on_closeOnSuccessOption_stateChanged(int state)
{
mDirOptions[mTasksPath][closeSuccessOption] = state == Qt::CheckState::Checked;
mDirOptions[mTasksPath][closeSuccessOption] = state == Qt::CheckState::Checked;
}

QDir MainWindow::chooseDirectoryDialog()
{
QFileDialog dialog;
dialog.setFileMode(QFileDialog::Directory);
dialog.exec();
return dialog.directory();
QFileDialog dialog;
dialog.setFileMode(QFileDialog::Directory);
dialog.exec();
return dialog.directory();
}

void MainWindow::resetUiOptions(const QHash<QString, QVariant> &options)
{
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->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->xmlFieldsDir->setText(options[xmlFieldsDir].toString());
mUi->xmlFieldsDir->setText(options[xmlFieldsDir].toString());
}

void MainWindow::loadSettings()

Check warning on line 151 in mainwindow.cpp

View workflow job for this annotation

GitHub Actions / format

mainwindow.cpp:151:18 [readability-convert-member-functions-to-static]

method 'loadSettings' can be made static
{
QSettings settings(mLocalSettings, QSettings::IniFormat);
auto groups = settings.childGroups();
for (auto &&g : groups) {
QSettings settings(mLocalSettings, QSettings::IniFormat);
auto groups = settings.childGroups();
for (auto &&g : groups) {
QHash<QString, QVariant> options;

settings.beginGroup(g);
settings.beginGroup(g);

auto defaultOptionsKeys = defaultOptions.keys();
for (auto &&key : defaultOptionsKeys) {
options[key] = settings.value(key, defaultOptions[key]);
}
settings.endGroup();
auto defaultOptionsKeys = defaultOptions.keys();
for (auto &&key : defaultOptionsKeys) {
options[key] = settings.value(key, defaultOptions[key]);
}
settings.endGroup();

mDirOptions[g] = options;
}
mDirOptions[g] = options;
}
}

void MainWindow::saveSettings()

Check warning on line 170 in mainwindow.cpp

View workflow job for this annotation

GitHub Actions / format

mainwindow.cpp:170:18 [readability-convert-member-functions-to-static]

method 'saveSettings' can be made static
{
QSettings settings(mLocalSettings, QSettings::IniFormat);
auto mDirOptionsKeys = mDirOptions.keys();
QSettings settings(mLocalSettings, QSettings::IniFormat);
auto mDirOptionsKeys = mDirOptions.keys();
for (auto &&dir : mDirOptionsKeys) {
settings.beginGroup(dir);
auto options = mDirOptions[dir].keys();
settings.beginGroup(dir);
auto options = mDirOptions[dir].keys();
for (auto &&option : options) {
settings.setValue(option, mDirOptions[dir][option]);
}
settings.endGroup();
}
settings.setValue(option, mDirOptions[dir][option]);
}
settings.endGroup();
}
}

void MainWindow::showNoQrsTsjMessage()
{
QMessageBox msgBox;
msgBox.setText(tr("There is no .qrs or .tsj files in solutions directory."));
msgBox.exec();
QMessageBox msgBox;
msgBox.setText(tr("There is no .qrs or .tsj files in solutions directory."));
msgBox.exec();
}

void MainWindow::showNoFieldsMessage()
{
QMessageBox msgBox;
msgBox.setText(tr("There is no .xml files in fields directory."));
msgBox.exec();
QMessageBox msgBox;
msgBox.setText(tr("There is no .xml files in fields directory."));
msgBox.exec();
}
Loading

0 comments on commit 6602d61

Please sign in to comment.