diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ set(QT_REQUIRED_VERSION "5.10.0") set(KMIME_LIB_VERSION "5.11.40") set(CALENDARUTILS_LIB_VERSION "5.11.40") -set(KCALENDARCORE_LIB_VERSION "5.11.44") +set(KCALENDARCORE_LIB_VERSION "5.11.45") set(IDENTITYMANAGEMENT_LIB_VERSION "5.11.40") set(AKONADICALENDAR_LIB_VERSION "5.11.40") set(PIMCOMMON_LIB_VERSION "5.11.40") diff --git a/src/attachmenthandler.h b/src/attachmenthandler.h --- a/src/attachmenthandler.h +++ b/src/attachmenthandler.h @@ -62,8 +62,8 @@ * @param incidence is a pointer to a valid Incidence object containing the attachment. * @return a pointer to the Attachment object located; 0 if no such attachment could be found. */ - KCalCore::Attachment::Ptr find(const QString &attachmentName, - const KCalCore::Incidence::Ptr &incidence); + KCalCore::Attachment find(const QString &attachmentName, + const KCalCore::Incidence::Ptr &incidence); /** * Finds the attachment in the user's calendar, by @p attachmentName and a scheduler message; @@ -73,16 +73,16 @@ * @param message is a pointer to a valid ScheduleMessage object containing the attachment. * @return a pointer to the Attachment object located; 0 if no such attachment could be found. */ - KCalCore::Attachment::Ptr find(const QString &attachmentName, - const KCalCore::ScheduleMessage::Ptr &message); + KCalCore::Attachment find(const QString &attachmentName, + const KCalCore::ScheduleMessage::Ptr &message); /** * Launches a viewer on the specified attachment. * * @param attachment is a pointer to a valid Attachment object. * @return true if the viewer program successfully launched; false otherwise. */ - bool view(const KCalCore::Attachment::Ptr &attachment); + bool view(const KCalCore::Attachment &attachment); /** * Launches a viewer on the specified attachment. @@ -124,7 +124,7 @@ @return true if the save operation was successful; false otherwise. */ - bool saveAs(const KCalCore::Attachment::Ptr &attachment); + bool saveAs(const KCalCore::Attachment &attachment); /** Saves the specified attachment to a file of the user's choice. diff --git a/src/attachmenthandler.cpp b/src/attachmenthandler.cpp --- a/src/attachmenthandler.cpp +++ b/src/attachmenthandler.cpp @@ -80,76 +80,76 @@ delete d; } -Attachment::Ptr AttachmentHandler::find(const QString &attachmentName, - const Incidence::Ptr &incidence) +Attachment AttachmentHandler::find(const QString &attachmentName, + const Incidence::Ptr &incidence) { if (!incidence) { - return Attachment::Ptr(); + return {}; } // get the attachment by name from the incidence const Attachment::List as = incidence->attachments(); - Attachment::Ptr a; + Attachment a; if (!as.isEmpty()) { Attachment::List::ConstIterator it; Attachment::List::ConstIterator end(as.constEnd()); for (it = as.constBegin(); it != end; ++it) { - if ((*it)->label() == attachmentName) { + if ((*it).label() == attachmentName) { a = *it; break; } } } - if (!a) { + if (a.isEmpty()) { KMessageBox::error( d->mParent, i18n("No attachment named \"%1\" found in the incidence.", attachmentName)); - return Attachment::Ptr(); + return {}; } - if (a->isUri()) { - auto job = KIO::stat(QUrl(a->uri()), KIO::StatJob::SourceSide, 0); + if (a.isUri()) { + auto job = KIO::stat(QUrl(a.uri()), KIO::StatJob::SourceSide, 0); KJobWidgets::setWindow(job, d->mParent); if (!job->exec()) { KMessageBox::sorry( d->mParent, i18n("The attachment \"%1\" is a web link that is inaccessible from this computer. ", - QUrl::fromPercentEncoding(a->uri().toLatin1()))); - return Attachment::Ptr(); + QUrl::fromPercentEncoding(a.uri().toLatin1()))); + return {}; } } return a; } -Attachment::Ptr AttachmentHandler::find(const QString &attachmentName, - const ScheduleMessage::Ptr &message) +Attachment AttachmentHandler::find(const QString &attachmentName, + const ScheduleMessage::Ptr &message) { if (!message) { - return Attachment::Ptr(); + return {}; } Incidence::Ptr incidence = message->event().dynamicCast(); if (!incidence) { KMessageBox::error( d->mParent, i18n("The calendar invitation stored in this email message is broken in some way. " "Unable to continue.")); - return Attachment::Ptr(); + return {}; } return find(attachmentName, incidence); } static QTemporaryFile *s_tempFile = nullptr; -static QUrl tempFileForAttachment(const Attachment::Ptr &attachment) +static QUrl tempFileForAttachment(const Attachment &attachment) { QUrl url; QMimeDatabase db; - QStringList patterns = db.mimeTypeForName(attachment->mimeType()).globPatterns(); + QStringList patterns = db.mimeTypeForName(attachment.mimeType()).globPatterns(); if (!patterns.empty()) { s_tempFile = new QTemporaryFile(QDir::tempPath() + QLatin1String( "/attachementview_XXXXXX") @@ -160,10 +160,10 @@ s_tempFile->setAutoRemove(false); s_tempFile->open(); s_tempFile->setPermissions(QFile::ReadUser); - s_tempFile->write(QByteArray::fromBase64(attachment->data())); + s_tempFile->write(QByteArray::fromBase64(attachment.data())); s_tempFile->close(); QFile tf(s_tempFile->fileName()); - if (tf.size() != attachment->size()) { + if (tf.size() != attachment.size()) { //whoops. failed to write the entire attachment. return an invalid URL. delete s_tempFile; s_tempFile = nullptr; @@ -174,23 +174,23 @@ return url; } -bool AttachmentHandler::view(const Attachment::Ptr &attachment) +bool AttachmentHandler::view(const Attachment &attachment) { - if (!attachment) { + if (attachment.isEmpty()) { return false; } bool stat = true; - if (attachment->isUri()) { - QDesktopServices::openUrl(QUrl(attachment->uri())); + if (attachment.isUri()) { + QDesktopServices::openUrl(QUrl(attachment.uri())); } else { // put the attachment in a temporary file and launch it QUrl tempUrl = tempFileForAttachment(attachment); if (tempUrl.isValid()) { KRun::RunFlags flags; flags |= KRun::DeleteTemporaryFiles; flags |= KRun::RunExecutables; - stat = KRun::runUrl(tempUrl, attachment->mimeType(), nullptr, flags); + stat = KRun::runUrl(tempUrl, attachment.mimeType(), nullptr, flags); } else { stat = false; KMessageBox::error( @@ -225,20 +225,20 @@ return view(find(attachmentName, message)); } -bool AttachmentHandler::saveAs(const Attachment::Ptr &attachment) +bool AttachmentHandler::saveAs(const Attachment &attachment) { // get the saveas file name const QString saveAsFile = QFileDialog::getSaveFileName(d->mParent, i18n( "Save Attachment"), - attachment->label()); + attachment.label()); if (saveAsFile.isEmpty()) { return false; } bool stat = false; - if (attachment->isUri()) { + if (attachment.isUri()) { // save the attachment url - auto job = KIO::file_copy(QUrl(attachment->uri()), QUrl::fromLocalFile(saveAsFile)); + auto job = KIO::file_copy(QUrl(attachment.uri()), QUrl::fromLocalFile(saveAsFile)); stat = job->exec(); } else { // put the attachment in a temporary file and save it diff --git a/src/incidenceattachmentmodel.cpp b/src/incidenceattachmentmodel.cpp --- a/src/incidenceattachmentmodel.cpp +++ b/src/incidenceattachmentmodel.cpp @@ -188,14 +188,14 @@ return QVariant(); } - KCalCore::Attachment::Ptr attachment = d->m_incidence->attachments().at(index.row()); + const KCalCore::Attachment attachment = d->m_incidence->attachments().at(index.row()); switch (role) { case Qt::DisplayRole: - return attachment->label(); + return attachment.label(); case AttachmentDataRole: - return attachment->decodedData(); + return attachment.decodedData(); case MimeTypeRole: - return attachment->mimeType(); + return attachment.mimeType(); } return QVariant(); } diff --git a/src/printing/calprintdefaultplugins.cpp b/src/printing/calprintdefaultplugins.cpp --- a/src/printing/calprintdefaultplugins.cpp +++ b/src/printing/calprintdefaultplugins.cpp @@ -587,7 +587,7 @@ if (!attachmentString.isEmpty()) { attachmentString += i18nc("Spacer for list of attachments", " "); } - attachmentString.append((*ait)->label()); + attachmentString.append((*ait).label()); } drawBoxWithCaption(p, attachmentsBox, attachmentCaption, attachmentString,