Commit 8bf2ad8d authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Modernize MessageList

Use range-based for loops and "auto" where it makes sense.
parent da743944
......@@ -202,14 +202,12 @@ void Aggregation::save(QDataStream &stream) const
QList< QPair< QString, int > > Aggregation::enumerateGroupingOptions()
{
QList< QPair< QString, int > > ret;
ret.append(QPair< QString, int >(i18nc("No grouping of messages", "None"), NoGrouping));
ret.append(QPair< QString, int >(i18n("By Exact Date (of Thread Leaders)"), GroupByDate));
ret.append(QPair< QString, int >(i18n("By Smart Date Ranges (of Thread Leaders)"), GroupByDateRange));
ret.append(QPair< QString, int >(i18n("By Smart Sender/Receiver"), GroupBySenderOrReceiver));
ret.append(QPair< QString, int >(i18n("By Sender"), GroupBySender));
ret.append(QPair< QString, int >(i18n("By Receiver"), GroupByReceiver));
return ret;
return { { i18nc("No grouping of messages", "None"), NoGrouping },
{ i18n("By Exact Date (of Thread Leaders)"), GroupByDate },
{ i18n("By Smart Date Ranges (of Thread Leaders)"), GroupByDateRange },
{ i18n("By Smart Sender/Receiver"), GroupBySenderOrReceiver },
{ i18n("By Sender"), GroupBySender },
{ i18n("By Receiver"), GroupByReceiver } };
}
QList< QPair< QString, int > > Aggregation::enumerateGroupExpandPolicyOptions(Grouping g)
......@@ -218,22 +216,21 @@ QList< QPair< QString, int > > Aggregation::enumerateGroupExpandPolicyOptions(Gr
if (g == NoGrouping) {
return ret;
}
ret.append(QPair< QString, int >(i18n("Never Expand Groups"), NeverExpandGroups));
ret.append({ i18n("Never Expand Groups"), NeverExpandGroups });
if ((g == GroupByDate) || (g == GroupByDateRange)) {
ret.append(QPair< QString, int >(i18n("Expand Recent Groups"), ExpandRecentGroups));
ret.append({ i18n("Expand Recent Groups"), ExpandRecentGroups });
}
ret.append(QPair< QString, int >(i18n("Always Expand Groups"), AlwaysExpandGroups));
ret.append({ i18n("Always Expand Groups"), AlwaysExpandGroups });
return ret;
}
QList< QPair< QString, int > > Aggregation::enumerateThreadingOptions()
{
QList< QPair< QString, int > > ret;
ret.append(QPair< QString, int >(i18nc("No threading of messages", "None"), NoThreading));
ret.append(QPair< QString, int >(i18n("Perfect Only"), PerfectOnly));
ret.append(QPair< QString, int >(i18n("Perfect and by References"), PerfectAndReferences));
ret.append(QPair< QString, int >(i18n("Perfect, by References and by Subject"), PerfectReferencesAndSubject));
return ret;
return { { i18nc("No threading of messages", "None"), NoThreading },
{ i18n("Perfect Only"), PerfectOnly },
{ i18n("Perfect and by References"), PerfectAndReferences },
{ i18n("Perfect, by References and by Subject"), PerfectReferencesAndSubject } };
}
QList< QPair< QString, int > > Aggregation::enumerateThreadLeaderOptions(Grouping g, Threading t)
......@@ -242,33 +239,31 @@ QList< QPair< QString, int > > Aggregation::enumerateThreadLeaderOptions(Groupin
if (t == NoThreading) {
return ret;
}
ret.append(QPair< QString, int >(i18n("Topmost Message"), TopmostMessage));
ret.append({ i18n("Topmost Message"), TopmostMessage });
if ((g != GroupByDate) && (g != GroupByDateRange)) {
return ret;
}
ret.append(QPair< QString, int >(i18n("Most Recent Message"), MostRecentMessage));
ret.append({ i18n("Most Recent Message"), MostRecentMessage });
return ret;
}
QList< QPair< QString, int > > Aggregation::enumerateThreadExpandPolicyOptions(Threading t)
{
QList< QPair< QString, int > > ret;
if (t == NoThreading) {
return ret;
return {};
}
ret.append(QPair< QString, int >(i18n("Never Expand Threads"), NeverExpandThreads));
ret.append(QPair< QString, int >(i18n("Expand Threads With Unread Messages"), ExpandThreadsWithUnreadMessages));
ret.append(QPair< QString, int >(i18n("Expand Threads With Unread or Important Messages"), ExpandThreadsWithUnreadOrImportantMessages));
ret.append(QPair< QString, int >(i18n("Always Expand Threads"), AlwaysExpandThreads));
return ret;
return { { i18n("Never Expand Threads"), NeverExpandThreads },
{ i18n("Expand Threads With Unread Messages"), ExpandThreadsWithUnreadMessages },
{ i18n("Expand Threads With Unread or Important Messages"), ExpandThreadsWithUnreadOrImportantMessages },
{ i18n("Always Expand Threads"), AlwaysExpandThreads } };
}
QList< QPair< QString, int > > Aggregation::enumerateFillViewStrategyOptions()
{
QList< QPair< QString, int > > ret;
ret.append(QPair< QString, int >(i18n("Favor Interactivity"), FavorInteractivity));
ret.append(QPair< QString, int >(i18n("Favor Speed"), FavorSpeed));
ret.append(QPair< QString, int >(i18n("Batch Job (No Interactivity)"), BatchNoInteractivity));
return ret;
return { { i18n("Favor Interactivity"), FavorInteractivity },
{ i18n("Favor Speed"), FavorSpeed },
{ i18n("Batch Job (No Interactivity)"), BatchNoInteractivity } };
}
......@@ -209,13 +209,12 @@ void Item::childItemStats(ChildItemStats &stats) const
Q_ASSERT(d_ptr->mChildItems);
stats.mTotalChildCount += d_ptr->mChildItems->count();
QList< Item * >::ConstIterator end(d_ptr->mChildItems->constEnd());
for (QList< Item * >::ConstIterator it = d_ptr->mChildItems->constBegin(); it != end; ++it) {
if (!(*it)->status().isRead()) {
for (const auto child : qAsConst(*d_ptr->mChildItems)) {
if (!child->status().isRead()) {
stats.mUnreadChildCount++;
}
if ((*it)->d_ptr->mChildItems) {
(*it)->childItemStats(stats);
if (child->d_ptr->mChildItems) {
child->childItemStats(stats);
}
}
}
......@@ -455,10 +454,9 @@ bool Item::recomputeMaxDate()
time_t newMaxDate = d_ptr->mDate;
if (d_ptr->mChildItems) {
QList< Item * >::ConstIterator end = d_ptr->mChildItems->constEnd();
for (QList< Item * >::ConstIterator it = d_ptr->mChildItems->constBegin(); it != end; ++it) {
if ((*it)->d_ptr->mMaxDate > newMaxDate) {
newMaxDate = (*it)->d_ptr->mMaxDate;
for (auto child : qAsConst(*d_ptr->mChildItems)) {
if (child->d_ptr->mMaxDate > newMaxDate) {
newMaxDate = child->d_ptr->mMaxDate;
}
}
}
......@@ -525,14 +523,12 @@ void Item::setViewable(Model *model, bool bViewable)
d_ptr->mIsViewable = true;
}
QList< Item * >::ConstIterator end(d_ptr->mChildItems->constEnd());
for (QList< Item * >::ConstIterator it = d_ptr->mChildItems->constBegin(); it != end; ++it) {
(*it)->setViewable(model, bViewable);
for (const auto child : qAsConst(*d_ptr->mChildItems)) {
child->setViewable(model, bViewable);
}
} else {
QList< Item * >::ConstIterator end(d_ptr->mChildItems->constEnd());
for (QList< Item * >::ConstIterator it = d_ptr->mChildItems->constBegin(); it != end; ++it) {
(*it)->setViewable(model, bViewable);
for (const auto child : qAsConst(*d_ptr->mChildItems)) {
child->setViewable(model, bViewable);
}
// It seems that we can avoid removing child items here since the parent has been removed: this is a hack tough
......@@ -756,9 +752,8 @@ void Item::dump(const QString &prefix)
return;
}
QList< Item * >::ConstIterator end(d_ptr->mChildItems->constEnd());
for (QList< Item * >::ConstIterator it = d_ptr->mChildItems->constBegin(); it != end; ++it) {
(*it)->dump(nPrefix);
for (const auto child : qAsConst(*d_ptr->mChildItems)) {
child->dump(nPrefix);
}
}
......
......@@ -59,8 +59,10 @@ Manager::Manager()
mCachedLocalizedUnknownText = i18nc("Unknown date", "Unknown");
loadConfiguration();
connect(MessageListSettings::self(), &MessageListSettings::configChanged, this, &Manager::reloadGlobalConfiguration);
connect(MessageCore::MessageCoreSettings::self(), &MessageCore::MessageCoreSettings::configChanged, this, &Manager::reloadGlobalConfiguration);
connect(MessageListSettings::self(), &MessageListSettings::configChanged,
this, &Manager::reloadGlobalConfiguration);
connect(MessageCore::MessageCoreSettings::self(), &MessageCore::MessageCoreSettings::configChanged,
this, &Manager::reloadGlobalConfiguration);
}
Manager::~Manager()
......
......@@ -196,14 +196,13 @@ void MessageItemPrivate::fillTagList(const Akonadi::Tag::List &taglist)
for (const Akonadi::Tag &tag : taglist) {
QString symbol = QStringLiteral("mail-tagged");
Akonadi::TagAttribute *attr = tag.attribute<Akonadi::TagAttribute>();
auto attr = tag.attribute<Akonadi::TagAttribute>();
if (attr) {
if (!attr->iconName().isEmpty()) {
symbol = attr->iconName();
}
}
MessageItem::Tag *messageListTag =
new MessageItem::Tag(SmallIcon(symbol), tag.name(), tag.url().url());
auto messageListTag = new MessageItem::Tag(SmallIcon(symbol), tag.name(), tag.url().url());
if (attr) {
messageListTag->setTextColor(attr->textColor());
......@@ -271,8 +270,8 @@ QString MessageItem::annotation() const
{
Q_D(const MessageItem);
if (d->mAkonadiItem.hasAttribute<Akonadi::EntityAnnotationsAttribute>()) {
Akonadi::EntityAnnotationsAttribute *attr = d->mAkonadiItem.attribute<Akonadi::EntityAnnotationsAttribute>();
const QMap<QByteArray, QByteArray> annotations = attr->annotations();
auto attr = d->mAkonadiItem.attribute<Akonadi::EntityAnnotationsAttribute>();
const auto annotations = attr->annotations();
QByteArray annot = annotations.value("/private/comment");
if (!annot.isEmpty()) {
return QString::fromLatin1(annot);
......@@ -570,7 +569,7 @@ QString MessageItem::accessibleText(const Theme *theme, int columnIndex)
for (Theme::Row *row : rows) {
QStringList leftStrings;
QStringList rightStrings;
const QList<Theme::ContentItem *> leftItems = row->leftItems();
const auto leftItems = row->leftItems();
leftStrings.reserve(leftItems.count());
for (Theme::ContentItem *contentItem : qAsConst(leftItems)) {
leftStrings.append(accessibleTextForField(contentItem->type()));
......@@ -589,14 +588,13 @@ QString MessageItem::accessibleText(const Theme *theme, int columnIndex)
void MessageItem::subTreeToList(QList< MessageItem * > &list)
{
list.append(this);
QList< Item * > *childList = childItems();
const auto childList = childItems();
if (!childList) {
return;
}
QList< Item * >::ConstIterator end(childList->constEnd());
for (QList< Item * >::ConstIterator it = childList->constBegin(); it != end; ++it) {
Q_ASSERT((*it)->type() == Item::Message);
static_cast< MessageItem * >(*it)->subTreeToList(list);
for (const auto child : *childList) {
Q_ASSERT(child->type() == Item::Message);
static_cast<MessageItem *>(child)->subTreeToList(list);
}
}
......@@ -709,7 +707,7 @@ void TagCache::retrieveTags(const Akonadi::Tag::List &tags, MessageItemPrivate *
}
//Because fillTagList expects to be called once we either fetch all or none
if (!toFetch.isEmpty()) {
Akonadi::TagFetchJob *tagFetchJob = new Akonadi::TagFetchJob(tags, this);
auto tagFetchJob = new Akonadi::TagFetchJob(tags, this);
tagFetchJob->fetchScope().fetchAttribute<Akonadi::TagAttribute>();
connect(tagFetchJob, &Akonadi::TagFetchJob::result, this, &TagCache::onTagsFetched);
mRequests.insert(tagFetchJob, m);
......@@ -732,12 +730,11 @@ void TagCache::onTagsFetched(KJob *job)
qCWarning(MESSAGELIST_LOG) << "Failed to fetch tags: " << job->errorString();
return;
}
Akonadi::TagFetchJob *fetchJob = static_cast<Akonadi::TagFetchJob *>(job);
auto fetchJob = static_cast<Akonadi::TagFetchJob *>(job);
Q_FOREACH (const Akonadi::Tag &tag, fetchJob->tags()) {
mCache.insert(tag.id(), new Akonadi::Tag(tag));
}
MessageItemPrivate *m = mRequests.take(fetchJob);
if (m) {
if (auto m = mRequests.take(fetchJob)) {
m->fillTagList(fetchJob->tags());
}
}
......@@ -25,7 +25,7 @@ using namespace MessageList::Core;
MessageItemSetManager::MessageItemSetManager()
{
mSets = new QHash< MessageItemSetReference, QHash< MessageItem *, MessageItem * > * >();
mSets = new QHash<MessageItemSetReference, QHash<MessageItem *, MessageItem *> *>();
}
MessageItemSetManager::~MessageItemSetManager()
......@@ -36,11 +36,9 @@ MessageItemSetManager::~MessageItemSetManager()
void MessageItemSetManager::clearAllSets()
{
QHash< MessageItemSetReference, QHash< MessageItem *, MessageItem * > * >::ConstIterator end(mSets->constEnd());
for (QHash< MessageItemSetReference, QHash< MessageItem *, MessageItem * > * >::ConstIterator it = mSets->constBegin(); it != end; ++it) {
for (auto it = mSets->cbegin(), end = mSets->cend(); it != end; ++it) {
delete(*it);
}
mSets->clear();
}
......@@ -51,46 +49,37 @@ int MessageItemSetManager::setCount() const
void MessageItemSetManager::removeSet(MessageItemSetReference ref)
{
QHash< MessageItem *, MessageItem * > *set = mSets->value(static_cast< unsigned long int >(ref), nullptr);
auto set = mSets->value(static_cast<ulong>(ref), nullptr);
if (!set) {
return;
}
mSets->remove(static_cast< unsigned long int >(ref));
mSets->remove(static_cast<ulong>(ref));
delete set;
}
QList< MessageItem * > MessageItemSetManager::messageItems(MessageItemSetReference ref)
{
QList< MessageItem * > ret;
QHash< MessageItem *, MessageItem * > *set = mSets->value(static_cast< unsigned long int >(ref), nullptr);
auto *set = mSets->value(static_cast<ulong>(ref), nullptr);
if (!set) {
return ret;
}
QHash< MessageItem *, MessageItem * >::ConstIterator end(set->constEnd());
ret.reserve(set->count());
for (QHash< MessageItem *, MessageItem * >::ConstIterator it = set->constBegin(); it != end; ++it) {
ret.append(*it);
return {};
}
return ret;
return set->values();
}
void MessageItemSetManager::removeMessageItemFromAllSets(MessageItem *mi)
{
QList< MessageItemSetReference > setsToBeKilled;
QHash< MessageItemSetReference, QHash< MessageItem *, MessageItem * > * >::ConstIterator end(mSets->end());
for (QHash< MessageItemSetReference, QHash< MessageItem *, MessageItem * > * >::ConstIterator it = mSets->constBegin(); it != end; ++it) {
for (auto it = mSets->cbegin(), end = mSets->cend(); it != end; ++it) {
(*it)->remove(mi);
if ((*it)->isEmpty()) {
setsToBeKilled.append(it.key());
}
}
QList< MessageItemSetReference >::ConstIterator endit2(setsToBeKilled.constEnd());
for (QList< MessageItemSetReference >::ConstIterator it2 = setsToBeKilled.constBegin(); it2 != endit2; ++it2) {
removeSet(*it2);
for (const auto set : setsToBeKilled) {
removeSet(set);
}
}
......@@ -99,7 +88,7 @@ MessageItemSetReference MessageItemSetManager::createSet()
static unsigned long int uNextId = 0;
uNextId++;
QHash< MessageItem *, MessageItem * > *set = mSets->value(uNextId, nullptr);
auto set = mSets->value(uNextId, nullptr);
// Here we assume that having 2^32 sets is impossible
// (that would be _at_least_ 2^32 * 8 bytes of allocated memory which is
......@@ -110,7 +99,7 @@ MessageItemSetReference MessageItemSetManager::createSet()
set = mSets->value(uNextId, nullptr);
}
set = new QHash< MessageItem *, MessageItem * >();
set = new QHash<MessageItem *, MessageItem *>();
mSets->insert(uNextId, set);
return static_cast< MessageItemSetReference >(uNextId);
......@@ -118,7 +107,7 @@ MessageItemSetReference MessageItemSetManager::createSet()
bool MessageItemSetManager::addMessageItem(MessageItemSetReference ref, MessageItem *mi)
{
QHash< MessageItem *, MessageItem * > *set = mSets->value(static_cast< unsigned long int >(ref), nullptr);
auto set = mSets->value(static_cast<ulong>(ref), nullptr);
if (!set) {
return false;
}
......
This diff is collapsed.
......@@ -48,9 +48,8 @@ public:
~RowShift()
{
QHash< int, ModelInvariantIndex * >::ConstIterator end(mInvariantHash->constEnd());
for (QHash< int, ModelInvariantIndex * >::ConstIterator it = mInvariantHash->constBegin(); it != end; ++it) {
(*it)->d->setRowMapper(nullptr);
for (const auto idx : qAsConst(*mInvariantHash)) {
idx->d->setRowMapper(nullptr);
}
delete mInvariantHash;
}
......@@ -84,9 +83,8 @@ ModelInvariantRowMapper::~ModelInvariantRowMapper()
}
// FIXME: optimize this (it CAN be optimized)
QHash< int, ModelInvariantIndex * >::ConstIterator end(d->mCurrentInvariantHash->constEnd());
for (QHash< int, ModelInvariantIndex * >::ConstIterator it = d->mCurrentInvariantHash->constBegin(); it != end; ++it) {
(*it)->d->setRowMapper(nullptr);
for (const auto idx : qAsConst(*d->mCurrentInvariantHash)) {
idx->d->setRowMapper(nullptr);
}
delete d->mCurrentInvariantHash;
......@@ -371,7 +369,7 @@ QList< ModelInvariantIndex * > *ModelInvariantRowMapper::modelIndexRowRangeToMod
// Find the invariants in range.
// It's somewhat impossible to split this in chunks.
QList< ModelInvariantIndex * > *invariantList = new QList< ModelInvariantIndex * >();
auto invariantList = new QList< ModelInvariantIndex * >();
const int end = startIndexRow + count;
for (int idx = startIndexRow; idx < end; idx++) {
......@@ -498,7 +496,7 @@ QList< ModelInvariantIndex * > *ModelInvariantRowMapper::modelRowsRemoved(int mo
// In most cases it's a relatively small sweep (and it's done once).
// It's somewhat impossible to split this in chunks.
QList< ModelInvariantIndex * > *deadInvariants = new QList< ModelInvariantIndex * >();
auto deadInvariants = new QList< ModelInvariantIndex * >();
const int end = modelIndexRowPosition + count;
for (int idx = modelIndexRowPosition; idx < end; idx++) {
......@@ -569,8 +567,8 @@ void ModelInvariantRowMapper::modelReset()
// FIXME: optimize this (it probably can be optimized by providing a more complex user interface)
QHash< int, ModelInvariantIndex * >::ConstIterator end(d->mCurrentInvariantHash->constEnd());
for (QHash< int, ModelInvariantIndex * >::ConstIterator it = d->mCurrentInvariantHash->constBegin(); it != end; ++it) {
(*it)->d->setRowMapper(nullptr);
for (const auto idx : qAsConst(*d->mCurrentInvariantHash)) {
idx->d->setRowMapper(nullptr);
}
d->mCurrentInvariantHash->clear();
......@@ -614,8 +612,8 @@ void ModelInvariantRowMapperPrivate::slotPerformLazyUpdate()
RowShift *shift = mRowShiftList->at(0);
// and update the invariants that belong to it
QHash< int, ModelInvariantIndex * >::Iterator it = shift->mInvariantHash->begin();
QHash< int, ModelInvariantIndex * >::Iterator end = shift->mInvariantHash->end();
auto it = shift->mInvariantHash->begin();
auto end = shift->mInvariantHash->end();
while (it != end) {
ModelInvariantIndex *invariant = *it;
......
......@@ -76,29 +76,29 @@ void SortOrder::setMessageSortDirection(SortOrder::SortDirection messageSortDire
mMessageSortDirection = messageSortDirection;
}
QList< QPair< QString, int > > SortOrder::enumerateMessageSortingOptions(Aggregation::Threading t)
QList<QPair<QString, int>> SortOrder::enumerateMessageSortingOptions(Aggregation::Threading t)
{
QList< QPair< QString, int > > ret;
ret.append(QPair< QString, int >(i18n("None (Storage Order)"), SortOrder::NoMessageSorting));
ret.append(QPair< QString, int >(i18n("By Date/Time"), SortOrder::SortMessagesByDateTime));
QList<QPair<QString, int>> ret;
ret.append({ i18n("None (Storage Order)"), SortOrder::NoMessageSorting });
ret.append({ i18n("By Date/Time"), SortOrder::SortMessagesByDateTime });
if (t != Aggregation::NoThreading) {
ret.append(QPair< QString, int >(i18n("By Date/Time of Most Recent in Subtree"), SortOrder::SortMessagesByDateTimeOfMostRecent));
ret.append({ i18n("By Date/Time of Most Recent in Subtree"), SortOrder::SortMessagesByDateTimeOfMostRecent });
}
ret.append(QPair< QString, int >(i18n("By Sender"), SortOrder::SortMessagesBySender));
ret.append(QPair< QString, int >(i18n("By Receiver"), SortOrder::SortMessagesByReceiver));
ret.append(QPair< QString, int >(i18n("By Smart Sender/Receiver"), SortOrder::SortMessagesBySenderOrReceiver));
ret.append(QPair< QString, int >(i18n("By Subject"), SortOrder::SortMessagesBySubject));
ret.append(QPair< QString, int >(i18n("By Size"), SortOrder::SortMessagesBySize));
ret.append(QPair< QString, int >(i18n("By Action Item Status"), SortOrder::SortMessagesByActionItemStatus));
ret.append(QPair< QString, int >(i18n("By Unread Status"), SortOrder::SortMessagesByUnreadStatus));
ret.append(QPair< QString, int >(i18n("By Important Status"), SortOrder::SortMessagesByImportantStatus));
ret.append(QPair< QString, int >(i18n("By Attachment Status"), SortOrder::SortMessagesByAttachmentStatus));
ret.append({ i18n("By Sender"), SortOrder::SortMessagesBySender });
ret.append({ i18n("By Receiver"), SortOrder::SortMessagesByReceiver });
ret.append({ i18n("By Smart Sender/Receiver"), SortOrder::SortMessagesBySenderOrReceiver });
ret.append({ i18n("By Subject"), SortOrder::SortMessagesBySubject });
ret.append({ i18n("By Size"), SortOrder::SortMessagesBySize });
ret.append({ i18n("By Action Item Status"), SortOrder::SortMessagesByActionItemStatus });
ret.append({ i18n("By Unread Status"), SortOrder::SortMessagesByUnreadStatus });
ret.append({ i18n("By Important Status"), SortOrder::SortMessagesByImportantStatus });
ret.append({ i18n("By Attachment Status"), SortOrder::SortMessagesByAttachmentStatus });
return ret;
}
QList< QPair< QString, int > > SortOrder::enumerateMessageSortDirectionOptions(MessageSorting ms)
QList<QPair<QString, int>> SortOrder::enumerateMessageSortDirectionOptions(MessageSorting ms)
{
QList< QPair< QString, int > > ret;
QList<QPair<QString, int>> ret;
if (ms == SortOrder::NoMessageSorting) {
return ret;
}
......@@ -107,64 +107,63 @@ QList< QPair< QString, int > > SortOrder::enumerateMessageSortDirectionOptions(M
(ms == SortOrder::SortMessagesByDateTime) ||
(ms == SortOrder::SortMessagesByDateTimeOfMostRecent)
) {
ret.append(QPair< QString, int >(i18n("Least Recent on Top"), SortOrder::Ascending));
ret.append(QPair< QString, int >(i18n("Most Recent on Top"), SortOrder::Descending));
ret.append({ i18n("Least Recent on Top"), SortOrder::Ascending });
ret.append({ i18n("Most Recent on Top"), SortOrder::Descending });
return ret;
}
ret.append(QPair< QString, int >(i18nc("Sort order for messages", "Ascending"), SortOrder::Ascending));
ret.append(QPair< QString, int >(i18nc("Sort order for messages", "Descending"), SortOrder::Descending));
ret.append({ i18nc("Sort order for messages", "Ascending"), SortOrder::Ascending });
ret.append({ i18nc("Sort order for messages", "Descending"), SortOrder::Descending });
return ret;
}
QList< QPair< QString, int > > SortOrder::enumerateGroupSortingOptions(Aggregation::Grouping g)
QList<QPair<QString, int>> SortOrder::enumerateGroupSortingOptions(Aggregation::Grouping g)
{
QList< QPair< QString, int > > ret;
QList<QPair< QString, int>> ret;
if (g == Aggregation::NoGrouping) {
return ret;
}
if ((g == Aggregation::GroupByDate) || (g == Aggregation::GroupByDateRange)) {
ret.append(QPair< QString, int >(i18n("by Date/Time"), SortOrder::SortGroupsByDateTime));
ret.append({ i18n("by Date/Time"), SortOrder::SortGroupsByDateTime });
} else {
ret.append(QPair< QString, int >(i18n("None (Storage Order)"), SortOrder::NoGroupSorting));
ret.append(QPair< QString, int >(i18n("by Date/Time of Most Recent Message in Group"), SortOrder::SortGroupsByDateTimeOfMostRecent));
ret.append({ i18n("None (Storage Order)"), SortOrder::NoGroupSorting });
ret.append({ i18n("by Date/Time of Most Recent Message in Group"), SortOrder::SortGroupsByDateTimeOfMostRecent });
}
if (g == Aggregation::GroupBySenderOrReceiver) {
ret.append(QPair< QString, int >(i18n("by Sender/Receiver"), SortOrder::SortGroupsBySenderOrReceiver));
ret.append({ i18n("by Sender/Receiver"), SortOrder::SortGroupsBySenderOrReceiver });
} else if (g == Aggregation::GroupBySender) {
ret.append(QPair< QString, int >(i18n("by Sender"), SortOrder::SortGroupsBySender));
ret.append({ i18n("by Sender"), SortOrder::SortGroupsBySender });
} else if (g == Aggregation::GroupByReceiver) {
ret.append(QPair< QString, int >(i18n("by Receiver"), SortOrder::SortGroupsByReceiver));
ret.append({ i18n("by Receiver"), SortOrder::SortGroupsByReceiver });
}
return ret;
}
QList< QPair< QString, int > > SortOrder::enumerateGroupSortDirectionOptions(Aggregation::Grouping g,
QList<QPair<QString, int>> SortOrder::enumerateGroupSortDirectionOptions(Aggregation::Grouping g,
GroupSorting gs)
{
QList< QPair< QString, int > > ret;
QList<QPair<QString, int>> ret;
if (g == Aggregation::NoGrouping || gs == SortOrder::NoGroupSorting) {
return ret;
}
if (gs == SortOrder::SortGroupsByDateTimeOfMostRecent) {
ret.append(QPair< QString, int >(i18n("Least Recent on Top"), SortOrder::Ascending));
ret.append(QPair< QString, int >(i18n("Most Recent on Top"), SortOrder::Descending));
ret.append({ i18n("Least Recent on Top"), SortOrder::Ascending });
ret.append({ i18n("Most Recent on Top"), SortOrder::Descending });
return ret;
}
ret.append(QPair< QString, int >(i18nc("Sort order for mail groups", "Ascending"), SortOrder::Ascending));
ret.append(QPair< QString, int >(i18nc("Sort order for mail groups", "Descending"), SortOrder::Descending));
ret.append({ i18nc("Sort order for mail groups", "Ascending"), SortOrder::Ascending });
ret.append({ i18nc("Sort order for mail groups", "Descending"), SortOrder::Descending });
return ret;
}
typedef QPair< QString, int > Pair;
typedef QList< Pair > OptionList;
typedef QList<QPair<QString,int>> OptionList;
static bool optionListHasOption(const OptionList &optionList, int optionValue,
int defaultOptionValue)
{
for (const Pair &pair : optionList) {
for (const auto &pair : optionList) {
if (pair.second == optionValue) {
return true;
}
......
......@@ -359,14 +359,12 @@ Theme::Row::Row()
Theme::Row::Row(const Row &src)
{
QList< ContentItem * >::ConstIterator end(src.mLeftItems.constEnd());
for (QList< ContentItem * >::ConstIterator it = src.mLeftItems.constBegin(); it != end; ++it) {
addLeftItem(new ContentItem(*(*it)));
for (const auto ci : qAsConst(src.mLeftItems)) {
addLeftItem(new ContentItem(*ci));
}
end = src.mRightItems.constEnd();
for (QList< ContentItem * >::ConstIterator it = src.mRightItems.constBegin(); it != end; ++it) {
addRightItem(new ContentItem(*(*it)));
for (const auto ci : qAsConst(src.mRightItems)) {
addRightItem(new ContentItem(*ci));
}
}
......@@ -435,15 +433,13 @@ void Theme::Row::removeRightItem(Theme::ContentItem *item)
bool Theme::Row::containsTextItems() const
{
QList< ContentItem * >::ConstIterator end(mLeftItems.constEnd());
for (QList< ContentItem * >::ConstIterator it = mLeftItems.constBegin(); it != end; ++it) {
if ((*it)->displaysText()) {
for (const auto</