00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "KoStyleCollection.h"
00022 #include "KoStyleDialog.h"
00023 #include "KoStyleDialog.moc"
00024 #include <KoFontDia.h>
00025 #include <KoGlobal.h>
00026
00027 #include <klocale.h>
00028 #include <kiconloader.h>
00029 #include <kdebug.h>
00030
00031 #include <QTabWidget>
00032 #include <QPushButton>
00033 #include <QLabel>
00034 #include <QComboBox>
00035 #include <QCheckBox>
00036 #include <QLayout>
00037 #include <QListWidget>
00038
00039 #include <Q3GridLayout>
00040 #include <Q3PtrList>
00041 #include <QFrame>
00042 #include <Q3ValueList>
00043 #include <QResizeEvent>
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 class KoStyleManagerPrivate
00062 {
00063 public:
00064 KoStylePreview* preview;
00065 QCheckBox* cbIncludeInTOC;
00066 };
00067
00068 KoStyleDialog::KoStyleDialog( QWidget *_parent, KoUnit::Unit unit,
00069 const KoStyleCollection& styles, const QString & activeStyleName,
00070 int flags )
00071 : KDialog( _parent )
00072 {
00073 setCaption( i18n("Style Manager") );
00074 setModal( true );
00075 setObjectName( "Stylist" );
00076 setButtons( Ok|Cancel|Apply );
00077
00078 d = new KoStyleManagerPrivate;
00079
00080 m_currentStyle =0L;
00081 noSignals=true;
00082 m_origStyles.setAutoDelete(false);
00083 m_changedStyles.setAutoDelete(false);
00084 setupWidget(styles);
00085 addGeneralTab( flags );
00086 KoStyleFontTab * fontTab = new KoStyleFontTab( m_tabs );
00087 addTab( fontTab );
00088
00089 KoStyleParagTab *newTab = new KoStyleParagTab( m_tabs );
00090 newTab->setWidget( new KoIndentSpacingWidget( unit, -1,newTab ) );
00091 addTab( newTab );
00092
00093 newTab = new KoStyleParagTab( m_tabs );
00094 newTab->setWidget( new KoParagAlignWidget( true, newTab ) );
00095 addTab( newTab );
00096
00097 newTab = new KoStyleParagTab( m_tabs );
00098 KoParagLayoutWidget *decorations = new KoParagDecorationWidget( newTab );
00099 decorations->layout()->setMargin(KDialog::marginHint());
00100 newTab->setWidget( decorations );
00101 addTab( newTab );
00102
00103 newTab = new KoStyleParagTab( m_tabs );
00104 newTab->setWidget( new KoParagCounterWidget( false , newTab ) );
00105 addTab( newTab );
00106
00107 newTab = new KoStyleParagTab( m_tabs );
00108 newTab->setWidget( new KoParagTabulatorsWidget( unit, -1, newTab ) );
00109 addTab( newTab );
00110
00111 QList<QListWidgetItem *> tmp = m_stylesList->findItems( activeStyleName, Qt::MatchExactly );
00112 if( !tmp.isEmpty() )
00113 m_stylesList->setCurrentItem( tmp.first() );
00114 else
00115 m_stylesList->setCurrentRow( 0 );
00116
00117 noSignals=false;
00118 switchStyle();
00119 setInitialSize( QSize( 600, 570 ) );
00120 }
00121
00122 KoStyleDialog::~KoStyleDialog()
00123 {
00124 for (unsigned int i =0 ; m_origStyles.count() > i ; i++) {
00125 KoParagStyle *orig = m_origStyles.at(i);
00126 KoParagStyle *changed = m_changedStyles.at(i);
00127 if( orig && changed && orig != changed )
00128 delete changed;
00129 }
00130
00131 delete d;
00132 }
00133
00134 void KoStyleDialog::addTab( KoStyleManagerTab * tab )
00135 {
00136 m_tabsList.append( tab );
00137 m_tabs->addTab( tab, tab->tabName() );
00138 tab->layout()->activate();
00139 }
00140
00141 void KoStyleDialog::setupWidget(const KoStyleCollection& styleCollection)
00142 {
00143 QFrame * frame1 = new QFrame();
00144 setMainWidget(frame1);
00145 Q3GridLayout *frame1Layout = new Q3GridLayout( frame1, 0, 0,
00146 0, KDialog::spacingHint() );
00147 numStyles = styleCollection.count();
00148 m_stylesList = new QListWidget( frame1 );
00149 m_stylesList->addItems( styleCollection.displayNameList() );
00150
00151 const Q3ValueList<KoUserStyle*> styleList = styleCollection.styleList();
00152 for ( Q3ValueList<KoUserStyle *>::const_iterator it = styleList.begin(), end = styleList.end();
00153 it != end ; ++it )
00154 {
00155 KoParagStyle* style = static_cast<KoParagStyle *>( *it );
00156 m_origStyles.append( style );
00157 m_changedStyles.append( style );
00158 m_styleOrder<< style->name();
00159 }
00160
00161 frame1Layout->addMultiCellWidget( m_stylesList, 0, 0, 0, 1 );
00162
00163
00164 m_moveUpButton = new QPushButton( frame1 );
00165 m_moveUpButton->setIcon( SmallIconSet( "up" ) );
00166 connect( m_moveUpButton, SIGNAL( clicked() ), this, SLOT( moveUpStyle() ) );
00167 frame1Layout->addWidget( m_moveUpButton, 1, 1 );
00168
00169 m_moveDownButton = new QPushButton( frame1 );
00170 m_moveDownButton->setIcon( SmallIconSet( "down" ) );
00171 connect( m_moveDownButton, SIGNAL( clicked() ), this, SLOT( moveDownStyle() ) );
00172 frame1Layout->addWidget( m_moveDownButton, 1, 0 );
00173
00174
00175 m_deleteButton = new QPushButton( frame1 );
00176 m_deleteButton->setText( i18n( "&Delete" ) );
00177 connect( m_deleteButton, SIGNAL( clicked() ), this, SLOT( deleteStyle() ) );
00178
00179 frame1Layout->addWidget( m_deleteButton, 2, 1 );
00180
00181 m_newButton = new QPushButton( frame1 );
00182 m_newButton->setText( i18n( "New" ) );
00183 connect( m_newButton, SIGNAL( clicked() ), this, SLOT( addStyle() ) );
00184
00185 frame1Layout->addWidget( m_newButton, 2, 0 );
00186
00187 m_tabs = new QTabWidget( frame1 );
00188 frame1Layout->addMultiCellWidget( m_tabs, 0, 2, 2, 2 );
00189
00190 connect( m_stylesList, SIGNAL( selectionChanged() ), this, SLOT( switchStyle() ) );
00191 connect( m_tabs, SIGNAL( currentChanged ( QWidget * ) ), this, SLOT( switchTabs() ) );
00192 }
00193
00194 void KoStyleDialog::addGeneralTab( int flags ) {
00195 QWidget *tab = new QWidget( m_tabs );
00196
00197 Q3GridLayout *tabLayout = new Q3GridLayout( tab );
00198 tabLayout->setSpacing( KDialog::spacingHint() );
00199 tabLayout->setMargin( KDialog::marginHint() );
00200
00201 m_nameString = new QLineEdit( tab );
00202 m_nameString->resize(m_nameString->sizeHint() );
00203 connect( m_nameString, SIGNAL( textChanged( const QString &) ), this, SLOT( renameStyle(const QString &) ) );
00204
00205 tabLayout->addWidget( m_nameString, 0, 1 );
00206
00207 QLabel *nameLabel = new QLabel( tab );
00208 nameLabel->setText( i18n( "Name:" ) );
00209 nameLabel->resize(nameLabel->sizeHint());
00210 nameLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00211
00212 tabLayout->addWidget( nameLabel, 0, 0 );
00213
00214 m_styleCombo = new QComboBox( tab );
00215 m_styleCombo->setEditable( false );
00216
00217 tabLayout->addWidget( m_styleCombo, 1, 1 );
00218
00219 QLabel *nextStyleLabel = new QLabel( tab );
00220 nextStyleLabel->setText( i18n( "Next style:" ) );
00221 nextStyleLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00222
00223 tabLayout->addWidget( nextStyleLabel, 1, 0 );
00224
00225 m_inheritCombo = new QComboBox( tab );
00226 m_inheritCombo->setEditable( false );
00227 tabLayout->addWidget( m_inheritCombo, 2, 1 );
00228
00229 QLabel *inheritStyleLabel = new QLabel( tab );
00230 inheritStyleLabel->setText( i18n( "Inherit style:" ) );
00231 inheritStyleLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00232
00233 tabLayout->addWidget( inheritStyleLabel, 2, 0 );
00234
00235 int row = 3;
00236
00237 if ( flags & ShowIncludeInToc ) {
00238 d->cbIncludeInTOC = new QCheckBox( i18n("Include in table of contents"), tab );
00239 tabLayout->addMultiCellWidget( d->cbIncludeInTOC, row, row, 0, 1 );
00240 ++row;
00241 } else {
00242 d->cbIncludeInTOC = 0;
00243 }
00244
00245
00246
00247
00248
00249 d->preview = new KoStylePreview( i18n( "Preview" ), i18n( "The quick brown fox jumps over the lazy dog. And, what about the cat, one may ask? Well, the cat is playing cards with the mouse, the bird and the fish. It is, to say the least a hell of a party!" ), tab );
00250
00251 tabLayout->addMultiCellWidget( d->preview, row, row, 0, 1 );
00252
00253 m_tabs->addTab( tab, i18n( "General" ) );
00254
00255 m_inheritCombo->addItem( i18n("<None>") );
00256
00257 for ( int i = 0; i < m_stylesList->count(); i++ )
00258 {
00259 m_styleCombo->addItem( m_stylesList->item(i)->text() );
00260 m_inheritCombo->addItem( m_stylesList->item(i)->text() );
00261 }
00262
00263 }
00264
00265 void KoStyleDialog::switchStyle() {
00266 kDebug(32500) << "KoStyleDialog::switchStyle noSignals=" << noSignals << endl;
00267 if(noSignals) return;
00268 noSignals=true;
00269
00270 if(m_currentStyle !=0L)
00271 save();
00272
00273 m_currentStyle = 0L;
00274 int num = styleIndex( m_stylesList->currentRow() );
00275 kDebug(32500) << "KoStyleDialog::switchStyle switching to " << num << endl;
00276 if(m_origStyles.at(num) == m_changedStyles.at(num)) {
00277 m_currentStyle = new KoParagStyle( *m_origStyles.at(num) );
00278 m_changedStyles.take(num);
00279 m_changedStyles.insert(num, m_currentStyle);
00280 } else {
00281 m_currentStyle = m_changedStyles.at(num);
00282 }
00283 updateGUI();
00284
00285 noSignals=false;
00286 }
00287
00288 void KoStyleDialog::switchTabs()
00289 {
00290
00291
00292 save();
00293 updatePreview();
00294 }
00295
00296
00297
00298
00299
00300
00301 int KoStyleDialog::styleIndex( int pos ) {
00302 int p = 0;
00303 for(unsigned int i=0; i < m_changedStyles.count(); i++) {
00304
00305 KoParagStyle * style = m_changedStyles.at(i);
00306 if ( !style ) continue;
00307 if ( p == pos )
00308 return i;
00309 ++p;
00310 }
00311 kWarning() << "KoStyleDialog::styleIndex no style found at pos " << pos << endl;
00312
00313 #ifdef __GNUC_
00314 #warning implement undo/redo
00315 #endif
00316
00317 return 0;
00318 }
00319
00320
00321 void KoStyleDialog::updateGUI() {
00322 kDebug(32500) << "KoStyleDialog::updateGUI m_currentStyle=" << m_currentStyle << " " << m_currentStyle->name() << endl;
00323 Q3PtrListIterator<KoStyleManagerTab> it( m_tabsList );
00324 for ( ; it.current() ; ++it )
00325 {
00326 it.current()->setStyle( m_currentStyle );
00327 it.current()->update();
00328 }
00329
00330 m_nameString->setText(m_currentStyle->displayName());
00331
00332 QString followingName = m_currentStyle->followingStyle() ? m_currentStyle->followingStyle()->displayName() : QString::null;
00333 kDebug(32500) << "KoStyleDialog::updateGUI updating combo to " << followingName << endl;
00334 for ( int i = 0; i < m_styleCombo->count(); i++ ) {
00335 if ( m_styleCombo->itemText( i ) == followingName ) {
00336 m_styleCombo->setCurrentIndex( i );
00337 kDebug(32500) << "found at " << i << endl;
00338 break;
00339 }
00340 }
00341
00342 QString inheritName = m_currentStyle->parentStyle() ? m_currentStyle->parentStyle()->displayName() : QString::null;
00343 kDebug(32500) << "KoStyleDialog::updateGUI updating combo to " << inheritName << endl;
00344 for ( int i = 0; i < m_inheritCombo->count(); i++ ) {
00345 if ( m_inheritCombo->itemText( i ) == inheritName ) {
00346 m_inheritCombo->setCurrentIndex( i );
00347 kDebug(32500) << "found at " << i << endl;
00348 break;
00349 }
00350 else
00351 m_inheritCombo->setCurrentIndex( 0 );
00352 }
00353
00354 if ( d->cbIncludeInTOC )
00355 d->cbIncludeInTOC->setChecked( m_currentStyle->isOutline() );
00356
00357
00358 m_deleteButton->setEnabled(m_stylesList->currentRow() != 0);
00359
00360 m_moveUpButton->setEnabled(m_stylesList->currentRow() != 0);
00361 m_moveDownButton->setEnabled(m_stylesList->currentRow()!=(int)m_stylesList->count()-1);
00362
00363 updatePreview();
00364 }
00365
00366 void KoStyleDialog::updatePreview()
00367 {
00368 d->preview->setStyle(m_currentStyle);
00369 d->preview->update();
00370 }
00371
00372 void KoStyleDialog::save() {
00373 if(m_currentStyle) {
00374
00375 Q3PtrListIterator<KoStyleManagerTab> it( m_tabsList );
00376 for ( ; it.current() ; ++it )
00377 it.current()->save();
00378
00379
00380 if ( m_currentStyle->name() != m_nameString->text() &&
00381 m_currentStyle->displayName() != m_nameString->text() )
00382 {
00383 m_currentStyle->setDisplayName( m_nameString->text() );
00384 }
00385
00386 int indexNextStyle = styleIndex( m_styleCombo->currentIndex() );
00387 m_currentStyle->setFollowingStyle( m_origStyles.at( indexNextStyle ) );
00388
00389 if ( m_inheritCombo->currentItem() == 0 )
00390 m_currentStyle->setParentStyle(0);
00391 else
00392 {
00393 int indexParentStyle=styleIndex( m_inheritCombo->currentItem()-1 );
00394 KoParagStyle *parent=m_origStyles.at(indexParentStyle);
00395 if( parent==0L )
00396 parent=m_changedStyles.at(indexParentStyle);
00397 m_currentStyle->setParentStyle( parent );
00398 }
00399
00400 if ( d->cbIncludeInTOC )
00401 m_currentStyle->setOutline( d->cbIncludeInTOC->isChecked() );
00402 }
00403 }
00404
00405 KoParagStyle * KoStyleDialog::style( const QString & _name )
00406 {
00407 for(unsigned int i=0; i < m_changedStyles.count(); i++) {
00408
00409 KoParagStyle * style = m_changedStyles.at(i);
00410 if ( !style ) continue;
00411 if ( style->name() == _name)
00412 return style;
00413 }
00414 return 0;
00415 }
00416
00417 QString KoStyleDialog::generateUniqueName()
00418 {
00419 int count = 1;
00420 QString name;
00421 do {
00422 name = "new" + QString::number( count++ );
00423 } while ( style( name ) );
00424 return name;
00425 }
00426
00427
00428 void KoStyleDialog::addStyle() {
00429 save();
00430
00431 QString str = i18n( "New Style Template (%1)" ,numStyles++);
00432 if ( m_currentStyle )
00433 {
00434 m_currentStyle = new KoParagStyle( *m_currentStyle );
00435 m_currentStyle->setDisplayName( str );
00436 m_currentStyle->setName( generateUniqueName() );
00437 }
00438 else
00439 m_currentStyle = new KoParagStyle( str );
00440 m_currentStyle->setFollowingStyle( m_currentStyle );
00441
00442 noSignals=true;
00443 m_origStyles.append(0L);
00444 m_changedStyles.append(m_currentStyle);
00445 m_stylesList->addItem( str );
00446 m_styleCombo->addItem( str );
00447 m_inheritCombo->addItem( str );
00448 m_stylesList->setCurrentRow( m_stylesList->count() - 1 );
00449 noSignals=false;
00450 m_styleOrder << m_currentStyle->name();
00451
00452 updateGUI();
00453 }
00454
00455 void KoStyleDialog::updateFollowingStyle( KoParagStyle *s )
00456 {
00457 for ( KoParagStyle* p = m_changedStyles.first(); p != 0L; p = m_changedStyles.next() )
00458 {
00459 if ( p->followingStyle() == s)
00460 p->setFollowingStyle(p);
00461 }
00462
00463 }
00464
00465 void KoStyleDialog::updateInheritStyle( KoParagStyle *s )
00466 {
00467 for ( KoParagStyle* p = m_changedStyles.first(); p != 0L; p = m_changedStyles.next() )
00468 {
00469
00470
00471
00472 if ( p->parentStyle() == s)
00473 p->setParentStyle(0L);
00474 }
00475
00476 }
00477
00478 void KoStyleDialog::deleteStyle() {
00479
00480 unsigned int cur = styleIndex( m_stylesList->currentRow() );
00481 unsigned int curItem = m_stylesList->currentRow();
00482 QString name = m_stylesList->currentItem()->text();
00483 KoParagStyle *s = m_changedStyles.at(cur);
00484 m_styleOrder.removeAll( s->name());
00485 updateFollowingStyle( s );
00486 updateInheritStyle( s );
00487 Q_ASSERT( s == m_currentStyle );
00488 delete s;
00489 m_currentStyle = 0L;
00490 m_changedStyles.remove(cur);
00491 m_changedStyles.insert(cur,0L);
00492
00493
00494
00495 m_stylesList->takeItem(curItem);
00496 m_styleCombo->removeItem(curItem);
00497
00498 m_inheritCombo->removeItem( m_inheritCombo->findText( name ) );
00499
00500 numStyles--;
00501 m_stylesList->setItemSelected( m_stylesList->currentItem(), true );
00502 }
00503
00504 void KoStyleDialog::moveUpStyle()
00505 {
00506 Q_ASSERT( m_currentStyle );
00507 if ( m_currentStyle )
00508 save();
00509 const QString currentStyleName = m_currentStyle->name();
00510 const QString currentStyleDisplayName = m_stylesList->currentItem()->text();
00511 int pos2 = m_styleOrder.indexOf( currentStyleName );
00512 if ( pos2 != -1 )
00513 {
00514 m_styleOrder.removeAt(pos2);
00515 m_styleOrder.insert( pos2-1, currentStyleName);
00516 }
00517
00518 int pos = m_stylesList->currentRow();
00519 noSignals=true;
00520 m_stylesList->item( pos )->setText( m_stylesList->item( pos-1 )->text() );
00521 m_styleCombo->setItemText( pos, m_stylesList->item( pos-1 )->text() );
00522
00523 m_stylesList->item(pos-1)->setText( currentStyleDisplayName );
00524 m_styleCombo->setItemText( pos-1, currentStyleDisplayName );
00525
00526 m_stylesList->setCurrentItem( m_stylesList->currentItem() );
00527 noSignals=false;
00528
00529 updateGUI();
00530 }
00531
00532 void KoStyleDialog::moveDownStyle()
00533 {
00534 Q_ASSERT( m_currentStyle );
00535 if ( m_currentStyle )
00536 save();
00537 const QString currentStyleName = m_currentStyle->name();
00538 const QString currentStyleDisplayName = m_stylesList->currentItem()->text();
00539 int pos2 = m_styleOrder.indexOf( currentStyleName );
00540 if ( pos2 != -1 )
00541 {
00542 m_styleOrder.removeAt( pos2 );
00543 m_styleOrder.insert( pos2+1, currentStyleName);
00544 }
00545
00546 int pos = m_stylesList->currentRow();
00547 noSignals=true;
00548 m_stylesList->item( pos )->setText( m_stylesList->item( pos+1 )->text() );
00549 m_styleCombo->setItemText( pos, m_stylesList->item( pos+1 )->text() );
00550 m_stylesList->item( pos+1 )->setText( currentStyleDisplayName );
00551 m_styleCombo->setItemText( pos+1, currentStyleDisplayName );
00552 m_stylesList->setCurrentItem( m_stylesList->currentItem() );
00553 noSignals=false;
00554
00555 updateGUI();
00556 }
00557
00558 void KoStyleDialog::slotOk() {
00559 save();
00560 apply();
00561 slotButtonClicked( Ok );
00562 }
00563
00564 void KoStyleDialog::slotApply() {
00565 save();
00566 apply();
00567 slotButtonClicked( Apply );
00568 }
00569
00570 void KoStyleDialog::apply() {
00571 noSignals=true;
00572 KoStyleChangeDefMap styleChanged;
00573 Q3PtrList<KoParagStyle> removeStyle;
00574 for (unsigned int i =0 ; m_origStyles.count() > i ; i++) {
00575 if(m_origStyles.at(i) == 0L && m_changedStyles.at(i)!=0L) {
00576 kDebug(32500) << "adding new " << m_changedStyles.at(i)->name() << " (" << i << ")" << endl;
00577 KoParagStyle *tmp = addStyleTemplate(m_changedStyles.take(i));
00578 m_changedStyles.insert(i, tmp);
00579 } else if(m_changedStyles.at(i) == 0L && m_origStyles.at(i) != 0L) {
00580 kDebug(32500) << "deleting orig " << m_origStyles.at(i)->name() << " (" << i << ")" << endl;
00581
00582 KoParagStyle *orig = m_origStyles.at(i);
00583
00584 KoStyleChangeDef tmp( -1,-1);
00585 styleChanged.insert( orig, tmp);
00586
00587 removeStyle.append( orig );
00588
00589
00590 } else if(m_changedStyles.at(i) != 0L && m_origStyles.at(i)!=0L) {
00591 kDebug(32500) << "update style " << m_changedStyles.at(i)->name() << " (" << i << ")" << endl;
00592 KoParagStyle *orig = m_origStyles.at(i);
00593 KoParagStyle *changed = m_changedStyles.at(i);
00594 if ( orig != changed )
00595 {
00596 int paragLayoutChanged = orig->paragLayout().compare( changed->paragLayout() );
00597 int formatChanged = orig->format().compare( changed->format() );
00598
00599
00600
00601
00602 *orig = *changed;
00603
00604
00605
00606 if ( formatChanged != 0 || paragLayoutChanged != 0 ) {
00607 KoStyleChangeDef tmp(paragLayoutChanged, formatChanged);
00608 styleChanged.insert( orig, tmp );
00609 }
00610
00611 }
00612
00613 }
00614
00615 }
00616
00617 applyStyleChange( styleChanged );
00618
00619 KoParagStyle *tmp = 0L;
00620 for ( tmp = removeStyle.first(); tmp ;tmp = removeStyle.next() )
00621 removeStyleTemplate( tmp );
00622
00623 updateStyleListOrder( m_styleOrder );
00624 updateAllStyleLists();
00625 noSignals=false;
00626 }
00627
00628 void KoStyleDialog::renameStyle(const QString &theText) {
00629 if(noSignals) return;
00630 noSignals=true;
00631
00632 int index = m_stylesList->currentRow();
00633 kDebug(32500) << "KoStyleDialog::renameStyle " << index << " to " << theText << endl;
00634
00635
00636 kDebug(32500) << "KoStyleDialog::renameStyle before " << m_styleCombo->currentText() << endl;
00637 m_styleCombo->setItemText( index, theText );
00638 m_inheritCombo->setItemText( index+1, theText );
00639
00640 kDebug(32500) << "KoStyleDialog::renameStyle after " << m_styleCombo->currentText() << endl;
00641 m_stylesList->item( index )->setText( theText );
00642
00643
00644 int synonyms = 0;
00645 for ( int i = 0; i < m_styleCombo->count(); i++ ) {
00646 if ( m_styleCombo->currentText() == m_stylesList->currentItem()->text() )
00647 ++synonyms;
00648 }
00649 Q_ASSERT( synonyms > 0 );
00650 noSignals=false;
00651
00652 bool state=!theText.isEmpty() && (synonyms == 1);
00653 enableButtonOk(state );
00654 enableButtonApply(state);
00655 m_deleteButton->setEnabled(state&&(m_stylesList->currentItem() != 0));
00656 m_newButton->setEnabled(state);
00657 m_stylesList->setEnabled( state );
00658 if ( state )
00659 {
00660 m_moveUpButton->setEnabled(m_stylesList->currentRow() != 0);
00661 m_moveDownButton->setEnabled(m_stylesList->currentRow()!=(int)m_stylesList->count()-1);
00662 }
00663 else
00664 {
00665 m_moveUpButton->setEnabled(false);
00666 m_moveDownButton->setEnabled(false);
00667 }
00668 }
00669
00671
00672 KoStyleParagTab::KoStyleParagTab( QWidget * parent )
00673 : KoStyleManagerTab( parent )
00674 {
00675 m_widget = 0L;
00676 }
00677
00678 void KoStyleParagTab::update()
00679 {
00680 m_widget->display( m_style->paragLayout() );
00681 }
00682
00683 void KoStyleParagTab::save()
00684 {
00685 m_widget->save( m_style->paragLayout() );
00686 }
00687
00688 void KoStyleParagTab::setWidget( KoParagLayoutWidget * widget )
00689 {
00690 m_widget = widget;
00691 }
00692
00693 void KoStyleParagTab::resizeEvent( QResizeEvent *e )
00694 {
00695 QWidget::resizeEvent( e );
00696 if ( m_widget ) m_widget->resize( size() );
00697 }
00698
00699 KoStyleFontTab::KoStyleFontTab( QWidget * parent )
00700 : KoStyleManagerTab( parent )
00701 {
00702 QTabWidget *fontTabContainer = new QTabWidget( this );
00703
00704 m_fontTab = new KoFontTab( KFontChooser::SmoothScalableFonts, this );
00705 m_decorationTab = new KoDecorationTab( this );
00706 m_highlightingTab = new KoHighlightingTab( this );
00707 m_layoutTab = new KoLayoutTab( true, this );
00708 m_languageTab = new KoLanguageTab( );
00709
00710 fontTabContainer->addTab( m_fontTab, i18n( "Font" ) );
00711 fontTabContainer->addTab( m_decorationTab, i18n( "Decoration" ) );
00712 fontTabContainer->addTab( m_highlightingTab, i18n( "Highlighting" ) );
00713 fontTabContainer->addTab( m_layoutTab, i18n( "Layout" ) );
00714 fontTabContainer->addTab( m_languageTab, i18n( "Language" ) );
00715 }
00716
00717 KoStyleFontTab::~KoStyleFontTab()
00718 {
00719 }
00720
00721 void KoStyleFontTab::update()
00722 {
00723 m_fontTab->setSelection( m_style->format().font() );
00724 m_highlightingTab->setUnderline( m_style->format().underlineType() );
00725 m_highlightingTab->setUnderlineStyle( m_style->format().underlineStyle() );
00726 m_highlightingTab->setUnderlineColor( m_style->format().textUnderlineColor() );
00727 m_highlightingTab->setStrikethrough( m_style->format().strikeOutType() );
00728 m_highlightingTab->setStrikethroughStyle( m_style->format().strikeOutStyle() );
00729 m_highlightingTab->setWordByWord( m_style->format().wordByWord() );
00730 m_highlightingTab->setCapitalisation( m_style->format().attributeFont() );
00731 m_decorationTab->setTextColor( m_style->format().color() );
00732 m_decorationTab->setBackgroundColor( m_style->format().textBackgroundColor() );
00733 m_decorationTab->setShadow( m_style->format().shadowDistanceX(), m_style->format().shadowDistanceY(), m_style->format().shadowColor() );
00734 m_layoutTab->setSubSuperScript( m_style->format().vAlign(), m_style->format().offsetFromBaseLine(), m_style->format().relativeTextSize() );
00735 m_layoutTab->setAutoHyphenation( m_style->format().hyphenation() );
00736 m_languageTab->setLanguage( m_style->format().language() );
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764 }
00765
00766 void KoStyleFontTab::save()
00767 {
00768 m_style->format() = KoTextFormat( m_fontTab->getSelection(),
00769 m_layoutTab->getSubSuperScript(),
00770 m_decorationTab->getTextColor(),
00771 m_decorationTab->getBackgroundColor(),
00772 m_highlightingTab->getUnderlineColor(),
00773 m_highlightingTab->getUnderline(),
00774 m_highlightingTab->getUnderlineStyle(),
00775 m_highlightingTab->getStrikethrough(),
00776 m_highlightingTab->getStrikethroughStyle(),
00777 m_highlightingTab->getCapitalisation(),
00778 m_languageTab->getLanguage(),
00779 m_layoutTab->getRelativeTextSize(),
00780 m_layoutTab->getOffsetFromBaseline(),
00781 m_highlightingTab->getWordByWord(),
00782 m_layoutTab->getAutoHyphenation(),
00783 m_decorationTab->getShadowDistanceX(),
00784 m_decorationTab->getShadowDistanceY(),
00785 m_decorationTab->getShadowColor()
00786 );
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807 }
00808
00809 QString KoStyleFontTab::tabName()
00810 {
00811 return i18n("Font");
00812 }