lib Library API Documentation

kformulaconfigpage.cc

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., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #include <qvariant.h>   // first for gcc 2.7.2
00022 #include <qbuttongroup.h>
00023 #include <qcheckbox.h>
00024 #include <qgroupbox.h>
00025 #include <qlabel.h>
00026 #include <qlayout.h>
00027 #include <qmap.h>
00028 #include <qradiobutton.h>
00029 #include <qspinbox.h>
00030 #include <qstringlist.h>
00031 #include <qvbox.h>
00032 #include <qwidget.h>
00033 
00034 //#include <algorithm>
00035 
00036 #include <kcolorbutton.h>
00037 #include <kconfig.h>
00038 #include <kdebug.h>
00039 #include <kdialog.h>
00040 #include <kfontdialog.h>
00041 #include <klistview.h>
00042 #include <klocale.h>
00043 #include <kmessagebox.h>
00044 #include <knuminput.h>
00045 #include <kpushbutton.h>
00046 
00047 #include "contextstyle.h"
00048 #include "kformulaconfigpage.h"
00049 #include "kformuladocument.h"
00050 #include "symboltable.h"
00051 
00052 KFORMULA_NAMESPACE_BEGIN
00053 
00054 class ConfigurePage::Private
00055 {
00056 public:
00057     QCheckBox* syntaxHighlighting;
00058     bool m_changed;
00059 };
00060 
00061 ConfigurePage::ConfigurePage( Document* document, QWidget* view, KConfig* config, QVBox* box, char* name )
00062     : QObject( box->parent(), name ), m_document( document ), m_view( view ), m_config( config )
00063 {
00064     d = new Private;
00065     d->m_changed = false;
00066     const ContextStyle& contextStyle = document->getContextStyle( true );
00067 
00068     // fonts
00069 
00070     QGroupBox *gbox = new QGroupBox( i18n( "Fonts" ), box );
00071     gbox->setColumnLayout( 0, Qt::Horizontal );
00072 
00073     QGridLayout* grid = new QGridLayout( gbox->layout(), 5, 3 );
00074     grid->setSpacing( KDialog::spacingHint() );
00075 
00076     grid->setColStretch(1, 1);
00077 
00078     defaultFont = contextStyle.getDefaultFont();
00079     nameFont = contextStyle.getNameFont();
00080     numberFont = contextStyle.getNumberFont();
00081     operatorFont = contextStyle.getOperatorFont();
00082 
00083     connect( buildFontLine( gbox, grid, 0, defaultFont,
00084             i18n( "Default font:" ), defaultFontName ),
00085             SIGNAL( clicked() ), SLOT( selectNewDefaultFont() ) );
00086 
00087     connect( buildFontLine( gbox, grid, 1, nameFont,
00088             i18n( "Name font:" ), nameFontName ),
00089             SIGNAL( clicked() ), SLOT( selectNewNameFont() ) );
00090 
00091     connect( buildFontLine( gbox, grid, 2, numberFont,
00092             i18n( "Number font:" ), numberFontName ),
00093             SIGNAL( clicked() ), SLOT( selectNewNumberFont() ) );
00094 
00095     connect( buildFontLine( gbox, grid, 3, operatorFont,
00096             i18n( "Operator font:" ), operatorFontName ),
00097             SIGNAL( clicked() ), SLOT( selectNewOperatorFont() ) );
00098 
00099     QLabel* sizeTitle = new QLabel( i18n( "Default base size:" ), gbox );
00100     grid->addWidget( sizeTitle, 4, 0 );
00101 
00102     sizeSpin = new KIntNumInput( contextStyle.baseSize(), gbox );
00103     sizeSpin->setRange( 8, 72, 1, true );
00104 
00105     grid->addMultiCellWidget( sizeSpin, 4, 4, 1, 2 );
00106 
00107     connect( sizeSpin, SIGNAL( valueChanged( int ) ),
00108             SLOT( baseSizeChanged( int ) ) );
00109 
00110     // syntax highlighting
00111 
00112     d->syntaxHighlighting = new QCheckBox( i18n( "Use syntax highlighting" ),box );
00113     d->syntaxHighlighting->setChecked( contextStyle.syntaxHighlighting() );
00114 
00115 //     hlBox = new QGroupBox( i18n( "Highlight Colors" ), box );
00116 //     hlBox->setColumnLayout( 0, Qt::Horizontal );
00117 
00118 //     grid = new QGridLayout( hlBox->layout(), 5, 2 );
00119 //     grid->setSpacing( KDialog::spacingHint() );
00120 
00121 //     QLabel* defaultLabel = new QLabel( hlBox, "defaultLabel" );
00122 //     defaultLabel->setText( i18n( "Default color:" ) );
00123 //     grid->addWidget( defaultLabel, 0, 0 );
00124 
00125 //     defaultColorBtn = new KColorButton( hlBox, "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, "numberColor" );
00135 //     numberColorBtn->setColor( contextStyle.getNumberColorPlain() );
00136 //     grid->addWidget( numberColorBtn, 1, 1 );
00137 
00138 
00139 //     QLabel* operatorLabel = new QLabel( hlBox, "operatorLabel" );
00140 //     operatorLabel->setText( i18n( "Operator color:" ) );
00141 //     grid->addWidget( operatorLabel, 2, 0 );
00142 
00143 //     operatorColorBtn = new KColorButton( hlBox, "operatorColor" );
00144 //     operatorColorBtn->setColor( contextStyle.getOperatorColorPlain() );
00145 //     grid->addWidget( operatorColorBtn, 2, 1 );
00146 
00147 
00148 //     QLabel* emptyLabel = new QLabel( hlBox, "emptyLabel" );
00149 //     emptyLabel->setText( i18n( "Empty color:" ) );
00150 //     grid->addWidget( emptyLabel, 3, 0 );
00151 
00152 //     emptyColorBtn = new KColorButton( hlBox, "emptyColor" );
00153 //     emptyColorBtn->setColor( contextStyle.getEmptyColorPlain() );
00154 //     grid->addWidget( emptyColorBtn, 3, 1 );
00155 
00156 
00157 //     QLabel* errorLabel = new QLabel( hlBox, "errorLabel" );
00158 //     errorLabel->setText( i18n( "Error color:" ) );
00159 //     grid->addWidget( errorLabel, 4, 0 );
00160 
00161 //     errorColorBtn = new KColorButton( hlBox, "errorColor" );
00162 //     errorColorBtn->setColor( contextStyle.getErrorColorPlain() );
00163 //     grid->addWidget( errorColorBtn, 4, 1 );
00164 
00165     connect( d->syntaxHighlighting, SIGNAL( clicked() ),
00166             SLOT( syntaxHighlightingClicked() ) );
00167 
00168     syntaxHighlightingClicked();
00169 
00170     styleBox = new QButtonGroup( i18n( "Font Style" ), box );
00171     styleBox->setColumnLayout( 0, Qt::Horizontal );
00172 
00173     grid = new QGridLayout( styleBox->layout(), 3, 1 );
00174     grid->setSpacing( KDialog::spacingHint() );
00175 
00176     esstixStyle = new QRadioButton( i18n( "Esstix font style" ), styleBox, "esstixStyle" );
00177     esstixStyle->setChecked( contextStyle.getFontStyle() == "esstix" );
00178 
00179     cmStyle = new QRadioButton( i18n( "Computer modern (TeX) style" ), styleBox, "cmStyle" );
00180     cmStyle->setChecked( contextStyle.getFontStyle() == "tex" );
00181 
00182     symbolStyle = new QRadioButton( i18n( "Symbol font style" ), styleBox, "symbolStyle" );
00183     symbolStyle->setChecked( !esstixStyle->isChecked() && !cmStyle->isChecked() );
00184 
00185     grid->addWidget( symbolStyle, 0, 0 );
00186     grid->addWidget( esstixStyle, 1, 0 );
00187     grid->addWidget( cmStyle, 2, 0 );
00188 
00189     connect( styleBox, SIGNAL( clicked( int ) ), this, SLOT( slotChanged() ) );
00190     connect( d->syntaxHighlighting, SIGNAL( clicked() ), this, SLOT( slotChanged() ) );
00191     connect( sizeSpin, SIGNAL( valueChanged( int ) ), this, SLOT( slotChanged() ) );
00192 
00193     Q_ASSERT( !d->m_changed );
00194 }
00195 
00196 ConfigurePage::~ConfigurePage()
00197 {
00198     delete d;
00199 }
00200 
00201 QPushButton* ConfigurePage::buildFontLine( QWidget* parent,
00202             QGridLayout* layout, int number, QFont font, 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(QFrame::StyledPanel | QFrame::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 static bool fontAvailable( QString fontName )
00223 {
00224     QFont f( fontName );
00225     QStringList fields = QStringList::split( '-', f.rawName() );
00226     if ( ( fields.size() > 1 ) &&
00227          ( ( fields[1].upper() == fontName.upper() ) ||
00228            ( fields[0].upper() == fontName.upper() ) ) ) {
00229         return true;
00230     }
00231     else {
00232         kdWarning(39001) << "Font '" << fontName << "' not found but '" << f.rawName() << "'." << endl;
00233         return false;
00234     }
00235 }
00236 
00237 
00238 inline void testFont( QStringList& missing, const QString& fontName ) {
00239     if ( !fontAvailable( fontName ) ) {
00240         missing.append( fontName );
00241     }
00242 }
00243 
00244 void ConfigurePage::apply()
00245 {
00246     if ( !d->m_changed )
00247         return;
00248     QString fontStyle;
00249     if ( esstixStyle->isChecked() ) {
00250         fontStyle = "esstix";
00251 
00252         QStringList missing;
00253         testFont( missing, "esstixeight" );
00254         testFont( missing, "esstixeleven" );
00255         testFont( missing, "esstixfifteen" );
00256         testFont( missing, "esstixfive" );
00257         testFont( missing, "esstixfour" );
00258         testFont( missing, "esstixfourteen" );
00259         testFont( missing, "esstixnine" );
00260         testFont( missing, "esstixone" );
00261         testFont( missing, "esstixseven" );
00262         testFont( missing, "esstixseventeen" );
00263         testFont( missing, "esstixsix" );
00264         testFont( missing, "esstixsixteen" );
00265         testFont( missing, "esstixten" );
00266         testFont( missing, "esstixthirteen" );
00267         testFont( missing, "esstixthree" );
00268         testFont( missing, "esstixtwelve" );
00269         testFont( missing, "esstixtwo" );
00270 
00271         if ( missing.count() > 0 ) {
00272             QString text = i18n( "The fonts '%1' are missing."
00273                                  " Do you want to change the font style anyway?" )
00274                            .arg( missing.join( "', '" ) );
00275             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00276                  KMessageBox::Cancel ) {
00277                 return;
00278             }
00279         }
00280     }
00281     else if ( cmStyle->isChecked() ) {
00282         fontStyle = "tex";
00283 
00284         QStringList missing;
00285         testFont( missing, "cmbx10" );
00286         testFont( missing, "cmex10" );
00287         testFont( missing, "cmmi10" );
00288         testFont( missing, "cmr10" );
00289         testFont( missing, "cmsy10" );
00290         testFont( missing, "msam10" );
00291         testFont( missing, "msbm10" );
00292 
00293         if ( missing.count() > 0 ) {
00294             QString text = i18n( "The fonts '%1' are missing."
00295                                  " Do you want to change the font style anyway?" )
00296                            .arg( missing.join( "', '" ) );
00297             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00298                  KMessageBox::Cancel ) {
00299                 return;
00300             }
00301         }
00302     }
00303     else { // symbolStyle->isChecked ()
00304         fontStyle = "symbol";
00305 
00306         QStringList missing;
00307         testFont( missing, "symbol" );
00308 
00309         if ( missing.count() > 0 ) {
00310             QString text = i18n( "The font 'symbol' is missing."
00311                                  " Do you want to change the font style anyway?" );
00312             if ( KMessageBox::warningContinueCancel( m_view, text ) ==
00313                  KMessageBox::Cancel ) {
00314                 return;
00315             }
00316 
00317         }
00318     }
00319 
00320     ContextStyle& contextStyle = m_document->getContextStyle( true );
00321 
00322     contextStyle.setDefaultFont( defaultFont );
00323     contextStyle.setNameFont( nameFont );
00324     contextStyle.setNumberFont( numberFont );
00325     contextStyle.setOperatorFont( operatorFont );
00326     contextStyle.setBaseSize( sizeSpin->value() );
00327 
00328     contextStyle.setFontStyle( fontStyle );
00329 
00330     contextStyle.setSyntaxHighlighting( d->syntaxHighlighting->isChecked() );
00331 //     contextStyle.setDefaultColor( defaultColorBtn->color() );
00332 //     contextStyle.setNumberColor( numberColorBtn->color() );
00333 //     contextStyle.setOperatorColor( operatorColorBtn->color() );
00334 //     contextStyle.setEmptyColor( emptyColorBtn->color() );
00335 //     contextStyle.setErrorColor( errorColorBtn->color() );
00336 
00337     m_config->setGroup( "kformula Font" );
00338     m_config->writeEntry( "defaultFont", defaultFont.toString() );
00339     m_config->writeEntry( "nameFont", nameFont.toString() );
00340     m_config->writeEntry( "numberFont", numberFont.toString() );
00341     m_config->writeEntry( "operatorFont", operatorFont.toString() );
00342     m_config->writeEntry( "baseSize", QString::number( sizeSpin->value() ) );
00343 
00344     m_config->writeEntry( "fontStyle", fontStyle );
00345 
00346 //     m_config->setGroup( "kformula Color" );
00347 //     m_config->writeEntry( "syntaxHighlighting", d->syntaxHighlighting->isChecked() );
00348 //     m_config->writeEntry( "defaultColor", defaultColorBtn->color() );
00349 //     m_config->writeEntry( "numberColor",  numberColorBtn->color() );
00350 //     m_config->writeEntry( "operatorColor", operatorColorBtn->color() );
00351 //     m_config->writeEntry( "emptyColor", emptyColorBtn->color() );
00352 //     m_config->writeEntry( "errorColor", errorColorBtn->color() );
00353 
00354     // notify!!!
00355     m_document->updateConfig();
00356     d->m_changed = false;
00357 }
00358 
00359 void ConfigurePage::slotDefault()
00360 {
00361     defaultFont = QFont( "Times", 12, QFont::Normal, true );
00362     nameFont = QFont( "Times" );
00363     numberFont = nameFont;
00364     operatorFont = nameFont;
00365 
00366     sizeSpin->setValue( 20 );
00367 
00368     updateFontLabel( defaultFont, defaultFontName );
00369     updateFontLabel( nameFont, nameFontName );
00370     updateFontLabel( numberFont, numberFontName );
00371     updateFontLabel( operatorFont, operatorFontName );
00372 
00373     symbolStyle->setChecked( true );
00374 
00375     d->syntaxHighlighting->setChecked( true );
00376     syntaxHighlightingClicked();
00377 
00378 //     defaultColorBtn->setColor( Qt::black );
00379 //     numberColorBtn->setColor( Qt::blue );
00380 //     operatorColorBtn->setColor( Qt::darkGreen );
00381 //     emptyColorBtn->setColor( Qt::blue );
00382 //     errorColorBtn->setColor( Qt::darkRed );
00383     slotChanged();
00384 }
00385 
00386 void ConfigurePage::syntaxHighlightingClicked()
00387 {
00388 //     bool checked = d->syntaxHighlighting->isChecked();
00389 //     hlBox->setEnabled( checked );
00390 }
00391 
00392 void ConfigurePage::selectNewDefaultFont()
00393 {
00394     if ( selectFont( defaultFont ) )
00395         updateFontLabel( defaultFont, defaultFontName );
00396 }
00397 
00398 void ConfigurePage::selectNewNameFont()
00399 {
00400     if ( selectFont( nameFont ) )
00401         updateFontLabel( nameFont, nameFontName );
00402 }
00403 
00404 void ConfigurePage::selectNewNumberFont()
00405 {
00406     if ( selectFont( numberFont ) )
00407         updateFontLabel( numberFont, numberFontName );
00408 }
00409 
00410 void ConfigurePage::selectNewOperatorFont()
00411 {
00412     if ( selectFont( operatorFont ) )
00413         updateFontLabel( operatorFont, operatorFontName );
00414 }
00415 
00416 bool ConfigurePage::selectFont( QFont & font )
00417 {
00418     QStringList list;
00419 
00420     KFontChooser::getFontList( list, KFontChooser::SmoothScalableFonts );
00421 
00422     KFontDialog dlg( m_view, 0, false, true, list );
00423     dlg.setFont( font );
00424 
00425     int result = dlg.exec();
00426     if (  KDialog::Accepted == result ) {
00427         font = dlg.font();
00428         slotChanged();
00429         return true;
00430     }
00431 
00432     return false;
00433 }
00434 
00435 void ConfigurePage::baseSizeChanged( int /*value*/ )
00436 {
00437 }
00438 
00439 void ConfigurePage::updateFontLabel( QFont font, QLabel* label )
00440 {
00441     label->setText( font.family() + ' ' + QString::number( font.pointSize() ) );
00442     label->setFont( font );
00443 }
00444 
00445 void ConfigurePage::slotChanged()
00446 {
00447     d->m_changed = true;
00448 }
00449 
00450 // class UsedFontItem : public KListViewItem {
00451 // public:
00452 //     UsedFontItem( MathFontsConfigurePage* page, QListView* parent, QString font )
00453 //         : KListViewItem( parent, font ), m_page( page ) {}
00454 
00455 //     int compare( QListViewItem* i, int col, bool ascending ) const;
00456 
00457 // private:
00458 //     MathFontsConfigurePage* m_page;
00459 // };
00460 
00461 // int UsedFontItem::compare( QListViewItem* i, int, bool ) const
00462 // {
00463 //     QValueVector<QString>::iterator lhsIt = m_page->findUsedFont( text( 0 ) );
00464 //     QValueVector<QString>::iterator rhsIt = m_page->findUsedFont( i->text( 0 ) );
00465 //     if ( lhsIt < rhsIt ) {
00466 //         return -1;
00467 //     }
00468 //     else if ( lhsIt > rhsIt ) {
00469 //         return 1;
00470 //     }
00471 //     return 0;
00472 // }
00473 
00474 // MathFontsConfigurePage::MathFontsConfigurePage( Document* document, QWidget* view,
00475 //                                                 KConfig* config, QVBox* box, char* name )
00476 //     : QObject( box->parent(), name ), m_document( document ), m_view( view ), m_config( config )
00477 // {
00478 //     QWidget* fontWidget = new QWidget( box );
00479 //     QGridLayout* fontLayout = new QGridLayout( fontWidget, 1, 1, KDialog::marginHint(), KDialog::spacingHint() );
00480 
00481 //     QHBoxLayout* hLayout = new QHBoxLayout( 0, 0, 6 );
00482 
00483 //     availableFonts = new KListView( fontWidget );
00484 //     availableFonts->addColumn( i18n( "Available Fonts" ) );
00485 //     hLayout->addWidget( availableFonts );
00486 
00487 //     QVBoxLayout* vLayout = new QVBoxLayout( 0, 0, 6 );
00488 //     QSpacerItem* spacer1 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
00489 //     vLayout->addItem( spacer1 );
00490 
00491 //     addFont = new KPushButton( fontWidget );
00492 //     addFont->setText( "->" );
00493 //     vLayout->addWidget( addFont );
00494 
00495 //     removeFont = new KPushButton( fontWidget );
00496 //     removeFont->setText( "<-" );
00497 //     vLayout->addWidget( removeFont );
00498 
00499 //     QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
00500 //     vLayout->addItem( spacer2 );
00501 
00502 //     hLayout->addLayout( vLayout );
00503 
00504 //     vLayout = new QVBoxLayout( 0, 0, 6 );
00505 
00506 //     moveUp = new KPushButton( fontWidget );
00507 //     moveUp->setText( i18n( "Up" ) );
00508 //     vLayout->addWidget( moveUp );
00509 
00510 //     requestedFonts = new KListView( fontWidget );
00511 //     requestedFonts->addColumn( i18n( "Used Fonts" ) );
00512 //     vLayout->addWidget( requestedFonts );
00513 
00514 //     moveDown = new KPushButton( fontWidget );
00515 //     moveDown->setText( i18n( "Down" ) );
00516 //     vLayout->addWidget( moveDown );
00517 
00518 //     hLayout->addLayout( vLayout );
00519 
00520 //     fontLayout->addLayout( hLayout, 0, 0 );
00521 
00522 // //     connect( availableFonts, SIGNAL( executed( QListViewItem* ) ),
00523 // //              this, SLOT( slotAddFont() ) );
00524 // //     connect( requestedFonts, SIGNAL( executed( QListViewItem* ) ),
00525 // //              this, SLOT( slotRemoveFont() ) );
00526 //     connect( addFont, SIGNAL( clicked() ), this, SLOT( slotAddFont() ) );
00527 //     connect( removeFont, SIGNAL( clicked() ), this, SLOT( slotRemoveFont() ) );
00528 //     connect( moveUp, SIGNAL( clicked() ), this, SLOT( slotMoveUp() ) );
00529 //     connect( moveDown, SIGNAL( clicked() ), this, SLOT( slotMoveDown() ) );
00530 
00531 //     const ContextStyle& contextStyle = document->getContextStyle( true );
00532 //     const SymbolTable& symbolTable = contextStyle.symbolTable();
00533 //     const QStringList& usedFonts = contextStyle.requestedFonts();
00534 
00535 //     QMap<QString, QString> fontMap;
00536 // //    symbolTable.findAvailableFonts( &fontMap );
00537 
00538 //     setupLists( usedFonts );
00539 // }
00540 
00541 // void MathFontsConfigurePage::apply()
00542 // {
00543 //     QStringList strings;
00544 //     std::copy( usedFontList.begin(), usedFontList.end(), std::back_inserter( strings ) );
00545 
00546 //     m_config->setGroup( "kformula Font" );
00547 //     m_config->writeEntry( "usedMathFonts", strings );
00548 
00549 //     ContextStyle& contextStyle = m_document->getContextStyle( true );
00550 //     contextStyle.setRequestedFonts( strings );
00551 // }
00552 
00553 // void MathFontsConfigurePage::slotDefault()
00554 // {
00555 //     QStringList usedFonts;
00556 
00557 //     usedFonts.push_back( "esstixone" );
00558 //     usedFonts.push_back( "esstixtwo" );
00559 //     usedFonts.push_back( "esstixthree" );
00560 //     usedFonts.push_back( "esstixfour" );
00561 //     usedFonts.push_back( "esstixfive" );
00562 //     usedFonts.push_back( "esstixsix" );
00563 //     usedFonts.push_back( "esstixseven" );
00564 //     usedFonts.push_back( "esstixeight" );
00565 //     usedFonts.push_back( "esstixnine" );
00566 //     usedFonts.push_back( "esstixten" );
00567 //     usedFonts.push_back( "esstixeleven" );
00568 //     usedFonts.push_back( "esstixtwelve" );
00569 //     usedFonts.push_back( "esstixthirteen" );
00570 //     usedFonts.push_back( "esstixfourteen" );
00571 //     usedFonts.push_back( "esstixfifteen" );
00572 //     usedFonts.push_back( "esstixsixteen" );
00573 //     usedFonts.push_back( "esstixseventeen" );
00574 
00575 //     usedFontList.clear();
00576 //     requestedFonts->clear();
00577 //     availableFonts->clear();
00578 
00579 //     setupLists( usedFonts );
00580 // }
00581 
00582 // QValueVector<QString>::iterator MathFontsConfigurePage::findUsedFont( QString name )
00583 // {
00584 //     return std::find( usedFontList.begin(), usedFontList.end(), name );
00585 // }
00586 
00587 // void MathFontsConfigurePage::setupLists( const QStringList& usedFonts )
00588 // {
00589 //     const ContextStyle& contextStyle = m_document->getContextStyle( true );
00590 //     const SymbolTable& symbolTable = contextStyle.symbolTable();
00591 
00592 //     QMap<QString, QString> fontMap;
00593 // //    symbolTable.findAvailableFonts( &fontMap );
00594 
00595 //     for ( QStringList::const_iterator it = usedFonts.begin(); it != usedFonts.end(); ++it ) {
00596 //         QMap<QString, QString>::iterator font = fontMap.find( *it );
00597 //         if ( font != fontMap.end() ) {
00598 //             fontMap.erase( font );
00599 //             new UsedFontItem( this, requestedFonts, *it );
00600 //             usedFontList.push_back( *it );
00601 //         }
00602 //     }
00603 //     for ( QMap<QString, QString>::iterator it = fontMap.begin(); it != fontMap.end(); ++it ) {
00604 //         new KListViewItem( availableFonts, it.key() );
00605 //     }
00606 // }
00607 
00608 // void MathFontsConfigurePage::slotAddFont()
00609 // {
00610 //     QListViewItem* fontItem = availableFonts->selectedItem();
00611 //     if ( fontItem ) {
00612 //         QString fontName = fontItem->text( 0 );
00613 //         //availableFonts->takeItem( fontItem );
00614 //         delete fontItem;
00615 
00616 //         new UsedFontItem( this, requestedFonts, fontName );
00617 //         usedFontList.push_back( fontName );
00618 //     }
00619 // }
00620 
00621 // void MathFontsConfigurePage::slotRemoveFont()
00622 // {
00623 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00624 //     if ( fontItem ) {
00625 //         QString fontName = fontItem->text( 0 );
00626 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00627 //         if ( it != usedFontList.end() ) {
00628 //             usedFontList.erase( it );
00629 //         }
00630 //         //requestedFonts->takeItem( fontItem );
00631 //         delete fontItem;
00632 //         new KListViewItem( availableFonts, fontName );
00633 //     }
00634 // }
00635 
00636 // void MathFontsConfigurePage::slotMoveUp()
00637 // {
00638 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00639 //     if ( fontItem ) {
00640 //         QString fontName = fontItem->text( 0 );
00641 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00642 //         if ( it != usedFontList.end() ) {
00643 //             uint pos = it - usedFontList.begin();
00644 //             if ( pos > 0 ) {
00645 //                 QValueVector<QString>::iterator before = it-1;
00646 //                 std::swap( *it, *before );
00647 //                 requestedFonts->sort();
00648 //             }
00649 //         }
00650 //     }
00651 // }
00652 
00653 // void MathFontsConfigurePage::slotMoveDown()
00654 // {
00655 //     QListViewItem* fontItem = requestedFonts->selectedItem();
00656 //     if ( fontItem ) {
00657 //         QString fontName = fontItem->text( 0 );
00658 //         QValueVector<QString>::iterator it = std::find( usedFontList.begin(), usedFontList.end(), fontName );
00659 //         if ( it != usedFontList.end() ) {
00660 //             uint pos = it - usedFontList.begin();
00661 //             if ( pos < usedFontList.size()-1 ) {
00662 //                 QValueVector<QString>::iterator after = it+1;
00663 //                 std::swap( *it, *after );
00664 //                 requestedFonts->sort();
00665 //             }
00666 //         }
00667 //     }
00668 // }
00669 
00670 KFORMULA_NAMESPACE_END
00671 
00672 using namespace KFormula;
00673 #include "kformulaconfigpage.moc"
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Mar 20 14:25:23 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003