F:/KPlato/koffice/libs/kformula/kformulaconfigpage.cc

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Andrea Rizzi <rizzi@kde.org>
00003                       Ulrich Kuettler <ulrich.kuettler@mailbox.tu-dresden.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library 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 GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <QVariant>   // first for gcc 2.7.2
00022 #include <q3buttongroup.h>
00023 #include <QCheckBox>
00024 #include <q3groupbox.h>
00025 #include <QLabel>
00026 #include <QLayout>
00027 #include <QMap>
00028 #include <QRadioButton>
00029 #include <QSpinBox>
00030 #include <QStringList>
00031 
00032 #include <QWidget>
00033 //Added by qt3to4:
00034 #include <Q3GridLayout>
00035 #include <Q3Frame>
00036 
00037 //#include <algorithm>
00038 
00039 #include <kcolorbutton.h>
00040 #include <kconfig.h>
00041 #include <kdebug.h>
00042 #include <kdialog.h>
00043 #include <kfontdialog.h>
00044 #include <k3listview.h>
00045 #include <klocale.h>
00046 #include <kmessagebox.h>
00047 #include <knuminput.h>
00048 #include <kpushbutton.h>
00049 #include <kvbox.h>
00050 
00051 #include "contextstyle.h"
00052 #include "kformulaconfigpage.h"
00053 #include "symboltable.h"
00054 #include "esstixfontstyle.h"
00055 #include "cmstyle.h"
00056 #include "symbolfontstyle.h"
00057 
00058 
00059 KFORMULA_NAMESPACE_BEGIN
00060 
00061 
00062 ConfigurePage::ConfigurePage( Document* document, QWidget* view, KConfig* config, KVBox* box, char* /*name*/ )
00063     : QObject( box->parent() ), m_document( document ), m_view( view ), m_config( config ), m_changed( false )
00064 {
00065 //    const ContextStyle& contextStyle = document->getContextStyle( true );
00066 
00067     // fonts
00068 
00069     Q3GroupBox *gbox = new Q3GroupBox( i18n( "Fonts" ), box );
00070     gbox->setColumnLayout( 0, Qt::Horizontal );
00071 
00072     Q3GridLayout* grid = new Q3GridLayout( gbox->layout(), 5, 3 );
00073     grid->setSpacing( KDialog::spacingHint() );
00074 
00075     grid->setColumnStretch(1, 1);
00076 
00077 /*    defaultFont = contextStyle.getDefaultFont();
00078     nameFont = contextStyle.getNameFont();
00079     numberFont = contextStyle.getNumberFont();
00080     operatorFont = contextStyle.getOperatorFont();*/
00081 
00082     connect( buildFontLine( gbox, grid, 0, defaultFont,
00083             i18n( "Default font:" ), defaultFontName ),
00084             SIGNAL( clicked() ), SLOT( selectNewDefaultFont() ) );
00085 
00086     connect( buildFontLine( gbox, grid, 1, nameFont,
00087             i18n( "Name font:" ), nameFontName ),
00088             SIGNAL( clicked() ), SLOT( selectNewNameFont() ) );
00089 
00090     connect( buildFontLine( gbox, grid, 2, numberFont,
00091             i18n( "Number font:" ), numberFontName ),
00092             SIGNAL( clicked() ), SLOT( selectNewNumberFont() ) );
00093 
00094     connect( buildFontLine( gbox, grid, 3, operatorFont,
00095             i18n( "Operator font:" ), operatorFontName ),
00096             SIGNAL( clicked() ), SLOT( selectNewOperatorFont() ) );
00097 
00098     QLabel* sizeTitle = new QLabel( i18n( "Default base size:" ), gbox );
00099     grid->addWidget( sizeTitle, 4, 0 );
00100 
00101 //    sizeSpin = new KIntNumInput( contextStyle.baseSize(), gbox );
00102 //    sizeSpin->setRange( 8, 72, 1, true );
00103 
00104     grid->addMultiCellWidget( sizeSpin, 4, 4, 1, 2 );
00105 
00106     connect( sizeSpin, SIGNAL( valueChanged( int ) ),
00107             SLOT( baseSizeChanged( int ) ) );
00108 
00109     // syntax highlighting
00110 
00111  //   syntaxHighlighting = new QCheckBox( i18n( "Use syntax highlighting" ),box );
00112  //   syntaxHighlighting->setChecked( contextStyle.syntaxHighlighting() );
00113 
00114 //     hlBox = new QGroupBox( i18n( "Highlight Colors" ), box );
00115 //     hlBox->setColumnLayout( 0, Qt::Horizontal );
00116 
00117 //     grid = new QGridLayout( hlBox->layout(), 5, 2 );
00118 //     grid->setSpacing( KDialog::spacingHint() );
00119 
00120 //     QLabel* defaultLabel = new QLabel( hlBox, "defaultLabel" );
00121 //     defaultLabel->setText( i18n( "Default color:" ) );
00122 //     grid->addWidget( defaultLabel, 0, 0 );
00123 
00124 //     defaultColorBtn = new KColorButton( hlBox );
00125 //defaultColorBtn->setObjectName( "defaultColor" );
00126 //     defaultColorBtn->setColor( contextStyle.getDefaultColor() );
00127 //     grid->addWidget( defaultColorBtn, 0, 1 );
00128 
00129 
00130 //     QLabel* numberLabel = new QLabel( hlBox, "numberLabel" );
00131 //     numberLabel->setText( i18n( "Number color:" ) );
00132 //     grid->addWidget( numberLabel, 1, 0 );
00133 
00134 //     numberColorBtn = new KColorButton( hlBox );
00135 //numberColorBtn->setObjectName( "numberColor" );
00136 //     numberColorBtn->setColor( contextStyle.getNumberColorPlain() );
00137 //     grid->addWidget( numberColorBtn, 1, 1 );
00138 
00139 
00140 //     QLabel* operatorLabel = new QLabel( hlBox, "operatorLabel" );
00141 //     operatorLabel->setText( i18n( "Operator color:" ) );
00142 //     grid->addWidget( operatorLabel, 2, 0 );
00143 
00144 //     operatorColorBtn = new KColorButton( hlBox );
00145 //operatorColorBtn->setObjectName( "operatorColor" );
00146 //     operatorColorBtn->setColor( contextStyle.getOperatorColorPlain() );
00147 //     grid->addWidget( operatorColorBtn, 2, 1 );
00148 
00149 
00150 //     QLabel* emptyLabel = new QLabel( hlBox, "emptyLabel" );
00151 //     emptyLabel->setText( i18n( "Empty color:" ) );
00152 //     grid->addWidget( emptyLabel, 3, 0 );
00153 
00154 //     emptyColorBtn = new KColorButton( hlBox );
00155 //emptyColorBtn->setObjectName( "emptyColor" );
00156 //     emptyColorBtn->setColor( contextStyle.getEmptyColorPlain() );
00157 //     grid->addWidget( emptyColorBtn, 3, 1 );
00158 
00159 
00160 //     QLabel* errorLabel = new QLabel( hlBox, "errorLabel" );
00161 //     errorLabel->setText( i18n( "Error color:" ) );
00162 //     grid->addWidget( errorLabel, 4, 0 );
00163 
00164 //     errorColorBtn = new KColorButton( hlBox );
00165 //errorColorBtn->setObjectName( "errorColor" );
00166 //     errorColorBtn->setColor( contextStyle.getErrorColorPlain() );
00167 //     grid->addWidget( errorColorBtn, 4, 1 );
00168 
00169     connect( syntaxHighlighting, SIGNAL( clicked() ),
00170             SLOT( syntaxHighlightingClicked() ) );
00171 
00172     syntaxHighlightingClicked();
00173 
00174     styleBox = new Q3ButtonGroup( i18n( "Font Style" ), box );
00175     styleBox->setColumnLayout( 0, Qt::Horizontal );
00176 
00177     grid = new Q3GridLayout( styleBox->layout(), 3, 1 );
00178     grid->setSpacing( KDialog::spacingHint() );
00179 
00180 //    esstixStyle = new QRadioButton( i18n( "Esstix font style" ), styleBox );
00181 //    esstixStyle->setChecked( contextStyle.getFontStyle() == "esstix" );
00182 
00183 //    cmStyle = new QRadioButton( i18n( "Computer modern (TeX) style" ), styleBox );
00184 //    cmStyle->setChecked( contextStyle.getFontStyle() == "tex" );
00185 
00186     symbolStyle = new QRadioButton( i18n( "Symbol font style" ), styleBox );
00187     symbolStyle->setChecked( !esstixStyle->isChecked() && !cmStyle->isChecked() );
00188 
00189     grid->addWidget( symbolStyle, 0, 0 );
00190     grid->addWidget( esstixStyle, 1, 0 );
00191     grid->addWidget( cmStyle, 2, 0 );
00192 
00193     connect( styleBox, SIGNAL( clicked( int ) ), this, SLOT( slotChanged() ) );
00194     connect( syntaxHighlighting, SIGNAL( clicked() ), this, SLOT( slotChanged() ) );
00195     connect( sizeSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
00196 
00197     Q_ASSERT( !m_changed );
00198 }
00199 
00200 
00201 QPushButton* ConfigurePage::buildFontLine( QWidget* parent,
00202             Q3GridLayout* layout, int number, QFont font, const QString & name,
00203             QLabel*& fontName )
00204 {
00205     QLabel* fontTitle = new QLabel( name, parent );
00206 
00207     QString labelName = font.family() + ' ' + QString::number( font.pointSize() );
00208     fontName = new QLabel( labelName, parent );
00209     fontName->setFont( font );
00210     fontName->setFrameStyle(Q3Frame::StyledPanel | Q3Frame::Sunken);
00211 
00212     QPushButton* chooseButton = new QPushButton( i18n( "Choose..." ), parent );
00213 
00214     layout->addWidget( fontTitle, number, 0 );
00215     layout->addWidget( fontName, number, 1 );
00216     layout->addWidget( chooseButton, number, 2 );
00217 
00218     return chooseButton;
00219 }
00220 
00221 
00222 void ConfigurePage::apply()
00223 {
00224     if ( !m_changed )
00225         return;
00226     QString fontStyle;
00227     if ( esstixStyle->isChecked() ) {
00228         fontStyle = "esstix";
00229 
00230         QStringList missing = EsstixFontStyle::missingFonts();
00231 
00232         if ( missing.count() > 0 ) {
00233             QString text = i18n( "The fonts '%1' are missing."
00234                                  " Do you want to change the font style anyway?"
00235                            ,missing.join( "', '" ) );
00236             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00237                  KMessageBox::Cancel ) {
00238                 return;
00239             }
00240         }
00241     }
00242     else if ( cmStyle->isChecked() ) {
00243         fontStyle = "tex";
00244 
00245         QStringList missing = CMStyle::missingFonts();
00246 
00247         if ( missing.count() > 0 && !CMStyle::m_installed) {
00248             QString text = i18n( "The fonts '%1' are missing."
00249                                  " Do you want to change the font style anyway?"
00250                            , missing.join( "', '" ) );
00251             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00252                  KMessageBox::Cancel ) {
00253                 return;
00254             }
00255         }
00256     }
00257     else { // symbolStyle->isChecked ()
00258         fontStyle = "symbol";
00259 
00260         QStringList missing = SymbolFontStyle::missingFonts();
00261 
00262         if ( missing.count() > 0 ) {
00263             QString text = i18n( "The font 'symbol' is missing."
00264                                  " Do you want to change the font style anyway?" );
00265             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00266                  KMessageBox::Cancel ) {
00267                 return;
00268             }
00269 
00270         }
00271     }
00272 
00273 /*    ContextStyle& contextStyle = m_document->getContextStyle( true );
00274 
00275     contextStyle.setDefaultFont( defaultFont );
00276     contextStyle.setNameFont( nameFont );
00277     contextStyle.setNumberFont( numberFont );
00278     contextStyle.setOperatorFont( operatorFont );
00279     contextStyle.setBaseSize( sizeSpin->value() );
00280 
00281     contextStyle.setFontStyle( fontStyle );
00282 
00283     contextStyle.setSyntaxHighlighting( syntaxHighlighting->isChecked() );*/
00284 //     contextStyle.setDefaultColor( defaultColorBtn->color() );
00285 //     contextStyle.setNumberColor( numberColorBtn->color() );
00286 //     contextStyle.setOperatorColor( operatorColorBtn->color() );
00287 //     contextStyle.setEmptyColor( emptyColorBtn->color() );
00288 //     contextStyle.setErrorColor( errorColorBtn->color() );
00289 
00290     m_config->setGroup( "kformula Font" );
00291     m_config->writeEntry( "defaultFont", defaultFont.toString() );
00292     m_config->writeEntry( "nameFont", nameFont.toString() );
00293     m_config->writeEntry( "numberFont", numberFont.toString() );
00294     m_config->writeEntry( "operatorFont", operatorFont.toString() );
00295     m_config->writeEntry( "baseSize", QString::number( sizeSpin->value() ) );
00296 
00297     m_config->writeEntry( "fontStyle", fontStyle );
00298 
00299 //     m_config->setGroup( "kformula Color" );
00300 //     m_config->writeEntry( "syntaxHighlighting", syntaxHighlighting->isChecked() );
00301 //     m_config->writeEntry( "defaultColor", defaultColorBtn->color() );
00302 //     m_config->writeEntry( "numberColor",  numberColorBtn->color() );
00303 //     m_config->writeEntry( "operatorColor", operatorColorBtn->color() );
00304 //     m_config->writeEntry( "emptyColor", emptyColorBtn->color() );
00305 //     m_config->writeEntry( "errorColor", errorColorBtn->color() );
00306 
00307     // notify!!!
00308 //    m_document->updateConfig();
00309     m_changed = false;
00310 }
00311 
00312 void ConfigurePage::slotDefault()
00313 {
00314     defaultFont = QFont( "Times", 12, QFont::Normal, true );
00315     nameFont = QFont( "Times" );
00316     numberFont = nameFont;
00317     operatorFont = nameFont;
00318 
00319     sizeSpin->setValue( 20 );
00320 
00321     updateFontLabel( defaultFont, defaultFontName );
00322     updateFontLabel( nameFont, nameFontName );
00323     updateFontLabel( numberFont, numberFontName );
00324     updateFontLabel( operatorFont, operatorFontName );
00325 
00326     symbolStyle->setChecked( true );
00327     if (CMStyle::missingFonts().isEmpty())
00328         cmStyle->setChecked( true );
00329     else if (EsstixFontStyle::missingFonts().isEmpty())
00330         esstixStyle->setChecked( true );
00331     else
00332         symbolStyle->setChecked( true );
00333 
00334     syntaxHighlighting->setChecked( true );
00335     syntaxHighlightingClicked();
00336 
00337 //     defaultColorBtn->setColor( Qt::black );
00338 //     numberColorBtn->setColor( Qt::blue );
00339 //     operatorColorBtn->setColor( Qt::darkGreen );
00340 //     emptyColorBtn->setColor( Qt::blue );
00341 //     errorColorBtn->setColor( Qt::darkRed );
00342     slotChanged();
00343 }
00344 
00345 void ConfigurePage::syntaxHighlightingClicked()
00346 {
00347 //     bool checked = syntaxHighlighting->isChecked();
00348 //     hlBox->setEnabled( checked );
00349 }
00350 
00351 void ConfigurePage::selectNewDefaultFont()
00352 {
00353     if ( selectFont( defaultFont ) )
00354         updateFontLabel( defaultFont, defaultFontName );
00355 }
00356 
00357 void ConfigurePage::selectNewNameFont()
00358 {
00359     if ( selectFont( nameFont ) )
00360         updateFontLabel( nameFont, nameFontName );
00361 }
00362 
00363 void ConfigurePage::selectNewNumberFont()
00364 {
00365     if ( selectFont( numberFont ) )
00366         updateFontLabel( numberFont, numberFontName );
00367 }
00368 
00369 void ConfigurePage::selectNewOperatorFont()
00370 {
00371     if ( selectFont( operatorFont ) )
00372         updateFontLabel( operatorFont, operatorFontName );
00373 }
00374 
00375 bool ConfigurePage::selectFont( QFont & font )
00376 {
00377     QStringList list;
00378 
00379     KFontChooser::getFontList( list, KFontChooser::SmoothScalableFonts );
00380 
00381     KFontDialog dlg( m_view, false, true, list );
00382     dlg.setFont( font );
00383 
00384     int result = dlg.exec();
00385     if (  KDialog::Accepted == result ) {
00386         font = dlg.font();
00387         slotChanged();
00388         return true;
00389     }
00390 
00391     return false;
00392 }
00393 
00394 void ConfigurePage::baseSizeChanged( int /*value*/ )
00395 {
00396 }
00397 
00398 void ConfigurePage::updateFontLabel( QFont font, QLabel* label )
00399 {
00400     label->setText( font.family() + ' ' + QString::number( font.pointSize() ) );
00401     label->setFont( font );
00402 }
00403 
00404 void ConfigurePage::slotChanged()
00405 {
00406     m_changed = true;
00407 }
00408 
00409 // class UsedFontItem : public K3ListViewItem {
00410 // public:
00411 //     UsedFontItem( MathFontsConfigurePage* page, QListView* parent, QString font )
00412 //         : K3ListViewItem( parent, font ), m_page( page ) {}
00413 
00414 //     int compare( QListViewItem* i, int col, bool ascending ) const;
00415 
00416 // private:
00417 //     MathFontsConfigurePage* m_page;
00418 // };
00419 
00420 // int UsedFontItem::compare( QListViewItem* i, int, bool ) const
00421 // {
00422 //     QValueVector<QString>::iterator lhsIt = m_page->findUsedFont( text( 0 ) );
00423 //     QValueVector<QString>::iterator rhsIt = m_page->findUsedFont( i->text( 0 ) );
00424 //     if ( lhsIt < rhsIt ) {
00425 //         return -1;
00426 //     }
00427 //     else if ( lhsIt > rhsIt ) {
00428 //         return 1;
00429 //     }
00430 //     return 0;
00431 // }
00432 
00433 // MathFontsConfigurePage::MathFontsConfigurePage( Document* document, QWidget* view,
00434 //                                                 KConfig* config, QVBox* box, char* name )
00435 //     : QObject( box->parent(), name ), m_document( document ), m_view( view ), m_config( config )
00436 // {
00437 //     QWidget* fontWidget = new QWidget( box );
00438 //     QGridLayout* fontLayout = new QGridLayout( fontWidget, 1, 1, KDialog::marginHint(), KDialog::spacingHint() );
00439 
00440 //     QHBoxLayout* hLayout = new QHBoxLayout( 0, 0, 6 );
00441 
00442 //     availableFonts = new K3ListView( fontWidget );
00443 //     availableFonts->addColumn( i18n( "Available Fonts" ) );
00444 //     hLayout->addWidget( availableFonts );
00445 
00446 //     QVBoxLayout* vLayout = new QVBoxLayout( 0, 0, 6 );
00447 //     QSpacerItem* spacer1 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
00448 //     vLayout->addItem( spacer1 );
00449 
00450 //     addFont = new KPushButton( fontWidget );
00451 //     addFont->setText( "->" );
00452 //     vLayout->addWidget( addFont );
00453 
00454 //     removeFont = new KPushButton( fontWidget );
00455 //     removeFont->setText( "<-" );
00456 //     vLayout->addWidget( removeFont );
00457 
00458 //     QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
00459 //     vLayout->addItem( spacer2 );
00460 
00461 //     hLayout->addLayout( vLayout );
00462 
00463 //     vLayout = new QVBoxLayout( 0, 0, 6 );
00464 
00465 //     moveUp = new KPushButton( fontWidget );
00466 //     moveUp->setText( i18n( "Up" ) );
00467 //     vLayout->addWidget( moveUp );
00468 
00469 //     requestedFonts = new K3ListView( fontWidget );
00470 //     requestedFonts->addColumn( i18n( "Used Fonts" ) );
00471 //     vLayout->addWidget( requestedFonts );
00472 
00473 //     moveDown = new KPushButton( fontWidget );
00474 //     moveDown->setText( i18n( "Down" ) );
00475 //     vLayout->addWidget( moveDown );
00476 
00477 //     hLayout->addLayout( vLayout );
00478 
00479 //     fontLayout->addLayout( hLayout, 0, 0 );
00480 
00481 // //     connect( availableFonts, SIGNAL( executed( QListViewItem* ) ),
00482 // //              this, SLOT( slotAddFont() ) );
00483 // //     connect( requestedFonts, SIGNAL( executed( QListViewItem* ) ),
00484 // //              this, SLOT( slotRemoveFont() ) );
00485 //     connect( addFont, SIGNAL( clicked() ), this, SLOT( slotAddFont() ) );
00486 //     connect( removeFont, SIGNAL( clicked() ), this, SLOT( slotRemoveFont() ) );
00487 //     connect( moveUp, SIGNAL( clicked() ), this, SLOT( slotMoveUp() ) );
00488 //     connect( moveDown, SIGNAL( clicked() ), this, SLOT( slotMoveDown() ) );
00489 
00490 //     const ContextStyle& contextStyle = document->getContextStyle( true );
00491 //     const SymbolTable& symbolTable = contextStyle.symbolTable();
00492 //     const QStringList& usedFonts = contextStyle.requestedFonts();
00493 
00494 //     QMap<QString, QString> fontMap;
00495 // //    symbolTable.findAvailableFonts( &fontMap );
00496 
00497 //     setupLists( usedFonts );
00498 // }
00499 
00500 // void MathFontsConfigurePage::apply()
00501 // {
00502 //     QStringList strings;
00503 //     std::copy( usedFontList.begin(), usedFontList.end(), std::back_inserter( strings ) );
00504 
00505 //     m_config->setGroup( "kformula Font" );
00506 //     m_config->writeEntry( "usedMathFonts", strings );
00507 
00508 //     ContextStyle& contextStyle = m_document->getContextStyle( true );
00509 //     contextStyle.setRequestedFonts( strings );
00510 // }
00511 
00512 // void MathFontsConfigurePage::slotDefault()
00513 // {
00514 //     QStringList usedFonts;
00515 
00516 //     usedFonts.push_back( "esstixone" );
00517 //     usedFonts.push_back( "esstixtwo" );
00518 //     usedFonts.push_back( "esstixthree" );
00519 //     usedFonts.push_back( "esstixfour" );
00520 //     usedFonts.push_back( "esstixfive" );
00521 //     usedFonts.push_back( "esstixsix" );
00522 //     usedFonts.push_back( "esstixseven" );
00523 //     usedFonts.push_back( "esstixeight" );
00524 //     usedFonts.push_back( "esstixnine" );
00525 //     usedFonts.push_back( "esstixten" );
00526 //     usedFonts.push_back( "esstixeleven" );
00527 //     usedFonts.push_back( "esstixtwelve" );
00528 //     usedFonts.push_back( "esstixthirteen" );
00529 //     usedFonts.push_back( "esstixfourteen" );
00530 //     usedFonts.push_back( "esstixfifteen" );
00531 //     usedFonts.push_back( "esstixsixteen" );
00532 //     usedFonts.push_back( "esstixseventeen" );
00533 
00534 //     usedFontList.clear();
00535 //     requestedFonts->clear();
00536 //     availableFonts->clear();
00537 
00538 //     setupLists( usedFonts );
00539 // }
00540 
00541 // QValueVector<QString>::iterator MathFontsConfigurePage::findUsedFont( QString name )
00542 // {
00543 //     return std::find( usedFontList.begin(), usedFontList.end(), name );
00544 // }
00545 
00546 // void MathFontsConfigurePage::setupLists( const QStringList& usedFonts )
00547 // {
00548 //     const ContextStyle& contextStyle = m_document->getContextStyle( true );
00549 //     const SymbolTable& symbolTable = contextStyle.symbolTable();
00550 
00551 //     QMap<QString, QString> fontMap;
00552 // //    symbolTable.findAvailableFonts( &fontMap );
00553 
00554 //     for ( QStringList::const_iterator it = usedFonts.begin(); it != usedFonts.end(); ++it ) {
00555 //         QMap<QString, QString>::iterator font = fontMap.find( *it );
00556 //         if ( font != fontMap.end() ) {
00557 //             fontMap.erase( font );
00558 //             new UsedFontItem( this, requestedFonts, *it );
00559 //             usedFontList.push_back( *it );
00560 //         }
00561 //     }
00562 //     for ( QMap<QString, QString>::iterator it = fontMap.begin(); it != fontMap.end(); ++it ) {
00563 //         new K3ListViewItem( availableFonts, it.key() );
00564 //     }
00565 // }
00566 
00567 // void MathFontsConfigurePage::slotAddFont()
00568 // {
00569 //     QListViewItem* fontItem = availableFonts->selectedItem();
00570 //     if ( fontItem ) {
00571 //         QString fontName = fontItem->text( 0 );
00572 //         //availableFonts->takeItem( fontItem );
00573 //         delete fontItem;
00574 
00575 //         new UsedFontItem( this, requestedFonts, fontName );
00576 //         usedFontList.push_back( fontName );
00577 //     }
00578 // }
00579 
00580 // void MathFontsConfigurePage::slotRemoveFont()
00581 // {
00582 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00583 //     if ( fontItem ) {
00584 //         QString fontName = fontItem->text( 0 );
00585 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00586 //         if ( it != usedFontList.end() ) {
00587 //             usedFontList.erase( it );
00588 //         }
00589 //         //requestedFonts->takeItem( fontItem );
00590 //         delete fontItem;
00591 //         new K3ListViewItem( availableFonts, fontName );
00592 //     }
00593 // }
00594 
00595 // void MathFontsConfigurePage::slotMoveUp()
00596 // {
00597 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00598 //     if ( fontItem ) {
00599 //         QString fontName = fontItem->text( 0 );
00600 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00601 //         if ( it != usedFontList.end() ) {
00602 //             uint pos = it - usedFontList.begin();
00603 //             if ( pos > 0 ) {
00604 //                 QValueVector<QString>::iterator before = it-1;
00605 //                 std::swap( *it, *before );
00606 //                 requestedFonts->sort();
00607 //             }
00608 //         }
00609 //     }
00610 // }
00611 
00612 // void MathFontsConfigurePage::slotMoveDown()
00613 // {
00614 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00615 //     if ( fontItem ) {
00616 //         QString fontName = fontItem->text( 0 );
00617 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00618 //         if ( it != usedFontList.end() ) {
00619 //             uint pos = it - usedFontList.begin();
00620 //             if ( pos < usedFontList.size()-1 ) {
00621 //                 QValueVector<QString>::iterator after = it+1;
00622 //                 std::swap( *it, *after );
00623 //                 requestedFonts->sort();
00624 //             }
00625 //         }
00626 //     }
00627 // }
00628 
00629 KFORMULA_NAMESPACE_END
00630 
00631 using namespace KFormula;
00632 #include "kformulaconfigpage.moc"

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