24 #include "blogpost_p.h" 30 #include <kcal/journal.h> 32 #include <QStringList> 37 : d_ptr( new BlogPostPrivate )
41 d_ptr->mPostId = post.
postId();
42 d_ptr->mTitle = post.
title();
43 d_ptr->mContent = post.
content();
45 d_ptr->mWpSlug = post.
slug();
47 d_ptr->mTags = post.
tags();
48 d_ptr->mMood = post.
mood();
50 d_ptr->mSummary = post.
summary();
51 d_ptr->mLink = post.
link();
52 d_ptr->mMusic = post.
music();
55 d_ptr->mError = post.
error();
57 d_ptr->mStatus = post.
status();
63 : d_ptr( new BlogPostPrivate )
66 d_ptr->mPrivate =
false;
72 : d_ptr( new BlogPostPrivate )
75 d_ptr->mPrivate =
false;
76 d_ptr->mPostId =
journal.customProperty(
"KBLOG",
"ID" );
77 d_ptr->mJournalId =
journal.uid();
79 d_ptr->mTitle =
journal.summary();
80 if (
journal.descriptionIsRich() ) {
81 d_ptr->mContent = d_ptr->cleanRichText(
journal.description() );
83 d_ptr->mContent =
journal.description();
85 d_ptr->mCategories =
journal.categories();
86 d_ptr->mCreationDateTime =
journal.dtStart();
110 QString url = blog.
url().url();
112 QString blogId = blog.
blogId();
114 QString
id = QLatin1String(
"kblog-") + url + QLatin1Char(
'-') + blogId + QLatin1Char(
'-') + username +
115 QLatin1Char(
'-') + d_ptr->mPostId;
116 KCal::Journal *
journal =
new KCal::Journal();
118 journal->setSummary( d_ptr->mTitle );
119 journal->setCategories( d_ptr->mCategories );
120 journal->setDescription( d_ptr->mContent,
true );
121 journal->setDtStart( d_ptr->mCreationDateTime );
122 journal->setCustomProperty(
"KBLOG",
"URL", url );
124 journal->setCustomProperty(
"KBLOG",
"BLOG", blogId );
125 journal->setCustomProperty(
"KBLOG",
"ID", d_ptr->mPostId );
131 return d_ptr->mJournalId;
136 return d_ptr->mPrivate;
141 d_ptr->mPrivate = privatePost;
146 return d_ptr->mPostId;
156 return d_ptr->mTitle;
161 d_ptr->mTitle =
title;
166 return d_ptr->mContent;
188 return d_ptr->mAdditionalContent;
198 return d_ptr->mWpSlug;
203 d_ptr->mWpSlug =
slug;
218 return d_ptr->mPermaLink;
223 d_ptr->mPermaLink = permalink;
228 return d_ptr->mCommentAllowed;
233 d_ptr->mCommentAllowed = commentAllowed;
238 return d_ptr->mCommentAllowed;
243 d_ptr->mTrackBackAllowed = allowTrackBacks;
248 return d_ptr->mSummary;
290 return d_ptr->mMusic;
295 d_ptr->mMusic =
music;
300 return d_ptr->mCategories;
310 return d_ptr->mCreationDateTime;
315 d_ptr->mCreationDateTime = datetime;
320 return d_ptr->mModificationDateTime;
325 d_ptr->mModificationDateTime = datetime;
330 return d_ptr->mStatus;
340 return d_ptr->mError;
345 d_ptr->mError =
error;
355 QString BlogPostPrivate::cleanRichText( QString richText )
const 357 QRegExp getBodyContents( QLatin1String(
"<body[^>]*>(.*)</body>") );
358 if ( getBodyContents.indexIn( richText ) ) {
360 richText = getBodyContents.cap( 1 );
362 richText.remove( QRegExp( QLatin1String(
"^\\s+") ) );
365 richText.replace( QRegExp( QLatin1String(
"<p style=\"[^\"]*\">" )), QLatin1String(
"<p>") );
368 if ( richText == QLatin1String(
"<p></p>") ) {
QString journalId() const
Returns the ID used by the journal in creation, if created from a journal.
bool isPrivate() const
Returns if the post is published or not.
QString summary() const
Returns the summary.
QString mood() const
Returns the mood.
QString postId() const
Returns the postId.
QString error() const
Returns the last error.
void setPermaLink(const KUrl &permalink) const
Set the perma link path.
KCal::Journal * journal(const Blog &blog) const
Returns a KCal journal from the blog post owned by the caller.
KDateTime creationDateTime() const
Returns the creation date time.
BlogPost & operator=(const BlogPost &post)
The overloaed = operator.
virtual ~BlogPost()
Virtual default destructor.
Status
The enumartion of the different post status, reflecting the status changes on the server.
QString title() const
Returns the title.
void setTitle(const QString &title)
Sets the title.
void setPostId(const QString &postId)
Sets the post id value.
KUrl permaLink() const
Returns the perma link path.
void setMood(const QString &mood)
Set the mood list.
void setCreationDateTime(const KDateTime &datetime)
Sets the creation time.
void setMusic(const QString &music)
Set the music.
QString additionalContent() const
Returns the additional content, (mt_text_more of MovableType API)
KUrl url() const
Get the URL for the blog's XML-RPC interface.
void setAdditionalContent(const QString &additionalContent)
Sets the additional content, (mt_text_more of MovableType API)
void setLink(const KUrl &link) const
Set the link path.
void setContent(const QString &content)
Sets the content.
KDateTime modificationDateTime() const
Returns the modification date time.
void setModificationDateTime(const KDateTime &datetime)
Sets the modification time.
void setStatus(Status status)
Sets the status.
void setTrackBackAllowed(bool allowTrackBacks)
Set whether track back should be allowed.
void setSlug(const QString &slug)
Sets the Wordpress slug property! (will use to set post's permalink) Currently just wordpress support...
QString content() const
Returns the content.
void setCommentAllowed(bool commentAllowed)
Set whether comments should be allowed.
void setPrivate(bool privatePost)
Sets the post to private viewings only.
Namespace for blog related classes.
Status status() const
Returns the status on the server.
BlogPost(const KBlog::BlogPost &post)
Constructor.
A class that represents a blog post on the server.
void setCategories(const QStringList &categories)
Sets the categories.
QString slug() const
Returns the Wordpress posts Slug (or permalink will use for post) Currently just wordpress supports t...
KUrl link() const
Returns the link path.
bool isTrackBackAllowed() const
Returns whether track back should be allowed.
QStringList categories() const
Returns the categories.
Status of a freshly constructed post on the client.
bool isCommentAllowed() const
Returns whether comments should be allowed.
void setSummary(const QString &summary)
Set the summary.
QString music() const
Returns the music.
void setTags(const QStringList &tags)
Set the tags list.
QStringList tags() const
Returns the tags list as a QStringList.
A class that provides methods to call functions on a supported blog web application.
This is the main interface for blogging APIs.
void swap(BlogPost &other)
The swap operator.
QString blogId() const
Returns the unique ID for the specific blog on the server.
void setError(const QString &error)
Sets the error.
QString username() const
Returns the username used in blog authentication.