From a1de50cd0a87e62a3c1fdfbcfc1e1e35ae14dfed Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Mon, 8 Jan 2018 07:57:06 +0100 Subject: [PATCH] Reduce duplicate code --- .../incorrectidentityfolderwarning.cpp | 19 ++++++++++--------- .../incorrectidentityfolderwarning.h | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp b/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp index ec851363a..63d07951f 100644 --- a/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp +++ b/src/editor/warningwidgets/incorrectidentityfolderwarning.cpp @@ -58,6 +58,13 @@ void IncorrectIdentityFolderWarning::dictionaryInvalid() updateText(); } +void IncorrectIdentityFolderWarning::addNewLine(QString &str) +{ + if (!str.isEmpty()) { + str += QLatin1Char('\n'); + } +} + void IncorrectIdentityFolderWarning::updateText() { QString text; @@ -65,21 +72,15 @@ void IncorrectIdentityFolderWarning::updateText() text = i18n("Transport was not found. Please verify that you will use a correct mail transport."); } if (mFccIsInvalid) { - if (!text.isEmpty()) { - text += QLatin1Char('\n'); - } + addNewLine(text); text += i18n("Sent Folder is not defined. Please verify it before to send it."); } if (mIdentityIsInvalid) { - if (!text.isEmpty()) { - text += QLatin1Char('\n'); - } + addNewLine(text); text += i18n("Identity was not found. Please verify that you will use a correct identity."); } if (mDictionaryIsInvalid) { - if (!text.isEmpty()) { - text += QLatin1Char('\n'); - } + addNewLine(text); text += i18n("Dictionary was not found. Please verify that you will use a correct dictionary."); } setText(text); diff --git a/src/editor/warningwidgets/incorrectidentityfolderwarning.h b/src/editor/warningwidgets/incorrectidentityfolderwarning.h index aa17846f7..f90bcfde4 100644 --- a/src/editor/warningwidgets/incorrectidentityfolderwarning.h +++ b/src/editor/warningwidgets/incorrectidentityfolderwarning.h @@ -35,6 +35,7 @@ public: void dictionaryInvalid(); private: + void addNewLine(QString &str); void updateText(); void slotHideAnnimationFinished(); bool mMailTransportIsInvalid = false;