Blokkal
an Extendable KDE Blogging Client
SourceForge.net Logo

blokkalblog.cpp

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 #include "blokkalblog.h"
00021 #include "blokkalblog.moc"
00022 
00023 #include "blokkalpluginmanager.h"
00024 #include "blokkalaccount.h"
00025 #include "blokkalblogconfig.h"
00026 #include "blokkalentry.h"
00027 #include "blokkalbehavioursettings.h"
00028 #include "blokkalui/editentrywidget.h"
00029 #include "blokkalui/browseentryviewfactory.h"
00030 #include "blokkalui/globalsettings.h"
00031 #include "blokkalui/view.h"
00032 #include "blokkalio/blogbrowsingdriver.h"
00033 
00034 #include <kdebug.h>
00035 #include <kicon.h>
00036 #include <kmessagebox.h>
00037 
00038 class Blokkal::Blog::Private {
00039 public:
00040         Private( void ) {}
00041 
00042         Account * account;
00043         BlogConfig * config;
00044 };
00045 
00046 Blokkal::Blog::Blog( Blokkal::Account * parentAccount, const QString & id ) :
00047 QObject( parentAccount ),
00048 d( new Private() )
00049 {
00050         d->account = parentAccount;
00051         d->config = new BlogConfig( id, parentAccount );
00052 }
00053 
00054 Blokkal::Blog::~Blog( void )
00055 {
00056         emit blogDestroyed( this );
00057         delete d->config;
00058         delete d;
00059 }
00060 
00061 QString Blokkal::Blog::type( void ) const
00062 {
00063         return i18n( "Blog" );
00064 }
00065 
00066 QString Blokkal::Blog::title( void ) const
00067 {
00068         return config()->title();
00069 }
00070 
00071 void Blokkal::Blog::setTitle( const QString & title )
00072 {
00073         config()->setTitle( title );
00074         emit propertiesChanged( this );
00075 }
00076 
00077 KIcon Blokkal::Blog::icon( void ) const
00078 {
00079         return account()->icon();
00080 }
00081 
00082 Blokkal::Account * Blokkal::Blog::account( void ) const
00083 {
00084         return d->account;
00085 }
00086 
00087 void Blokkal::Blog::startNewEntry( void )
00088 {
00089         Blokkal::Entry * const entry = createEntry();
00090         Ui::View * const view = entry->view();
00091         if( !view ) {
00092                 KMessageBox::error( Ui::GlobalSettings::self()->mainWidget(), i18n( "Unable to create a view." ) );
00093                 delete entry;
00094                 return;
00095         }
00096         
00097         view->showView();
00098 }
00099 
00100 void Blokkal::Blog::browseEntries( void )
00101 {
00102         
00103         if( blogBrowsingDriver() ) {
00104                 Ui::BrowseEntryDialog * const browseView = blogBrowsingDriver()->browseBlogDialog( Io::BlogBrowsingDriver::BrowseEdit );
00105                 if( !browseView ) {
00106                         KMessageBox::error( Ui::GlobalSettings::self()->mainWidget(),
00107                                             i18n( "The component required to browse old entries failed to load." ) );
00108                         return;
00109                 }
00110                 browseView->show();
00111         }
00112         else {
00113                 kError() << "no BlogBrowsingDriver" << endl;
00114         }
00115 }
00116 
00117 QString Blokkal::Blog::id( void ) const
00118 {
00119         return config()->id();
00120 }
00121 
00122 Blokkal::BlogConfig * Blokkal::Blog::config( void ) const
00123 {
00124         return d->config;
00125 }
00126 
00127 void Blokkal::Blog::removeBlog( void )
00128 {
00129         config()->remove();
00130         deleteLater();
00131 }
00132 
00133 void Blokkal::Blog::saveProperties( void )
00134 {
00135 }
00136 
00137 Blokkal::Ui::EditEntryWidget * Blokkal::Blog::createEditEntryWidget( Blokkal::Entry * entry, QWidget * parent )
00138 {
00139         return new Ui::EditEntryWidget( entry, parent );
00140 }
00141 
00142 unsigned int Blokkal::Blog::supportedFeatures( void ) const
00143 {
00144         return FeatureDate|FeatureSubject|FeatureText;
00145 }
00146 
00147 QList< QAction * > Blokkal::Blog::actionList( void )
00148 {
00149         return QList<QAction*>();
00150 }