void PostEntry::submitPost(int blogId, const BilboPost &postData) { setCurrentPostFromEditor(); if (d->mCurrentPost.content().isEmpty() || d->mCurrentPost.title().isEmpty()) { if (KMessageBox::warningContinueCancel(this, i18n("Your post title or body is empty.\nAre you sure you want to submit this post?") ) == KMessageBox::Cancel) { return; } } bool isNew = false; if (d->mCurrentPost.status() == BilboPost::New) { isNew = true; } QPointer<SendToBlogDialog> dia = new SendToBlogDialog(isNew, d->mCurrentPost.isPrivate(), this); dia->setAttribute(Qt::WA_DeleteOnClose, false); if (dia->exec() == QDialog::Accepted) { this->setCursor(Qt::BusyCursor); d->mCurrentPost.setProperties(postData); d->mCurrentPostBlogId = blogId; QString msgType; if (dia->isPrivate()) { msgType = i18nc("Post status, e.g Draft or Published Post", "draft"); d->mCurrentPost.setPrivate(true); } else { msgType = i18nc("Post status, e.g Draft or Published Post", "post"); d->mCurrentPost.setPrivate(false); } QString statusMsg; if (dia->isNew()) { statusMsg = i18n("Submitting new %1...", msgType); d->isNewPost = true; } else { statusMsg = i18n("Modifying %1...", msgType); d->isNewPost = false; } Q_EMIT showStatusMessage(statusMsg, true); Backend *b = new Backend(d->mCurrentPostBlogId, this); connect(b, &Backend::sigError, this, &PostEntry::slotError); if (uploadMediaFiles(b)) { qCDebug(BLOGILO_LOG) << "Uploading"; showProgressBar(); connect(b, &Backend::sigPostPublished, this, &PostEntry::slotPostPublished); if (d->isNewPost) { b->publishPost(&d->mCurrentPost); } else { b->modifyPost(&d->mCurrentPost); } } else { deleteProgressBar(); } } delete dia; }
BilboPost* PostEntry::currentPost() { setCurrentPostFromEditor(); return &d->mCurrentPost; }