F:/KPlato/koffice/libs/kotext/KoHighlightingTab.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C)  2001, 2002 Montel Laurent <lmontel@mandrakesoft.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KoHighlightingTab.h"
00021 #include "KoTextFormat.h"
00022 
00023 #include <QStringList>
00024 #include <q3buttongroup.h>
00025 #include <QRadioButton>
00026 #include <QCheckBox>
00027 
00028 #include <kcombobox.h>
00029 #include <kcolorbutton.h>
00030 
00031 #include "KoHighlightingTab.moc"
00032 
00033 
00034 KoHighlightingTab::KoHighlightingTab( QWidget* parent, const char* name, Qt::WFlags fl ) 
00035         : KoHighlightingTabBase( parent/*, name, fl*/ )
00036 {
00037     underlineStyleKComboBox->addItems( KoTextFormat::underlineTypeList() );
00038     underlineLineStyleKComboBox->addItems( KoTextFormat::underlineStyleList() );
00039     strikethroughStyleKComboBox->addItems( KoTextFormat::strikeOutTypeList() );
00040     strikethroughLineStyleKComboBox->addItems( KoTextFormat::strikeOutStyleList() );
00041 
00042     capitalisationButtonGroup->setColumnLayout( 3, Qt::Horizontal );
00043     QStringList attributes = KoTextFormat::fontAttributeList();
00044     for ( QStringList::Iterator it = attributes.begin(); it != attributes.end(); ++it ) {
00045         capitalisationButtonGroup->insert( new QRadioButton( *it, capitalisationButtonGroup ) );
00046     }
00047     capitalisationButtonGroup->setButton( 0 );
00048 
00049     connect( underlineStyleKComboBox, SIGNAL( activated( int ) ), this, SLOT( slotUnderlineChanged( int ) ) );
00050     connect( underlineLineStyleKComboBox, SIGNAL( activated( int ) ), this, SIGNAL( underlineStyleChanged( int ) ) );
00051     connect( underlineKColorButton, SIGNAL( changed( const QColor & ) ), this, SIGNAL( underlineColorChanged( const QColor & ) ) );
00052     connect( strikethroughStyleKComboBox, SIGNAL( activated( int ) ), this, SLOT( slotStrikethroughChanged( int ) ) );
00053     connect( strikethroughLineStyleKComboBox, SIGNAL( activated( int ) ), this, SIGNAL( strikethroughStyleChanged( int ) ) );
00054     connect( underlineWordByWordCheckBox, SIGNAL( toggled( bool ) ), this, SIGNAL( wordByWordChanged( bool ) ) );
00055     connect( capitalisationButtonGroup, SIGNAL( clicked( int ) ), this, SIGNAL( capitalisationChanged( int ) ) );
00056 }
00057 
00058 KoHighlightingTab::~KoHighlightingTab()
00059 {
00060 }
00061 
00062 KoTextFormat::UnderlineType KoHighlightingTab::getUnderline() const
00063 {
00064     return static_cast<KoTextFormat::UnderlineType>( underlineStyleKComboBox->currentIndex() );
00065 }
00066 
00067 KoTextFormat::UnderlineStyle KoHighlightingTab::getUnderlineStyle() const
00068 {
00069     return static_cast<KoTextFormat::UnderlineStyle>( underlineLineStyleKComboBox->currentIndex() );
00070 }
00071 
00072 QColor KoHighlightingTab::getUnderlineColor() const
00073 {
00074     return underlineKColorButton->color();
00075 }
00076 
00077 KoTextFormat::StrikeOutType KoHighlightingTab::getStrikethrough() const
00078 {
00079     return static_cast<KoTextFormat::StrikeOutType>( strikethroughStyleKComboBox->currentIndex() );
00080 }
00081 
00082 KoTextFormat::StrikeOutStyle KoHighlightingTab::getStrikethroughStyle() const
00083 {
00084     return static_cast<KoTextFormat::StrikeOutStyle>( strikethroughLineStyleKComboBox->currentIndex() );
00085 }
00086 
00087 bool KoHighlightingTab::getWordByWord() const
00088 {
00089     return underlineWordByWordCheckBox->isOn();
00090 }
00091 
00092 KoTextFormat::AttributeStyle KoHighlightingTab::getCapitalisation() const
00093 {
00094     return static_cast<KoTextFormat::AttributeStyle>( capitalisationButtonGroup->selectedId() );
00095 }
00096 
00097 void KoHighlightingTab::setUnderline( KoTextFormat::UnderlineType item )
00098 {
00099     underlineStyleKComboBox->setCurrentIndex( static_cast<int>( item ) );
00100     slotUnderlineChanged( static_cast<int>( item ) );
00101 }
00102 
00103 void KoHighlightingTab::setUnderlineStyle( KoTextFormat::UnderlineStyle item )
00104 {
00105     underlineLineStyleKComboBox->setCurrentIndex( static_cast<int>( item ) );
00106     emit underlineStyleChanged( static_cast<int>( item ) );
00107 }
00108 
00109 void KoHighlightingTab::setUnderlineColor( const QColor &color )
00110 {
00111     underlineKColorButton->setColor( color );
00112 }
00113 
00114 void KoHighlightingTab::setStrikethrough( int item )
00115 {
00116     strikethroughStyleKComboBox->setCurrentIndex( static_cast<int>( item ) );
00117     slotStrikethroughChanged( static_cast<int>( item ) );
00118 }
00119 
00120 void KoHighlightingTab::setStrikethroughStyle( int item )
00121 {
00122     strikethroughLineStyleKComboBox->setCurrentIndex( static_cast<int>( item ) );
00123     emit strikethroughStyleChanged( static_cast<int>( item ) );
00124 }
00125 
00126 void KoHighlightingTab::setWordByWord( bool state )
00127 {
00128     underlineWordByWordCheckBox->setChecked( state );
00129 }
00130 
00131 void KoHighlightingTab::setCapitalisation( int item )
00132 {
00133     capitalisationButtonGroup->setButton( static_cast<int>( item ) );
00134     emit capitalisationChanged( static_cast<int>( item ) );
00135 }
00136 
00137 void KoHighlightingTab::slotUnderlineChanged( int item )
00138 {
00139     underlineLineStyleKComboBox->setEnabled( item > 0 );
00140     underlineKColorButton->setEnabled( item > 0 );
00141     underlineWordByWordCheckBox->setEnabled( ( item > 0 ) || ( strikethroughStyleKComboBox->currentIndex() > 0 ) );
00142     emit underlineChanged( item );
00143 }
00144 
00145 void KoHighlightingTab::slotStrikethroughChanged( int item )
00146 {
00147     strikethroughLineStyleKComboBox->setEnabled( item > 0 );
00148     underlineWordByWordCheckBox->setEnabled( ( item > 0 ) || ( underlineStyleKComboBox->currentIndex() > 0 ) );
00149     emit strikethroughChanged(  item );
00150 }
00151 

Généré le Wed Nov 22 23:41:08 2006 pour KPlato par  doxygen 1.5.1-p1