Commit 4de6bf22 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some clazy warning

parent 1905f49a
Pipeline #22594 failed with stage
in 60 minutes and 1 second
......@@ -63,9 +63,9 @@ void RecipientsEditorTest::test_addLineOnCommaPress()
QApplication::setActiveWindow(&editor);
QVERIFY(QTest::qWaitForWindowActive(&editor));
QCOMPARE(editor.recipients().size(), 0);
QVERIFY(editor.recipients().isEmpty());
auto lineEdit = editor.lines().first()->findChild<MessageComposer::RecipientLineEdit *>();
auto lineEdit = editor.lines().constFirst()->findChild<MessageComposer::RecipientLineEdit *>();
lineEdit->setFocus();
// Simulate typing email address
......
......@@ -246,7 +246,7 @@ void AttachmentControllerBase::Private::viewSelectedAttachments()
void AttachmentControllerBase::Private::editSelectedAttachment()
{
Q_ASSERT(selectedParts.count() == 1);
q->editAttachment(selectedParts.first(), MessageViewer::EditorWatcher::NoOpenWithDialog);
q->editAttachment(selectedParts.constFirst(), MessageViewer::EditorWatcher::NoOpenWithDialog);
}
void AttachmentControllerBase::Private::editSelectedAttachmentWith()
......@@ -268,19 +268,19 @@ void AttachmentControllerBase::Private::removeSelectedAttachments()
void AttachmentControllerBase::Private::saveSelectedAttachmentAs()
{
Q_ASSERT(selectedParts.count() == 1);
q->saveAttachmentAs(selectedParts.first());
q->saveAttachmentAs(selectedParts.constFirst());
}
void AttachmentControllerBase::Private::selectedAttachmentProperties()
{
Q_ASSERT(selectedParts.count() == 1);
q->attachmentProperties(selectedParts.first());
q->attachmentProperties(selectedParts.constFirst());
}
void AttachmentControllerBase::Private::reloadAttachment()
{
Q_ASSERT(selectedParts.count() == 1);
AttachmentUpdateJob *ajob = new AttachmentUpdateJob(selectedParts.first(), q);
AttachmentUpdateJob *ajob = new AttachmentUpdateJob(selectedParts.constFirst(), q);
connect(ajob, &AttachmentUpdateJob::result, q, [this](KJob *job) {
updateJobResult(job);
});
......@@ -659,7 +659,7 @@ void AttachmentControllerBase::showContextMenu()
) {
menu.addAction(d->viewContextAction);
}
d->createOpenWithMenu(&menu, d->selectedParts.first());
d->createOpenWithMenu(&menu, d->selectedParts.constFirst());
}
menu.addAction(d->openContextAction);
}
......
......@@ -378,7 +378,8 @@ void RichTextComposerNg::insertSignature(const KIdentityManagement::Signature &s
// We added the text of the signature above, now it is time to add the images as well.
if (signature.isInlinedHtml()) {
for (const KIdentityManagement::Signature::EmbeddedImagePtr &image : signature.embeddedImages()) {
const QList<KIdentityManagement::Signature::EmbeddedImagePtr> embeddedImages = signature.embeddedImages();
for (const KIdentityManagement::Signature::EmbeddedImagePtr &image : embeddedImages) {
composerControler()->composerImages()->loadImage(image->image, image->name, image->name);
}
}
......
......@@ -1186,7 +1186,7 @@ void ComposerViewBase::slotAutoSaveComposeResult(KJob *job)
// The messages were composed successfully. Only save the first message, there should
// only be one anyway, since crypto is disabled.
qCDebug(MESSAGECOMPOSER_LOG) << "NoError.";
writeAutoSaveToDisk(composer->resultMessages().first());
writeAutoSaveToDisk(composer->resultMessages().constFirst());
Q_ASSERT(composer->resultMessages().size() == 1);
if (m_autoSaveInterval > 0) {
......
......@@ -67,11 +67,15 @@ MessageComposer::ComposerAttachmentInterface ComposerViewInterface::attachments(
{
MessageComposer::ComposerAttachmentInterface attachmentInterface;
if (mComposerView) {
attachmentInterface.setCount(mComposerView->attachmentModel()->attachments().count());
const int countElement = mComposerView->attachmentModel()->attachments().count();
attachmentInterface.setCount(countElement);
QStringList fileNames;
QStringList nameAndSize;
QStringList names;
fileNames.reserve(countElement);
nameAndSize.reserve(countElement);
names.reserve(countElement);
for (const MessageCore::AttachmentPart::Ptr &attachment : mComposerView->attachmentModel()->attachments()) {
fileNames.append(attachment->fileName());
names.append(attachment->name());
......
......@@ -139,6 +139,6 @@ void AttachmentJob::process()
Q_D(AttachmentJob);
// The content has been created by our subjob.
Q_ASSERT(d->subjobContents.count() == 1);
d->resultContent = d->subjobContents.first();
d->resultContent = d->subjobContents.constFirst();
emitResult();
}
......@@ -173,7 +173,7 @@ void EncryptJob::doStart()
// and we want to use that
if (!d->content || !d->content->hasContent()) {
if (d->subjobContents.size() == 1) {
d->content = d->subjobContents.first();
d->content = d->subjobContents.constFirst();
}
}
......@@ -204,7 +204,7 @@ void EncryptJob::slotResult(KJob *job)
if (subjobs().size() == 2) {
auto pjob = static_cast<ProtectedHeadersJob *>(subjobs().last());
if (pjob) {
auto cjob =dynamic_cast<ContentJobBase *>(job);
auto cjob = qobject_cast<ContentJobBase *>(job);
Q_ASSERT(cjob);
pjob->setContent(cjob->content());
}
......@@ -221,7 +221,7 @@ void EncryptJob::process()
// and we want to use that
if (!d->content || !d->content->hasContent()) {
Q_ASSERT(d->subjobContents.size() == 1);
d->content = d->subjobContents.first();
d->content = d->subjobContents.constFirst();
}
const QGpgME::Protocol *proto = nullptr;
......
......@@ -286,6 +286,6 @@ void MainTextJob::process()
Q_D(MainTextJob);
// The content has been created by our subjob.
Q_ASSERT(d->subjobContents.count() == 1);
d->resultContent = d->subjobContents.first();
d->resultContent = d->subjobContents.constFirst();
emitResult();
}
......@@ -167,7 +167,6 @@ void SignJob::doStart()
void SignJob::slotResult(KJob *job)
{
Q_D(SignJob);
if (error()) {
ContentJobBase::slotResult(job);
return;
......@@ -175,7 +174,7 @@ void SignJob::slotResult(KJob *job)
if (subjobs().size() == 2) {
auto pjob = static_cast<ProtectedHeadersJob *>(subjobs().last());
if (pjob) {
auto cjob = dynamic_cast<ContentJobBase *>(job);
auto cjob = qobject_cast<ContentJobBase *>(job);
Q_ASSERT(cjob);
pjob->setContent(cjob->content());
}
......@@ -193,7 +192,7 @@ void SignJob::process()
// and we want to use that
if (!d->content) {
Q_ASSERT(d->subjobContents.size() == 1);
d->content = d->subjobContents.first();
d->content = d->subjobContents.constFirst();
}
//d->resultContent = new KMime::Content;
......
......@@ -415,7 +415,7 @@ const SortOrder Manager::sortOrderForStorageModel(const StorageModel *storageMod
return ret;
}
void Manager::saveSortOrderForStorageModel(const StorageModel *storageModel, const SortOrder &order, bool storageUsesPrivateSortOrder)
void Manager::saveSortOrderForStorageModel(const StorageModel *storageModel, SortOrder order, bool storageUsesPrivateSortOrder)
{
KConfigGroup conf(MessageListSettings::self()->config(), MessageList::Util::storageModelSortOrderGroup());
order.writeConfig(conf, storageModel->id(), storageUsesPrivateSortOrder);
......
......@@ -115,7 +115,7 @@ public:
// sort order management
const SortOrder sortOrderForStorageModel(const StorageModel *storageModel, bool *storageUsesPrivateSortOrder);
void saveSortOrderForStorageModel(const StorageModel *storageModel, const SortOrder &order, bool storageUsesPrivateSortOrder);
void saveSortOrderForStorageModel(const StorageModel *storageModel, SortOrder order, bool storageUsesPrivateSortOrder);
// theme sets management
const Theme *themeForStorageModel(const Akonadi::Collection &col, bool *storageUsesPrivateTheme);
......
......@@ -3446,7 +3446,7 @@ ModelPrivate::ViewItemJobResult ModelPrivate::viewItemJobStepInternalForJobPass1
return ViewItemJobCompleted;
}
ModelPrivate::ViewItemJobResult ModelPrivate::viewItemJobStepInternalForJob(ViewItemJob *job, const QElapsedTimer &elapsedTimer)
ModelPrivate::ViewItemJobResult ModelPrivate::viewItemJobStepInternalForJob(ViewItemJob *job, QElapsedTimer elapsedTimer)
{
// This function does a timed chunk of work for a single Fill View job.
// It attempts to process messages until a timeout forces it to return to the caller.
......
......@@ -79,7 +79,7 @@ public:
ViewItemJobInterrupted
};
ViewItemJobResult viewItemJobStepInternal();
ViewItemJobResult viewItemJobStepInternalForJob(ViewItemJob *job, const QElapsedTimer &elapsedTimer);
ViewItemJobResult viewItemJobStepInternalForJob(ViewItemJob *job, QElapsedTimer elapsedTimer);
// FIXME: Those look like they should be made virtual in some job class! -> Refactor
ViewItemJobResult viewItemJobStepInternalForJobPass1Fill(ViewItemJob *job, QElapsedTimer elapsedTimer);
......
......@@ -129,7 +129,7 @@ Pane::Pane(bool restoreSession, QAbstractItemModel *model, QItemSelectionModel *
const QAbstractProxyModel *proxyModel = qobject_cast<const QAbstractProxyModel *>(d->mSelectionModel->model());
while (proxyModel) {
if (static_cast<const QAbstractItemModel *>(proxyModel) == d->mModel) {
if (proxyModel == d->mModel) {
break;
}
......@@ -138,7 +138,7 @@ Pane::Pane(bool restoreSession, QAbstractItemModel *model, QItemSelectionModel *
if (!nextProxyModel) {
// It's the final model in the chain, so it is necessarily the sourceModel.
Q_ASSERT(qobject_cast<const QAbstractItemModel *>(proxyModel->sourceModel()) == d->mModel);
Q_ASSERT(proxyModel->sourceModel() == d->mModel);
break;
}
proxyModel = nextProxyModel;
......
......@@ -148,6 +148,7 @@ Collection::List StorageModel::displayedCollections() const
Collection::List collections;
const QModelIndexList indexes = d->mSelectionModel->selectedRows();
collections.reserve(indexes.count());
for (const QModelIndex &index : indexes) {
Collection c = index.data(EntityTreeModel::CollectionRole).value<Collection>();
if (c.isValid()) {
......@@ -163,6 +164,7 @@ QString StorageModel::id() const
QStringList ids;
const QModelIndexList indexes = d->mSelectionModel->selectedRows();
ids.reserve(indexes.count());
for (const QModelIndex &index : indexes) {
Collection c = index.data(EntityTreeModel::CollectionRole).value<Collection>();
if (c.isValid()) {
......
......@@ -231,7 +231,8 @@ QDebug operator <<(QDebug d, const DKIMAuthenticationStatusInfo &t)
d << "mAuthservId: " << t.authservId();
d << "mReasonSpec: " << t.reasonSpec();
d << "mAuthVersion: " << t.authVersion() << '\n';
for (const DKIMAuthenticationStatusInfo::AuthStatusInfo &info : t.listAuthStatusInfo()) {
const auto listAuthStatusInfo = t.listAuthStatusInfo();
for (const DKIMAuthenticationStatusInfo::AuthStatusInfo &info : listAuthStatusInfo) {
d << "mListAuthStatusInfo: " << info.method << " : " << info.result << " : " << info.methodVersion << " : " << info.reason << '\n';
d << "Property:" << '\n';
if (!info.smtp.isEmpty()) {
......
......@@ -73,7 +73,7 @@ void DKIMManagerKeyWidget::customContextMenuRequested(const QPoint &)
QTreeWidgetItem *item = mTreeWidget->currentItem();
QMenu menu(this);
if (item) {
menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy Key"), this, [this, item]() {
menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy Key"), this, [item]() {
QApplication::clipboard()->setText(item->text(2));
});
menu.addSeparator();
......
......@@ -112,7 +112,9 @@ void DKIMManageRulesWidget::loadSettings()
void DKIMManageRulesWidget::saveSettings()
{
QVector<MessageViewer::DKIMRule> rules;
for (int i = 0, total = mTreeWidget->topLevelItemCount(); i < total; ++i) {
const int total = mTreeWidget->topLevelItemCount();
rules.reserve(total);
for (int i = 0; i < total; ++i) {
QTreeWidgetItem *item = mTreeWidget->topLevelItem(i);
DKIMManageRulesWidgetItem *ruleItem = static_cast<DKIMManageRulesWidgetItem *>(item);
rules.append(ruleItem->rule());
......
......@@ -253,7 +253,7 @@ public:
QVariant format(KMime::Message *message, MimeTreeParser::NodeHelper *nodeHelper) override
{
const auto value = nodeHelper->mailHeaderAsAddressList(header.constData(), message);
return QVariant::fromValue(static_cast<const KMime::Headers::Generics::AddressList *>(value));
return QVariant::fromValue(value);
}
protected:
......
......@@ -194,7 +194,7 @@ void QuoteHtmlTest::testQuoteHtml_data()
"<div class=\"quotelevel2\"><div dir=\"ltr\"><span class=\"quotemarks\">>></span><font color=\"#007000\">quote2</font></div></div><blockquote><div class=\"quotelevelmark\" ><a href=\"kmail:levelquote?-1 \"><img src=\"%2\"/></a></div><br/></blockquote><div class=\"quotelevelmark\" ><a href=\"kmail:levelquote?1 \"><img src=\"%1\"/></a></div>"
"<div class=\"quotelevel2\"><div dir=\"ltr\"><span class=\"quotemarks\">>></span><font color=\"#007000\">new quote2</font></div></div></blockquote><div class=\"quotelevelmark\" ><a href=\"kmail:levelquote?0 \"><img src=\"%1\"/></a></div>"
"<div class=\"quotelevel1\"><div dir=\"ltr\"><span class=\"quotemarks\">></span><font color=\"#008000\">new quote1</font></div></div></blockquote><div class=\"noquote\"><div dir=\"ltr\">new text</div></div>")
.arg(mCollapseIcon).arg(mExpandIcon)
.arg(mCollapseIcon, mExpandIcon)
<< true << 2;
QTest::newRow("bug-369072-expand-quotelevel1") << QStringLiteral(
......@@ -203,7 +203,7 @@ void QuoteHtmlTest::testQuoteHtml_data()
"<div class=\"quotelevel1\"><div dir=\"ltr\"><span class=\"quotemarks\">></span><font color=\"#008000\">quote1</font></div></div><blockquote><div class=\"quotelevelmark\" ><a href=\"kmail:levelquote?-1 \"><img src=\"%2\"/></a></div><br/>"
"<blockquote></blockquote></blockquote><div class=\"quotelevelmark\" ><a href=\"kmail:levelquote?0 \"><img src=\"%1\"/></a></div>"
"<div class=\"quotelevel1\"><div dir=\"ltr\"><span class=\"quotemarks\">></span><font color=\"#008000\">new quote1</font></div></div></blockquote><div class=\"noquote\"><div dir=\"ltr\">new text</div></div>")
.arg(mCollapseIcon).arg(mExpandIcon)
.arg(mCollapseIcon, mExpandIcon)
<< true << 1;
QTest::newRow("bug-370452") << QStringLiteral("test\n> blo\n>\n>\n>\n> bla\nnew text")
......
......@@ -92,7 +92,7 @@ int main(int argc, char **argv)
parser.process(app);
QString fileName;
if (parser.positionalArguments().count()) {
if (!parser.positionalArguments().isEmpty()) {
fileName = parser.positionalArguments().at(0);
} else {
fileName
......
......@@ -91,7 +91,7 @@ KMime::Content::List MimePartTreeView::selectedContents() const
KMime::Content::List contents;
QItemSelectionModel *selectModel = selectionModel();
const QModelIndexList selectedRows = selectModel->selectedRows();
contents.reserve(selectedRows.count());
for (const QModelIndex &index : selectedRows) {
KMime::Content *content = static_cast<KMime::Content *>(index.internalPointer());
if (content) {
......
......@@ -39,6 +39,7 @@ TemplatesTextEditor::TemplatesTextEditor(QWidget *parent)
setFont(f);
QStringList excludeKeyWord;
const QStringList lst = TemplateParser::Util::keywords();
excludeKeyWord.reserve(lst.count() * 2);
for (QString str : lst) {
excludeKeyWord << str.remove(QLatin1Char('%'));
excludeKeyWord << str.replace(QLatin1String("\\("), QLatin1String("("));
......
......@@ -69,7 +69,9 @@ void InterceptorManager::removeInterceptor(WebEngineViewer::NetworkPluginUrlInte
QList<QAction *> InterceptorManager::interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const
{
QList<QAction *> actions;
for (WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface : d->mManager->interfaceList()) {
const auto interfaceList = d->mManager->interfaceList();
actions.reserve(interfaceList.count());
for (WebEngineViewer::NetworkPluginUrlInterceptorInterface *interface : interfaceList) {
actions.append(interface->interceptorUrlActions(result));
}
return actions;
......
......@@ -278,9 +278,8 @@ void WebEngineAccessKey::handleSearchAccessKey(const QVariant &res)
}
if (d->mActionCollection) {
for (QAction *act : d->mActionCollection->actions()) {
QAction *a = qobject_cast<QAction *>(act);
if (a) {
const QKeySequence shortCut = a->shortcut();
if (act) {
const QKeySequence shortCut = act->shortcut();
if (!shortCut.isEmpty()) {
auto lstUnusedKeys = unusedKeys;
for (QChar c : qAsConst(unusedKeys)) {
......
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