From 43307bee28da92c55d46856e9cd2f4be6bbf24d1 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Sun, 28 Jan 2024 11:25:46 +0400 Subject: [PATCH] Make ContentSelector errors localizable --- components/contentselector/model/contentmodel.cpp | 4 +++- components/contentselector/model/contentmodel.hpp | 4 ++++ components/contentselector/model/loadordererror.cpp | 12 ------------ components/contentselector/model/loadordererror.hpp | 1 - 4 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 components/contentselector/model/loadordererror.cpp diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 0aab06ac90..d800112712 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -723,8 +723,10 @@ QString ContentSelectorModel::ContentModel::toolTip(const EsmFile* file) const int index = indexFromItem(item(file->filePath())).row(); for (const LoadOrderError& error : checkForLoadOrderErrors(file, index)) { + assert(error.errorCode() != LoadOrderError::ErrorCode::ErrorCode_None); + text += "

"; - text += error.toolTip(); + text += mErrorToolTips[error.errorCode() - 1].arg(error.fileName()); text += "

"; } text += (""); diff --git a/components/contentselector/model/contentmodel.hpp b/components/contentselector/model/contentmodel.hpp index 1ba3090a32..f754b9ea30 100644 --- a/components/contentselector/model/contentmodel.hpp +++ b/components/contentselector/model/contentmodel.hpp @@ -93,6 +93,10 @@ namespace ContentSelectorModel QIcon mWarningIcon; bool mShowOMWScripts; + QString mErrorToolTips[ContentSelectorModel::LoadOrderError::ErrorCode_LoadOrder] + = { tr("Unable to find dependent file: %1"), tr("Dependent file needs to be active: %1"), + tr("This file needs to load after %1") }; + public: QString mMimeType; QStringList mMimeTypes; diff --git a/components/contentselector/model/loadordererror.cpp b/components/contentselector/model/loadordererror.cpp deleted file mode 100644 index c1b2025588..0000000000 --- a/components/contentselector/model/loadordererror.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "loadordererror.hpp" -#include - -QString ContentSelectorModel::LoadOrderError::sErrorToolTips[ErrorCode_LoadOrder] - = { QString("Unable to find dependent file: %1"), QString("Dependent file needs to be active: %1"), - QString("This file needs to load after %1") }; - -QString ContentSelectorModel::LoadOrderError::toolTip() const -{ - assert(mErrorCode); - return sErrorToolTips[mErrorCode - 1].arg(mFileName); -} diff --git a/components/contentselector/model/loadordererror.hpp b/components/contentselector/model/loadordererror.hpp index 8f47b6ed6a..b066ce4d4e 100644 --- a/components/contentselector/model/loadordererror.hpp +++ b/components/contentselector/model/loadordererror.hpp @@ -28,7 +28,6 @@ namespace ContentSelectorModel } inline ErrorCode errorCode() const { return mErrorCode; } inline QString fileName() const { return mFileName; } - QString toolTip() const; private: ErrorCode mErrorCode;