Blokkal
an Extendable KDE Blogging Client
SourceForge.net Logo

blokkalentry.h

00001 /***************************************************************************
00002  *   Copyright (C) 2006 - 2008 by Martin Mueller                           *
00003  *   orvio@orvio.de                                                        *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef BLOKKALBLOKKALENTRY_H
00021 #define BLOKKALBLOKKALENTRY_H
00022 
00023 #include "blokkalconfigbase.h"
00024 #include "blokkal_export.h"
00025 #include "blokkalui/entryextensionwidget.h"
00026 
00027 #include <kurl.h>
00028 
00029 #include <QtCore/QObject>
00030 
00031 class KIcon;
00032 
00033 namespace Blokkal {
00034 class Blog;
00035 namespace Ui {
00036 class View;
00037 }
00038 namespace Io {
00039 class EntryJob;
00040 }
00047 class BLOKKAL_EXPORT Entry : public QObject, protected Blokkal::ConfigBase
00048 {
00049 Q_OBJECT
00050 public:
00054         enum JobType {
00055                 PostJob = 1, 
00056                 DeleteJob = 2, 
00057                 UserJob = 10 
00058         };
00059                 
00066         virtual ~Entry( void );
00067 
00072         QString id( void ) const;
00073 
00078         Blokkal::Blog * blog( void ) const;
00079 
00084         virtual QString text( void ) const;
00085 
00090         virtual QString subject( void ) const;
00091 
00099         virtual QString preview( void ) const;
00100 
00105         virtual KIcon icon( void ) const;
00106 
00111         QDateTime date( void ) const;
00112 
00117         void setDate( const QDateTime & date );
00118 
00123         void setSubject( const QString & subject);
00124 
00129         void setText( const QString & text );
00130 
00135         virtual Blokkal::Io::EntryJob * createJob( Blokkal::Entry::JobType type ) = 0;
00136 
00140         Blokkal::Ui::View * view( void );
00141 
00152         QString fileName( bool check = FALSE ) const;
00153 
00159         bool saveAs( const QString & fileName );
00160 
00168         virtual Blokkal::Ui::EntryExtensionWidget * createExtensionWidget( Ui::EntryExtensionWidget::ExtensionWidget extension, Blokkal::Ui::EditEntryWidget * parent );
00169 
00183         static Blokkal::Entry * open( const QString & fileName, bool * canceled = 0, bool neverAsk = FALSE );
00184 
00189         QStringList categories( void ) const;
00190 
00195         void setCategories( const QStringList & ids );
00196 
00206         virtual void merge( const Blokkal::Entry * entry );
00207 
00214         bool isDirty( void ) const;
00215 
00221         void setDirty( bool dirty );
00222 
00229         KUrl url( void ) const;
00230 
00231 public Q_SLOTS:
00235         void ref( void );
00236 
00241         void deref( void );
00242         
00243 Q_SIGNALS:
00248         void entryDestroyed( Blokkal::Entry * entry );
00249 
00250 protected:
00261         Entry( Blog * parentBlog, const QString & id = QString::null, const KUrl & url = KUrl() );
00262 
00268         void setFileName( const QString & fileName ) const;
00269 
00276         virtual void saveProperties( void );
00277 
00284         virtual void readProperties( void );
00285 
00286 private:
00287         class Private;
00288         Private * const d;
00289 };
00290 
00291 }
00292 
00293 #endif