Commit a1726612 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move in util class

parent 8dbdb3f8
......@@ -587,3 +587,12 @@ void Util::addHelpTextAction(QAction *act, const QString &text)
act->setWhatsThis(text);
}
}
const QTextCodec *Util::codecForName(const QByteArray &_str)
{
if (_str.isEmpty()) {
return nullptr;
}
const QByteArray codec = _str.toLower();
return KCharsets::charsets()->codecForName(QLatin1String(codec));
}
......@@ -66,6 +66,9 @@ Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool saveAttachments(const KMime::Content
Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT QAction *createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent);
Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool excludeExtraHeader(const QString &s);
/** Return a QTextCodec for the specified charset.
* This function is a bit more tolerant, than QTextCodec::codecForName */
MESSAGEVIEWER_EXPORT const QTextCodec *codecForName(const QByteArray &_str);
}
}
Q_DECLARE_METATYPE(KService::Ptr)
......
......@@ -755,6 +755,5 @@ MessageViewer::DKIMWidgetInfo *Viewer::dkimWidgetInfo()
Q_D(Viewer);
return d->mDkimWidgetInfo;
}
#endif
}
......@@ -1888,7 +1888,7 @@ const QTextCodec *ViewerPrivate::overrideCodec() const
if (mOverrideEncoding.isEmpty() || mOverrideEncoding == QLatin1String("Auto")) { // Auto
return nullptr;
} else {
return ViewerPrivate::codecForName(mOverrideEncoding.toLatin1());
return MessageViewer::Util::codecForName(mOverrideEncoding.toLatin1());
}
}
......@@ -1988,15 +1988,6 @@ KMime::Content *ViewerPrivate::findContentByType(KMime::Content *content, const
}
//-----------------------------------------------------------------------------
const QTextCodec *ViewerPrivate::codecForName(const QByteArray &_str)
{
if (_str.isEmpty()) {
return nullptr;
}
const QByteArray codec = _str.toLower();
return KCharsets::charsets()->codecForName(QLatin1String(codec));
}
void ViewerPrivate::update(MimeTreeParser::UpdateMode updateMode)
{
// Avoid flicker, somewhat of a cludge
......
......@@ -368,10 +368,6 @@ public:
KMime::Content *findContentByType(KMime::Content *content, const QByteArray &type); //TODO(Andras) move to MimeTreeParser::NodeHelper
/** Return a QTextCodec for the specified charset.
* This function is a bit more tolerant, than QTextCodec::codecForName */
static const QTextCodec *codecForName(const QByteArray &_str); //TODO(Andras) move to a utility class?
/** Saves the relative position of the scroll view. Call this before calling update()
if you want to preserve the current view. */
void saveRelativePosition();
......
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