Blokkal
an Extendable KDE Blogging Client
SourceForge.net Logo

editentrywidget.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 "editentrywidget.h"
00021 #include "editentrywidget.moc"
00022 
00023 #include "../blokkalprotocol.h"
00024 #include "../blokkalaccount.h"
00025 #include "../blokkalblog.h"
00026 #include "../blokkalentry.h"
00027 #include "../blokkalio/categorymanager.h"
00028 #include "entryextensionwidget.h"
00029 #include "htmlentrytextedit.h"
00030 #include "categoryview.h"
00031 #include "formattingbackend.h"
00032 
00033 #include <klineedit.h>
00034 #include <kdatetimewidget.h>
00035 #include <kpushbutton.h>
00036 #include <klocale.h>
00037 #include <kdialog.h>
00038 #include <kxmlguifactory.h>
00039 #include <kmenu.h>
00040 #include <kiconloader.h>
00041 #include <kdebug.h>
00042 #include <kactioncollection.h>
00043 #include <kaction.h>
00044 #include <kpushbutton.h>
00045 
00046 #include <QLayout>
00047 #include <QLabel>
00048 #include <QCheckBox>
00049 #include <QTimer>
00050 #include <QSignalMapper>
00051 #include <QSplitter>
00052 
00053 class Blokkal::Ui::EditEntryWidget::Private
00054 {
00055 public:
00056         Private( Blokkal::Entry * entry, unsigned int features ) :
00057         entry( entry ),
00058         features( features ),
00059         entryHadNoDate( FALSE ),
00060         extension0( 0 ),
00061         extension1( 0 ),
00062         extension2( 0 ),
00063         extension3( 0 ),
00064         extension4( 0 ),
00065         addCategoryButton( 0 ),
00066         addCategoryPopup( 0 ),
00067         newCategoryLineEdit( 0 ),
00068         removeCategoryButton( 0 ),
00069         removeCategoryPopup( 0 ) {}
00070 
00071         Blokkal::Entry * const entry;
00072         const unsigned int features;
00073 
00074         KDateTimeWidget * dateWidget;
00075         QCheckBox * useCurrentDateCheckBox;
00076 
00077         QLabel * subjectLabel;
00078         KLineEdit * subjectLineEdit;
00079 
00080         QSplitter * textCategorySplitter;
00081         Blokkal::Ui::HtmlEntryTextEdit * entryTextEdit;
00082 
00083         QSplitter * categoryExtensionSplitter;
00084         QWidget * categoryToolsContainer;
00085         Blokkal::Ui::CategoryView * categoryView;
00086 
00087         bool entryHadNoDate;
00088         EntryExtensionWidget * extension0;
00089         EntryExtensionWidget * extension1;
00090         EntryExtensionWidget * extension2;
00091         EntryExtensionWidget * extension3;
00092         EntryExtensionWidget * extension4;
00093         FormattingBackend * formattingBackend;
00094         
00095         KPushButton * addCategoryButton;
00096         KMenu * addCategoryPopup;
00097         KLineEdit * newCategoryLineEdit;
00098 
00099         KPushButton * removeCategoryButton;
00100         KMenu * removeCategoryPopup;
00101         QMap<QString, KAction * > removeCategoryActions;
00102         QSignalMapper * removeCategoryMapper;
00103         KActionCollection * removeActionCollection;
00104 
00105         QString caption;
00106 };
00107 
00108 Blokkal::Ui::EditEntryWidget::EditEntryWidget( Blokkal::Entry * entry, QWidget * parentWidget ) :
00109 QWidget( parentWidget ),
00110 d( new Private( entry, entry->blog()->supportedFeatures() ) )
00111 {
00112         setLayout( new QVBoxLayout( this ) );
00113         layout()->setMargin( 0 );
00114 
00115         d->extension0 = entry->createExtensionWidget( EntryExtensionWidget::ExtensionWidget0, this );
00116         if( d->extension0 ) {
00117                 connect( d->extension0,
00118                          SIGNAL( contentChanged( Blokkal::Ui::EntryExtensionWidget * ) ),
00119                          SLOT( emitContentsChanged( void ) ) );
00120                 layout()->addWidget( d->extension0 );
00121         }
00122         //date
00123         QHBoxLayout * dateLayout = new QHBoxLayout( 0 );
00124         dateLayout->setMargin( 0 );
00125         dateLayout->setSpacing( KDialog::spacingHint() );
00126         d->dateWidget = new KDateTimeWidget( this );
00127         dateLayout->addWidget( d->dateWidget );
00128         d->useCurrentDateCheckBox = new QCheckBox( i18n( "Use current date" ), this );
00129         dateLayout->addWidget( d->useCurrentDateCheckBox );
00130         layout()->addItem( dateLayout );
00131         connect( d->dateWidget,
00132                  SIGNAL( valueChanged ( const QDateTime & ) ),
00133                  SLOT( slotDateChanged( void ) ) );
00134         d->extension1 = entry->createExtensionWidget( EntryExtensionWidget::ExtensionWidget1, this );
00135         if( d->extension1 ) {
00136                 connect( d->extension1,
00137                          SIGNAL( contentChanged( Blokkal::Ui::EntryExtensionWidget * ) ),
00138                          SLOT( emitContentsChanged( void ) ) );
00139                 dateLayout->addWidget( d->extension1 );
00140         }
00141 
00142         //subject
00143         QHBoxLayout * subjectLayout = new QHBoxLayout( 0 );
00144         subjectLayout->setMargin( 0 );
00145         subjectLayout->setSpacing( KDialog::spacingHint() );
00146         d->subjectLabel = new QLabel( i18n( "Subject"), this );
00147         subjectLayout->addWidget( d->subjectLabel );
00148         d->subjectLineEdit = new KLineEdit( this );
00149         d->subjectLabel->setBuddy( d->subjectLineEdit );
00150         subjectLayout->addWidget( d->subjectLineEdit );
00151         layout()->addItem( subjectLayout );
00152         connect( d->subjectLineEdit,
00153                  SIGNAL( textChanged ( const QString & ) ),
00154                  SLOT( emitContentsChanged( void ) ) );
00155         d->extension2 = entry->createExtensionWidget( EntryExtensionWidget::ExtensionWidget2, this );
00156         if( d->extension2 ) {
00157                 connect( d->extension2,
00158                          SIGNAL( contentChanged( Blokkal::Ui::EntryExtensionWidget * ) ),
00159                          SLOT( emitContentsChanged( void ) ) );
00160                 subjectLayout->addWidget( d->extension2 );
00161         }
00162 
00163         //text edit
00164         d->textCategorySplitter = new QSplitter( this );
00165         layout()->addWidget( d->textCategorySplitter );
00166         QSizePolicy policy( QSizePolicy::Expanding, QSizePolicy::Expanding );
00167         policy.setVerticalStretch( 2 );
00168         policy.setHorizontalStretch( 2 );
00169         d->textCategorySplitter->setSizePolicy( policy );
00170         d->entryTextEdit = new HtmlEntryTextEdit();
00171         d->textCategorySplitter->addWidget( d->entryTextEdit );
00172         d->textCategorySplitter->setStretchFactor( 0, 2 );
00173         connect( d->entryTextEdit,
00174                  SIGNAL( plainTextChanged( void ) ),
00175                  SLOT( emitContentsChanged( void ) ) );
00176         
00177         //category view + extension
00178         d->categoryExtensionSplitter = new QSplitter( Qt::Vertical );
00179         d->textCategorySplitter->addWidget( d->categoryExtensionSplitter );
00180         d->categoryExtensionSplitter->setMinimumWidth( 30 );
00181         d->extension3 = entry->createExtensionWidget( EntryExtensionWidget::ExtensionWidget3, this );
00182         if( d->extension3 ) {
00183                 d->categoryExtensionSplitter->addWidget( d->extension3 );
00184                 connect( d->extension3,
00185                          SIGNAL( contentChanged( Blokkal::Ui::EntryExtensionWidget * ) ),
00186                          SLOT( emitContentsChanged( void ) ) );
00187                 connect( d->extension3,
00188                          SIGNAL( visibilityChanged( void ) ),
00189                          SLOT( updateSplitterVisibility( void ) ) );
00190         }
00191         d->categoryToolsContainer = new QWidget( );
00192         d->categoryExtensionSplitter->addWidget( d->categoryToolsContainer );
00193         QVBoxLayout * categoryToolsContainerLayout = new QVBoxLayout( d->categoryToolsContainer );
00194         categoryToolsContainerLayout->setMargin( 0 );
00195         d->categoryView = new CategoryView( entry,
00196                                             !( d->features & Blog::FeatureMultipleCategories ),
00197                                             d->categoryToolsContainer );
00198         categoryToolsContainerLayout->addWidget( d->categoryView );
00199         d->categoryView->selectCategories( entry->categories() );
00200         connect( d->categoryView,
00201                  SIGNAL( categorySelectionChanged( void ) ),
00202                  SLOT( emitContentsChanged( void ) ) );
00203         if( ( ( d->features & ( Blog::FeatureAddCategories ) ) & ~Blog::FeatureCategory )
00204             || ( ( d->features & ( Blog::FeatureRemoveCategories ) ) & ~Blog::FeatureCategory ) )
00205         {
00206                 QHBoxLayout * categoryToolsLayout = new QHBoxLayout( 0 );
00207                 categoryToolsLayout->setMargin( 0 );
00208                 if( ( d->features & ( Blog::FeatureAddCategories ) ) & ~Blog::FeatureCategory ) {
00209                         //setup button
00210                         d->addCategoryButton = new KPushButton( d->categoryToolsContainer );
00211                         KGuiItem addItem;
00212                         addItem = KStandardGuiItem::add();
00213                         if( addItem.icon().isNull() ) {
00214                                 d->addCategoryButton->setText( addItem.text() );
00215                         }
00216                         else {
00217                                 d->addCategoryButton->setIcon( addItem.icon() );
00218                         }
00219                         d->addCategoryButton->setToolTip( i18n( "Add Categories" ) );
00220                         categoryToolsLayout->addWidget( d->addCategoryButton );
00221                         //setup popup
00222                         d->addCategoryPopup = new KMenu( this );
00223                         QWidget * newCategoryItem = new QWidget( d->addCategoryPopup );
00224                         QLayout * newCategoryItemLayout = new QHBoxLayout( newCategoryItem );
00225                         newCategoryItemLayout->setMargin( 1 );
00226                         QLabel * newCategoryLabel = new QLabel( newCategoryItem );
00227                         newCategoryLabel->setPixmap( SmallIcon( "document-new" ) );
00228                         newCategoryItemLayout->addWidget( newCategoryLabel );
00229                         d->newCategoryLineEdit = new KLineEdit( newCategoryItem );
00230                         newCategoryItemLayout->addWidget( d->newCategoryLineEdit );
00231                         d->newCategoryLineEdit->setFocusPolicy( Qt::ClickFocus );
00232                         connect( d->newCategoryLineEdit,
00233                                  SIGNAL( returnPressed( void ) ),
00234                                  SLOT( emitNewCategory( void ) ) );
00235                         newCategoryLabel->setBuddy( d->newCategoryLineEdit );
00236                         KAction * newCategoryAction = new KAction( KIcon("filenew"), i18n("New Category..."), d->addCategoryPopup );
00237                         newCategoryAction->setDefaultWidget( newCategoryItem );
00238                         d->addCategoryPopup->addAction( newCategoryAction );
00239                         
00240                         d->addCategoryButton->setMenu( d->addCategoryPopup );
00241                         //d->addCategoryButton->setMenuDelay( 1 );
00242                 }
00243                 if( ( d->features & ( Blog::FeatureRemoveCategories ) ) & ~Blog::FeatureCategory ) {
00244                         //setup button
00245                         d->removeCategoryButton = new KPushButton( d->categoryToolsContainer );
00246                         KGuiItem removeItem;
00247                         removeItem = KStandardGuiItem::remove();
00248                         if( removeItem.icon().isNull() ) {
00249                                 d->removeCategoryButton->setText( removeItem.text() );
00250                         }
00251                         else {
00252                                 d->removeCategoryButton->setIcon( removeItem.icon() );
00253                         }
00254                         d->removeCategoryButton->setToolTip( i18n( "Remove Categories" ) );
00255                         categoryToolsLayout->addWidget( d->removeCategoryButton );
00256                         //setup popup
00257                         d->removeCategoryPopup = new KMenu( this );
00258                         d->removeCategoryButton->setMenu( d->removeCategoryPopup );
00259                         //d->removeCategoryButton->setPopupDelay( 1 );
00260                         d->removeActionCollection = new KActionCollection( d->removeCategoryPopup );
00261                         d->removeCategoryMapper = new QSignalMapper( this );
00262                         connect( d->removeCategoryMapper,
00263                                  SIGNAL( mapped( const QString & ) ),
00264                                  SLOT( emitCategoryRemoved( const QString & ) ) );
00265                         Io::CategoryManager * categoryManager = entry->blog()->account()->categoryManager();
00266                         Io::CategoryList categoryList = categoryManager->categories( entry->blog()->id() );
00267                         for( Blokkal::Io::CategoryList::ConstIterator it = categoryList.begin();
00268                              it != categoryList.end();
00269                              ++it )
00270                         {
00271                                 QString actionText = (*it)->name();
00272                                 actionText.replace( '&', "&&" );
00273                                 KAction * action = new KAction( actionText,d->removeActionCollection );
00274                                 d->removeCategoryActions.insert( (*it)->id(), action );
00275                                 connect( action, SIGNAL( triggered (Qt::MouseButtons, Qt::KeyboardModifiers ) ),
00276                                          d->removeCategoryMapper, SLOT( map( void ) ) );
00277                                 d->removeCategoryMapper->setMapping( action, (*it)->id() );
00278                                 /*action->setShortcut( 0 );
00279                                 unsigned index = 0;
00280                                 for( ; index < d->removeCategoryPopup->count(); ++index ) {
00281                                         if( QString::localeAwareCompare( d->removeCategoryPopup->text( d->removeCategoryPopup->idAt( index ) ),
00282                                                                          actionText ) > 0 )
00283                                         {
00284                                                 break;
00285                                         }
00286                                 }
00287                                 d->removeCategoryActions[(*it)->id()]->plug(d->removeCategoryPopup, index );*/
00288                                 d->removeCategoryPopup->addAction( action );
00289                         }
00290                 }
00291                 
00292                 categoryToolsContainerLayout->addLayout( categoryToolsLayout );
00293         }
00294         
00295         //extension 4
00296         d->extension4 = entry->createExtensionWidget( EntryExtensionWidget::ExtensionWidget4, this );
00297         if( d->extension4 ) {
00298                 connect( d->extension4,
00299                          SIGNAL( contentChanged( Blokkal::Ui::EntryExtensionWidget * ) ),
00300                          SLOT( emitContentsChanged( void ) ) );
00301                 layout()->addWidget( d->extension4 );
00302         }
00303 
00304         //initialisation done, set widget contents
00305         rollBack();
00306 
00307         //start update timer
00308         QTimer * timer = new QTimer( this );
00309         connect( timer,
00310                  SIGNAL( timeout( void ) ),
00311                  SLOT( updateEntryDateTime( void ) ) );
00312         timer->start( 500 );
00313 
00314         if( d->extension0 ) {
00315                 d->extension0->postInit();
00316         }
00317         if( d->extension1 ) {
00318                 d->extension1->postInit();
00319         }
00320         if( d->extension2 ) {
00321                 d->extension2->postInit();
00322         }
00323         if( d->extension3 ) {
00324                 d->extension3->postInit();
00325         }
00326         if( d->extension4 ) {
00327                 d->extension4->postInit();
00328         }
00329 
00330         d->formattingBackend = entry->blog()->account()->protocol()->createFormattingBackend( this );
00331         d->formattingBackend->setTextEdit( d->entryTextEdit );
00332 
00333         hideFeature( 0 );
00334 
00335         KConfigGroup configGroup = KGlobal::config()->group( "EditEntryWidget" );
00336         d->textCategorySplitter->restoreState( configGroup.readEntry( "text-category-splitter-state", QByteArray() ) );
00337 }
00338 
00339 Blokkal::Ui::EditEntryWidget::~EditEntryWidget( void )
00340 {
00341         KConfigGroup configGroup = KGlobal::config()->group( "EditEntryWidget" );
00342         if( d->features & Blog::FeatureCategory
00343             && !d->categoryExtensionSplitter->isHidden() )
00344         {
00345                 configGroup.writeEntry( "text-category-splitter-state", d->textCategorySplitter->saveState() );
00346         }
00347 
00348         delete d;
00349 }
00350 
00351 Blokkal::Entry * Blokkal::Ui::EditEntryWidget::entry( void ) const
00352 {
00353         return d->entry;
00354 }
00355 
00356 Blokkal::Entry * Blokkal::Ui::EditEntryWidget::apply( void )
00357 {
00358         entry()->setDate( d->dateWidget->dateTime() );
00359         entry()->setSubject( d->subjectLineEdit->text() );
00360         entry()->setText( d->entryTextEdit->toPlainText() );
00361         entry()->setCategories( d->categoryView->selectedCategories() );
00362 
00363         if( d->extension0 ) {
00364                 d->extension0->apply();
00365         }
00366         if( d->extension1 ) {
00367                 d->extension1->apply();
00368         }
00369         if( d->extension2 ) {
00370                 d->extension2->apply();
00371         }
00372         if( d->extension3 ) {
00373                 d->extension3->apply();
00374         }
00375         if( d->extension4 ) {
00376                 d->extension4->apply();
00377         }
00378         
00379 
00380         return entry();
00381 }
00382 
00383 
00384 void Blokkal::Ui::EditEntryWidget::updateEntryDateTime( void )
00385 {
00386         if( d->useCurrentDateCheckBox->isChecked() ) {
00387                 d->dateWidget->setDateTime( QDateTime::currentDateTime() );
00388         }
00389 }
00390 
00391 void Blokkal::Ui::EditEntryWidget::emitContentsChanged( void )
00392 {
00393         emit contentsChanged();
00394 
00395         if( !d->subjectLineEdit->hasFocus()
00396             && !d->entryTextEdit->hasFocus() )
00397         {
00398                 return;
00399         }
00400 
00401         const int maxCaptionLength = 50;
00402         //the +1 is needed for the "..." replacement below to work
00403         if( ( d->subjectLineEdit->hasFocus()
00404               && d->subjectLineEdit->cursorPosition() > maxCaptionLength + 1 )
00405             || ( d->entryTextEdit->hasFocus()
00406                  && d->entryTextEdit->textCursor().position() > maxCaptionLength + 1) )
00407         {
00408                 return;
00409         }
00410 
00411 
00412         QString subject = d->subjectLineEdit->text();
00413         QString newCaption = QString::null;
00414         if( !subject.isEmpty() ) {
00415                 newCaption = subject;
00416         }
00417         else {
00418                 QTextBlock currentBlock = d->entryTextEdit->document()->findBlock( 0 );
00419                 int needed = maxCaptionLength + 1;
00420                 for( ;
00421                      currentBlock.isValid() && needed > 0;
00422                      currentBlock = currentBlock.next() )
00423                 {
00424                         QString text = currentBlock.text();
00425                         newCaption.append( text.left( needed ) );
00426                         needed -= text.length();
00427                         needed = needed < 0 ? 0 : needed;
00428                 }
00429         }
00430 
00431         if( newCaption.length() > maxCaptionLength ) {
00432                 newCaption = newCaption.left( maxCaptionLength );
00433                 const QString elideString = i18n( "..." );
00434                 newCaption.replace( maxCaptionLength - elideString.length(),
00435                                     elideString.length(),
00436                                     elideString );
00437         }       
00438 
00439         if( caption() != newCaption ) {
00440                 setCaption( newCaption );
00441                 emit captionChanged( caption() );
00442         }
00443 }
00444 
00445 void Blokkal::Ui::EditEntryWidget::slotDateChanged( void )
00446 {
00447         //if the entry was created by this widget
00448         //the new date is not really a modification
00449         if( !( d->useCurrentDateCheckBox->isChecked() && d->entryHadNoDate ) ) {
00450                 emitContentsChanged();
00451         }
00452 }
00453 
00454 Blokkal::Ui::EntryExtensionWidget * Blokkal::Ui::EditEntryWidget::extensionWidget( EntryExtensionWidget::ExtensionWidget extension ) const
00455 {
00456         switch( extension ) {
00457         case EntryExtensionWidget::ExtensionWidget0:
00458                 return d->extension0;
00459                 break;
00460         case EntryExtensionWidget::ExtensionWidget1:
00461                 return d->extension1;
00462                 break;
00463         case EntryExtensionWidget::ExtensionWidget2:
00464                 return d->extension2;
00465                 break;
00466         case EntryExtensionWidget::ExtensionWidget3:
00467                 return d->extension3;
00468                 break;
00469         case EntryExtensionWidget::ExtensionWidget4:
00470                 return d->extension4;
00471                 break;
00472         }
00473         
00474         return 0;
00475 }
00476 
00477 bool Blokkal::Ui::EditEntryWidget::isContentLegal( void )
00478 {
00479         return !d->entryTextEdit->document()->isEmpty();
00480 }
00481 
00482 void Blokkal::Ui::EditEntryWidget::emitNewCategory( void )
00483 {
00484         if( !d->newCategoryLineEdit ) {
00485                 kWarning() << k_funcinfo << "has been called with 0 newCategoryLineEdit!" << endl;
00486                 return;
00487         }
00488 
00489         if( d->addCategoryPopup ) {
00490                 d->addCategoryPopup->close();
00491         }
00492         else {
00493                 kWarning() << k_funcinfo << "has been called with 0 addCategoryPopup!" << endl;
00494         }
00495 
00496         emit newCategory( d->newCategoryLineEdit->text() );
00497         d->newCategoryLineEdit->clear();
00498 }
00499 
00500 void Blokkal::Ui::EditEntryWidget::emitCategoryRemoved( const QString & categoryId )
00501 {
00502         emit destroyCategory( categoryId );
00503 }
00504 
00505 void Blokkal::Ui::EditEntryWidget::rollBack( void )
00506 {
00507         d->subjectLineEdit->setText( entry()->subject() );
00508         d->entryTextEdit->setPlainText( entry()->text() );
00509         d->categoryView->selectCategories( entry()->categories() );
00510 
00511         if( entry()->id().isNull() ) {
00512                 d->dateWidget->setDateTime( QDateTime::currentDateTime() );
00513                 d->useCurrentDateCheckBox->setChecked( TRUE );
00514                 d->entryHadNoDate = TRUE;
00515         }
00516         else {
00517                 d->dateWidget->setDateTime( entry()->date() );
00518                 d->useCurrentDateCheckBox->setChecked( FALSE );
00519                 d->entryHadNoDate = FALSE;
00520         }
00521         
00522         if( d->extension0 ) {
00523                 d->extension0->rollBack();
00524         }
00525         if( d->extension1 ) {
00526                 d->extension1->rollBack();
00527         }
00528         if( d->extension2 ) {
00529                 d->extension2->rollBack();
00530         }
00531         if( d->extension3 ) {
00532                 d->extension3->rollBack();
00533         }
00534         if( d->extension4 ) {
00535                 d->extension4->rollBack();
00536         }
00537 }
00538 
00539 void Blokkal::Ui::EditEntryWidget::hideFeature( unsigned int hideFeatures )
00540 {
00541         if( hideFeatures & Blog::FeatureDate ) {
00542                 d->dateWidget->hide();
00543                 d->useCurrentDateCheckBox->hide();
00544         }
00545         else if( d->features & Blog::FeatureDate ) {
00546                 d->dateWidget->show();
00547                 d->useCurrentDateCheckBox->show();
00548         }
00549         else {
00550                 d->dateWidget->hide();
00551                 d->useCurrentDateCheckBox->hide();              
00552         }
00553         
00554         if( hideFeatures & Blog::FeatureSubject ) {
00555                 d->subjectLabel->hide();
00556                 d->subjectLineEdit->hide();
00557         }
00558         else if( d->features & Blog::FeatureSubject ) {
00559                 d->subjectLabel->show();
00560                 d->subjectLineEdit->show();
00561         }
00562         else {
00563                 d->subjectLabel->hide();
00564                 d->subjectLineEdit->hide();             
00565         }
00566         
00567         if( hideFeatures & Blog::FeatureText ) {
00568                 d->entryTextEdit->setEnabled( FALSE );
00569         }
00570         else if( d->features & Blog::FeatureText ) {
00571                 d->entryTextEdit->setEnabled( TRUE );
00572         }
00573         else {
00574                 d->entryTextEdit->setEnabled( FALSE );
00575         }
00576         
00577         if( hideFeatures & Blog::FeatureCategory ) {
00578                 d->categoryToolsContainer->hide();
00579         }
00580         else if( d->features & Blog::FeatureCategory ) {
00581                 d->categoryToolsContainer->show();
00582         }
00583         else {
00584                 d->categoryToolsContainer->hide();
00585         }
00586         
00587         if( ( hideFeatures & Blog::FeatureAddCategories )
00588             && d->addCategoryButton )
00589         {
00590                 d->addCategoryButton->hide();
00591         }
00592         else if( ( ( d->features & ( Blog::FeatureAddCategories ) ) & ~Blog::FeatureCategory )
00593                  && d->addCategoryButton )
00594         {
00595                 d->addCategoryButton->show();
00596         }
00597         else if( d->addCategoryButton ) {
00598                 d->addCategoryButton->hide();
00599         }
00600         
00601         if( ( hideFeatures & Blog::FeatureRemoveCategories )
00602             && d->removeCategoryButton )
00603         {
00604                 d->removeCategoryButton->hide();
00605         }
00606         else if( ( ( d->features & ( Blog::FeatureRemoveCategories ) ) & ~Blog::FeatureCategory )
00607                  && d->removeCategoryButton )
00608         {
00609                 d->removeCategoryButton->show();
00610         }
00611         else if( d->removeCategoryButton ) {
00612                 d->removeCategoryButton->show();
00613         }
00614 
00615         updateSplitterVisibility();
00616 }
00617 
00618 QString Blokkal::Ui::EditEntryWidget::caption( void ) const
00619 {
00620         return d->caption;
00621 }
00622 
00623 void Blokkal::Ui::EditEntryWidget::setCaption( const QString & caption )
00624 {
00625         d->caption = caption;
00626 }
00627 
00628 void Blokkal::Ui::EditEntryWidget::updateSplitterVisibility( void )
00629 {
00630         if( d->categoryToolsContainer->isHidden()
00631             && ( !d->extension3 || ( d->extension3
00632                                      && d->extension3->isHidden() ) ) )
00633         {
00634                 d->categoryExtensionSplitter->hide();
00635         }
00636         else if ( !d->categoryToolsContainer->isHidden()
00637                   || ( d->extension3
00638                        && !d->extension3->isHidden() ) )
00639         {
00640                 d->categoryExtensionSplitter->show();
00641         }
00642 }
00643 
00644 Blokkal::Ui::HtmlEntryTextEdit * Blokkal::Ui::EditEntryWidget::entryTextEdit( void ) const
00645 {
00646         return d->entryTextEdit;
00647 }
00648 
00649 Blokkal::Ui::FormattingBackend * Blokkal::Ui::EditEntryWidget::formattingBackend( void ) const
00650 {
00651         return d->formattingBackend;
00652 }