Commit 2d3518bd authored by Laurent Montel's avatar Laurent Montel 😁

Avoid duplicate code

parent 28077ee5
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.5.40")
set(PIM_VERSION "5.5.41")
project(pimcommon VERSION ${PIM_VERSION})
......
......@@ -44,6 +44,7 @@
#include <QDesktopServices>
#include <KMessageBox>
#include <KLocalizedString>
#include <KEmailAddress>
#include <QTextStream>
#include <QWidget>
......@@ -145,3 +146,20 @@ void PimCommon::Util::invokeHelp(const QString &docfile, const QString &anchor)
QDesktopServices::openUrl(url);
}
}
QStringList PimCommon::Util::generateEmailList(const QStringList &list)
{
QString str;
const int numberOfElement{list.count()};
for (int i = 0; i < numberOfElement; i++) {
QString tmpStr = list.at(i);
if (!tmpStr.trimmed().isEmpty()) {
if (!str.isEmpty()) {
str.append(QStringLiteral(", "));
}
str.append(tmpStr);
}
}
const QStringList emails = KEmailAddress::splitAddressList(str);
return emails;
}
......@@ -63,6 +63,7 @@ PIMCOMMON_EXPORT bool saveToFile(const QString &filename, const QString &text);
PIMCOMMON_EXPORT QString loadToFile(const QString &filter, QWidget *parent, const QUrl &url = QUrl(), const QString &caption = QString());
PIMCOMMON_EXPORT void invokeHelp(const QString &docfile, const QString &anchor = QString());
PIMCOMMON_EXPORT bool isImapResource(const QString &identifier);
PIMCOMMON_EXPORT QStringList generateEmailList(const QStringList &list);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment