From 6602d61b27f84deb777dc469f0be7d07b360506c Mon Sep 17 00:00:00 2001 From: MinyazevR Date: Mon, 1 Jul 2024 05:08:58 +0300 Subject: [PATCH] Never use tabs --- .clang-format | 9 +-- checker.h | 44 +++++++------- main.cpp | 20 +++---- mainwindow.cpp | 158 ++++++++++++++++++++++++------------------------- mainwindow.h | 32 +++++----- 5 files changed, 128 insertions(+), 135 deletions(-) diff --git a/.clang-format b/.clang-format index d5e65e6..833a619 100644 --- a/.clang-format +++ b/.clang-format @@ -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 diff --git a/checker.h b/checker.h index a806d23..4b96536 100644 --- a/checker.h +++ b/checker.h @@ -19,7 +19,7 @@ class Checker : public QObject { - Q_OBJECT + Q_OBJECT public: explicit Checker(const QString &tasksPath); @@ -29,33 +29,33 @@ class Checker : public QObject const QHash &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 task_results_t; + typedef QList task_results_t; - static void reduceFunction(QHash &result, const task_results_t &intermediate); + static void reduceFunction(QHash &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 handleJsonReport(const QString &filename); + static QPair handleJsonReport(const QString &filename); QString createHtmlReport(const QHash> &result); @@ -63,15 +63,15 @@ class Checker : public QObject static QStringList generatePatcherOptions(const QHash &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(); }; diff --git a/main.cpp b/main.cpp index 1b4fe73..ac79ab6 100644 --- a/main.cpp +++ b/main.cpp @@ -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(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 15d0753..32ad8a9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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() { 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 &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() { - 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 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() { - 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(); } diff --git a/mainwindow.h b/mainwindow.h index e722262..65a29da 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -25,26 +25,26 @@ QT_END_NAMESPACE class MainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow() override; private slots: - void on_chooseField_clicked(); + void on_chooseField_clicked(); - void on_openTasks_clicked(); + void on_openTasks_clicked(); - void on_runCheckButton_clicked(); + void on_runCheckButton_clicked(); - void on_wPcheckBox_stateChanged(int state); + void on_wPcheckBox_stateChanged(int state); - void on_wPPCheckBox_stateChanged(int state); + void on_wPPCheckBox_stateChanged(int state); - void on_resetPCheckBox_stateChanged(int state); + void on_resetPCheckBox_stateChanged(int state); - void on_showConsoleCheckBox_stateChanged(int state); + void on_showConsoleCheckBox_stateChanged(int state); void on_closeOnSuccessOption_stateChanged(int state); @@ -53,20 +53,20 @@ class MainWindow : public QMainWindow void resetUiOptions(const QHash &options); - void loadSettings(); + void loadSettings(); - void saveSettings(); + void saveSettings(); static void showNoQrsTsjMessage(); static void showNoFieldsMessage(); - Ui::MainWindow *mUi; - QDir mTasksDir; - QDir mFieldsDir; - QString mTasksPath; - QDir mStudioDir; - QString mLocalSettings; + Ui::MainWindow *mUi; + QDir mTasksDir; + QDir mFieldsDir; + QString mTasksPath; + QDir mStudioDir; + QString mLocalSettings; QHash> mDirOptions; };