Source Code (Use browser search to find items of interest.)

Class Index

kword'KWStyleManager (./koffice/kword/stylist.h:44)

class KWStyleManager : public QTabDialog
{
    Q_OBJECT

public:
    KWStyleManager( QWidget *_parent, KWordDocument *_doc, QStringList _fontList );

protected:
    void setupTab1();
    void setupTab2();

    QWidget *tab1, *tab2;
    QGridLayout *grid1, *grid2;
    QListBox *lStyleList;
    QPushButton *bEdit, *bDelete, *bAdd, *bUp, *bDown, *bCopy;
    KButtonBox *bButtonBox;
    QComboBox *cFont, *cColor, *cBorder, *cIndent, *cAlign, *cNumbering, *cTabs;
    QCheckBox *cSmart;

    KWordDocument *doc;
    KWStyleEditor *editor;
    QStringList fontList;

protected slots:
    void apply();
    void editStyle();
    void editStyle( int ) { editStyle(); }
    void addStyle();
    void deleteStyle();
    void updateStyleList();
    void updateButtons( const QString & );
    void smartClicked();

};

/******************************************************************/
/* Class: KWStylePreview                                         */
/******************************************************************/


kword'KWStyleManager::KWStyleManager() (./koffice/kword/stylist.cc:55)

KWStyleManager::KWStyleManager( QWidget *_parent, KWordDocument *_doc, QStringList _fontList )
    : QTabDialog( _parent, "", true )
{
    fontList = _fontList;
    doc = _doc;
    editor = 0L;

    setupTab1();
    setupTab2();

    setOkButton( i18n( "Close" ) );

    connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( apply() ) );

    resize( 500, 400 );
}

/*================================================================*/

kword'KWStyleManager::setupTab1() (./koffice/kword/stylist.cc:73)

void KWStyleManager::setupTab1()
{
    tab1 = new QWidget( this );

    grid1 = new QGridLayout( tab1, 1, 2, 15, 7 );

    lStyleList = new QListBox( tab1 );
    for ( unsigned int i = 0; i < doc->paragLayoutList.count(); i++ )
	lStyleList->insertItem( doc->paragLayoutList.at( i )->getName() );
    connect( lStyleList, SIGNAL( selected( int ) ), this, SLOT( editStyle( int ) ) );
    grid1->addWidget( lStyleList, 0, 0 );

    bButtonBox = new KButtonBox( tab1, KButtonBox::VERTICAL );
    bAdd = bButtonBox->addButton( i18n( "&Add.." ), false );
    connect( bAdd, SIGNAL( clicked() ), this, SLOT( addStyle() ) );
    bDelete = bButtonBox->addButton( i18n( "&Delete" ), false );
    connect( bDelete, SIGNAL( clicked() ), this, SLOT( deleteStyle() ) );
    bButtonBox->addStretch();
    bEdit = bButtonBox->addButton( i18n( "&Edit..." ), false );
    connect( bEdit, SIGNAL( clicked() ), this, SLOT( editStyle() ) );
    bCopy = bButtonBox->addButton( i18n( "&Copy..." ), false );
    bButtonBox->addStretch();
    bUp = bButtonBox->addButton( i18n( "Up" ), false );
    bDown = bButtonBox->addButton( i18n( "D&own" ), false );
    bButtonBox->layout();
    grid1->addWidget( bButtonBox, 0, 1 );

    grid1->addColSpacing( 0, lStyleList->width() );
    grid1->addColSpacing( 1, bButtonBox->width() );
    grid1->setColStretch( 0, 1 );

    grid1->addRowSpacing( 0, lStyleList->height() );
    grid1->addRowSpacing( 0, bButtonBox->height() );
    grid1->setRowStretch( 0, 1 );

    grid1->activate();

    addTab( tab1, i18n( "Style Manager" ) );

    connect( lStyleList, SIGNAL( highlighted( const QString & ) ), this, SLOT( updateButtons( const QString & ) ) );
    lStyleList->setCurrentItem( 0 );
}

/*================================================================*/

kword'KWStyleManager::setupTab2() (./koffice/kword/stylist.cc:117)

void KWStyleManager::setupTab2()
{
    tab2 = new QWidget( this );

    grid2 = new QGridLayout( tab2, 9, 1, 15, 7 );

    cSmart = new QCheckBox( i18n( "&Smart updating of fonts and colors" ), tab2 );
    grid2->addWidget( cSmart, 0, 0 );

    cFont = new QComboBox( false, tab2 );
    cFont->insertItem( i18n( "Don't update Fonts" ) );
    cFont->insertItem( i18n( "Update Font Families of same sized Fonts" ) );
    cFont->insertItem( i18n( "Update Font Families of all sized Fonts" ) );
    cFont->insertItem( i18n( "Update Font Families and Attributes of same sized Fonts" ) );
    cFont->insertItem( i18n( "Update Font Families and Attributes of all sized Fonts" ) );
    cFont->resize( cFont->sizeHint() );
    grid2->addWidget( cFont, 1, 0 );

    cColor = new QComboBox( false, tab2 );
    cColor->insertItem( i18n( "Don't update Colors" ) );
    cColor->insertItem( i18n( "Update Colors" ) );
    cColor->resize( cFont->sizeHint() );
    grid2->addWidget( cColor, 2, 0 );

    cIndent = new QComboBox( false, tab2 );
    cIndent->insertItem( i18n( "Don't update Indents and Spacing" ) );
    cIndent->insertItem( i18n( "Update Indents and Spacing" ) );
    cIndent->resize( cFont->sizeHint() );
    grid2->addWidget( cIndent, 3, 0 );

    cAlign = new QComboBox( false, tab2 );
    cAlign->insertItem( i18n( "Don't update Aligns/Flows" ) );
    cAlign->insertItem( i18n( "Update Aligns/Flows" ) );
    cAlign->resize( cFont->sizeHint() );
    grid2->addWidget( cAlign, 4, 0 );

    cNumbering = new QComboBox( false, tab2 );
    cNumbering->insertItem( i18n( "Don't update Numbering" ) );
    cNumbering->insertItem( i18n( "Update Numbering" ) );
    cNumbering->resize( cFont->sizeHint() );
    grid2->addWidget( cNumbering, 5, 0 );

    cBorder = new QComboBox( false, tab2 );
    cBorder->insertItem( i18n( "Don't update Borders" ) );
    cBorder->insertItem( i18n( "Update Borders" ) );
    cBorder->resize( cFont->sizeHint() );
    grid2->addWidget( cBorder, 6, 0 );

    cTabs = new QComboBox( false, tab2 );
    cTabs->insertItem( i18n( "Don't update Tabulators" ) );
    cTabs->insertItem( i18n( "Update Tabulators" ) );
    cTabs->resize( cFont->sizeHint() );
    grid2->addWidget( cTabs, 7, 0 );

    grid2->addColSpacing( 0, cSmart->width() );
    grid2->addColSpacing( 0, cFont->width() );
    grid2->addColSpacing( 0, cAlign->width() );
    grid2->addColSpacing( 0, cColor->width() );
    grid2->addColSpacing( 0, cNumbering->width() );
    grid2->addColSpacing( 0, cIndent->width() );
    grid2->addColSpacing( 0, cBorder->width() );
    grid2->addColSpacing( 0, cTabs->width() );
    grid2->setColStretch( 0, 1 );

    grid2->addRowSpacing( 0, cSmart->height() );
    grid2->addRowSpacing( 1, cFont->height() );
    grid2->addRowSpacing( 2, cColor->height() );
    grid2->addRowSpacing( 3, cIndent->height() );
    grid2->addRowSpacing( 4, cAlign->height() );
    grid2->addRowSpacing( 5, cNumbering->height() );
    grid2->addRowSpacing( 6, cBorder->height() );
    grid2->addRowSpacing( 7, cTabs->height() );
    grid2->setRowStretch( 0, 0 );
    grid2->setRowStretch( 1, 0 );
    grid2->setRowStretch( 2, 0 );
    grid2->setRowStretch( 3, 0 );
    grid2->setRowStretch( 4, 0 );
    grid2->setRowStretch( 5, 0 );
    grid2->setRowStretch( 6, 0 );
    grid2->setRowStretch( 7, 0 );
    grid2->setRowStretch( 8, 1 );

    grid2->activate();

    addTab( tab2, i18n( "Update Configuration" ) );

    cSmart->setChecked( FALSE );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_FONT_FAMILY_SAME_SIZE )
	cFont->setCurrentItem( 1 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_FONT_FAMILY_ALL_SIZE )
	cFont->setCurrentItem( 2 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_FONT_ALL_SAME_SIZE )
	cFont->setCurrentItem( 3 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_FONT_ALL_ALL_SIZE )
	cFont->setCurrentItem( 4 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_COLOR )
	cColor->setCurrentItem( 1 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_INDENT )
	cIndent->setCurrentItem( 1 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_BORDER )
	cBorder->setCurrentItem( 1 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_ALIGN )
	cAlign->setCurrentItem( 1 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_NUMBERING )
	cNumbering->setCurrentItem( 1 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_TABS )
	cTabs->setCurrentItem( 1 );
    if ( doc->getApplyStyleTemplate() & KWordDocument::U_SMART ) {
	cSmart->setChecked( TRUE );
	cFont->setEnabled( FALSE );
	cColor->setEnabled( FALSE );
    }

    connect( cSmart, SIGNAL( clicked() ),
	     this, SLOT( smartClicked() ) );
}

/*================================================================*/

kword'KWStyleManager::smartClicked() (./koffice/kword/stylist.cc:235)

void KWStyleManager::smartClicked()
{
    cFont->setEnabled( !cSmart->isChecked() );
    cColor->setEnabled( !cSmart->isChecked() );
}

/*================================================================*/

kword'KWStyleManager::editStyle() (./koffice/kword/stylist.cc:242)

void KWStyleManager::editStyle()
{
    if ( editor ) {
	disconnect( editor, SIGNAL( updateStyleList() ), this, SLOT( updateStyleList() ) );
	delete editor;
	editor = 0L;
    }

    editor = new KWStyleEditor( this, doc->paragLayoutList.at( lStyleList->currentItem() ), doc, fontList );
    connect( editor, SIGNAL( updateStyleList() ), this, SLOT( updateStyleList() ) );
    editor->setCaption( i18n( "KWord - Stylist" ) );
    editor->show();
}

/*================================================================*/

kword'KWStyleManager::addStyle() (./koffice/kword/stylist.cc:257)

void KWStyleManager::addStyle()
{
    QString str;
    str.sprintf( "%s ( %d )", i18n( "New Style Template" ).ascii(), doc->paragLayoutList.count() );
    ( void )new KWParagLayout( doc, true, str );
    lStyleList->insertItem( str );
    lStyleList->setCurrentItem( lStyleList->count() - 1 );
    editStyle();
    doc->updateAllStyleLists();
}

/*================================================================*/

kword'KWStyleManager::deleteStyle() (./koffice/kword/stylist.cc:269)

void KWStyleManager::deleteStyle()
{
    doc->paragLayoutList.remove( lStyleList->currentItem() );
    updateStyleList();
}

/*================================================================*/

kword'KWStyleManager::apply() (./koffice/kword/stylist.cc:276)

void KWStyleManager::apply()
{
    int f = 0;

    if ( cFont->currentItem() == 1 )
	f = f | KWordDocument::U_FONT_FAMILY_SAME_SIZE;
    else if ( cFont->currentItem() == 2 )
	f = f | KWordDocument::U_FONT_FAMILY_ALL_SIZE;
    else if ( cFont->currentItem() == 3 )
	f = f | KWordDocument::U_FONT_ALL_SAME_SIZE;
    else if ( cFont->currentItem() == 4 )
	f = f | KWordDocument::U_FONT_ALL_ALL_SIZE;

    if ( cColor->currentItem() == 1 )
	f = f | KWordDocument::U_COLOR;
    if ( cAlign->currentItem() == 1 )
	f = f | KWordDocument::U_ALIGN;
    if ( cBorder->currentItem() == 1 )
	f = f | KWordDocument::U_BORDER;
    if ( cNumbering->currentItem() == 1 )
	f = f | KWordDocument::U_NUMBERING;
    if ( cIndent->currentItem() == 1 )
	f = f | KWordDocument::U_INDENT;
    if ( cTabs->currentItem() == 1 )
	f = f | KWordDocument::U_TABS;

    if ( cSmart->isChecked() )
	f = f | KWordDocument::U_SMART;

    doc->setApplyStyleTemplate( f );
}

/*================================================================*/

kword'KWStyleManager::updateStyleList() (./koffice/kword/stylist.cc:309)

void KWStyleManager::updateStyleList()
{
    lStyleList->clear();
    for ( unsigned int i = 0; i < doc->paragLayoutList.count(); i++ )
	lStyleList->insertItem( doc->paragLayoutList.at( i )->getName() );
    doc->updateAllStyleLists();
    lStyleList->setCurrentItem( 0 );
}

/*================================================================*/

kword'KWStyleManager::updateButtons() (./koffice/kword/stylist.cc:319)

void KWStyleManager::updateButtons( const QString &s )
{
    if ( s == QString( "Standard" ) ||
	 s == QString( "Head 1" ) ||
	 s == QString( "Head 2" ) ||
	 s == QString( "Head 3" ) ||
	 s == QString( "Enumerated List" ) ||
	 s == QString( "Bullet List" ) ||
	 s == QString( "Alphabetical List" ) )
	bDelete->setEnabled( false );
    else
	bDelete->setEnabled( true );
}

/******************************************************************/
/* Class: KWStylePreview					  */
/******************************************************************/

/*================================================================*/