Commit 1033d0fc authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some code to for(...:...)

parent fc4b7ea5
......@@ -156,19 +156,19 @@ void MessageComposer::ComposerViewBase::setMessage(const KMime::Message::Ptr &ms
// If we are loading from a draft, load unexpanded aliases as well
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-To")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
foreach (const QString &addr, spl) {
for (const QString &addr : spl) {
m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::To);
}
}
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-CC")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
foreach (const QString &addr, spl) {
for (const QString &addr : spl) {
m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::Cc);
}
}
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-BCC")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
foreach (const QString &addr, spl) {
for (const QString &addr : spl) {
m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::Bcc);
}
}
......@@ -1096,11 +1096,11 @@ void MessageComposer::ComposerViewBase::cleanupAutoSave()
autoSaveDir.setNameFilters(autoSaveFilter);
// Return the files to be removed
QStringList autoSaveFiles = autoSaveDir.entryList();
const QStringList autoSaveFiles = autoSaveDir.entryList();
qCDebug(MESSAGECOMPOSER_LOG) << "There are" << autoSaveFiles.count() << "to be deleted.";
// Delete each file
foreach (const QString &file, autoSaveFiles) {
for (const QString &file : autoSaveFiles) {
autoSaveDir.remove(file);
}
m_autoSaveUUID.clear();
......
......@@ -1021,7 +1021,7 @@ void MessageFactory::applyCharset(const KMime::Message::Ptr msg)
QList<QByteArray> chars;
chars.reserve(charsets.count());
foreach (const QString &charset, charsets) {
for (const QString &charset : charsets) {
chars << charset.toLatin1();
}
......
......@@ -88,7 +88,7 @@ void DistributionListExpandJob::slotExpansionDone(KJob *job)
const KContacts::Addressee::List contacts = expandJob->contacts();
foreach (const KContacts::Addressee &contact, contacts) {
for (const KContacts::Addressee &contact : contacts) {
mEmailAddresses << contact.fullEmail();
}
......
......@@ -70,7 +70,7 @@ static inline bool containsAliases(const QString &address)
static bool containsAliases(const QStringList &addresses)
{
foreach (const QString &address, addresses) {
for (const QString &address : addresses) {
if (containsAliases(address)) {
return true;
}
......
......@@ -218,7 +218,7 @@ void RecipientsPicker::slotSearchLDAP()
void RecipientsPicker::ldapSearchResult()
{
const KContacts::Addressee::List contacts = mLdapSearchDialog->selectedContacts();
foreach (const KContacts::Addressee &contact, contacts) {
for (const KContacts::Addressee &contact : contacts) {
bool tooManyAddress = false;
Q_EMIT pickedRecipient(Recipient(contact.fullEmail(), Recipient::Undefined), tooManyAddress);
if (tooManyAddress) {
......
......@@ -224,7 +224,7 @@ bool MessageComposer::Util::makeMultiMime(Kleo::CryptoMessageFormat format, bool
QByteArray MessageComposer::Util::selectCharset(const QList<QByteArray> &charsets, const QString &text)
{
foreach (const QByteArray &name, charsets) {
for (const QByteArray &name : charsets) {
// We use KCharsets::codecForName() instead of QTextCodec::codecForName() here, because
// the former knows us-ascii is latin1.
QTextCodec *codec = KCharsets::charsets()->codecForName(QString::fromLatin1(name));
......
......@@ -94,7 +94,7 @@ void AttachmentFromFolderJob::Private::compressFolder()
void AttachmentFromFolderJob::Private::addEntity(const QFileInfoList &f, const QString &path)
{
foreach (const QFileInfo &info, f) {
for (const QFileInfo &info : f) {
qCDebug(MESSAGECORE_LOG) << q->maximumAllowedSize() << "Attachment size : " << mZip->device()->size();
if (q->maximumAllowedSize() != -1 && mZip->device()->size() > q->maximumAllowedSize()) {
......
......@@ -163,7 +163,7 @@ typedef QList< Pair > OptionList;
static bool optionListHasOption(const OptionList &optionList, int optionValue,
int defaultOptionValue)
{
foreach (const Pair &pair, optionList) {
for (const Pair &pair : optionList) {
if (pair.second == optionValue) {
return true;
}
......
......@@ -480,7 +480,7 @@ static inline void paint_tag_list(const QList< MessageItem::Tag * > &tagList, QP
int &left, int top, int &right, bool alignOnRight, int iconSize)
{
if (alignOnRight) {
foreach (const MessageItem::Tag *tag, tagList) {
for (const MessageItem::Tag *tag : tagList) {
right -= iconSize; // this icon is always present
if (right < 0) {
return;
......@@ -489,7 +489,7 @@ static inline void paint_tag_list(const QList< MessageItem::Tag * > &tagList, QP
right -= gHorizontalItemSpacing;
}
} else {
foreach (const MessageItem::Tag *tag, tagList) {
for (const MessageItem::Tag *tag : tagList) {
if (left > right - iconSize) {
return;
}
......
......@@ -1441,8 +1441,8 @@ void View::growOrShrinkExistingSelection(const QModelIndex &newSelectedIndex, bo
selectionModel()->select(newSelectedIndex, QItemSelectionModel::Rows | QItemSelectionModel::Select);
} else {
// selecting something below the top: shrink selection
QModelIndexList selectedIndexes = selection.indexes();
foreach (const QModelIndex &idx, selectedIndexes) {
const QModelIndexList selectedIndexes = selection.indexes();
for (const QModelIndex &idx : selectedIndexes) {
if ((idx.column() == 0) && (visualRect(idx).top() > selectedVisualCoordinate)) {
selectionModel()->select(idx, QItemSelectionModel::Rows | QItemSelectionModel::Deselect);
}
......@@ -1454,8 +1454,8 @@ void View::growOrShrinkExistingSelection(const QModelIndex &newSelectedIndex, bo
selectionModel()->select(newSelectedIndex, QItemSelectionModel::Rows | QItemSelectionModel::Select);
} else {
// selecting something above bottom: shrink selection
QModelIndexList selectedIndexes = selection.indexes();
foreach (const QModelIndex &idx, selectedIndexes) {
const QModelIndexList selectedIndexes = selection.indexes();
for (const QModelIndex &idx : selectedIndexes) {
if ((idx.column() == 0) && (visualRect(idx).top() < selectedVisualCoordinate)) {
selectionModel()->select(idx, QItemSelectionModel::Rows | QItemSelectionModel::Deselect);
}
......
......@@ -154,7 +154,7 @@ QString MessageList::Util::contentSummary(const Akonadi::Item &item)
const int maxLines = 5;
const QStringList lines = content.split(QLatin1Char('\n'));
QString ret;
foreach (const QString &line, lines) {
for (const QString &line : lines) {
const QString lineTrimmed = line.trimmed();
const bool isQuoted = lineTrimmed.startsWith(QLatin1Char('>')) || lineTrimmed.startsWith(QLatin1Char('|'));
if (!isQuoted && !lineTrimmed.isEmpty()) {
......
......@@ -144,9 +144,9 @@ StorageModel::~StorageModel()
Collection::List StorageModel::displayedCollections() const
{
Collection::List collections;
QModelIndexList indexes = d->mSelectionModel->selectedRows();
const QModelIndexList indexes = d->mSelectionModel->selectedRows();
foreach (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
Collection c = index.data(EntityTreeModel::CollectionRole).value<Collection>();
if (c.isValid()) {
collections << c;
......@@ -159,9 +159,9 @@ Collection::List StorageModel::displayedCollections() const
QString StorageModel::id() const
{
QStringList ids;
QModelIndexList indexes = d->mSelectionModel->selectedRows();
const QModelIndexList indexes = d->mSelectionModel->selectedRows();
foreach (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
Collection c = index.data(EntityTreeModel::CollectionRole).value<Collection>();
if (c.isValid()) {
ids << QString::number(c.id());
......@@ -183,9 +183,9 @@ bool StorageModel::isOutBoundFolder(const Akonadi::Collection &c) const
bool StorageModel::containsOutboundMessages() const
{
QModelIndexList indexes = d->mSelectionModel->selectedRows();
const QModelIndexList indexes = d->mSelectionModel->selectedRows();
foreach (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
Collection c = index.data(EntityTreeModel::CollectionRole).value<Collection>();
if (c.isValid()) {
return isOutBoundFolder(c);
......@@ -197,11 +197,11 @@ bool StorageModel::containsOutboundMessages() const
int StorageModel::initialUnreadRowCountGuess() const
{
QModelIndexList indexes = d->mSelectionModel->selectedRows();
const QModelIndexList indexes = d->mSelectionModel->selectedRows();
int unreadCount = 0;
foreach (const QModelIndex &index, indexes) {
for (const QModelIndex &index : indexes) {
Collection c = index.data(EntityTreeModel::CollectionRole).value<Collection>();
if (c.isValid()) {
unreadCount += c.statistics().unreadCount();
......@@ -409,7 +409,7 @@ QMimeData *StorageModel::mimeData(const QList< MessageList::Core::MessageItem *
QMimeData *data = new QMimeData();
QList<QUrl> urls;
urls.reserve(items.count());
foreach (MessageList::Core::MessageItem *mi, items) {
for (MessageList::Core::MessageItem *mi : items) {
Akonadi::Item item = itemForRow(mi->currentModelIndexRow());
urls << item.url(Item::UrlWithMimeType);
}
......
......@@ -118,7 +118,7 @@ bool Widget::canAcceptDrag(const QDropEvent *e)
}
const QList<QUrl> urls = e->mimeData()->urls();
foreach (const QUrl &url, urls) {
for (const QUrl &url : urls) {
const Collection collection = Collection::fromUrl(url);
if (collection.isValid()) { // You're not supposed to drop collections here
return false;
......
......@@ -89,9 +89,9 @@ KMime::Content::List MimePartTreeView::selectedContents()
{
KMime::Content::List contents;
QItemSelectionModel *selectModel = selectionModel();
QModelIndexList selectedRows = selectModel->selectedRows();
const QModelIndexList selectedRows = selectModel->selectedRows();
Q_FOREACH (const QModelIndex &index, selectedRows) {
for (const QModelIndex &index : selectedRows) {
KMime::Content *content = static_cast<KMime::Content *>(index.internalPointer());
if (content) {
contents.append(content);
......
......@@ -53,8 +53,8 @@ void PluginLoaderBase::doScan(const char *path)
{
mPluginMap.clear();
const auto list = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1(path), QStandardPaths::LocateDirectory);
foreach (const auto &folder, list) {
const QStringList list = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QString::fromLatin1(path), QStandardPaths::LocateDirectory);
for (const QString &folder : list) {
doScanOneFolder(folder);
}
}
......
......@@ -918,10 +918,10 @@ void ViewerPrivate::collectionFetchedForStoringDecryptedMessage(KJob *job)
if (!col.isValid()) {
return;
}
Akonadi::AgentInstance::List instances = Akonadi::AgentManager::self()->instances();
const Akonadi::AgentInstance::List instances = Akonadi::AgentManager::self()->instances();
const QString itemResource = col.resource();
Akonadi::AgentInstance resourceInstance;
foreach (const Akonadi::AgentInstance &instance, instances) {
for (const Akonadi::AgentInstance &instance : instances) {
if (instance.identifier() == itemResource) {
resourceInstance = instance;
break;
......
......@@ -827,8 +827,8 @@ void NodeHelper::mergeExtraNodes(KMime::Content *node)
return;
}
QList<KMime::Content * > extraNodes = extraContents(node);
Q_FOREACH (KMime::Content *extra, extraNodes) {
const QList<KMime::Content * > extraNodes = extraContents(node);
for (KMime::Content *extra : extraNodes) {
if (node->bodyIsMessage()) {
qCWarning(MIMETREEPARSER_LOG) << "Asked to attach extra content to a kmime::message, this does not make sense. Attaching to:" << node <<
node->encodedContent() << "\n====== with =======\n" << extra << extra->encodedContent();
......
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