Commit c48f13ad authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reduce duplicate code + add missing Q_REQUIRED_RESULT

parent 72ce09a0
Pipeline #24581 passed with stage
in 78 minutes and 52 seconds
...@@ -185,8 +185,8 @@ void AttachmentControllerBase::Private::compressJobResult(KJob *job) ...@@ -185,8 +185,8 @@ void AttachmentControllerBase::Private::compressJobResult(KJob *job)
return; return;
} }
Q_ASSERT(dynamic_cast<AttachmentCompressJob *>(job)); AttachmentCompressJob *ajob = dynamic_cast<AttachmentCompressJob *>(job);
AttachmentCompressJob *ajob = static_cast<AttachmentCompressJob *>(job); Q_ASSERT(ajob);
AttachmentPart::Ptr originalPart = ajob->originalPart(); AttachmentPart::Ptr originalPart = ajob->originalPart();
AttachmentPart::Ptr compressedPart = ajob->compressedPart(); AttachmentPart::Ptr compressedPart = ajob->compressedPart();
...@@ -219,8 +219,8 @@ void AttachmentControllerBase::Private::loadJobResult(KJob *job) ...@@ -219,8 +219,8 @@ void AttachmentControllerBase::Private::loadJobResult(KJob *job)
return; return;
} }
Q_ASSERT(dynamic_cast<AttachmentLoadJob *>(job)); AttachmentLoadJob *ajob = dynamic_cast<AttachmentLoadJob *>(job);
AttachmentLoadJob *ajob = static_cast<AttachmentLoadJob *>(job); Q_ASSERT(ajob);
AttachmentPart::Ptr part = ajob->attachmentPart(); AttachmentPart::Ptr part = ajob->attachmentPart();
q->addAttachment(part); q->addAttachment(part);
} }
...@@ -291,8 +291,8 @@ void AttachmentControllerBase::Private::updateJobResult(KJob *job) ...@@ -291,8 +291,8 @@ void AttachmentControllerBase::Private::updateJobResult(KJob *job)
KMessageBox::sorry(wParent, job->errorString(), i18n("Failed to reload attachment")); KMessageBox::sorry(wParent, job->errorString(), i18n("Failed to reload attachment"));
return; return;
} }
Q_ASSERT(dynamic_cast<AttachmentUpdateJob *>(job)); AttachmentUpdateJob *ajob = dynamic_cast<AttachmentUpdateJob *>(job);
AttachmentUpdateJob *ajob = static_cast<AttachmentUpdateJob *>(job); Q_ASSERT(ajob);
AttachmentPart::Ptr originalPart = ajob->originalPart(); AttachmentPart::Ptr originalPart = ajob->originalPart();
AttachmentPart::Ptr updatedPart = ajob->updatedPart(); AttachmentPart::Ptr updatedPart = ajob->updatedPart();
...@@ -837,7 +837,7 @@ void AttachmentControllerBase::saveAttachmentAs(const AttachmentPart::Ptr &part) ...@@ -837,7 +837,7 @@ void AttachmentControllerBase::saveAttachmentAs(const AttachmentPart::Ptr &part)
pname = i18n("unnamed"); pname = i18n("unnamed");
} }
QUrl url = QFileDialog::getSaveFileUrl(d->wParent, i18n("Save Attachment As"), QUrl::fromLocalFile(pname)); const QUrl url = QFileDialog::getSaveFileUrl(d->wParent, i18n("Save Attachment As"), QUrl::fromLocalFile(pname));
if (url.isEmpty()) { if (url.isEmpty()) {
qCDebug(MESSAGECOMPOSER_LOG) << "Save Attachment As dialog canceled."; qCDebug(MESSAGECOMPOSER_LOG) << "Save Attachment As dialog canceled.";
...@@ -943,7 +943,7 @@ void AttachmentControllerBase::showAddAttachmentFileDialog() ...@@ -943,7 +943,7 @@ void AttachmentControllerBase::showAddAttachmentFileDialog()
QUrl urlWithEncoding = url; QUrl urlWithEncoding = url;
MessageCore::StringUtil::setEncodingFile(urlWithEncoding, encoding); MessageCore::StringUtil::setEncodingFile(urlWithEncoding, encoding);
QMimeDatabase mimeDb; QMimeDatabase mimeDb;
auto mimeType = mimeDb.mimeTypeForUrl(urlWithEncoding); const auto mimeType = mimeDb.mimeTypeForUrl(urlWithEncoding);
if (mimeType.name() == QLatin1String("inode/directory")) { if (mimeType.name() == QLatin1String("inode/directory")) {
const int rc = KMessageBox::warningYesNo(d->wParent, i18n("Do you really want to attach this directory \"%1\"?", url.toLocalFile()), const int rc = KMessageBox::warningYesNo(d->wParent, i18n("Do you really want to attach this directory \"%1\"?", url.toLocalFile()),
i18nc("@title:window", "Attach directory")); i18nc("@title:window", "Attach directory"));
......
...@@ -55,7 +55,7 @@ public: ...@@ -55,7 +55,7 @@ public:
void doStart(); // slot void doStart(); // slot
void composeStep1(); void composeStep1();
void composeStep2(); void composeStep2();
QList<ContentJobBase *> createEncryptJobs(ContentJobBase *contentJob, bool sign); Q_REQUIRED_RESULT QList<ContentJobBase *> createEncryptJobs(ContentJobBase *contentJob, bool sign);
void contentJobFinished(KJob *job); // slot void contentJobFinished(KJob *job); // slot
void composeWithLateAttachments(KMime::Message *headers, KMime::Content *content, const AttachmentPart::List &parts, const std::vector<GpgME::Key> &keys, const QStringList &recipients); void composeWithLateAttachments(KMime::Message *headers, KMime::Content *content, const AttachmentPart::List &parts, const std::vector<GpgME::Key> &keys, const QStringList &recipients);
void attachmentsFinished(KJob *job); // slot void attachmentsFinished(KJob *job); // slot
......
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