Commit 188f8fd6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to QVector

parent 78a347a2
cmake_minimum_required(VERSION 3.5)
set(PIM_VERSION "5.13.43")
set(PIM_VERSION "5.13.44")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -53,7 +53,7 @@ void EncryptJobTest::initTestCase()
void EncryptJobTest::testContentDirect()
{
MessageComposer::Composer *composer = new MessageComposer::Composer;
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
charsets << "us-ascii";
composer->globalPart()->setCharsets(charsets);
MessageComposer::TextPart *part = new MessageComposer::TextPart(this);
......@@ -87,7 +87,7 @@ void EncryptJobTest::testContentDirect()
void EncryptJobTest::testContentChained()
{
MessageComposer::Composer *composer = new MessageComposer::Composer;
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
charsets << "us-ascii";
composer->globalPart()->setCharsets(charsets);
MessageComposer::TextPart *part = new MessageComposer::TextPart(this);
......
......@@ -54,7 +54,7 @@ void MainTextJobTest::testPlainText()
{
Composer *composer = new Composer;
composer->globalPart()->setGuiEnabled(false);
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
charsets << "us-ascii" << "utf-8";
composer->globalPart()->setCharsets(charsets);
TextPart *textPart = new TextPart;
......@@ -104,7 +104,7 @@ void MainTextJobTest::testCustomCharset()
Composer *composer = new Composer;
composer->globalPart()->setGuiEnabled(false);
QByteArray charset("iso-8859-2");
composer->globalPart()->setCharsets(QList<QByteArray>() << charset);
composer->globalPart()->setCharsets(QVector<QByteArray>() << charset);
TextPart *textPart = new TextPart;
QString data = QStringLiteral("şi el o să se-nchidă cu o frunză de pelin");
textPart->setWrappedPlainText(data);
......@@ -142,7 +142,7 @@ void MainTextJobTest::testBadCharset()
Composer *composer = new Composer;
composer->globalPart()->setGuiEnabled(false);
QByteArray charset("us-ascii"); // Cannot handle Romanian chars.
composer->globalPart()->setCharsets(QList<QByteArray>() << charset);
composer->globalPart()->setCharsets(QVector<QByteArray>() << charset);
TextPart *textPart = new TextPart;
QString data = QStringLiteral("el a plâns peste ţară cu lacrima limbii noastre");
textPart->setWrappedPlainText(data);
......
......@@ -61,7 +61,7 @@ void SignEncryptTest::testContent()
QVERIFY(sJob);
QVERIFY(eJob);
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
charsets << "us-ascii";
composer->globalPart()->setCharsets(charsets);
MessageComposer::TextPart *part = new MessageComposer::TextPart(this);
......
......@@ -40,7 +40,7 @@ void UtilTest::testSelectCharset()
// Pick a charset that actually works.
{
QString text = QStringLiteral("text 123 ăîşţâ");
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
charsets << "us-ascii";
charsets << "iso-8859-1";
charsets << "iso-8859-2"; // This one works.
......@@ -51,7 +51,7 @@ void UtilTest::testSelectCharset()
// Pick as simple a charset as possible.
{
QString text = QStringLiteral("plain English text");
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
charsets << "us-ascii"; // This one works.
charsets << "iso-8859-1";
charsets << "utf-8";
......@@ -62,7 +62,7 @@ void UtilTest::testSelectCharset()
// Return empty charset if none works.
{
QString text = QStringLiteral("text 123 ăîşţâ");
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
QByteArray choice = Util::selectCharset(charsets, text);
QVERIFY(choice.isEmpty());
charsets << "us-ascii";
......
......@@ -1692,7 +1692,7 @@ void ComposerViewBase::setCryptoOptions(bool sign, bool encrypt, Kleo::CryptoMes
m_neverEncrypt = neverEncryptDrafts;
}
void ComposerViewBase::setCharsets(const QList< QByteArray > &charsets)
void ComposerViewBase::setCharsets(const QVector< QByteArray > &charsets)
{
m_charsets = charsets;
}
......
......@@ -177,7 +177,7 @@ public:
* the default values will be used.
*/
void setCryptoOptions(bool sign, bool encrypt, Kleo::CryptoMessageFormat format, bool neverEncryptDrafts = false);
void setCharsets(const QList< QByteArray > &charsets);
void setCharsets(const QVector<QByteArray> &charsets);
void setMDNRequested(bool mdnRequested);
void setUrgent(bool urgent);
......@@ -356,7 +356,7 @@ private:
QString m_from;
QString m_subject;
QStringList mExpandedTo, mExpandedCc, mExpandedBcc, mExpandedReplyTo;
QList< QByteArray > m_charsets;
QVector< QByteArray > m_charsets;
QMap<QByteArray, QString> m_customHeader;
int m_pendingQueueJobs = 0;
......
......@@ -962,7 +962,7 @@ void MessageFactoryNG::applyCharset(const KMime::Message::Ptr msg)
} else if (!codec->canEncode(body)) { // charset can't encode body, fall back to preferred
const QStringList charsets = MessageComposer::MessageComposerSettings::preferredCharsets();
QList<QByteArray> chars;
QVector<QByteArray> chars;
chars.reserve(charsets.count());
for (const QString &charset : charsets) {
chars << charset.toLatin1();
......
......@@ -21,7 +21,7 @@
*/
#include "job/attachmentjob.h"
#include <QVector>
#include "contentjobbase_p.h"
#include "part/globalpart.h"
#include "job/singlepartjob.h"
......
......@@ -90,7 +90,7 @@ bool MainTextJobPrivate::chooseCharsetAndEncode()
{
Q_Q(MainTextJob);
const QList<QByteArray> charsets = q->globalPart()->charsets(true);
const QVector<QByteArray> charsets = q->globalPart()->charsets(true);
if (charsets.isEmpty()) {
q->setError(JobBase::BugError);
q->setErrorText(i18n("No charsets were available for encoding. Please check your configuration and make sure it contains at least one charset for sending."));
......
......@@ -28,7 +28,7 @@ public:
{
}
QList<QByteArray> charsets;
QVector<QByteArray> charsets;
QWidget *parentWidgetForGui = nullptr;
bool guiEnabled = true;
bool fallbackCharsetEnabled = false;
......@@ -78,9 +78,9 @@ void GlobalPart::setFallbackCharsetEnabled(bool enabled)
d->fallbackCharsetEnabled = enabled;
}
QList<QByteArray> GlobalPart::charsets(bool forceFallback) const
QVector<QByteArray> GlobalPart::charsets(bool forceFallback) const
{
QList<QByteArray> ret = d->charsets;
QVector<QByteArray> ret = d->charsets;
if (d->fallbackCharsetEnabled || forceFallback) {
ret << "us-ascii";
ret << "utf-8";
......@@ -88,7 +88,7 @@ QList<QByteArray> GlobalPart::charsets(bool forceFallback) const
return ret;
}
void GlobalPart::setCharsets(const QList<QByteArray> &charsets)
void GlobalPart::setCharsets(const QVector<QByteArray> &charsets)
{
d->charsets = charsets;
}
......
......@@ -45,8 +45,8 @@ public:
Q_REQUIRED_RESULT bool isFallbackCharsetEnabled() const;
void setFallbackCharsetEnabled(bool enabled);
Q_REQUIRED_RESULT QList<QByteArray> charsets(bool forceFallback = false) const;
void setCharsets(const QList<QByteArray> &charsets);
Q_REQUIRED_RESULT QVector<QByteArray> charsets(bool forceFallback = false) const;
void setCharsets(const QVector<QByteArray> &charsets);
Q_REQUIRED_RESULT bool is8BitAllowed() const;
void set8BitAllowed(bool allowed);
......
......@@ -226,7 +226,7 @@ bool MessageComposer::Util::makeMultiMime(Kleo::CryptoMessageFormat format, bool
}
}
QByteArray MessageComposer::Util::selectCharset(const QList<QByteArray> &charsets, const QString &text)
QByteArray MessageComposer::Util::selectCharset(const QVector<QByteArray> &charsets, const QString &text)
{
for (const QByteArray &name : charsets) {
// We use KCharsets::codecForName() instead of QTextCodec::codecForName() here, because
......
......@@ -36,7 +36,7 @@ class Content;
namespace MessageComposer {
namespace Util {
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QByteArray selectCharset(const QList<QByteArray> &charsets, const QString &text);
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QByteArray selectCharset(const QVector<QByteArray> &charsets, const QString &text);
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QStringList AttachmentKeywords();
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QString cleanedUpHeaderString(const QString &s);
......
......@@ -186,7 +186,7 @@ void Aggregation::save(QDataStream &stream) const
stream << (int)mFillViewStrategy;
}
QList< QPair< QString, int > > Aggregation::enumerateGroupingOptions()
QVector< QPair< QString, int > > Aggregation::enumerateGroupingOptions()
{
return { {
i18nc("No grouping of messages", "None"), NoGrouping
......@@ -208,9 +208,9 @@ QList< QPair< QString, int > > Aggregation::enumerateGroupingOptions()
} };
}
QList< QPair< QString, int > > Aggregation::enumerateGroupExpandPolicyOptions(Grouping g)
QVector< QPair< QString, int > > Aggregation::enumerateGroupExpandPolicyOptions(Grouping g)
{
QList< QPair< QString, int > > ret;
QVector< QPair< QString, int > > ret;
if (g == NoGrouping) {
return ret;
}
......@@ -222,7 +222,7 @@ QList< QPair< QString, int > > Aggregation::enumerateGroupExpandPolicyOptions(Gr
return ret;
}
QList< QPair< QString, int > > Aggregation::enumerateThreadingOptions()
QVector< QPair< QString, int > > Aggregation::enumerateThreadingOptions()
{
return { {
i18nc("No threading of messages", "None"), NoThreading
......@@ -238,9 +238,9 @@ QList< QPair< QString, int > > Aggregation::enumerateThreadingOptions()
} };
}
QList< QPair< QString, int > > Aggregation::enumerateThreadLeaderOptions(Grouping g, Threading t)
QVector< QPair< QString, int > > Aggregation::enumerateThreadLeaderOptions(Grouping g, Threading t)
{
QList< QPair< QString, int > > ret;
QVector< QPair< QString, int > > ret;
if (t == NoThreading) {
return ret;
}
......@@ -252,7 +252,7 @@ QList< QPair< QString, int > > Aggregation::enumerateThreadLeaderOptions(Groupin
return ret;
}
QList< QPair< QString, int > > Aggregation::enumerateThreadExpandPolicyOptions(Threading t)
QVector< QPair< QString, int > > Aggregation::enumerateThreadExpandPolicyOptions(Threading t)
{
if (t == NoThreading) {
return {};
......@@ -272,7 +272,7 @@ QList< QPair< QString, int > > Aggregation::enumerateThreadExpandPolicyOptions(T
} };
}
QList< QPair< QString, int > > Aggregation::enumerateFillViewStrategyOptions()
QVector< QPair< QString, int > > Aggregation::enumerateFillViewStrategyOptions()
{
return { {
i18n("Favor Interactivity"), FavorInteractivity
......
......@@ -156,7 +156,7 @@ public:
* pairs in that the first item is the localized description of the
* option value and the second item is the integer option value itself.
*/
static QList< QPair< QString, int > > enumerateGroupingOptions();
static QVector< QPair< QString, int > > enumerateGroupingOptions();
/**
* Returns the current GroupExpandPolicy.
......@@ -181,7 +181,7 @@ public:
* of the option value and the second item is the integer option value itself.
* If the returned list is empty then the value of the option is meaningless in the current context.
*/
static QList< QPair< QString, int > > enumerateGroupExpandPolicyOptions(Grouping g);
static QVector< QPair< QString, int > > enumerateGroupExpandPolicyOptions(Grouping g);
/**
* Returns the current threading method.
......@@ -204,7 +204,7 @@ public:
* The returned descriptors are pairs in that the first item is the localized description
* of the option value and the second item is the integer option value itself.
*/
static QList< QPair< QString, int > > enumerateThreadingOptions();
static QVector< QPair< QString, int > > enumerateThreadingOptions();
/**
* Returns the current thread leader determination method.
......@@ -231,7 +231,7 @@ public:
* of the option value and the second item is the integer option value itself.
* If the returned list is empty then the value of the option is meaningless in the current context.
*/
static QList< QPair< QString, int > > enumerateThreadLeaderOptions(Grouping g, Threading t);
static QVector< QPair< QString, int > > enumerateThreadLeaderOptions(Grouping g, Threading t);
/**
* Returns the current thread expand policy.
......@@ -257,7 +257,7 @@ public:
* of the option value and the second item is the integer option value itself.
* If the returned list is empty then the value of the option is meaningless in the current context.
*/
static QList< QPair< QString, int > > enumerateThreadExpandPolicyOptions(Threading t);
static QVector< QPair< QString, int > > enumerateThreadExpandPolicyOptions(Threading t);
/**
* Returns the current fill view strategy.
......@@ -280,7 +280,7 @@ public:
* The returned descriptors are pairs in that the first item is the localized description
* of the option value and the second item is the integer option value itself.
*/
static QList< QPair< QString, int > > enumerateFillViewStrategyOptions();
static QVector< QPair< QString, int > > enumerateFillViewStrategyOptions();
/**
* Pure virtual reimplemented from OptionSet.
......
......@@ -76,9 +76,9 @@ void SortOrder::setMessageSortDirection(SortOrder::SortDirection messageSortDire
mMessageSortDirection = messageSortDirection;
}
QList<QPair<QString, int> > SortOrder::enumerateMessageSortingOptions(Aggregation::Threading t)
QVector<QPair<QString, int> > SortOrder::enumerateMessageSortingOptions(Aggregation::Threading t)
{
QList<QPair<QString, int> > ret;
QVector<QPair<QString, int> > ret;
ret.append({ i18n("None (Storage Order)"), SortOrder::NoMessageSorting });
ret.append({ i18n("By Date/Time"), SortOrder::SortMessagesByDateTime });
if (t != Aggregation::NoThreading) {
......@@ -96,9 +96,9 @@ QList<QPair<QString, int> > SortOrder::enumerateMessageSortingOptions(Aggregatio
return ret;
}
QList<QPair<QString, int> > SortOrder::enumerateMessageSortDirectionOptions(MessageSorting ms)
QVector<QPair<QString, int> > SortOrder::enumerateMessageSortDirectionOptions(MessageSorting ms)
{
QList<QPair<QString, int> > ret;
QVector<QPair<QString, int> > ret;
if (ms == SortOrder::NoMessageSorting) {
return ret;
}
......@@ -117,9 +117,9 @@ QList<QPair<QString, int> > SortOrder::enumerateMessageSortDirectionOptions(Mess
return ret;
}
QList<QPair<QString, int> > SortOrder::enumerateGroupSortingOptions(Aggregation::Grouping g)
QVector<QPair<QString, int> > SortOrder::enumerateGroupSortingOptions(Aggregation::Grouping g)
{
QList<QPair< QString, int> > ret;
QVector<QPair< QString, int> > ret;
if (g == Aggregation::NoGrouping) {
return ret;
}
......@@ -141,9 +141,9 @@ QList<QPair<QString, int> > SortOrder::enumerateGroupSortingOptions(Aggregation:
return ret;
}
QList<QPair<QString, int> > SortOrder::enumerateGroupSortDirectionOptions(Aggregation::Grouping g, GroupSorting gs)
QVector<QPair<QString, int> > SortOrder::enumerateGroupSortDirectionOptions(Aggregation::Grouping g, GroupSorting gs)
{
QList<QPair<QString, int> > ret;
QVector<QPair<QString, int> > ret;
if (g == Aggregation::NoGrouping || gs == SortOrder::NoGroupSorting) {
return ret;
}
......@@ -158,7 +158,7 @@ QList<QPair<QString, int> > SortOrder::enumerateGroupSortDirectionOptions(Aggreg
return ret;
}
typedef QList<QPair<QString, int> > OptionList;
typedef QVector<QPair<QString, int> > OptionList;
static bool optionListHasOption(const OptionList &optionList, int optionValue, int defaultOptionValue)
{
for (const auto &pair : optionList) {
......
......@@ -136,7 +136,7 @@ public:
* The returned descriptors are pairs in that the first item is the localized description
* of the option value and the second item is the integer option value itself.
*/
static QList< QPair< QString, int > > enumerateMessageSortingOptions(Aggregation::Threading t);
static QVector<QPair<QString, int> > enumerateMessageSortingOptions(Aggregation::Threading t);
/**
* Enumerates the available message sorting directions for the specified MessageSorting option.
......@@ -144,7 +144,7 @@ public:
* of the option value and the second item is the integer option value itself.
* If the returned list is empty then the value of the option is meaningless in the current context.
*/
static QList< QPair< QString, int > > enumerateMessageSortDirectionOptions(MessageSorting ms);
static QVector< QPair< QString, int > > enumerateMessageSortDirectionOptions(MessageSorting ms);
/**
* Enumerates the group sorting options compatible with the specified Grouping.
......@@ -152,7 +152,7 @@ public:
* of the option value and the second item is the integer option value itself.
* If the returned list is empty then the value of the option is meaningless in the current context.
*/
static QList< QPair< QString, int > > enumerateGroupSortingOptions(Aggregation::Grouping g);
static QVector< QPair< QString, int > > enumerateGroupSortingOptions(Aggregation::Grouping g);
/**
* Enumerates the group sort direction options compatible with the specified Grouping and GroupSorting.
......@@ -160,7 +160,7 @@ public:
* of the option value and the second item is the integer option value itself.
* If the returned list is empty then the value of the option is meaningless in the current context.
*/
static QList< QPair< QString, int > > enumerateGroupSortDirectionOptions(Aggregation::Grouping g, GroupSorting groupSorting);
static QVector< QPair< QString, int > > enumerateGroupSortDirectionOptions(Aggregation::Grouping g, GroupSorting groupSorting);
/**
* Checks if this sort order can be used in combination with the given aggregation.
......
......@@ -1062,7 +1062,7 @@ void Theme::setGroupHeaderBackgroundStyle(Theme::GroupHeaderBackgroundStyle grou
mGroupHeaderBackgroundStyle = groupHeaderBackgroundStyle;
}
QList<QPair<QString, int> > Theme::enumerateViewHeaderPolicyOptions()
QVector<QPair<QString, int> > Theme::enumerateViewHeaderPolicyOptions()
{
return { {
i18n("Never Show"), NeverShowHeader
......@@ -1072,7 +1072,7 @@ QList<QPair<QString, int> > Theme::enumerateViewHeaderPolicyOptions()
} };
}
QList<QPair<QString, int> > Theme::enumerateGroupHeaderBackgroundStyles()
QVector<QPair<QString, int> > Theme::enumerateGroupHeaderBackgroundStyles()
{
return { {
i18n("Plain Rectangles"), PlainRect
......
......@@ -965,7 +965,7 @@ public:
* The returned descriptors are pairs in that the first item is the localized description
* of the option value and the second item is the integer option value itself.
*/
static QList< QPair< QString, int > > enumerateGroupHeaderBackgroundStyles();
static QVector< QPair< QString, int > > enumerateGroupHeaderBackgroundStyles();
/**
* Returns the currently set ViewHeaderPolicy
......@@ -994,7 +994,7 @@ public:
* The returned descriptors are pairs in that the first item is the localized description
* of the option value and the second item is the integer option value itself.
*/
static QList< QPair< QString, int > > enumerateViewHeaderPolicyOptions();
static QVector<QPair<QString, int> > enumerateViewHeaderPolicyOptions();
inline const QPixmap *pixmap(ThemeIcon icon) const
{
......
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