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