• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KBlog Client Library

blogpost.cpp

00001 /*
00002   This file is part of the kblog library.
00003 
00004   Copyright (c) 2006-2007 Christian Weilbach <christian_weilbach@web.de>
00005   Copyright (c) 2007 Mike Arthur <mike@mikearthur.co.uk>
00006 
00007   This library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Library General Public
00009   License as published by the Free Software Foundation; either
00010   version 2 of the License, or (at your option) any later version.
00011 
00012   This library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Library General Public License for more details.
00016 
00017   You should have received a copy of the GNU Library General Public License
00018   along with this library; see the file COPYING.LIB.  If not, write to
00019   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020   Boston, MA 02110-1301, USA.
00021 */
00022 
00023 #include "blogpost.h"
00024 #include "blogpost_p.h"
00025 
00026 #include "blog.h"
00027 
00028 #include <KDateTime>
00029 #include <KUrl>
00030 #include <kcal/journal.h>
00031 
00032 #include <QStringList>
00033 
00034 namespace KBlog {
00035 
00036 BlogPost::BlogPost( const KBlog::BlogPost &post )
00037   : d_ptr( new BlogPostPrivate )
00038 {
00039   d_ptr->q_ptr = this;
00040   d_ptr->mPrivate = post.isPrivate();
00041   d_ptr->mPostId = post.postId();
00042   d_ptr->mTitle = post.title();
00043   d_ptr->mContent = post.content();
00044   d_ptr->mCategories = post.categories();
00045   d_ptr->mError = post.error();
00046   d_ptr->mJournalId = post.journalId();
00047   d_ptr->mStatus = post.status();
00048   d_ptr->mCreationDateTime = post.creationDateTime();
00049   d_ptr->mModificationDateTime = post.modificationDateTime();
00050 }
00051 
00052 BlogPost::BlogPost( const QString &postId )
00053   : d_ptr( new BlogPostPrivate )
00054 {
00055   d_ptr->q_ptr = this;
00056   d_ptr->mPrivate = false;
00057   d_ptr->mPostId = postId;
00058   d_ptr->mStatus = New;
00059 }
00060 
00061 BlogPost::BlogPost( const KCal::Journal &journal )
00062   : d_ptr( new BlogPostPrivate )
00063 {
00064   d_ptr->q_ptr = this;
00065   d_ptr->mPrivate = false;
00066   d_ptr->mPostId = journal.customProperty( "KBLOG", "ID" );
00067   d_ptr->mJournalId = journal.uid();
00068   d_ptr->mStatus = New;
00069   d_ptr->mTitle = journal.summary();
00070   d_ptr->mContent = journal.description();
00071   d_ptr->mCategories = journal.categories();
00072   d_ptr->mCreationDateTime = journal.dtStart();
00073 }
00074 
00075 // BlogPost::BlogPost( const KCal::Journal &journal, BlogPostPrivate &dd )
00076 //   : d_ptr( &dd )
00077 // {
00078 //   d_ptr->q_ptr = this;
00079 //   d_ptr->mPrivate = false;
00080 //   d_ptr->mPostId = journal.customProperty( "KBLOG", "ID" );
00081 //   d_ptr->mJournalId = journal.uid();
00082 //   d_ptr->mStatus = New;
00083 //   d_ptr->mTitle = journal.summary();
00084 //   d_ptr->mContent = journal.description();
00085 //   d_ptr->mCategories = journal.categories();
00086 //   d_ptr->mCreationDateTime = journal.dtStart();
00087 // }
00088 
00089 BlogPost::~BlogPost()
00090 {
00091   delete d_ptr;
00092 }
00093 
00094 KCal::Journal *BlogPost::journal( const Blog &blog ) const
00095 {
00096   QString url = blog.url().url();
00097   QString username = blog.username();
00098   QString blogId = blog.blogId();
00099   // Generate unique ID. Should be unique enough...
00100   QString id = "kblog-" + url + '-' + blogId  + '-' + username +
00101       '-' + d_ptr->mPostId;
00102   KCal::Journal *journal = new KCal::Journal();
00103   journal->setUid( id );
00104   journal->setSummary( d_ptr->mTitle );
00105   journal->setCategories( d_ptr->mCategories );
00106   journal->setDescription( d_ptr->mContent, true );
00107   journal->setDtStart( d_ptr->mCreationDateTime );
00108   journal->setCustomProperty( "KBLOG", "URL", url );
00109   journal->setCustomProperty( "KBLOG", "USER", blog.username() );
00110   journal->setCustomProperty( "KBLOG", "BLOG", blogId );
00111   journal->setCustomProperty( "KBLOG", "ID", d_ptr->mPostId );
00112   return journal;
00113 }
00114 
00115 QString BlogPost::journalId() const
00116 {
00117   return d_ptr->mJournalId;
00118 }
00119 
00120 bool BlogPost::isPrivate() const
00121 {
00122   return d_ptr->mPrivate;
00123 }
00124 
00125 void BlogPost::setPrivate( bool privatePost )
00126 {
00127   d_ptr->mPrivate = privatePost;
00128 }
00129 
00130 QString BlogPost::postId() const
00131 {
00132   return d_ptr->mPostId;
00133 }
00134 
00135 void BlogPost::setPostId( const QString &postId )
00136 {
00137   d_ptr->mPostId = postId;
00138 }
00139 
00140 QString BlogPost::title() const
00141 {
00142   return d_ptr->mTitle;
00143 }
00144 
00145 void BlogPost::setTitle( const QString &title )
00146 {
00147   d_ptr->mTitle = title;
00148 }
00149 
00150 QString BlogPost::content() const
00151 {
00152   return d_ptr->mContent;
00153 }
00154 
00155 void BlogPost::setContent( const QString &content )
00156 {
00157   d_ptr->mContent = content;
00158 }
00159 
00160 // QString BlogPost::abbreviatedContent() const
00161 // {
00162 //   //TODO
00163 //   return 0;
00164 // }
00165 //
00166 // void BlogPost::setAbbreviatedContent( const QString &abbreviatedContent )
00167 // {
00168 //   Q_UNUSED( abbreviatedContent );
00169 //   //TODO
00170 // }
00171 
00172 KUrl BlogPost::link() const
00173 {
00174   return d_ptr->mLink;
00175 }
00176 
00177 void BlogPost::setLink( const KUrl &link ) const
00178 {
00179   d_ptr->mLink = link;
00180 }
00181 
00182 KUrl BlogPost::permaLink() const
00183 {
00184   return d_ptr->mPermaLink;
00185 }
00186 
00187 void BlogPost::setPermaLink( const KUrl &permalink ) const
00188 {
00189   d_ptr->mPermaLink = permalink;
00190 }
00191 
00192 bool BlogPost::isCommentAllowed() const
00193 {
00194   return d_ptr->mCommentAllowed;
00195 }
00196 
00197 void BlogPost::setCommentAllowed( bool commentAllowed )
00198 {
00199   d_ptr->mCommentAllowed = commentAllowed;
00200 }
00201 
00202 bool BlogPost::isTrackBackAllowed() const
00203 {
00204   return d_ptr->mCommentAllowed;
00205 }
00206 
00207 void BlogPost::setTrackBackAllowed ( bool allowTrackBacks )
00208 {
00209   d_ptr->mTrackBackAllowed = allowTrackBacks;
00210 }
00211 
00212 QString BlogPost::summary() const
00213 {
00214   return d_ptr->mSummary;
00215 }
00216 
00217 void BlogPost::setSummary( const QString &summary )
00218 {
00219   d_ptr->mSummary = summary;
00220 }
00221 
00222 QStringList BlogPost::tags() const
00223 {
00224   return d_ptr->mTags;
00225 }
00226 
00227 void BlogPost::setTags( const QStringList &tags )
00228 {
00229   d_ptr->mTags = tags;
00230 }
00231 
00232 // QList<KUrl> BlogPost::trackBackUrls() const
00233 // {
00234 //   //TODO
00235 //   return QList<KUrl>();
00236 // }
00237 //
00238 // void BlogPost::setTrackBackUrls( const QList<KUrl> &trackBackUrls )
00239 // {
00240 //   Q_UNUSED( trackBackUrls );
00241 //   //TODO
00242 // }
00243 
00244 QString BlogPost::mood() const
00245 {
00246   return d_ptr->mMood;
00247 }
00248 
00249 void BlogPost::setMood( const QString &mood )
00250 {
00251   d_ptr->mMood = mood;
00252 }
00253 
00254 QString BlogPost::music() const
00255 {
00256   return d_ptr->mMusic;
00257 }
00258 
00259 void BlogPost::setMusic( const QString &music )
00260 {
00261   d_ptr->mMusic = music;
00262 }
00263 
00264 QStringList BlogPost::categories() const
00265 {
00266   return d_ptr->mCategories;
00267 }
00268 
00269 void BlogPost::setCategories( const QStringList &categories )
00270 {
00271   d_ptr->mCategories = categories;
00272 }
00273 
00274 KDateTime BlogPost::creationDateTime() const
00275 {
00276   return d_ptr->mCreationDateTime;
00277 }
00278 
00279 void BlogPost::setCreationDateTime( const KDateTime &datetime )
00280 {
00281   d_ptr->mCreationDateTime = datetime;
00282 }
00283 
00284 KDateTime BlogPost::modificationDateTime() const
00285 {
00286   return d_ptr->mModificationDateTime;
00287 }
00288 
00289 void BlogPost::setModificationDateTime( const KDateTime &datetime )
00290 {
00291   d_ptr->mModificationDateTime = datetime;
00292 }
00293 
00294 BlogPost::Status BlogPost::status() const
00295 {
00296   return d_ptr->mStatus;
00297 }
00298 
00299 void BlogPost::setStatus( BlogPost::Status status )
00300 {
00301   d_ptr->mStatus = status;
00302 }
00303 
00304 QString BlogPost::error() const
00305 {
00306   return d_ptr->mError;
00307 }
00308 
00309 void BlogPost::setError( const QString &error )
00310 {
00311   d_ptr->mError = error;
00312 }
00313 
00314 BlogPost &BlogPost::operator=( const BlogPost &other )
00315 {
00316   BlogPost copy( other );
00317   swap( copy );
00318   return *this;
00319 }
00320 
00321 } // namespace KBlog
00322 

KBlog Client Library

Skip menu "KBlog Client Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal