From 3ed990861a52f090d355555d5f5d3b76a9b4608c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 29 Jul 2017 08:43:34 +0200 Subject: [PATCH] NOISSUE simplify ProblemProvider --- api/logic/ProblemProvider.h | 19 ++----------------- api/logic/minecraft/ProfilePatch.cpp | 2 +- application/pages/VersionPage.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/api/logic/ProblemProvider.h b/api/logic/ProblemProvider.h index b30e1776a..7dedccd77 100644 --- a/api/logic/ProblemProvider.h +++ b/api/logic/ProblemProvider.h @@ -7,23 +7,8 @@ enum class ProblemSeverity Error }; -class PatchProblem +struct PatchProblem { -public: - PatchProblem(ProblemSeverity severity, const QString & description) - { - m_severity = severity; - m_description = description; - } - const QString & getDescription() const - { - return m_description; - } - const ProblemSeverity getSeverity() const - { - return m_severity; - } -private: ProblemSeverity m_severity; QString m_description; }; @@ -52,7 +37,7 @@ public: { m_problemSeverity = severity; } - m_problems.append(PatchProblem(severity, description)); + m_problems.append({severity, description}); } private: diff --git a/api/logic/minecraft/ProfilePatch.cpp b/api/logic/minecraft/ProfilePatch.cpp index a2605278c..049463acd 100644 --- a/api/logic/minecraft/ProfilePatch.cpp +++ b/api/logic/minecraft/ProfilePatch.cpp @@ -184,5 +184,5 @@ const QList ProfilePatch::getProblems() { return file->getProblems(); } - return {PatchProblem(ProblemSeverity::Error, QObject::tr("Patch is not loaded yet."))}; + return {{ProblemSeverity::Error, QObject::tr("Patch is not loaded yet.")}}; } diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp index 90fd32411..c280f98fd 100644 --- a/application/pages/VersionPage.cpp +++ b/application/pages/VersionPage.cpp @@ -119,10 +119,9 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) ui->packageView->setModel(proxy); ui->packageView->installEventFilter(this); ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection); - connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, - this, &VersionPage::versionCurrent); + connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent); auto smodel = ui->packageView->selectionModel(); - connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(packageCurrent(QModelIndex, QModelIndex))); + connect(smodel, &QItemSelectionModel::currentChanged, this, &VersionPage::packageCurrent); updateVersionControls(); // select first item. preselect(0); @@ -168,15 +167,15 @@ void VersionPage::packageCurrent(const QModelIndex ¤t, const QModelIndex & QString problemOut; for (auto &problem: problems) { - if(problem.getSeverity() == ProblemSeverity::Error) + if(problem.m_severity == ProblemSeverity::Error) { problemOut += tr("Error: "); } - else if(problem.getSeverity() == ProblemSeverity::Warning) + else if(problem.m_severity == ProblemSeverity::Warning) { problemOut += tr("Warning: "); } - problemOut += problem.getDescription(); + problemOut += problem.m_description; problemOut += "\n"; } ui->frame->setModDescription(problemOut);